#if os(macOS) import SwiftUI // 原生 macOS 登录:以 Commilitia 账户(Auth Broker)登录为主,免相机——ASWebAuthenticationSession // 弹系统授权窗,回调经 cdrop:// 回到 app(见 BrokerLogin / AuthManager.startBrokerLogin)。不复用 // iOS 的 LoginView(其二维码 / UIImage 路径为 iOS 专属,且没人扫 Mac 屏幕来登录 Mac 自己)。 struct MacLoginView: View { @Environment(AuthManager.self) private var auth @State private var busy = false var body: some View { VStack(spacing: 20) { Image(systemName: "paperplane.fill") .font(.system(size: 52)) .foregroundStyle(.tint) Text("Commilitia Drop") .font(.largeTitle.weight(.semibold)) Text("跨设备直连传输与云剪贴板") .font(.callout) .foregroundStyle(.secondary) Button { busy = true Task { await auth.startBrokerLogin() busy = false } } label: { Text(busy ? "登录中…" : "使用 Commilitia 账户登录") .frame(maxWidth: 260) } .controlSize(.large) .buttonStyle(.borderedProminent) .disabled(busy) if !auth.statusText.isEmpty { Text(auth.statusText) .font(.caption) .foregroundStyle(.secondary) } } .padding(40) .frame(maxWidth: .infinity, maxHeight: .infinity) } } #endif