feat(webui): replace 「侧栏默认折叠」 with 「钉住侧栏展开」 pin option
The old default-collapsed pref went inert once the sidebar became a hover-expand rail with no collapse button. Repurpose it as an explicit opt-out: when 「钉住侧栏展开」 is on, the sidebar stays permanently expanded and no longer collapses to the rail or reacts to hover. Renamed the appearance field sidebarDefaultCollapsed -> sidebarPinned across the webui types/defaults/settings UI and the core ui-config interface, defaults and validator (kept in lock-step so persistence round-trips). Wired into main-layout: effectiveCollapsed = !editing && !sidebarPinned.
This commit is contained in:
5 files changed
+12
-10
No files matched your search
@@ -100,7 +100,7 @@ export interface UiAppearance {
|
|||||||
/** Hard-disable all UI animations (stronger than reduceMotion). */
|
/** Hard-disable all UI animations (stronger than reduceMotion). */
|
||||||
disableMotion: boolean;
|
disableMotion: boolean;
|
||||||
highContrast: boolean;
|
highContrast: boolean;
|
||||||
sidebarDefaultCollapsed: boolean;
|
sidebarPinned: boolean;
|
||||||
timeFormat: TimeFormat;
|
timeFormat: TimeFormat;
|
||||||
/** Dashboard poll interval (ms); 0 = paused. */
|
/** Dashboard poll interval (ms); 0 = paused. */
|
||||||
pollInterval: number;
|
pollInterval: number;
|
||||||
@@ -226,7 +226,7 @@ const DEFAULT_APPEARANCE: UiAppearance = {
|
|||||||
reduceMotion: false,
|
reduceMotion: false,
|
||||||
disableMotion: false,
|
disableMotion: false,
|
||||||
highContrast: false,
|
highContrast: false,
|
||||||
sidebarDefaultCollapsed: false,
|
sidebarPinned: false,
|
||||||
timeFormat: '24h',
|
timeFormat: '24h',
|
||||||
pollInterval: 3000,
|
pollInterval: 3000,
|
||||||
customCss: '',
|
customCss: '',
|
||||||
@@ -531,7 +531,7 @@ export function normalizeAppearance(value: unknown, imageState: ServerImageState
|
|||||||
reduceMotion: boolOr(v.reduceMotion, DEFAULT_APPEARANCE.reduceMotion),
|
reduceMotion: boolOr(v.reduceMotion, DEFAULT_APPEARANCE.reduceMotion),
|
||||||
disableMotion: boolOr(v.disableMotion, DEFAULT_APPEARANCE.disableMotion),
|
disableMotion: boolOr(v.disableMotion, DEFAULT_APPEARANCE.disableMotion),
|
||||||
highContrast: boolOr(v.highContrast, DEFAULT_APPEARANCE.highContrast),
|
highContrast: boolOr(v.highContrast, DEFAULT_APPEARANCE.highContrast),
|
||||||
sidebarDefaultCollapsed: boolOr(v.sidebarDefaultCollapsed, DEFAULT_APPEARANCE.sidebarDefaultCollapsed),
|
sidebarPinned: boolOr(v.sidebarPinned, DEFAULT_APPEARANCE.sidebarPinned),
|
||||||
timeFormat: oneOf<TimeFormat>(v.timeFormat, ['12h', '24h'], DEFAULT_APPEARANCE.timeFormat),
|
timeFormat: oneOf<TimeFormat>(v.timeFormat, ['12h', '24h'], DEFAULT_APPEARANCE.timeFormat),
|
||||||
pollInterval: clampNum(v.pollInterval, 0, 60_000, DEFAULT_APPEARANCE.pollInterval),
|
pollInterval: clampNum(v.pollInterval, 0, 60_000, DEFAULT_APPEARANCE.pollInterval),
|
||||||
customCss: typeof v.customCss === 'string' ? v.customCss.slice(0, 50_000) : DEFAULT_APPEARANCE.customCss,
|
customCss: typeof v.customCss === 'string' ? v.customCss.slice(0, 50_000) : DEFAULT_APPEARANCE.customCss,
|
||||||
|
|||||||
@@ -29,9 +29,10 @@ export function MainLayout({ status, onLogout, children }: MainLayoutProps) {
|
|||||||
const { editing } = useLayout();
|
const { editing } = useLayout();
|
||||||
const { kiosk, exit: exitKiosk } = useKiosk();
|
const { kiosk, exit: exitKiosk } = useKiosk();
|
||||||
// The sidebar rests as a slim icon rail and auto-expands on hover/focus (the
|
// The sidebar rests as a slim icon rail and auto-expands on hover/focus (the
|
||||||
// peek logic below) — there's no collapse button. Layout-edit mode force-
|
// peek logic below) — there's no collapse button. Two cases force it fully
|
||||||
// expands it so the drag-to-reorder list has room.
|
// expanded: layout-edit mode (the drag-to-reorder list needs room) and the
|
||||||
const effectiveCollapsed = !editing;
|
// 「钉住侧栏展开」 appearance pref (operator opted out of the rail entirely).
|
||||||
|
const effectiveCollapsed = !editing && !appearance.sidebarPinned;
|
||||||
// Hover/focus peek: while collapsed, hovering (or keyboard-focusing) the rail
|
// Hover/focus peek: while collapsed, hovering (or keyboard-focusing) the rail
|
||||||
// temporarily expands it. The rail lives in the flex flow, so the page
|
// temporarily expands it. The rail lives in the flex flow, so the page
|
||||||
// content is pushed right rather than overlaid. The pinned `collapsed` pref
|
// content is pushed right rather than overlaid. The pinned `collapsed` pref
|
||||||
|
|||||||
@@ -486,8 +486,8 @@ function AppearancePanel() {
|
|||||||
<SettingRow label="高对比模式" hint="加强边框与次要文字的对比度。" layout="inline">
|
<SettingRow label="高对比模式" hint="加强边框与次要文字的对比度。" layout="inline">
|
||||||
<ToggleSwitch value={a.highContrast} onChange={(highContrast) => setAppearance({ highContrast })} ariaLabel="高对比模式" />
|
<ToggleSwitch value={a.highContrast} onChange={(highContrast) => setAppearance({ highContrast })} ariaLabel="高对比模式" />
|
||||||
</SettingRow>
|
</SettingRow>
|
||||||
<SettingRow label="侧栏默认折叠" hint="新会话首次进入时侧栏默认收起(手动展开/收起后以手动选择为准)。" layout="inline">
|
<SettingRow label="钉住侧栏展开" hint="侧栏常驻展开,不再收成图标轨、也不随悬停自动收起。" layout="inline">
|
||||||
<ToggleSwitch value={a.sidebarDefaultCollapsed} onChange={(sidebarDefaultCollapsed) => setAppearance({ sidebarDefaultCollapsed })} ariaLabel="侧栏默认折叠" />
|
<ToggleSwitch value={a.sidebarPinned} onChange={(sidebarPinned) => setAppearance({ sidebarPinned })} ariaLabel="钉住侧栏展开" />
|
||||||
</SettingRow>
|
</SettingRow>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ export const DEFAULT_APPEARANCE: UiAppearance = {
|
|||||||
reduceMotion: false,
|
reduceMotion: false,
|
||||||
disableMotion: false,
|
disableMotion: false,
|
||||||
highContrast: false,
|
highContrast: false,
|
||||||
sidebarDefaultCollapsed: false,
|
sidebarPinned: false,
|
||||||
timeFormat: '24h',
|
timeFormat: '24h',
|
||||||
pollInterval: 3000,
|
pollInterval: 3000,
|
||||||
customCss: '',
|
customCss: '',
|
||||||
|
|||||||
@@ -300,7 +300,8 @@ export interface UiAppearance {
|
|||||||
reduceMotion: boolean;
|
reduceMotion: boolean;
|
||||||
disableMotion: boolean;
|
disableMotion: boolean;
|
||||||
highContrast: boolean;
|
highContrast: boolean;
|
||||||
sidebarDefaultCollapsed: boolean;
|
/** Pin the sidebar permanently expanded, opting out of the hover-expand rail. */
|
||||||
|
sidebarPinned: boolean;
|
||||||
timeFormat: TimeFormat;
|
timeFormat: TimeFormat;
|
||||||
pollInterval: number;
|
pollInterval: number;
|
||||||
/** Operator custom CSS (applied post-auth only; stripped from /api/ui/public). */
|
/** Operator custom CSS (applied post-auth only; stripped from /api/ui/public). */
|
||||||
|
|||||||
Reference in new issue
Block a user