feat: 更新Podfile和Podfile.lock,移除Alamofire依赖并添加API认证机制文档
- 注释掉Podfile中的Alamofire依赖,更新Podfile.lock以反映更改。 - 在yana/APIs/API-README.md中新增自动认证Header机制的详细文档,描述其工作原理、实现细节及最佳实践。 - 在yana/yanaApp.swift中将print语句替换为debugInfo以增强调试信息的输出。 - 在API相关文件中实现用户认证状态检查和相关header的自动添加逻辑,提升API请求的安全性和用户体验。 - 更新多个文件中的日志输出,确保在DEBUG模式下提供详细的调试信息。
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import SwiftUI
|
||||
|
||||
struct MeView: View {
|
||||
@State private var showLogoutConfirmation = false
|
||||
var body: some View {
|
||||
GeometryReader { geometry in
|
||||
ScrollView {
|
||||
@@ -48,7 +49,9 @@ struct MeView: View {
|
||||
.padding(.top, 40)
|
||||
|
||||
// 退出登录按钮
|
||||
Button(action: {}) {
|
||||
Button(action: {
|
||||
showLogoutConfirmation = true
|
||||
}) {
|
||||
HStack {
|
||||
Image(systemName: "rectangle.portrait.and.arrow.right")
|
||||
.font(.system(size: 16))
|
||||
@@ -72,6 +75,27 @@ struct MeView: View {
|
||||
}
|
||||
}
|
||||
.ignoresSafeArea(.container, edges: .top)
|
||||
.alert("确认退出", isPresented: $showLogoutConfirmation) {
|
||||
Button("取消", role: .cancel) { }
|
||||
Button("退出", role: .destructive) {
|
||||
performLogout()
|
||||
}
|
||||
} message: {
|
||||
Text("确定要退出登录吗?")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - 退出登录方法
|
||||
private func performLogout() {
|
||||
debugInfo("🔓 开始执行退出登录...")
|
||||
|
||||
// 清除所有认证数据(包括 keychain 中的内容)
|
||||
UserInfoManager.clearAllAuthenticationData()
|
||||
|
||||
// 发送通知重置 window root 为 login view
|
||||
NotificationCenter.default.post(name: .homeLogout, object: nil)
|
||||
|
||||
debugInfo("✅ 退出登录完成")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,4 +135,4 @@ struct MenuItemView: View {
|
||||
|
||||
#Preview {
|
||||
MeView()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user