fix
This commit is contained in:
parent
c5b2cb3e83
commit
b067991c8b
@ -58,98 +58,94 @@ struct SettingsAccountView: View {
|
||||
}
|
||||
|
||||
// MARK: - 内部视图扩展
|
||||
extension SettingsAccountView {
|
||||
// 统一的条目容器样式
|
||||
private struct AccountRow: View {
|
||||
let icon: String
|
||||
let title: String
|
||||
let subtitle: String
|
||||
var actions: AnyView
|
||||
|
||||
// 统一的条目容器样式
|
||||
struct AccountRow: View {
|
||||
let icon: String
|
||||
let title: String
|
||||
let subtitle: String
|
||||
var actions: AnyView
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 16) {
|
||||
// 模拟 Logo
|
||||
Circle()
|
||||
.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(title)
|
||||
.font(.subheadline)
|
||||
.foregroundColor(.secondary)
|
||||
|
||||
Text(subtitle)
|
||||
.font(.system(size: 15, weight: .medium, design: .monospaced))
|
||||
.lineLimit(1)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
actions
|
||||
}
|
||||
.padding(16)
|
||||
}
|
||||
}
|
||||
|
||||
struct AccountCreditView: View {
|
||||
@Environment(AppContext.self) var appContext: AppContext
|
||||
@Environment(\.openWindow) var openWindow
|
||||
@Environment(\.dismissWindow) var dismissWindow
|
||||
|
||||
let username: String
|
||||
|
||||
var body: some View {
|
||||
AccountRow(icon: "person.fill", title: "当前登录账号", subtitle: username, actions: AnyView(
|
||||
HStack(spacing: 12) {
|
||||
// Button("修改密码") {
|
||||
//
|
||||
// }
|
||||
// .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)
|
||||
}
|
||||
))
|
||||
var body: some View {
|
||||
HStack(spacing: 16) {
|
||||
// 模拟 Logo
|
||||
Circle()
|
||||
.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(title)
|
||||
.font(.subheadline)
|
||||
.foregroundColor(.secondary)
|
||||
|
||||
Text(subtitle)
|
||||
.font(.system(size: 15, weight: .medium, design: .monospaced))
|
||||
.lineLimit(1)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
actions
|
||||
}
|
||||
.padding(16)
|
||||
}
|
||||
|
||||
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(
|
||||
private struct AccountCreditView: View {
|
||||
@Environment(AppContext.self) var appContext: AppContext
|
||||
@Environment(\.openWindow) var openWindow
|
||||
@Environment(\.dismissWindow) var dismissWindow
|
||||
|
||||
let username: String
|
||||
|
||||
var body: some View {
|
||||
AccountRow(icon: "person.fill", title: "当前登录账号", subtitle: username, actions: AnyView(
|
||||
HStack(spacing: 12) {
|
||||
// Button("修改密码") {
|
||||
//
|
||||
// }
|
||||
// .buttonStyle(.link)
|
||||
|
||||
Button("退出登录") {
|
||||
Task { @MainActor in
|
||||
try await appContext.logout()
|
||||
}
|
||||
|
||||
self.appContext.appScene = .login(username: nil)
|
||||
self.appContext.appScene = .login(username: username)
|
||||
self.dismissWindow(id: "settings")
|
||||
self.openWindow(id: "main")
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
.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: - 子组件:设备属性行
|
||||
struct DevicePropertyRow<Content: View>: View {
|
||||
private struct DevicePropertyRow<Content: View>: View {
|
||||
let title: String
|
||||
let value: String
|
||||
let trailingContent: () -> Content
|
||||
|
||||
@ -133,7 +133,7 @@ struct SettingsNetworkView: View {
|
||||
|
||||
}
|
||||
|
||||
struct StatusRow: View {
|
||||
private struct StatusRow: View {
|
||||
let title: String
|
||||
let value: String
|
||||
let valueColor: Color
|
||||
|
||||
@ -92,7 +92,7 @@ struct SettingsSystemView: View {
|
||||
}
|
||||
|
||||
// MARK: - 子组件:开关行
|
||||
struct ToggleRow: View {
|
||||
private struct ToggleRow: View {
|
||||
let icon: String
|
||||
let title: String
|
||||
@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 {
|
||||
withAnimation {
|
||||
isSubmitting = true
|
||||
@ -156,28 +184,5 @@ struct SettingsUserIssueView: View {
|
||||
|
||||
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: - 子组件:侧边栏按钮样式
|
||||
struct SidebarItem: View {
|
||||
private struct SidebarItem: View {
|
||||
let icon: String
|
||||
let title: String
|
||||
let isSelected: Bool
|
||||
|
||||
@ -43,7 +43,8 @@ class AppUpdateManager {
|
||||
}
|
||||
}
|
||||
|
||||
struct VersionComparator {
|
||||
private struct VersionComparator {
|
||||
|
||||
/// 比较版本号:如果 current < latest 返回 true (需要更新)
|
||||
static func isVersion(_ current: String, olderThan latest: String) -> Bool {
|
||||
let currentComponents = current.split(separator: ".").map { Int($0) ?? 0 }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user