/** * 驾驶舱一级模式与二级面板目录。 * * 稳定英文键是唯一状态标识;中文只用于展示(见 ADR 0003 与 CONTEXT.md)。 * 本文件是纯逻辑,不引用 Vue、DOM 或任何接口字段,便于直接单测。 */ /** 一级模式英文键。 */ export const MODES = ['overview', 'infrastructure', 'monitoring', 'warningResponse'] /** 一级模式展示名。 */ export const MODE_LABELS = { overview: '总体概览', infrastructure: '基础设施', monitoring: '运行监测', warningResponse: '预警处置', } /** 二级面板展示名,按 panelId 解析;业务逻辑不读中文。 */ export const PANEL_LABELS = { situationSummary: '态势总览', infrastructureSummary: '基础设施', monitoringSummary: '运行监测', alertSettings: '预警设置', archive: '基础档案', operation: '运行信息', management: '管理信息', emergency: '应急保障', monitoringOverview: '监测概览', monitoringDistribution: '监测分布', operationOverview: '运行概况', monitoringPointLedger: '监测点台账', currentEvents: '当前预警', historyAnalysis: '历史分析', responseEfficiency: '预警效率', eventAnalysis: '预警分析', } /** * 模式 → 左右两栏面板,顺序固定(ADR 0003)。 * panelId 扁平且全局唯一,不带模式前缀。 */ const COLUMNS = { overview: { left: ['situationSummary', 'infrastructureSummary'], right: ['monitoringSummary', 'alertSettings'], }, infrastructure: { left: ['archive', 'operation'], right: ['management', 'emergency'], }, monitoring: { left: ['monitoringOverview', 'monitoringDistribution'], right: ['operationOverview', 'monitoringPointLedger'], }, warningResponse: { left: ['currentEvents', 'historyAnalysis'], right: ['responseEfficiency', 'eventAnalysis'], }, } /** * 二级面板图标(`CockpitIcon` 的语义名,按 panelId 映射)。 * * 批次 1 第三轮:图标全部换为维护者指定的 Texture/Icon 目录 I/Pipe/Q 系列切图 * (I=次要、Pipe=主要、Q=补充),经**去色 + 项目主蓝 #01abea(--cyan)染色**统一风格, * 生成件在 `public/cockpit/assets/icons/panel/`(manifest key `icon.panel.*`)。 * **纯视觉**:不参与面板标识、排序与断言,走查认面板仍只认 `data-panel-id`。 * * 未列出的 panelId 返回空串 → 渲染层不画图标,不抛错(与 `iconFor` 的未知名行为一致)。 */ export const PANEL_ICONS = { situationSummary: 'panelSituation', infrastructureSummary: 'panelSituation', monitoringSummary: 'panelMonitoring', alertSettings: 'panelAlert', archive: 'panelArchive', operation: 'panelMonitoring', management: 'panelArchive', emergency: 'panelEmergency', monitoringOverview: 'panelMonitoring', monitoringDistribution: 'panelDistribution', operationOverview: 'panelMonitoring', monitoringPointLedger: 'panelLedger', currentEvents: 'panelCurrent', historyAnalysis: 'panelHistory', responseEfficiency: 'panelEfficiency', eventAnalysis: 'panelAnalysis', } export function isKnownMode(mode) { return MODES.includes(mode) } export function isKnownPanel(panelId) { return Object.prototype.hasOwnProperty.call(PANEL_LABELS, panelId) } export function modeLabel(mode) { return MODE_LABELS[mode] || mode } export function labelForPanel(panelId) { return PANEL_LABELS[panelId] || panelId } /** 面板图标语义名;无对应图标时返回空串(渲染层据此不画图标)。 */ export function panelIcon(panelId) { return PANEL_ICONS[panelId] || '' } /** 返回模式的左右两栏面板;未知模式直接报错,避免静默渲染空壳。 */ export function columnsForMode(mode) { const columns = COLUMNS[mode] if (!columns) { throw new Error(`未知一级模式: ${mode}`) } return { left: [...columns.left], right: [...columns.right] } } /** 返回模式的全部面板,左栏在前。 */ export function panelsForMode(mode) { const { left, right } = columnsForMode(mode) return [...left, ...right] } /** 进入模式时的默认展开集合:全部面板展开。 */ export function defaultExpandedPanelIds(mode) { return panelsForMode(mode) } /** * 收起或展开单个面板,返回新集合(不改原数组)。 * 纯函数,store 只做薄封装,便于脱离 Vue 单测。 */ export function toggleExpanded(expandedPanelIds, panelId) { return expandedPanelIds.includes(panelId) ? expandedPanelIds.filter((id) => id !== panelId) : [...expandedPanelIds, panelId] }