Files
ShadowsocksX-NG/ShadowsocksX-NG2/App/WorkspaceRoute.swift
T
Qiu Yuzhou 0d0e74d59c feat(ui): menu-bar-only form with scene-based main window
Replace the hybrid form (LSUIElement + runtime activation-policy
switching + AppKit-owned NSWindow) with a plain SwiftUI Window scene:
the app stays accessory at all times, launch presents the workspace
window via defaultLaunchBehavior(.presented), and the status menu
reopens it after close via openWindow. Drop AppDelegate and the
window-opening adapter and intents; WorkspaceRoute keeps navigation
state only, with the scene id defined there. Documented in ADR 0016
and CONTEXT.md.
2026-09-28 19:18:27 +08:00

34 lines
1.4 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import Combine
/// 单一主 workspace 的有限 destination 词汇。它只描述导航位置,不携带功能区
/// 的选择、sheet、alert 或编辑草稿。
enum WorkspaceDestination: String, CaseIterable, Hashable, Identifiable, Sendable {
case home
case servers
case subscriptions
case settings
case diagnostics
var id: Self { self }
}
/// workspace route module:集中 destination 与 workspace 内部导航。路由状态
/// 只存在于进程内,新实例始终从 home 开始。主窗口的呈现:启动由 Window
/// scene 的 defaultLaunchBehavior(.presented) 自动呈现,关窗后由状态菜单经
/// SwiftUI `openWindow` 重开(scene id 单点定义见 workspaceSceneID);本
/// module 不依赖任何 UI framework,也不持有开窗 effect。
@MainActor
final class WorkspaceRoute: ObservableObject {
/// 主 workspace 的 SwiftUI `Window` scene id:scene 在组合根(MainApp)
/// 以此常量声明,状态菜单是关窗后的重开入口。字面量单点定义在此,防
/// scene id 散落(架构测试锚定)。
static let workspaceSceneID = "workspace"
@Published private(set) var destination: WorkspaceDestination = .home
/// workspace 内部导航只改变 route destination;开窗不由 route 驱动。
func navigate(to destination: WorkspaceDestination) {
self.destination = destination
}
}