原生 macOS 客户端脚手架 + 元数据完整命名去缩写
- 命名去缩写:xcodegen 项目 + 四 target CDrop*→CommilitiaDrop*(CommilitiaDrop / …Share / …Widgets / …Tests);3 个 widget/control kind net.commilitia.cdrop.*→net.commilitia.Commilitia-Drop.*(旧装控件将成孤儿,需在设备重加);Tests @testable import CommilitiaDrop。刻意不动线协议 / 身份标识——bundle ID 家族、URL scheme cdrop://、Bonjour _cdrop._tcp、keychain service、DataChannel cdrop-file、entitlements 文件名——以免破跨端互通或丢会话 - 新增 macOS app target CommilitiaDropMac(platform macOS / deploymentTarget 26.0 / ARCHS arm64 / 与 iOS 同 bundle net.commilitia.Commilitia-Drop,同 App Store 记录 + 同 App Group):sources 仅 MacApp/,Info.plist 经 xcodegen 生成,本地 ad-hoc 免账号编译 - Mac 壳 MacApp/(Allman,#if os(macOS) 守卫,独立 @main 不与 iOS CDropApp 冲突):CommilitiaDropMacApp(@main + 单窗口 Window + windowResizability contentMinSize + 去 ⌘N + MenuBarExtra window 风格)、MacRootView(NavigationSplitView 侧栏五区骨架 传输/文件/消息/设备/设置 + 占位详情 MacPlaceholder + 品牌头)、MacMenuContent(菜单栏占位) - Support/macOS/AppMac.entitlements:App Group group.net.commilitia.Commilitia-Drop 预置待用;macOS 下 App Group 属受限能力须 provisioning profile,故脚手架阶段 project.yml 暂不引用,待 Phase 6 Developer ID 签名再挂 - 根 Justfile:ios-sim-build / ios-device 跟随重命名(项目 / scheme / .app 路径);新增 mac-build(xcodegen + xcodebuild -sdk macosx,本地 ad-hoc) - 验证:CommilitiaDropMac.app 与 CommilitiaDrop.app(iOS 模拟器)均 BUILD SUCCEEDED;WebRTC 走 -clonedSourcePackagesDirPath 复用已缓存 xcframework
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
#if os(macOS)
|
||||
import SwiftUI
|
||||
|
||||
// 原生 macOS 客户端入口。单窗口 + 菜单栏常驻,桌面壳(MacRootView)替代 iOS 的标签栏。
|
||||
// 当前为脚手架:导航骨架 + 菜单栏占位;引擎(LibWebRtcEngine + 离屏 WebView)、复用视图与
|
||||
// 桌面专属功能(剪贴板自动同步 / 全局热键 / 原生通知)随后续阶段并入。iOS 入口另见 CDropApp。
|
||||
@main
|
||||
struct CommilitiaDropMacApp: App
|
||||
{
|
||||
var body: some Scene
|
||||
{
|
||||
// 启动即打开的单主窗口。
|
||||
Window("Commilitia Drop", id: "main")
|
||||
{
|
||||
MacRootView()
|
||||
.frame(minWidth: 820, minHeight: 560)
|
||||
}
|
||||
.defaultLaunchBehavior(.presented)
|
||||
.windowResizability(.contentMinSize)
|
||||
.commands
|
||||
{
|
||||
// 单窗口应用:移除「新建」(⌘N),对本应用无意义。
|
||||
CommandGroup(replacing: .newItem) {}
|
||||
}
|
||||
|
||||
// 菜单栏常驻:状态 + 快捷剪贴板 / Quick Send(当前占位)。
|
||||
MenuBarExtra
|
||||
{
|
||||
MacMenuContent()
|
||||
}
|
||||
label:
|
||||
{
|
||||
Image(systemName: "paperplane")
|
||||
}
|
||||
.menuBarExtraStyle(.window)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,27 @@
|
||||
#if os(macOS)
|
||||
import SwiftUI
|
||||
|
||||
// 菜单栏常驻内容(占位):后续接入连接状态 + 一键剪贴板 push/pull + Quick Send。
|
||||
struct MacMenuContent: View
|
||||
{
|
||||
@Environment(\.openWindow) private var openWindow
|
||||
|
||||
var body: some View
|
||||
{
|
||||
VStack(alignment: .leading, spacing: 10)
|
||||
{
|
||||
Text("Commilitia Drop")
|
||||
.font(.headline)
|
||||
Text("桌面功能适配中")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
|
||||
Divider()
|
||||
Button("打开主窗口") { openWindow(id: "main") }
|
||||
Button("退出") { NSApplication.shared.terminate(nil) }
|
||||
}
|
||||
.padding(12)
|
||||
.frame(width: 240)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,126 @@
|
||||
#if os(macOS)
|
||||
import SwiftUI
|
||||
|
||||
// 桌面根界面:NavigationSplitView 侧栏(传输 / 文件 / 消息 / 设备 / 设置)+ 详情 NavigationStack,
|
||||
// 替代 iOS 的标签栏。当前为脚手架:各区详情为占位(MacPlaceholder),随后续阶段接入复用视图
|
||||
// 与桌面专属功能。分区标签暂硬编中文;接入 i18n(Shared/I18n)后改走 t()(与 iOS 单一真源一致)。
|
||||
struct MacRootView: View
|
||||
{
|
||||
@State private var selection: MacSection = .transfers
|
||||
|
||||
var body: some View
|
||||
{
|
||||
NavigationSplitView
|
||||
{
|
||||
List(selection: $selection)
|
||||
{
|
||||
brandHeader
|
||||
.listRowInsets(EdgeInsets(top: 10, leading: 8, bottom: 14, trailing: 8))
|
||||
.listRowSeparator(.hidden)
|
||||
.selectionDisabled()
|
||||
Section
|
||||
{
|
||||
ForEach(MacSection.sidebar)
|
||||
{ section in
|
||||
Label(section.title, systemImage: section.icon)
|
||||
.tag(section)
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationSplitViewColumnWidth(min: 200, ideal: 220, max: 280)
|
||||
.navigationTitle("Commilitia Drop")
|
||||
}
|
||||
detail:
|
||||
{
|
||||
NavigationStack
|
||||
{
|
||||
detail
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var detail: some View
|
||||
{
|
||||
switch selection
|
||||
{
|
||||
case .transfers:
|
||||
MacPlaceholder(section: .transfers)
|
||||
case .files:
|
||||
MacPlaceholder(section: .files)
|
||||
case .messages:
|
||||
MacPlaceholder(section: .messages)
|
||||
case .devices:
|
||||
MacPlaceholder(section: .devices)
|
||||
case .settings:
|
||||
MacPlaceholder(section: .settings)
|
||||
}
|
||||
}
|
||||
|
||||
private var brandHeader: some View
|
||||
{
|
||||
HStack(spacing: 10)
|
||||
{
|
||||
Image(systemName: "paperplane.fill")
|
||||
.font(.title2)
|
||||
.foregroundStyle(.tint)
|
||||
Text("Commilitia Drop")
|
||||
.font(.title3.weight(.semibold))
|
||||
.lineLimit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 侧栏分区。与 iOS 标签一致:传输 / 文件 / 消息 / 设备 / 设置。
|
||||
enum MacSection: Hashable, Identifiable, CaseIterable
|
||||
{
|
||||
case transfers, files, messages, devices, settings
|
||||
|
||||
var id: Self { self }
|
||||
|
||||
var title: String
|
||||
{
|
||||
switch self
|
||||
{
|
||||
case .transfers: return "传输"
|
||||
case .files: return "文件"
|
||||
case .messages: return "消息"
|
||||
case .devices: return "设备"
|
||||
case .settings: return "设置"
|
||||
}
|
||||
}
|
||||
|
||||
var icon: String
|
||||
{
|
||||
switch self
|
||||
{
|
||||
case .transfers: return "arrow.up.arrow.down"
|
||||
case .files: return "folder"
|
||||
case .messages: return "bubble.left.and.bubble.right"
|
||||
case .devices: return "laptopcomputer.and.iphone"
|
||||
case .settings: return "gearshape"
|
||||
}
|
||||
}
|
||||
|
||||
static var sidebar: [MacSection] { MacSection.allCases }
|
||||
}
|
||||
|
||||
// 阶段占位详情:标明该区将接入的功能,随后续阶段替换为实际视图。
|
||||
struct MacPlaceholder: View
|
||||
{
|
||||
let section: MacSection
|
||||
|
||||
var body: some View
|
||||
{
|
||||
ContentUnavailableView
|
||||
{
|
||||
Label(section.title, systemImage: section.icon)
|
||||
}
|
||||
description:
|
||||
{
|
||||
Text("即将接入(原生数据面复用 iOS 引擎,桌面功能适配中)。")
|
||||
}
|
||||
.navigationTitle(section.title)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user