From c123af8a4785122a631bb259177e17bd94521b40 Mon Sep 17 00:00:00 2001 From: anlicheng <244108715@qq.com> Date: Wed, 25 Mar 2026 14:16:50 +0800 Subject: [PATCH] fix --- punchnet/Views/Network/NetworkView.swift | 7 +++++-- punchnet/Views/Settings/SettingsAccountView.swift | 5 ++++- punchnet/punchnetApp.swift | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/punchnet/Views/Network/NetworkView.swift b/punchnet/Views/Network/NetworkView.swift index e59eccd..9965a91 100644 --- a/punchnet/Views/Network/NetworkView.swift +++ b/punchnet/Views/Network/NetworkView.swift @@ -20,7 +20,8 @@ enum NetworkShowMode: String, CaseIterable { // MARK: - 主网络视图 struct NetworkView: View { @Environment(AppContext.self) var appContext: AppContext - + @Environment(\.openWindow) var openWindow + @State private var showMode: NetworkShowMode = .resource @State private var connectState: ConnectState = .disconnected @@ -68,7 +69,9 @@ struct NetworkView: View { .frame(width: 160) } - SettingsLink { + Button { + openWindow(id: "settings") + } label: { Image(systemName: "slider.horizontal.3") .font(.system(size: 14)) .foregroundColor(.secondary) diff --git a/punchnet/Views/Settings/SettingsAccountView.swift b/punchnet/Views/Settings/SettingsAccountView.swift index 94cb0ec..647f6fc 100644 --- a/punchnet/Views/Settings/SettingsAccountView.swift +++ b/punchnet/Views/Settings/SettingsAccountView.swift @@ -100,6 +100,7 @@ extension SettingsAccountView { struct AccountCreditView: View { @Environment(AppContext.self) var appContext: AppContext @Environment(\.openWindow) var openWindow + @Environment(\.dismissWindow) var dismissWindow let username: String @@ -116,6 +117,7 @@ extension SettingsAccountView { try await appContext.logout() } self.appContext.appScene = .login(username: username) + self.dismissWindow(id: "settings") self.openWindow(id: "main") } .buttonStyle(.bordered) @@ -129,6 +131,7 @@ extension SettingsAccountView { struct TokenCreditView: View { @Environment(AppContext.self) var appContext: AppContext @Environment(\.openWindow) var openWindow + @Environment(\.dismissWindow) var dismissWindow let token: String @@ -139,8 +142,8 @@ extension SettingsAccountView { try await appContext.logout() } self.appContext.appScene = .login(username: nil) + self.dismissWindow(id: "settings") self.openWindow(id: "main") - // 执行关闭当前窗口的操作 } .buttonStyle(.bordered) .foregroundColor(.red) diff --git a/punchnet/punchnetApp.swift b/punchnet/punchnetApp.swift index a0cbe82..b3386d7 100644 --- a/punchnet/punchnetApp.swift +++ b/punchnet/punchnetApp.swift @@ -67,7 +67,7 @@ struct punchnetApp: App { .defaultPosition(.center) .windowStyle(.hiddenTitleBar) - Settings { + Window("settings", id: "settings") { SettingsView() .environment(self.appContext) .frame(width: 750, height: 450)