29e5c0a739
- 命名去缩写: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
127 lines
3.5 KiB
Swift
127 lines
3.5 KiB
Swift
#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
|