512d7563ee
- 引擎 / 鉴权跨平台 in-place(iOS 路径 #if 守卫、逐字不变,仅加 macOS/AppKit 分支):EngineController(import 守卫 + 剪贴板 UIPasteboard→NSPasteboard 上下行两处 + device_type 平台条件)、EngineWebView(UIViewRepresentable→typealias 统一后分 NSViewRepresentable)、Theme(动态色 Color(nsColor:dynamicProvider) 同 RGB)、DeviceNameStore(Host.current().localizedName)、PushRegistry(NSApplication.registerForRemoteNotifications)、Auth/BrokerLogin(presentationAnchor→NSApplication.keyWindow)、Auth/AuthManager(死 import UIKit 守卫)
- BackgroundTaskManager:整文件 #if os(iOS)(BGContinuedProcessingTask 为 API_UNAVAILABLE(macos)、编译级拒绝)+ macOS 同签名 no-op stub,使 EngineController.syncBackgroundTask 调用点无须改动
- device_type 修正(非机械):Mac 原生客户端 boot 注入 device_type=macos(与桌面 Wails 客户端一致,后端 / 各端已识别),不再硬编 ios——否则其他端设备列表图标错、且触发其 isWakeable 的 contains("ios") 误判本 Mac 可推送唤醒
- CommilitiaDropMac target 纳入「引擎 + 登录」最小集:Shared + Sources/Engine + Sources/Auth(除 iOS 专属 LoginView)+ RecordsStore / PushRegistry / LocalNetworkPermission / DeviceNameStore / BackgroundTaskManager + Resources/i18n;依赖 WebRTC;Info.plist 加 cdrop:// 回调 scheme(ASWebAuthenticationSession OAuth 回调)+ 本地网络(NSLocalNetworkUsageDescription / NSBonjourServices _cdrop._tcp)
- Mac 壳接引擎:CommilitiaDropMacApp(@State auth + engine,MacAppRoot 登录门 + 会话激活分桶记录)、MacLoginView(Broker 账户登录,免相机)、MacRootView(背景挂离屏引擎 WebView 保活 + 设备真实 presence 列表 + 设置账号/登出/引擎日志)、MacMenuContent(账号 + 在线设备数)。传输/文件/消息详情暂占位,随 Phase 3b 复用 iOS 视图
- 验证:just mac-build(CommilitiaDropMac.app)+ iOS 模拟器(CommilitiaDrop.app)均 BUILD SUCCEEDED。运行期登录 / 引擎联通待真机自测(Broker OAuth 需账号交互)
47 lines
1.6 KiB
Swift
47 lines
1.6 KiB
Swift
import SwiftUI
|
||
import WebKit
|
||
|
||
// 跨平台桥接:iOS 用 UIViewRepresentable,macOS 原生用 NSViewRepresentable,二者所需方法名
|
||
// (makeUIView/updateUIView 与 makeNSView/updateNSView)不同,故经 typealias 统一协议名后,
|
||
// struct 体内仅方法实现按平台分支。
|
||
#if os(iOS)
|
||
private typealias PlatformViewRepresentable = UIViewRepresentable
|
||
#else
|
||
private typealias PlatformViewRepresentable = NSViewRepresentable
|
||
#endif
|
||
|
||
// 把 EngineController 持有的离屏 WKWebView 桥进 SwiftUI 视图树(保持存活)。无可见 UI
|
||
// 用途——引擎由 controller 经 JS 桥驱动(见 ios/PLAN.md arch A)。
|
||
struct EngineWebView: PlatformViewRepresentable
|
||
{
|
||
let controller: EngineController
|
||
// 会话源:在构建 WebView(注入 __CDROP_BOOT__)之前确定性接好。冷启动重开时,本视图的
|
||
// makeUIView 可能先于 AppRoot.onAppear 跑——若那时 controller.auth 仍为 nil,boot 注入
|
||
// session:null → 引擎报「missing injected session」整个 boot 死(#11)。故在此同步接好。
|
||
let auth: AuthManager
|
||
|
||
#if os(iOS)
|
||
func makeUIView(context: Context) -> WKWebView
|
||
{
|
||
controller.auth = auth
|
||
return controller.makeWebView()
|
||
}
|
||
|
||
func updateUIView(_ uiView: WKWebView, context: Context)
|
||
{
|
||
// 无需更新。
|
||
}
|
||
#else
|
||
func makeNSView(context: Context) -> WKWebView
|
||
{
|
||
controller.auth = auth
|
||
return controller.makeWebView()
|
||
}
|
||
|
||
func updateNSView(_ nsView: WKWebView, context: Context)
|
||
{
|
||
// 无需更新。
|
||
}
|
||
#endif
|
||
}
|