48 lines
1.1 KiB
Swift
48 lines
1.1 KiB
Swift
//
|
|
// dimensionhubApp.swift
|
|
// dimensionhub
|
|
//
|
|
// Created by 安礼成 on 2025/2/18.
|
|
//
|
|
|
|
import SwiftUI
|
|
import SwiftData
|
|
|
|
@main
|
|
struct dimensionhubApp: App {
|
|
var sharedModelContainer: ModelContainer = {
|
|
let schema = Schema([
|
|
Item.self
|
|
])
|
|
let modelConfiguration = ModelConfiguration(
|
|
schema: schema,
|
|
isStoredInMemoryOnly: false,
|
|
allowsSave: true
|
|
)
|
|
|
|
do {
|
|
return try ModelContainer(for: schema, configurations: [modelConfiguration])
|
|
} catch {
|
|
fatalError("Could not create ModelContainer: \(error)")
|
|
}
|
|
}()
|
|
|
|
init() {
|
|
if let userId = UserDefaults.standard.string(forKey: "userId") {
|
|
print("user_id is: \(userId)")
|
|
} else {
|
|
UserDefaults.standard.set(Utils.defaultUserId(), forKey: "userId")
|
|
}
|
|
}
|
|
|
|
var body: some Scene {
|
|
WindowGroup {
|
|
NavigationStack {
|
|
IndexView()
|
|
}
|
|
.navigationViewStyle(.stack)
|
|
}
|
|
.modelContainer(sharedModelContainer)
|
|
}
|
|
}
|