fix
This commit is contained in:
parent
c5b2cb3e83
commit
b067991c8b
@ -58,98 +58,94 @@ struct SettingsAccountView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - 内部视图扩展
|
// MARK: - 内部视图扩展
|
||||||
extension SettingsAccountView {
|
// 统一的条目容器样式
|
||||||
|
private struct AccountRow: View {
|
||||||
|
let icon: String
|
||||||
|
let title: String
|
||||||
|
let subtitle: String
|
||||||
|
var actions: AnyView
|
||||||
|
|
||||||
// 统一的条目容器样式
|
var body: some View {
|
||||||
struct AccountRow: View {
|
HStack(spacing: 16) {
|
||||||
let icon: String
|
// 模拟 Logo
|
||||||
let title: String
|
Circle()
|
||||||
let subtitle: String
|
.fill(Color.blue.gradient)
|
||||||
var actions: AnyView
|
.frame(width: 32, height: 32)
|
||||||
|
.overlay(
|
||||||
|
Image(systemName: icon)
|
||||||
|
.foregroundColor(.white)
|
||||||
|
.font(.system(size: 14))
|
||||||
|
)
|
||||||
|
|
||||||
var body: some View {
|
VStack(alignment: .leading, spacing: 2) {
|
||||||
HStack(spacing: 16) {
|
Text(title)
|
||||||
// 模拟 Logo
|
.font(.subheadline)
|
||||||
Circle()
|
.foregroundColor(.secondary)
|
||||||
.fill(Color.blue.gradient)
|
|
||||||
.frame(width: 32, height: 32)
|
|
||||||
.overlay(
|
|
||||||
Image(systemName: icon)
|
|
||||||
.foregroundColor(.white)
|
|
||||||
.font(.system(size: 14))
|
|
||||||
)
|
|
||||||
|
|
||||||
VStack(alignment: .leading, spacing: 2) {
|
Text(subtitle)
|
||||||
Text(title)
|
.font(.system(size: 15, weight: .medium, design: .monospaced))
|
||||||
.font(.subheadline)
|
.lineLimit(1)
|
||||||
.foregroundColor(.secondary)
|
|
||||||
|
|
||||||
Text(subtitle)
|
|
||||||
.font(.system(size: 15, weight: .medium, design: .monospaced))
|
|
||||||
.lineLimit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
Spacer()
|
|
||||||
|
|
||||||
actions
|
|
||||||
}
|
}
|
||||||
.padding(16)
|
|
||||||
|
Spacer()
|
||||||
|
|
||||||
|
actions
|
||||||
}
|
}
|
||||||
|
.padding(16)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct AccountCreditView: View {
|
private struct AccountCreditView: View {
|
||||||
@Environment(AppContext.self) var appContext: AppContext
|
@Environment(AppContext.self) var appContext: AppContext
|
||||||
@Environment(\.openWindow) var openWindow
|
@Environment(\.openWindow) var openWindow
|
||||||
@Environment(\.dismissWindow) var dismissWindow
|
@Environment(\.dismissWindow) var dismissWindow
|
||||||
|
|
||||||
let username: String
|
let username: String
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
AccountRow(icon: "person.fill", title: "当前登录账号", subtitle: username, actions: AnyView(
|
AccountRow(icon: "person.fill", title: "当前登录账号", subtitle: username, actions: AnyView(
|
||||||
HStack(spacing: 12) {
|
HStack(spacing: 12) {
|
||||||
// Button("修改密码") {
|
// Button("修改密码") {
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
// .buttonStyle(.link)
|
// .buttonStyle(.link)
|
||||||
|
|
||||||
Button("退出登录") {
|
|
||||||
Task { @MainActor in
|
|
||||||
try await appContext.logout()
|
|
||||||
}
|
|
||||||
self.appContext.appScene = .login(username: username)
|
|
||||||
self.dismissWindow(id: "settings")
|
|
||||||
self.openWindow(id: "main")
|
|
||||||
}
|
|
||||||
.buttonStyle(.bordered)
|
|
||||||
.foregroundColor(.red)
|
|
||||||
}
|
|
||||||
))
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct TokenCreditView: View {
|
|
||||||
@Environment(AppContext.self) var appContext: AppContext
|
|
||||||
@Environment(\.openWindow) var openWindow
|
|
||||||
@Environment(\.dismissWindow) var dismissWindow
|
|
||||||
|
|
||||||
let token: String
|
|
||||||
|
|
||||||
var body: some View {
|
|
||||||
AccountRow(icon: "key.horizontal.fill", title: "Token 登录", subtitle: token, actions: AnyView(
|
|
||||||
Button("退出登录") {
|
Button("退出登录") {
|
||||||
Task { @MainActor in
|
Task { @MainActor in
|
||||||
try await appContext.logout()
|
try await appContext.logout()
|
||||||
}
|
}
|
||||||
|
self.appContext.appScene = .login(username: username)
|
||||||
self.appContext.appScene = .login(username: nil)
|
|
||||||
self.dismissWindow(id: "settings")
|
self.dismissWindow(id: "settings")
|
||||||
self.openWindow(id: "main")
|
self.openWindow(id: "main")
|
||||||
}
|
}
|
||||||
.buttonStyle(.bordered)
|
.buttonStyle(.bordered)
|
||||||
.foregroundColor(.red)
|
.foregroundColor(.red)
|
||||||
))
|
}
|
||||||
}
|
))
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private struct TokenCreditView: View {
|
||||||
|
@Environment(AppContext.self) var appContext: AppContext
|
||||||
|
@Environment(\.openWindow) var openWindow
|
||||||
|
@Environment(\.dismissWindow) var dismissWindow
|
||||||
|
|
||||||
|
let token: String
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
AccountRow(icon: "key.horizontal.fill", title: "Token 登录", subtitle: token, actions: AnyView(
|
||||||
|
Button("退出登录") {
|
||||||
|
Task { @MainActor in
|
||||||
|
try await appContext.logout()
|
||||||
|
}
|
||||||
|
|
||||||
|
self.appContext.appScene = .login(username: nil)
|
||||||
|
self.dismissWindow(id: "settings")
|
||||||
|
self.openWindow(id: "main")
|
||||||
|
}
|
||||||
|
.buttonStyle(.bordered)
|
||||||
|
.foregroundColor(.red)
|
||||||
|
))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -96,7 +96,7 @@ struct SettingsDeviceView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - 子组件:设备属性行
|
// MARK: - 子组件:设备属性行
|
||||||
struct DevicePropertyRow<Content: View>: View {
|
private struct DevicePropertyRow<Content: View>: View {
|
||||||
let title: String
|
let title: String
|
||||||
let value: String
|
let value: String
|
||||||
let trailingContent: () -> Content
|
let trailingContent: () -> Content
|
||||||
|
|||||||
@ -133,7 +133,7 @@ struct SettingsNetworkView: View {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct StatusRow: View {
|
private struct StatusRow: View {
|
||||||
let title: String
|
let title: String
|
||||||
let value: String
|
let value: String
|
||||||
let valueColor: Color
|
let valueColor: Color
|
||||||
|
|||||||
@ -92,7 +92,7 @@ struct SettingsSystemView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - 子组件:开关行
|
// MARK: - 子组件:开关行
|
||||||
struct ToggleRow: View {
|
private struct ToggleRow: View {
|
||||||
let icon: String
|
let icon: String
|
||||||
let title: String
|
let title: String
|
||||||
@Binding var isOn: Bool
|
@Binding var isOn: Bool
|
||||||
|
|||||||
@ -122,7 +122,35 @@ struct SettingsUserIssueView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - 提交逻辑
|
// MARK: - 成功弹窗视图
|
||||||
|
private var successPopup: some View {
|
||||||
|
VStack(spacing: 16) {
|
||||||
|
Image(systemName: "checkmark.seal.fill")
|
||||||
|
.font(.system(size: 44))
|
||||||
|
.foregroundStyle(.green.gradient)
|
||||||
|
|
||||||
|
Text("发送成功")
|
||||||
|
.font(.headline)
|
||||||
|
|
||||||
|
Text("感谢您的支持!")
|
||||||
|
.font(.subheadline)
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
}
|
||||||
|
.padding(40)
|
||||||
|
.background(.ultraThinMaterial) // macOS 磨砂质感
|
||||||
|
.cornerRadius(24)
|
||||||
|
.shadow(color: .black.opacity(0.15), radius: 20)
|
||||||
|
.transition(.asymmetric(
|
||||||
|
insertion: .scale(scale: 0.8).combined(with: .opacity),
|
||||||
|
removal: .opacity.combined(with: .scale(scale: 1.1))
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: Actions 提交逻辑
|
||||||
|
extension SettingsUserIssueView {
|
||||||
|
|
||||||
private func submitFeedback() async {
|
private func submitFeedback() async {
|
||||||
withAnimation {
|
withAnimation {
|
||||||
isSubmitting = true
|
isSubmitting = true
|
||||||
@ -157,27 +185,4 @@ struct SettingsUserIssueView: View {
|
|||||||
self.isSubmitting = false
|
self.isSubmitting = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - 成功弹窗视图
|
|
||||||
private var successPopup: some View {
|
|
||||||
VStack(spacing: 16) {
|
|
||||||
Image(systemName: "checkmark.seal.fill")
|
|
||||||
.font(.system(size: 44))
|
|
||||||
.foregroundStyle(.green.gradient)
|
|
||||||
|
|
||||||
Text("发送成功")
|
|
||||||
.font(.headline)
|
|
||||||
|
|
||||||
Text("感谢您的支持!")
|
|
||||||
.font(.subheadline)
|
|
||||||
.foregroundColor(.secondary)
|
|
||||||
}
|
|
||||||
.padding(40)
|
|
||||||
.background(.ultraThinMaterial) // macOS 磨砂质感
|
|
||||||
.cornerRadius(24)
|
|
||||||
.shadow(color: .black.opacity(0.15), radius: 20)
|
|
||||||
.transition(.asymmetric(
|
|
||||||
insertion: .scale(scale: 0.8).combined(with: .opacity),
|
|
||||||
removal: .opacity.combined(with: .scale(scale: 1.1))
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -111,7 +111,7 @@ struct SettingsView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - 子组件:侧边栏按钮样式
|
// MARK: - 子组件:侧边栏按钮样式
|
||||||
struct SidebarItem: View {
|
private struct SidebarItem: View {
|
||||||
let icon: String
|
let icon: String
|
||||||
let title: String
|
let title: String
|
||||||
let isSelected: Bool
|
let isSelected: Bool
|
||||||
|
|||||||
@ -43,7 +43,8 @@ class AppUpdateManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct VersionComparator {
|
private struct VersionComparator {
|
||||||
|
|
||||||
/// 比较版本号:如果 current < latest 返回 true (需要更新)
|
/// 比较版本号:如果 current < latest 返回 true (需要更新)
|
||||||
static func isVersion(_ current: String, olderThan latest: String) -> Bool {
|
static func isVersion(_ current: String, olderThan latest: String) -> Bool {
|
||||||
let currentComponents = current.split(separator: ".").map { Int($0) ?? 0 }
|
let currentComponents = current.split(separator: ".").map { Int($0) ?? 0 }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user