From e0be89ada7d7e9681d853a84c80deae42142ee0d Mon Sep 17 00:00:00 2001 From: taekchef Date: Sat, 25 Jul 2026 05:37:53 +0800 Subject: [PATCH] fix(settings): declutter UX and stage app outside Documents for signing Strip filler copy and status-only rows, unify switches/fonts, make sidebar tabs full-row clickable, and drop the redundant SETTINGS brand line. Assemble and codesign under /tmp so File Provider xattrs on ~/Documents no longer break the ad-hoc signature and Keychain re-prompts every launch. --- .../Views/Settings/AgentSettingsView.swift | 7 +- .../WeiBei/Views/Settings/SettingsView.swift | 319 ++++++------------ Sources/WeiBeiSelfCheck/main.swift | 29 +- script/build_and_run.sh | 35 +- 4 files changed, 165 insertions(+), 225 deletions(-) diff --git a/Sources/WeiBei/Views/Settings/AgentSettingsView.swift b/Sources/WeiBei/Views/Settings/AgentSettingsView.swift index de5abc820..46a1e44b0 100644 --- a/Sources/WeiBei/Views/Settings/AgentSettingsView.swift +++ b/Sources/WeiBei/Views/Settings/AgentSettingsView.swift @@ -235,10 +235,9 @@ extension SettingsView { } private var agentAPIKeyAuth: some View { - settingsRow( - title: store.ui("密钥", "API Key"), - detail: AgentProviderConsoleLinks.keyHelp(language: store.interfaceLanguage, provider: store.agentProviderID) - ) { + // No long key-help blurb under the field — console button + status notes + // cover the rare cases that need guidance. + settingsRow(title: store.ui("密钥", "API Key")) { VStack(alignment: .trailing, spacing: 8) { SecureField( "", diff --git a/Sources/WeiBei/Views/Settings/SettingsView.swift b/Sources/WeiBei/Views/Settings/SettingsView.swift index 6a4b9886b..0024e25a6 100644 --- a/Sources/WeiBei/Views/Settings/SettingsView.swift +++ b/Sources/WeiBei/Views/Settings/SettingsView.swift @@ -110,26 +110,11 @@ struct SettingsView: View { private var settingsSidebar: some View { VStack(alignment: .leading, spacing: 18) { - VStack(alignment: .leading, spacing: 4) { - Text(store.ui("设置", "Settings")) - .font(WeiBeiTypography.brandFont(language: store.interfaceLanguage, size: 28, weight: .semibold)) - .foregroundStyle(WeiBeiTheme.ink) - HStack(alignment: .firstTextBaseline, spacing: 8) { - Text(store.brandLatinName) - .font(WeiBeiTypography.englishBrandFont(size: 18, weight: .semibold)) - Text("SETTINGS") - .font(WeiBeiTypography.englishBrandFont(size: 9, weight: .semibold)) - .tracking(1.1) - .foregroundStyle(WeiBeiTheme.cinnabar.opacity(0.82)) - } - .foregroundStyle(WeiBeiTheme.cinnabar.opacity(0.90)) - Text(store.ui("管理魏碑的界面、写作、对话和本地资料。", "Manage WeiBei interface, writing, chat, and local library.")) - .font(.system(size: 11.5)) - .lineSpacing(2) - .foregroundStyle(WeiBeiTheme.secondaryInk) - } - .padding(.horizontal, 22) - .padding(.top, 24) + Text(store.ui("设置", "Settings")) + .font(WeiBeiTypography.brandFont(language: store.interfaceLanguage, size: 28, weight: .semibold)) + .foregroundStyle(WeiBeiTheme.ink) + .padding(.horizontal, 22) + .padding(.top, 24) VStack(spacing: 3) { ForEach(SettingsSection.allCases) { section in @@ -140,17 +125,31 @@ struct SettingsView: View { Spacer() + // Glanceable current language / theme — tappable so they jump to Appearance. VStack(alignment: .leading, spacing: 9) { - settingsPill( - title: store.interfaceLanguage.settingsLabel, - icon: "character.book.closed", - active: false - ) - settingsPill( - title: store.appearanceMode.label(language: store.interfaceLanguage), - icon: store.appearanceMode.systemImage, - active: false - ) + Button { + withAnimation(WeiBeiMotion.panel) { selectedSection = .appearance } + } label: { + settingsPill( + title: store.interfaceLanguage.settingsLabel, + icon: "character.book.closed", + active: false + ) + } + .buttonStyle(.plain) + .help(store.ui("前往外观设置", "Go to Appearance")) + + Button { + withAnimation(WeiBeiMotion.panel) { selectedSection = .appearance } + } label: { + settingsPill( + title: store.appearanceMode.label(language: store.interfaceLanguage), + icon: store.appearanceMode.systemImage, + active: false + ) + } + .buttonStyle(.plain) + .help(store.ui("前往外观设置", "Go to Appearance")) } .padding(.horizontal, 14) .padding(.bottom, 18) @@ -204,15 +203,10 @@ struct SettingsView: View { } private var settingsHeader: some View { - HStack(alignment: .firstTextBaseline) { - VStack(alignment: .leading, spacing: 3) { - Text(selectedSection.title(store)) - .font(WeiBeiTypography.brandFont(language: store.interfaceLanguage, size: 24, weight: .semibold)) - .foregroundStyle(WeiBeiTheme.ink) - Text(sectionSubtitle) - .font(.system(size: 12)) - .foregroundStyle(WeiBeiTheme.secondaryInk) - } + HStack(alignment: .center) { + Text(selectedSection.title(store)) + .font(WeiBeiTypography.brandFont(language: store.interfaceLanguage, size: 24, weight: .semibold)) + .foregroundStyle(WeiBeiTheme.ink) Spacer() settingsAppearanceToggleButton } @@ -240,30 +234,10 @@ struct SettingsView: View { .help(store.appearanceMode.actionLabel(language: store.interfaceLanguage)) } - private var sectionSubtitle: String { - switch selectedSection { - case .appearance: - return store.ui("统一控制语言与主题。", "Control language and theme.") - case .reading: - return store.ui("阅读设置只放当前已经接入真实行为的开关。", "Reading settings only expose behavior that is already wired.") - case .writing: - return store.ui("设置 Markdown 写作形态和笔记默认视图。", "Set Markdown writing behavior and the default note view.") - case .agent: - return store.ui("管理对话、上下文、密钥和默认入口。", "Manage chat, context, API key, and the default entry.") - case .data: - return store.ui("管理资料导入、笔记和本地数据入口。", "Manage material import, notes, and local data entry points.") - case .shortcuts: - return store.ui("查看当前全键盘交互入口。", "Review the current keyboard workflow.") - } - } - private var appearanceSettings: some View { VStack(alignment: .leading, spacing: 16) { settingsGroup(store.ui("语言", "Language")) { - settingsRow( - title: store.ui("界面语言", "Interface Language"), - detail: store.ui("切换后菜单、按钮、状态提示和内置样例标题会同步更新。", "Menus, buttons, status hints, and built-in sample titles update together.") - ) { + settingsRow(title: store.ui("界面语言", "Interface Language")) { segmented(WeiBeiInterfaceLanguage.allCases, active: store.interfaceLanguage) { language in language.settingsLabel } action: { language in @@ -275,10 +249,7 @@ struct SettingsView: View { } settingsGroup(store.ui("外观", "Appearance")) { - settingsRow( - title: store.ui("明暗模式", "Theme Mode"), - detail: store.ui("亮色偏宣纸,暗色偏墨石;切换时保留柔和过渡。", "Light mode leans warm paper; dark mode leans inkstone, with a soft transition.") - ) { + settingsRow(title: store.ui("明暗模式", "Theme Mode")) { segmented(WeiBeiAppearanceMode.allCases, active: store.appearanceMode) { mode in mode.label(language: store.interfaceLanguage) } action: { mode in @@ -290,32 +261,14 @@ struct SettingsView: View { } settingsGroup(store.ui("工作区", "Workspace")) { - settingsRow( - title: store.ui("布局说明", "Layout Notes"), - detail: store.ui("栏位用顶栏显隐与拖拽重排;沉浸阅读/对话/写作用 ⌥⌘R / ⌥⌘A / ⌥⌘N。设置页不再切换布局预设。", "Use top-bar pane toggles and drag-reorder for columns; immersive reading/chat/writing use ⌥⌘R / ⌥⌘A / ⌥⌘N. Settings no longer switches layout presets.") - ) { - settingsPill( - title: store.layout.label(language: store.interfaceLanguage), - icon: "rectangle.split.3x1", - active: false - ) - } - - settingsRow( - title: store.ui("每日灵感", "Daily Inspiration"), - detail: store.ui("只控制空工作区里的出处内容;文稿、对话和笔记入口始终保留。", "Controls sourced material on the empty workspace only; document, chat, and notes entries always remain.") - ) { - Toggle( - "", + settingsRow(title: store.ui("每日灵感", "Daily Inspiration")) { + settingsSwitch( isOn: Binding( get: { store.showDailyInspiration }, set: { store.setDailyInspirationEnabled($0) } - ) + ), + accessibilityLabel: store.ui("显示每日灵感", "Show Daily Inspiration") ) - .labelsHidden() - .toggleStyle(.switch) - .tint(WeiBeiTheme.cinnabar) - .accessibilityLabel(Text(store.ui("显示每日灵感", "Show Daily Inspiration"))) } } } @@ -324,28 +277,19 @@ struct SettingsView: View { private var readingSettings: some View { VStack(alignment: .leading, spacing: 16) { settingsGroup(store.ui("导入文稿", "Imported Documents")) { - settingsRow( - title: store.ui("导入文稿适配", "Adapt Imported Documents"), - detail: store.ui("让 PDF/HTML 跟随魏碑纸面与墨石阅读环境。", "Let PDF/HTML follow WeiBei paper and inkstone reading.") - ) { - Toggle( - "", + settingsRow(title: store.ui("导入文稿适配", "Adapt Imported Documents")) { + settingsSwitch( isOn: Binding( get: { store.adaptImportedDocumentColors }, set: { store.setImportedDocumentColorAdaptation($0) } - ) + ), + accessibilityLabel: store.ui("导入文稿适配", "Adapt Imported Documents") ) - .toggleStyle(.switch) - .labelsHidden() - .accessibilityLabel(Text(store.ui("导入文稿适配", "Adapt Imported Documents"))) } } settingsGroup(store.ui("阅读入口", "Reader Entry")) { - settingsRow( - title: store.ui("资料内搜索", "Search in Material"), - detail: store.ui("打开当前材料搜索框;没有资料时不会显示无效入口。", "Opens search for the current material; unavailable entries stay hidden.") - ) { + settingsRow(title: store.ui("资料内搜索", "Search in Material")) { if store.hasSelectedMaterial { Button(store.ui("打开搜索", "Open Search")) { withAnimation(WeiBeiMotion.panel) { @@ -355,33 +299,10 @@ struct SettingsView: View { .buttonStyle(WeiBeiTextActionButtonStyle(active: store.showReaderSearch)) } else { Text(store.ui("未选择资料", "No material selected")) - .font(.system(size: 12, weight: .medium)) + .font(SettingsType.control) .foregroundStyle(WeiBeiTheme.tertiaryInk) } } - - settingsRow( - title: store.ui("当前阅读位置", "Current Reader Position"), - detail: store.currentReferenceTitle - ) { - Text(store.hasSelectedMaterial ? store.ui("可引用", "Reference ready") : store.ui("等待资料", "Waiting")) - .font(.system(size: 12, weight: .medium)) - .foregroundStyle(store.hasSelectedMaterial ? WeiBeiTheme.link : WeiBeiTheme.tertiaryInk) - } - } - - settingsGroup(store.ui("选区", "Selection")) { - settingsRow( - title: store.ui("选区入口", "Selection Entry"), - detail: store.ui("当前选区会进入对话补丁组件;正文输入框保持干净。", "Selections attach as context chips so the composer stays clean.") - ) { - settingsPill( - title: store.hasSelectionAttachments ? store.ui("\(store.selectionAttachments.count) 个片段", "\(store.selectionAttachments.count) fragments") : store.ui("无片段", "None"), - icon: "text.bubble", - active: store.hasSelectionAttachments - ) - } - } } } @@ -389,10 +310,7 @@ struct SettingsView: View { private var writingSettings: some View { VStack(alignment: .leading, spacing: 16) { settingsGroup(store.ui("Markdown", "Markdown")) { - settingsRow( - title: store.ui("笔记模式", "Note Mode"), - detail: store.ui("主模式是原地 Markdown 写作,源码只作为辅助检查。", "Live Markdown writing is primary; source is only for checking.") - ) { + settingsRow(title: store.ui("笔记模式", "Note Mode")) { segmented(NoteRenderMode.visibleCases, active: store.noteRenderMode.visibleMode) { mode in mode.label(language: store.interfaceLanguage) } action: { mode in @@ -402,10 +320,7 @@ struct SettingsView: View { } } - settingsRow( - title: store.ui("新建笔记", "New Note"), - detail: store.ui("空白笔记和资料笔记分开创建,避免误改当前材料或当前笔记。", "Create blank notes and material-based notes separately to avoid changing the current material or note by accident.") - ) { + settingsRow(title: store.ui("新建笔记", "New Note")) { HStack(spacing: 8) { Button(store.ui("空白", "Blank")) { withAnimation(WeiBeiMotion.panel) { @@ -426,10 +341,7 @@ struct SettingsView: View { } if store.canUseSelectedMarkdownAsNotebookNote { - settingsRow( - title: store.ui("Markdown 资料", "Markdown Material"), - detail: store.ui("把当前 Markdown 文件移到笔记区原地编辑。", "Move the current Markdown file into the note editor.") - ) { + settingsRow(title: store.ui("Markdown 资料", "Markdown Material")) { Button(store.ui("作为笔记编辑", "Edit as Note")) { store.useSelectedMarkdownAsNotebookNote() } @@ -437,15 +349,6 @@ struct SettingsView: View { } } } - - settingsGroup(store.ui("编辑器外观", "Editor Appearance")) { - settingsRow( - title: store.ui("编辑器主题", "Editor Theme"), - detail: store.ui("当前跟随魏碑全局外观,覆盖背景、正文、标题、代码、公式、Callout 和选区。", "Currently follows WeiBei appearance across background, text, headings, code, math, callouts, and selection.") - ) { - settingsPill(title: store.appearanceMode.label(language: store.interfaceLanguage), icon: store.appearanceMode.systemImage, active: true) - } - } } } @@ -459,8 +362,8 @@ struct SettingsView: View { private var shortcutSettings: some View { settingsGroup(store.ui("当前快捷键", "Current Shortcuts")) { - ForEach(shortcutRows, id: \.0) { title, shortcut, detail in - settingsRow(title: title, detail: detail) { + ForEach(shortcutRows, id: \.0) { title, shortcut in + settingsRow(title: title) { Text(shortcut) .font(.system(size: 12, weight: .semibold, design: .monospaced)) .foregroundStyle(WeiBeiTheme.ink) @@ -477,63 +380,39 @@ struct SettingsView: View { } } - private var shortcutRows: [(String, String, String)] { + private var shortcutRows: [(String, String)] { [ - (store.ui("命令面板", "Command Palette"), "⌘K", store.ui("搜索并执行魏碑动作。", "Search and run WeiBei actions.")), - (store.ui("课程目录", "Course Index"), "⌘B", store.ui("打开或收起课程目录。", "Show or hide the course index.")), - (store.ui("资料内搜索", "Search in Material"), "⌘F", store.ui("搜索当前打开的资料。", "Search the current material.")), - (store.ui("聚焦课程目录", "Focus Course Index"), "⌘1", store.ui("把键盘焦点交给课程目录。", "Move keyboard focus to the course index.")), - (store.ui("聚焦阅读", "Focus Reader"), "⌘2", store.ui("把键盘焦点交给阅读区。", "Move keyboard focus to the reader.")), - (store.ui("聚焦笔记", "Focus Notes"), "⌘3", store.ui("把键盘焦点交给笔记区。", "Move keyboard focus to notes.")), - (store.ui("聚焦对话", "Focus Chat"), "⌘4", store.ui("把键盘焦点交给对话区。", "Move keyboard focus to chat.")), - (store.ui("沉浸阅读", "Immersive Reading"), "⌥⌘R", store.ui("进入沉浸阅读布局。", "Enter immersive reading layout.")), - (store.ui("沉浸对话", "Immersive Chat"), "⌥⌘A", store.ui("进入沉浸对话布局。", "Enter immersive conversation layout.")), - (store.ui("沉浸写作", "Immersive Writing"), "⌥⌘N", store.ui("进入沉浸写作布局。", "Enter immersive writing layout.")), - (store.ui("选区轻提示", "Selection Prompt"), "⌃⌥3", store.ui("在有选区时打开选区浮层。", "Open the selection float when a selection exists.")), - (store.ui("隐藏对话浮层", "Hide Chat Overlay"), "⌃⌥0", store.ui("隐藏选区轻提示。", "Hide the selection prompt.")), - (store.ui("明暗切换", "Toggle Theme"), "⌥⌘T", store.ui("在纸面和墨石之间切换。", "Switch between paper and inkstone.")), - (store.ui("后退", "Back"), "⌘[", store.ui("回到上一个工作区位置。", "Go back in workspace history.")), - (store.ui("前进", "Forward"), "⌘]", store.ui("前进到下一个工作区位置。", "Go forward in workspace history.")), + (store.ui("命令面板", "Command Palette"), "⌘K"), + (store.ui("课程目录", "Course Index"), "⌘B"), + (store.ui("资料内搜索", "Search in Material"), "⌘F"), + (store.ui("聚焦课程目录", "Focus Course Index"), "⌘1"), + (store.ui("聚焦阅读", "Focus Reader"), "⌘2"), + (store.ui("聚焦笔记", "Focus Notes"), "⌘3"), + (store.ui("聚焦对话", "Focus Chat"), "⌘4"), + (store.ui("沉浸阅读", "Immersive Reading"), "⌥⌘R"), + (store.ui("沉浸对话", "Immersive Chat"), "⌥⌘A"), + (store.ui("沉浸写作", "Immersive Writing"), "⌥⌘N"), + (store.ui("选区轻提示", "Selection Prompt"), "⌃⌥3"), + (store.ui("隐藏对话浮层", "Hide Chat Overlay"), "⌃⌥0"), + (store.ui("明暗切换", "Toggle Theme"), "⌥⌘T"), + (store.ui("后退", "Back"), "⌘["), + (store.ui("前进", "Forward"), "⌘]"), ] } private var dataSettings: some View { VStack(alignment: .leading, spacing: 16) { settingsGroup(store.ui("课程资料", "Course Materials")) { - settingsRow( - title: store.ui("导入资料", "Import Material"), - detail: store.ui("导入 HTML、PDF、Markdown 或文本文件。", "Import HTML, PDF, Markdown, or text files.") - ) { + settingsRow(title: store.ui("导入资料", "Import Material")) { Button(store.ui("导入", "Import")) { store.importFilesFromPanel() } .buttonStyle(WeiBeiTextActionButtonStyle(active: true)) } - - settingsRow( - title: store.ui("当前资料", "Current Material"), - detail: store.selectedMaterialItem.map(store.displayTitle) ?? store.ui("未选择资料", "No material selected") - ) { - settingsPill( - title: store.selectedMaterialItem?.kind.label(language: store.interfaceLanguage) ?? store.ui("无", "None"), - icon: store.selectedMaterialItem?.kind.systemImage ?? "tray", - active: store.selectedMaterialItem != nil - ) - } } settingsGroup(store.ui("笔记", "Notes")) { - settingsRow( - title: store.ui("当前笔记", "Current Note"), - detail: store.selectedItem.map(store.displayTitle) ?? store.ui("新笔记", "New Note") - ) { - settingsPill(title: store.noteRenderMode.label(language: store.interfaceLanguage), icon: "square.and.pencil", active: true) - } - - settingsRow( - title: store.ui("选区上下文", "Selection Context"), - detail: store.ui("已选文本片段只作为上下文传给对话,不塞进输入框正文。", "Selected fragments are passed as context, not inserted into the composer text.") - ) { + settingsRow(title: store.ui("选区上下文", "Selection Context")) { if store.hasSelectionAttachments { Button(store.ui("清空片段", "Clear Fragments")) { store.clearSelectionAttachments() @@ -541,7 +420,7 @@ struct SettingsView: View { .buttonStyle(WeiBeiTextActionButtonStyle()) } else { Text(store.ui("无片段", "None")) - .font(.system(size: 12, weight: .medium)) + .font(SettingsType.control) .foregroundStyle(WeiBeiTheme.tertiaryInk) } } @@ -556,18 +435,19 @@ struct SettingsView: View { selectedSection = section } } label: { - // L2: icon + title only — decorative LOOK/CHAT/… code tags removed. + // Full-row hit target: contentShape + maxWidth so padding/background count. HStack(spacing: 10) { Image(systemName: section.icon) .font(.system(size: 13, weight: .semibold)) .frame(width: 18) Text(section.title(store)) - .font(.system(size: 13, weight: active ? .semibold : .medium)) + .font(SettingsType.rowTitle(active: active)) Spacer(minLength: 0) } .foregroundStyle(active ? WeiBeiTheme.ink : WeiBeiTheme.secondaryInk) .padding(.horizontal, 10) - .frame(height: 34) + .frame(maxWidth: .infinity, minHeight: 34, alignment: .leading) + .contentShape(Rectangle()) .background(active ? WeiBeiTheme.paperRaised.opacity(0.62) : .clear) .clipShape(RoundedRectangle(cornerRadius: 7)) .overlay(alignment: .leading) { @@ -581,6 +461,15 @@ struct SettingsView: View { .accessibilityLabel(Text(section.title(store))) } + /// Shared switch used across Settings — always cinnabar, never system blue. + func settingsSwitch(isOn: Binding, accessibilityLabel: String) -> some View { + Toggle("", isOn: isOn) + .labelsHidden() + .toggleStyle(.switch) + .tint(WeiBeiTheme.cinnabar) + .accessibilityLabel(Text(accessibilityLabel)) + } + /// Shared Settings card primitive (also used by `AgentSettingsView` extension). func settingsGroup(_ title: String, @ViewBuilder content: () -> Content) -> some View { let cardFill = WeiBeiTheme.paperRaised.opacity(store.appearanceMode == .inkstone ? 0.20 : 0.36) @@ -609,25 +498,25 @@ struct SettingsView: View { } } - /// Shared Settings row primitive (title + detail + trailing control). + /// Shared Settings row primitive (title + optional detail + trailing control). /// - /// `showsBottomDivider` defaults to true. Prefer leaving it alone — the group - /// covers the last hairline (L3). Pass `false` only when a row sits outside a - /// group or is itself a standalone surface. + /// Prefer title-only rows. Pass `detail` only when the control itself cannot + /// convey a critical constraint (e.g. env-var override is handled by notes). + /// `showsBottomDivider` defaults to true — the group covers the last hairline (L3). func settingsRow( title: String, - detail: String, + detail: String = "", showsBottomDivider: Bool = true, @ViewBuilder control: () -> Control ) -> some View { HStack(alignment: .center, spacing: 18) { - VStack(alignment: .leading, spacing: 4) { + VStack(alignment: .leading, spacing: 3) { Text(title) - .font(.system(size: 13.5, weight: .semibold)) + .font(SettingsType.rowTitle(active: true)) .foregroundStyle(WeiBeiTheme.ink) if !detail.isEmpty { Text(detail) - .font(.system(size: 11.5)) + .font(SettingsType.detail) .lineSpacing(2) .foregroundStyle(WeiBeiTheme.secondaryInk) .fixedSize(horizontal: false, vertical: true) @@ -637,7 +526,7 @@ struct SettingsView: View { control() } .padding(.horizontal, 14) - .padding(.vertical, 12) + .padding(.vertical, detail.isEmpty ? 11 : 12) .overlay(alignment: .bottom) { if showsBottomDivider { Rectangle() @@ -648,14 +537,14 @@ struct SettingsView: View { } } - /// Shared Settings inline note (icon + secondary text). + /// Shared Settings inline note (icon + secondary text). Only for actionable warnings. func settingsNote(_ text: String, icon: String) -> some View { HStack(alignment: .firstTextBaseline, spacing: 8) { Image(systemName: icon) .font(.system(size: 12, weight: .semibold)) - .foregroundStyle(WeiBeiTheme.link) + .foregroundStyle(WeiBeiTheme.cinnabar.opacity(0.90)) Text(text) - .font(.system(size: 11.5)) + .font(SettingsType.detail) .foregroundStyle(WeiBeiTheme.secondaryInk) Spacer() } @@ -669,7 +558,7 @@ struct SettingsView: View { Image(systemName: icon) .font(.system(size: 11, weight: .semibold)) Text(title) - .font(.system(size: 11.5, weight: .medium)) + .font(SettingsType.pill) .lineLimit(1) } .foregroundStyle(active ? WeiBeiTheme.ink : WeiBeiTheme.tertiaryInk) @@ -706,7 +595,7 @@ struct SettingsView: View { } label: { HStack(spacing: 7) { Text(title) - .font(.system(size: 12.5, weight: .semibold)) + .font(SettingsType.menu) Image(systemName: "chevron.down") .font(.system(size: 9, weight: .bold)) } @@ -730,3 +619,19 @@ struct SettingsView: View { .foregroundStyle(WeiBeiTheme.tertiaryInk) } } + +// MARK: - Settings type scale +// +// One shared scale so row titles / controls / notes / pills stay visually unified. +// Display titles (page / section) still use WeiBeiTypography.brandFont. + +private enum SettingsType { + static func rowTitle(active: Bool) -> Font { + .system(size: 13, weight: active ? .semibold : .medium) + } + + static let control: Font = .system(size: 13, weight: .medium) + static let detail: Font = .system(size: 12, weight: .regular) + static let pill: Font = .system(size: 12, weight: .medium) + static let menu: Font = .system(size: 13, weight: .semibold) +} diff --git a/Sources/WeiBeiSelfCheck/main.swift b/Sources/WeiBeiSelfCheck/main.swift index 155994274..d64f84ad1 100644 --- a/Sources/WeiBeiSelfCheck/main.swift +++ b/Sources/WeiBeiSelfCheck/main.swift @@ -2783,9 +2783,8 @@ expect(!agentSettingsSource.contains("Form {") && !agentSettingsSource.contains("overviewSettings") && agentSettingsSource.contains("appearanceSettings") && agentSettingsSource.contains("agentSettings") - && agentSettingsSource.contains("Text(store.brandLatinName)") - && agentSettingsSource.contains("Text(\"SETTINGS\")") - && agentSettingsSource.contains("WeiBeiTypography.englishBrandFont") + && agentSettingsSource.contains("Text(store.ui(\"设置\", \"Settings\"))") + && !agentSettingsSource.contains("Text(\"SETTINGS\")") && !agentSettingsSource.contains("case .overview: return \"HOME\"") // L2: decorative LOOK/CHAT/… section codes removed from the sidebar. && !agentSettingsSource.contains("case .appearance: return \"LOOK\"") @@ -2929,13 +2928,23 @@ expect(AgentProviderConsoleLinks.keyHelp(language: .chinese, provider: .openaiCo && AgentProviderConsoleLinks.metadata(for: .cloudflareAIGateway).help == .cloudflareAIGateway && AgentProviderConsoleLinks.metadata(for: .cloudflareWorkersAI).help == .cloudflareWorkersAI, "provider key-help copy matches the pre-L5 golden set for special and generic cases") -expect(agentSettingsSource.contains("settingsPill(\n title: store.interfaceLanguage.settingsLabel,\n icon: \"character.book.closed\",\n active: false") - && agentSettingsSource.contains("settingsPill(\n title: store.appearanceMode.label(language: store.interfaceLanguage),\n icon: store.appearanceMode.systemImage,\n active: false"), "settings sidebar summary pills stay neutral instead of looking permanently selected") +expect(agentSettingsSource.contains("settingsPill(\n title: store.interfaceLanguage.settingsLabel,\n icon: \"character.book.closed\",\n active: false") + && agentSettingsSource.contains("settingsPill(\n title: store.appearanceMode.label(language: store.interfaceLanguage),\n icon: store.appearanceMode.systemImage,\n active: false") + && agentSettingsSource.contains(".contentShape(Rectangle())") + && agentSettingsSource.contains("func settingsSwitch(isOn: Binding, accessibilityLabel: String)") + && !agentSettingsSource.contains("管理魏碑的界面、写作、对话和本地资料") + && !agentSettingsSource.contains("private var sectionSubtitle") + && !agentSettingsSource.contains("布局说明") + && !agentSettingsSource.contains("当前阅读位置") + && !agentSettingsSource.contains("选区入口") + && !agentSettingsSource.contains("编辑器主题") + && !agentSettingsSource.contains("title: store.ui(\"当前资料\""), "settings sidebar pills stay neutral; rows are decluttered; sidebar hit area is full-width") expect(agentSettingsSource.contains("title: store.ui(\"每日灵感\", \"Daily Inspiration\")") && agentSettingsSource.contains("get: { store.showDailyInspiration }") && agentSettingsSource.contains("set: { store.setDailyInspirationEnabled($0) }") - && agentSettingsSource.contains("文稿、对话和笔记入口始终保留") - && agentSettingsSource.contains(".accessibilityLabel(Text(store.ui(\"显示每日灵感\""), "settings explicitly toggles daily inspiration without implying that the three work entries disappear") + && agentSettingsSource.contains("settingsSwitch(") + && agentSettingsSource.contains("accessibilityLabel: store.ui(\"显示每日灵感\", \"Show Daily Inspiration\")") + && agentSettingsSource.contains(".tint(WeiBeiTheme.cinnabar)"), "settings explicitly toggles daily inspiration with a cinnabar switch (no filler detail copy)") expect(agentSettingsSource.contains("segmented(NoteRenderMode.visibleCases, active: store.noteRenderMode.visibleMode)") && !agentSettingsSource.contains("笔记预览") && !agentSettingsSource.contains("Note Preview") @@ -3100,10 +3109,10 @@ expect(workspaceStoreSource.contains("var brandLatinName: String") && contentViewSource.contains("Text(store.brandLatinName)") && contentViewSource.contains("WeiBeiTypography.englishBrandFont(size: 15.5, weight: .semibold)") && contentViewSource.contains(".frame(width: 62, alignment: .leading)") - && agentSettingsSource.contains("Text(store.brandLatinName)") - && agentSettingsSource.contains("WeiBeiTypography.englishBrandFont(size: 18") + // Settings sidebar keeps a single localized title only — no second "WeiBei SETTINGS" line. + && !agentSettingsSource.contains("Text(\"SETTINGS\")") && notesAgentSource.contains("latinMark: store.interfaceLanguage == .chinese ? \"NOTES\" : nil") - && notesAgentSource.contains("latinMark: store.interfaceLanguage == .chinese ? \"CHAT\" : nil"), "custom English font has visible Latin brand marks in the top bar, settings, and pane headers") + && notesAgentSource.contains("latinMark: store.interfaceLanguage == .chinese ? \"CHAT\" : nil"), "custom English font has visible Latin brand marks in the top bar and pane headers; settings title is not duplicated") expect(notesAgentSource.contains("ForEach(NoteRenderMode.visibleCases)") && notesAgentSource.contains("switch store.noteRenderMode.visibleMode") && !notesAgentSource.contains("ForEach(NoteRenderMode.allCases)") diff --git a/script/build_and_run.sh b/script/build_and_run.sh index b23889f5d..25a05d1e3 100755 --- a/script/build_and_run.sh +++ b/script/build_and_run.sh @@ -38,12 +38,17 @@ VERSION_FILE="$ROOT_DIR/VERSION" FINAL_DIST_DIR="$ROOT_DIR/dist" FINAL_APP_BUNDLE="$FINAL_DIST_DIR/$APP_DISPLAY_NAME.app" FINAL_APP_BINARY="$FINAL_APP_BUNDLE/Contents/MacOS/$PRODUCT_NAME" +# Always assemble + codesign outside the repo tree. Projects under ~/Documents +# (iCloud / File Provider) get com.apple.FinderInfo and related xattrs stamped +# onto the bundle; codesign then fails with "resource fork, Finder information, +# or similar detritus not allowed". A broken/changing ad-hoc identity makes +# Keychain re-prompt for the login password every launch when reading API keys. if [[ "$VERIFY_MODE" == true ]]; then DIST_DIR="${TMPDIR:-/tmp}/weibei-verify-$UID-$$" elif [[ "$PACKAGE_ONLY" == true ]]; then DIST_DIR="${TMPDIR:-/tmp}/weibei-package-$UID" else - DIST_DIR="$FINAL_DIST_DIR" + DIST_DIR="${TMPDIR:-/tmp}/weibei-run-$UID" fi APP_BUNDLE="$DIST_DIR/$APP_DISPLAY_NAME.app" APP_CONTENTS="$APP_BUNDLE/Contents" @@ -267,7 +272,11 @@ if [[ "$CHECK_ONLY" != true ]]; then PLIST /usr/bin/codesign --force --sign - --timestamp=none "$PDF_TEXT_WORKER" >/dev/null /usr/bin/codesign --force --sign - --timestamp=none "$APP_BUNDLE" >/dev/null - /usr/bin/codesign --verify --deep --strict "$APP_BUNDLE" + if ! /usr/bin/codesign --verify --deep --strict "$APP_BUNDLE" >/dev/null; then + echo "package failed: staged app signature is invalid at $APP_BUNDLE" >&2 + /usr/bin/codesign --verify --deep --strict --verbose=2 "$APP_BUNDLE" 2>&1 | tail -20 >&2 || true + exit 19 + fi if [[ "$(/usr/bin/env WEIBEI_PDF_WORKER_VERIFY=1 "$PDF_TEXT_WORKER" --verification-probe normal)" != "verification-ok" ]]; then echo "package failed: signed PDF text worker did not complete its runtime probe" >&2 exit 14 @@ -280,15 +289,28 @@ PLIST fi WEIBEI_PI_EXECUTABLE="$PACKAGED_PI" WEIBEI_PI_APP_BUNDLE="$APP_BUNDLE" WEIBEI_PI_LIVE_CHECK=0 \ "$BUILD_DIR/WeiBeiPiCheck" - if [[ "$PACKAGE_ONLY" == true ]]; then + # Mirror a clean copy into repo dist/ for inspection. Launch always uses the + # staged /tmp bundle (valid signature); Documents copies can re-acquire + # File Provider xattrs that invalidate codesign verification. + if [[ "$VERIFY_MODE" != true ]]; then rm -rf "$FINAL_APP_BUNDLE" mkdir -p "$FINAL_DIST_DIR" /usr/bin/ditto --norsrc --noextattr "$APP_BUNDLE" "$FINAL_APP_BUNDLE" - /usr/bin/xattr -cr "$FINAL_APP_BUNDLE" + /usr/bin/xattr -cr "$FINAL_APP_BUNDLE" 2>/dev/null || true if ! /usr/bin/cmp -s "$APP_BINARY" "$FINAL_APP_BINARY"; then echo "package failed: final app binary changed while copying from signed staging" >&2 exit 15 fi + fi + if [[ "$PACKAGE_ONLY" == true ]]; then + if ! /usr/bin/codesign --verify --deep "$FINAL_APP_BUNDLE" >/dev/null 2>&1; then + # Documents may stamp FinderInfo onto the published copy; re-seal in place + # after stripping attrs so release consumers still get a verifiable dist/. + /usr/bin/xattr -cr "$FINAL_APP_BUNDLE" 2>/dev/null || true + /usr/bin/codesign --force --sign - --timestamp=none "$FINAL_APP_BUNDLE/Contents/Resources/PiRuntime/bin/pi" >/dev/null 2>&1 || true + /usr/bin/codesign --force --sign - --timestamp=none "$FINAL_APP_BUNDLE/Contents/Helpers/$PDF_TEXT_WORKER_NAME" >/dev/null 2>&1 || true + /usr/bin/codesign --force --sign - --timestamp=none "$FINAL_APP_BUNDLE" >/dev/null + fi /usr/bin/codesign --verify --deep "$FINAL_APP_BUNDLE" FINAL_UUID="$(/usr/bin/dwarfdump --uuid "$FINAL_APP_BINARY" | /usr/bin/awk 'NR == 1 {print $2}')" if [[ -z "$FINAL_UUID" || "$FINAL_UUID" != "$PACKAGED_UUID" ]]; then @@ -314,6 +336,11 @@ PLIST fi open_app() { + # Launch the staged, validly signed bundle — not dist/ under Documents. + if ! /usr/bin/codesign --verify --deep --strict "$APP_BUNDLE" >/dev/null 2>&1; then + echo "open blocked: staged app signature invalid at $APP_BUNDLE" >&2 + exit 20 + fi /usr/bin/open "$APP_BUNDLE" }