Files
suixinkan_uikit/suixinkan/DataStore/AppStore.swift
汉秋 b7d74905b7 Add login flow, session routing, and MainTab shell aligned with reference UI.
Implement token-based root routing, Android-matched login screen, five-slot MainTabBar with scan action, and placeholder tab pages.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-06 15:12:34 +08:00

45 lines
879 B
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// AppStore.swift
// suixinkan
//
import Foundation
/// Android `AppStoreDataSource`
/// Token
final class AppStore {
static let shared = AppStore()
private enum Key {
static let token = "key_in_token"
}
private let defaults: UserDefaults
init(defaults: UserDefaults = .standard) {
self.defaults = defaults
}
/// Token
var token: String {
get { defaults.string(forKey: Key.token) ?? "" }
set { defaults.set(newValue, forKey: Key.token) }
}
/// Token
var isLoggedIn: Bool {
!token.isEmpty
}
/// Token
func saveToken(_ token: String) {
self.token = token
}
///
func logout() {
token = ""
}
}