- 删除分组实体:分组视图/编辑器/仓储与 groupId 全部移除,升级首启清理 instance-groups.json 与 fleet.groupMode - 新增批量标签表:三态覆盖度(未贴 / N/M / 全部),整批加减与新建标签 - 配色重构,全应用零蓝色:石墨墨色承担主操作与选中态,颜色只留给状态语义; 浅色改中性冷灰,深色改低明度石墨三层 - 选中态改实心主色 + onPrimary,替换不可读的低透明度色雾(主题块、图例胶囊) - 应用图标重做为扁平石墨底 + 黄铜 SIM 面板,参数化光栅化脚本与参考稿 - 运行概览:检测进度并入副标题,读数栅格固定八格两行并保留不可用占位 - 实例详情:仪表改两列发丝线栅格,缺数据留轨道,修掉头部高度回弹; 补齐设备名称/存储总量/可用存储/使用率四个字段名 - 版本号显示去掉括号,设置页只显示 0.2.2 - 文档:新增 docs/ios-native-0.2.2.md,同步 ios-native.md 与两处 README
84 lines
2.8 KiB
Swift
84 lines
2.8 KiB
Swift
import Foundation
|
|
|
|
enum DefaultContainer {
|
|
private static let credentials: any CredentialStore = FileCredentialStore(
|
|
location: documentFileURL("credentials.json")
|
|
)
|
|
|
|
private static let logStore: any LogStore = FileLogStore(
|
|
location: documentFileURL("log-center.json")
|
|
)
|
|
|
|
static func documentFileURL(_ name: String) -> URL {
|
|
let directory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
|
|
return directory.appendingPathComponent(name)
|
|
}
|
|
|
|
@MainActor
|
|
static func makeFleetModel() -> FleetViewModel {
|
|
purgeLegacyGrouping()
|
|
return FleetViewModel(
|
|
repository: FileInstanceRepository(location: documentFileURL("instances.json")),
|
|
probe: ConnectionProbe(client: SimAdminClient()),
|
|
credentials: credentials,
|
|
deviceService: DeviceService(
|
|
client: SimAdminClient(),
|
|
sessions: InstanceSessionStore(),
|
|
credentials: credentials
|
|
)
|
|
)
|
|
}
|
|
|
|
/// 0.2.2 起分组被标签取代,遗留的分组文件与偏好键一次性清掉,避免 Documents 里留死数据。
|
|
private static func purgeLegacyGrouping() {
|
|
try? FileManager.default.removeItem(at: documentFileURL("instance-groups.json"))
|
|
UserDefaults.standard.removeObject(forKey: "fleet.groupMode")
|
|
}
|
|
|
|
@MainActor
|
|
static func makeMessagesModel() -> MessagesViewModel {
|
|
MessagesViewModel(
|
|
repository: FileInstanceRepository(location: documentFileURL("instances.json")),
|
|
service: MessageService(
|
|
client: SimAdminClient(),
|
|
sessions: InstanceSessionStore(),
|
|
credentials: credentials
|
|
)
|
|
)
|
|
}
|
|
|
|
@MainActor
|
|
static func makeLogsModel(autoRefreshOnAppear: Bool = true) -> LogsViewModel {
|
|
let store = logStore
|
|
return LogsViewModel(
|
|
repository: FileInstanceRepository(location: documentFileURL("instances.json")),
|
|
service: LogCenterService(
|
|
client: SimAdminClient(),
|
|
sessions: InstanceSessionStore(),
|
|
credentials: credentials,
|
|
store: store
|
|
),
|
|
store: store,
|
|
autoRefreshOnAppear: autoRefreshOnAppear
|
|
)
|
|
}
|
|
|
|
@MainActor
|
|
static func makeSettingsModel() -> SettingsViewModel {
|
|
SettingsViewModel(store: logStore)
|
|
}
|
|
|
|
@MainActor
|
|
static func makeDeviceModel(instance: Instance) -> DeviceViewModel {
|
|
DeviceViewModel(
|
|
instance: instance,
|
|
service: DeviceService(
|
|
client: SimAdminClient(),
|
|
sessions: InstanceSessionStore(),
|
|
credentials: credentials
|
|
),
|
|
probe: ConnectionProbe(client: SimAdminClient())
|
|
)
|
|
}
|
|
}
|