Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a769c535b |
No files matched your search
@@ -65,6 +65,7 @@ import { CLUE_PREFS_ID, CLUE_WINDOW_SURFACE_SETTING, type SidebarPrefs } from '.
|
||||
import { api } from './api.ts'
|
||||
import { parsePrefs, syncClueWindowSurface } from './prefs.ts'
|
||||
import { AddPluginModal, type PluginKind } from './add-plugin-modal.tsx'
|
||||
import { CollapsedPanelsSetting } from './collapsed-panels-setting.tsx'
|
||||
import { t } from './locales.ts'
|
||||
import type { SidebarStore } from './state.ts'
|
||||
import { mergeGuideEntries, type NativeGuideCatalog, type NativeGuideEntry } from './native/guide-catalog.ts'
|
||||
@@ -1890,6 +1891,12 @@ export function SideCardSection(props: SideCardSectionInjected & Partial<PropsRu
|
||||
{group === 'general' && (
|
||||
<div className={css.group}>
|
||||
<h2 className={css.groupHeading}>{t('settingsGeneralTitle')}</h2>
|
||||
{/* 侧栏入口折叠: which left-sidebar entries stay out of the way.
|
||||
The host folds an entry into its More menu when the entry's
|
||||
panel id is in the host's pin storage; this block is where the
|
||||
user picks that set. */}
|
||||
<CollapsedPanelsSetting />
|
||||
|
||||
<SettingRow label={t('settingsOpenToolsTitle')} description={t('settingsOpenToolsDesc')} className={css.row}>
|
||||
<ToggleSwitch
|
||||
aria-label={t('settingsOpenToolsTitle')}
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
/**
|
||||
* The "folded sidebar entries" setting.
|
||||
*
|
||||
* The host's left sidebar folds an entry away when its panel id is listed in
|
||||
* `unpinned` (localStorage `dsh-desktop.sidebar.panel-pins`); the folded
|
||||
* entries move into the host's own More menu, where the user can pin any of
|
||||
* them back. This block lists the entries we know of and writes that list —
|
||||
* so which entries stay out of the way is the user's choice, not a constant
|
||||
* in our source.
|
||||
*
|
||||
* Writing the list also marks it as "taken over" (`…:collapsed-defaults` =
|
||||
* `custom`), which tells our startup helper to stop merging the default
|
||||
* set back in.
|
||||
*/
|
||||
|
||||
import { useEffect, useState } from 'react'
|
||||
import { t } from './locales.ts'
|
||||
import { Checkbox, SettingRow } from './ui/index.ts'
|
||||
|
||||
/** The host's pin storage: `{ unpinned: string[] }`. */
|
||||
const PIN_KEY = 'dsh-desktop.sidebar.panel-pins'
|
||||
/** Our marker key: the default set we already applied, or `custom`. */
|
||||
const MARK_KEY = 'dsh-apes-sidebar:collapsed-defaults'
|
||||
|
||||
/** The marker value that means "the user manages this list now". */
|
||||
const CUSTOM_MARK = 'custom'
|
||||
|
||||
/**
|
||||
* The entries this setting can fold.
|
||||
*
|
||||
* The ids are the panel ids the registering plugins use; an entry that is
|
||||
* not installed simply does not appear in the sidebar.
|
||||
*/
|
||||
const CANDIDATE_PANELS = [
|
||||
{ id: 'dsh-market', label: '插件市场' },
|
||||
{ id: 'dsh-context', label: '上下文洞察' },
|
||||
{ id: 'task-board', label: '任务看板' },
|
||||
{ id: 'forge-review', label: '代码评审' },
|
||||
] as const
|
||||
|
||||
/** The entries currently folded away. */
|
||||
function readUnpinned(): string[] {
|
||||
if (typeof localStorage === 'undefined') return []
|
||||
try {
|
||||
const raw = localStorage.getItem(PIN_KEY)
|
||||
if (raw === null) return []
|
||||
const value = JSON.parse(raw) as { unpinned?: unknown }
|
||||
return Array.isArray(value.unpinned) ? value.unpinned.filter((id): id is string => typeof id === 'string') : []
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the folded set and reload, so the host's pin store picks it up.
|
||||
*
|
||||
* @param ids - the panel ids to fold away.
|
||||
*/
|
||||
function writeUnpinned(ids: string[]): void {
|
||||
if (typeof localStorage === 'undefined') return
|
||||
try {
|
||||
localStorage.setItem(PIN_KEY, JSON.stringify({ unpinned: ids }))
|
||||
localStorage.setItem(MARK_KEY, CUSTOM_MARK)
|
||||
location.reload()
|
||||
} catch {
|
||||
// A storage that refuses the write keeps the current layout.
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The setting block: one checkbox per known entry plus an apply button.
|
||||
*
|
||||
* @returns the setting rows.
|
||||
*/
|
||||
export function CollapsedPanelsSetting(): React.ReactNode {
|
||||
const [selected, setSelected] = useState<string[]>([])
|
||||
|
||||
useEffect(() => {
|
||||
setSelected(readUnpinned())
|
||||
}, [])
|
||||
|
||||
function toggle(id: string, next: boolean): void {
|
||||
setSelected(current => (next ? [...current.filter(entry => entry !== id), id] : current.filter(entry => entry !== id)))
|
||||
}
|
||||
|
||||
return (
|
||||
<div data-apesi-collapsed-panels="setting">
|
||||
<div className="css.subHeading" style={{ color: 'var(--dsw-alias-label-primary, inherit)' }}>{t('settingsCollapsedPanelsTitle')}</div>
|
||||
{CANDIDATE_PANELS.map(panel => (
|
||||
<SettingRow
|
||||
key={panel.id}
|
||||
label={panel.label}
|
||||
description={t('settingsCollapsedPanelsDesc')}
|
||||
>
|
||||
<Checkbox
|
||||
aria-label={panel.label}
|
||||
checked={selected.includes(panel.id)}
|
||||
onChange={event => toggle(panel.id, event.currentTarget.checked)}
|
||||
/>
|
||||
</SettingRow>
|
||||
))}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => writeUnpinned(selected)}
|
||||
style={{
|
||||
marginTop: '8px',
|
||||
padding: '6px 14px',
|
||||
borderRadius: '6px',
|
||||
border: '1px solid var(--dsw-alias-border-l1, rgba(0,0,0,0.12))',
|
||||
background: 'var(--dsw-alias-bg-container, transparent)',
|
||||
color: 'var(--dsw-alias-label-primary, inherit)',
|
||||
cursor: 'pointer',
|
||||
}}
|
||||
>
|
||||
{t('settingsCollapsedPanelsApply')}
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -107,6 +107,9 @@ function ensureDefaultCollapsedPanels(): void {
|
||||
if (typeof localStorage === 'undefined') return
|
||||
try {
|
||||
const mark = localStorage.getItem(PANEL_PIN_MARK_KEY)
|
||||
// `custom` = the user manages the folded set in the settings block; the
|
||||
// default set must not creep back in.
|
||||
if (mark === 'custom') return
|
||||
if (mark === DEFAULT_COLLAPSED_PANELS.join(',')) return
|
||||
const raw = localStorage.getItem(PANEL_PIN_KEY)
|
||||
const current = raw === null ? [] : (JSON.parse(raw)?.unpinned ?? [])
|
||||
|
||||
@@ -506,6 +506,9 @@ export const zh = {
|
||||
settingsMobileTreeTitle: '窄屏时任务页默认树状图',
|
||||
settingsMobileTreeDesc: '手机 / 窄屏下任务页默认用经典树,而不是工作流图;页内切换仍可临时改成图',
|
||||
settingsGeneralTitle: '常规',
|
||||
settingsCollapsedPanelsTitle: '折叠的侧栏入口',
|
||||
settingsCollapsedPanelsDesc: '勾选后该入口从左侧栏收进「更多」菜单,随时可在那里钉回。',
|
||||
settingsCollapsedPanelsApply: '应用并刷新',
|
||||
settingsPopup: '功能设置',
|
||||
settingsViewerCatchAll: '兜底:任意文件',
|
||||
viewerMarkdown: 'Markdown',
|
||||
@@ -1779,6 +1782,9 @@ export const en: Record<keyof typeof zh, string> = {
|
||||
settingsMobileTreeTitle: 'Default the Tasks page to the tree',
|
||||
settingsMobileTreeDesc: "On a phone / narrow viewport the Tasks page opens as the classic tree instead of the workflow graph; the in-page toggle still switches it ad hoc",
|
||||
settingsGeneralTitle: 'General',
|
||||
settingsCollapsedPanelsTitle: 'Folded sidebar entries',
|
||||
settingsCollapsedPanelsDesc: 'Checked entries move out of the left sidebar into the More menu; pin them back from there.',
|
||||
settingsCollapsedPanelsApply: 'Apply and refresh',
|
||||
settingsPopup: 'Feature settings',
|
||||
settingsViewerCatchAll: 'Catch-all: any file',
|
||||
viewerMarkdown: 'Markdown',
|
||||
|
||||
Reference in new issue
Block a user