feat: 1 2

This commit is contained in:
jinyaqiu 2025-08-27 15:41:33 +08:00
parent 112912a6d3
commit 44c1ed4d60
3 changed files with 37 additions and 1 deletions

View File

@ -4,7 +4,7 @@ import Security
/// Keychain
public class KeychainHelper {
// Keychain
private enum KeychainKey: String {
private enum KeychainKey: String, CaseIterable {
case accessToken = "com.memorywake.accessToken"
case refreshToken = "com.memorywake.refreshToken"
}
@ -35,6 +35,38 @@ public class KeychainHelper {
delete(for: .refreshToken)
}
/// Keychain
public static func clearAll() {
// keychain
KeychainKey.allCases.forEach { key in
delete(for: key)
}
//
let query: [String: Any] = [
kSecClass as String: kSecClassGenericPassword,
kSecReturnAttributes as String: true,
kSecMatchLimit as String: kSecMatchLimitAll
]
var result: AnyObject?
let status = SecItemCopyMatching(query as CFDictionary, &result)
if status == errSecSuccess, let items = result as? [[String: Any]] {
for item in items {
if let account = item[kSecAttrAccount as String] as? String,
let service = item[kSecAttrService as String] as? String {
let deleteQuery: [String: Any] = [
kSecClass as String: kSecClassGenericPassword,
kSecAttrAccount as String: account,
kSecAttrService as String: service
]
SecItemDelete(deleteQuery as CFDictionary)
}
}
}
}
// MARK: -
private static func save(_ string: String, for key: KeychainKey) -> Bool {

View File

@ -2,6 +2,7 @@ import SwiftUI
@MainActor
enum AppRoute: Hashable {
case login
case avatarBox
case feedbackView
case feedbackDetail(type: FeedbackView.FeedbackType)
@ -12,6 +13,8 @@ enum AppRoute: Hashable {
@ViewBuilder
var view: some View {
switch self {
case .login:
LoginView()
case .avatarBox:
AvatarBoxView()
case .feedbackView:

View File

@ -56,6 +56,7 @@ public struct AvatarPicker: View {
SVGImage(svgName: "IP")
.frame(width: avatarSize, height: avatarSize)
.contentShape(Rectangle())
.clipShape(RoundedRectangle(cornerRadius: 20))
.overlay(
RoundedRectangle(cornerRadius: 20)
.stroke(style: StrokeStyle(