init: init proj
This commit is contained in:
82
DDYSClient/Views/Settings/SettingsView.swift
Normal file
82
DDYSClient/Views/Settings/SettingsView.swift
Normal file
@@ -0,0 +1,82 @@
|
||||
import SwiftUI
|
||||
|
||||
struct SettingsView: View {
|
||||
@State private var showWebLogin = false
|
||||
@State private var showCookieInput = false
|
||||
@State private var showClearAlert = false
|
||||
private let cookieManager = CookieManager.shared
|
||||
|
||||
var body: some View {
|
||||
Form {
|
||||
// 认证状态
|
||||
Section("认证") {
|
||||
HStack {
|
||||
Label("状态", systemImage: cookieManager.isAuthenticated ? "checkmark.circle.fill" : "xmark.circle")
|
||||
.foregroundStyle(cookieManager.isAuthenticated ? .green : .secondary)
|
||||
Spacer()
|
||||
Text(cookieManager.isAuthenticated ? "已认证" : "未认证")
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
|
||||
#if canImport(WebKit)
|
||||
Button {
|
||||
showWebLogin = true
|
||||
} label: {
|
||||
Label("WebView 登录", systemImage: "globe")
|
||||
}
|
||||
#endif
|
||||
|
||||
Button {
|
||||
showCookieInput = true
|
||||
} label: {
|
||||
Label("手动输入 Cookie", systemImage: "doc.text")
|
||||
}
|
||||
|
||||
if cookieManager.isAuthenticated {
|
||||
Button(role: .destructive) {
|
||||
cookieManager.clearCookies()
|
||||
} label: {
|
||||
Label("退出登录", systemImage: "rectangle.portrait.and.arrow.right")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 缓存管理
|
||||
Section("数据") {
|
||||
Button(role: .destructive) {
|
||||
showClearAlert = true
|
||||
} label: {
|
||||
Label("清除观看记录", systemImage: "trash")
|
||||
}
|
||||
}
|
||||
|
||||
// 关于
|
||||
Section("关于") {
|
||||
HStack {
|
||||
Text("版本")
|
||||
Spacer()
|
||||
Text("1.0.0")
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
}
|
||||
.formStyle(.grouped)
|
||||
.navigationTitle("设置")
|
||||
.sheet(isPresented: $showWebLogin) {
|
||||
#if canImport(WebKit)
|
||||
WebLoginView()
|
||||
#endif
|
||||
}
|
||||
.sheet(isPresented: $showCookieInput) {
|
||||
CookieInputView()
|
||||
}
|
||||
.alert("确认清除", isPresented: $showClearAlert) {
|
||||
Button("清除", role: .destructive) {
|
||||
WatchProgressStore.shared.clearAll()
|
||||
}
|
||||
Button("取消", role: .cancel) {}
|
||||
} message: {
|
||||
Text("将清除所有观看进度记录,此操作不可撤销。")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user