From aa526639c6fbb502a0bc9792a674ca49dbc13414 Mon Sep 17 00:00:00 2001 From: zeng Date: Tue, 9 Jun 2026 14:29:16 +0800 Subject: [PATCH] 1 --- .../AppleParty/LoginView/APWebLoginVC.swift | 9 +++++--- AppleParty/AppleParty/RootView/APRootWC.swift | 21 +++++++++++++++---- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/AppleParty/AppleParty/LoginView/APWebLoginVC.swift b/AppleParty/AppleParty/LoginView/APWebLoginVC.swift index 4467228..139f71c 100644 --- a/AppleParty/AppleParty/LoginView/APWebLoginVC.swift +++ b/AppleParty/AppleParty/LoginView/APWebLoginVC.swift @@ -129,9 +129,12 @@ class APWebLoginVC: NSViewController { } func closeView() { - guard let window = view.window, let parent = window.sheetParent - else { return } - parent.endSheet(window) + guard let window = view.window else { return } + if let parent = window.sheetParent { + parent.endSheet(window) + } else { + window.close() + } } } diff --git a/AppleParty/AppleParty/RootView/APRootWC.swift b/AppleParty/AppleParty/RootView/APRootWC.swift index 79c6fea..bcd85a8 100644 --- a/AppleParty/AppleParty/RootView/APRootWC.swift +++ b/AppleParty/AppleParty/RootView/APRootWC.swift @@ -10,6 +10,8 @@ import Cocoa class APRootWC: NSWindowController { + private var loginWindowController: NSWindowController? + override func windowDidLoad() { super.windowDidLoad() setupUI() @@ -57,11 +59,22 @@ class APRootWC: NSWindowController { if #available(macOS 11.0, *) { self?.window?.subtitle = UserCenter.shared.accountEmail } + self?.loginWindowController = nil } - let pannel = NSPanel(contentViewController: vc) - pannel.minSize = NSSize(width: 900, height: 680) - pannel.setFrame(NSRect(origin: .zero, size: NSSize(width: 980, height: 760)), display: true) - window?.beginSheet(pannel, completionHandler: nil) + vc.cancelHandle = { [weak self] in + self?.loginWindowController = nil + } + + let loginWindow = NSWindow(contentViewController: vc) + loginWindow.title = "App Store Connect" + loginWindow.styleMask = [.titled, .closable, .miniaturizable, .resizable] + loginWindow.minSize = NSSize(width: 900, height: 680) + loginWindow.setFrame(NSScreen.main?.visibleFrame ?? NSRect(x: 0, y: 0, width: 1280, height: 800), display: true) + + let loginWC = NSWindowController(window: loginWindow) + loginWindowController = loginWC + loginWC.showWindow(self) + loginWindow.makeKeyAndOrderFront(self) } }