From f57a375407c633d42bdaa5d333cff56fdb105414 Mon Sep 17 00:00:00 2001 From: Zyy Date: Tue, 1 Dec 2026 17:17:35 +0800 Subject: [PATCH] feat(frontend): show compact release channel badges in the sidebar Co-authored-by: Codex --- .../cpr-dev-guide/references/frontend.md | 4 +- docs/architecture.md | 5 ++- frontend/src/api/modules/settings/system.ts | 2 +- frontend/src/layout/components/AppSidebar.vue | 39 +++++++++++++++---- .../components/system-update-modal/index.vue | 9 +---- .../constants/system-update-channels.ts | 9 +++++ 6 files changed, 50 insertions(+), 18 deletions(-) create mode 100644 frontend/src/layout/constants/system-update-channels.ts diff --git a/.agents/skills/cpr-dev-guide/references/frontend.md b/.agents/skills/cpr-dev-guide/references/frontend.md index fbccd2242..f540d61dc 100644 --- a/.agents/skills/cpr-dev-guide/references/frontend.md +++ b/.agents/skills/cpr-dev-guide/references/frontend.md @@ -4,7 +4,9 @@ ## 领域必读 -确定页面方案或审查结论前,读取[前端职责](../../../../docs/architecture.md#34-前端模块职责)、[文案与信息层级](../../../../docs/theme.md#界面文案与信息层级)和[界面验证](../../../../CONTRIBUTING.md#界面验证)的完整章节,局部修改同样读取。明确本次用户操作、原页面、最接近的同类实现及可复用基础组件,沿用既有设计与请求层,按本轮验收分工留存所需截图 +确定页面方案或审查结论前,读取[前端职责](../../../../docs/architecture.md#34-前端模块职责)、[文案与信息层级](../../../../docs/theme.md#界面文案与信息层级)和[界面验证](../../../../CONTRIBUTING.md#界面验证)的完整章节,局部修改同样读取。新增或移动文件时,页面与布局按同一套目录规则,根据调用范围和导出内容区分组件私有实现、共享常量和共享纯函数 + +明确本次用户操作、原页面、最接近的同类实现及可复用基础组件,沿用既有设计与请求层,按本轮验收分工留存所需截图 ## 按改动补齐规范 diff --git a/docs/architecture.md b/docs/architecture.md index 0dd4de215..34243222e 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -372,7 +372,7 @@ Provider 可为模型提供来源账号集合;Core 在公开目录查询时结 | `i18n/` | Vue I18n 实例、三语资源和应用语言策略;从全局 Composer 派生 UI 库语言,不翻译用户数据或远端自由文本 | | `utils/` | 跨页面使用的数据判断、数字/金额/时长格式化、位置校验、颜色和通用操作辅助;业务专用逻辑放回所属页面或组件 | -页面采用统一骨架,目录按实际需要创建: +页面(`views/<页面>/`)和应用布局(`layout/`)采用同一套目录规则,以页面为例,目录按需创建: ```text views/<页面>/ @@ -389,7 +389,8 @@ views/<页面>/ └── constants.ts ``` -- 页面根目录放入口、页面级逻辑与常量,卡片、弹窗和页面分区统一放在 `components/`,不在根目录另按功能或厂商平行分组。实际子路由可保留子页面目录,如 `views/plugins/page/` +- 根目录放入口与模块级逻辑。模块已有 `constants.ts` 时复用,按主题单列的共享常量放在 `constants/<主题>.ts` +- 卡片、弹窗和页面分区统一放在 `components/`,不在根目录另按功能或厂商平行分组。实际子路由可保留子页面目录,如 `views/plugins/page/` - 普通组件使用按职责命名的 PascalCase `.vue` 文件;需要封装一组共同维护的私有实现时,使用小写连字符目录和 `index.vue` 入口。文件长度或只有一个调用方不单独构成拆分或合并理由 - 不为整页内容再套一个目录;页面布局与独立卡片直接放在页面 `components/`。多文件组件内部优先平铺,私有子组件、composable、类型和纯函数就近放置,不机械重复 `components/composables/utils` 层级。进一步分目录应当封装独立的界面职责或生命周期 - `composables/` 保留页面查询、操作协调和跨组件共享的流程,组件自己的请求、计时器、DOM 交互及清理随组件放置;`utils/` 只放页面内共享的纯函数,组件私有计算留在组件内 diff --git a/frontend/src/api/modules/settings/system.ts b/frontend/src/api/modules/settings/system.ts index 5de0010b9..d27a57646 100644 --- a/frontend/src/api/modules/settings/system.ts +++ b/frontend/src/api/modules/settings/system.ts @@ -14,7 +14,7 @@ export interface SystemVersion { buildTime: string deploymentMode: string deploymentModeLabel: string - updateChannel: string + updateChannel: SystemUpdateChannel | 'unknown' latestVersion: string | null hasUpdate: boolean updateCached: boolean diff --git a/frontend/src/layout/components/AppSidebar.vue b/frontend/src/layout/components/AppSidebar.vue index 8b2c51a7f..faa898038 100644 --- a/frontend/src/layout/components/AppSidebar.vue +++ b/frontend/src/layout/components/AppSidebar.vue @@ -28,10 +28,11 @@ import { useI18n } from 'vue-i18n' import { isNavigationFailure, NavigationFailureType, useRoute, useRouter } from 'vue-router' import AppBrandMark from '@/components/AppBrandMark.vue' import AppLanguageMenu from '@/components/AppLanguageMenu.vue' +import { systemUpdateChannelLabels } from '@/layout/constants/system-update-channels' import { pluginPageLocation, shortPluginInstanceId } from '@/router/plugin' import { useAuthStore } from '@/stores/modules/auth' import { usePluginViewsStore } from '@/stores/modules/plugin-views' -import { useSystemUpdateStore } from '@/stores/modules/system-update' +import { normalizeSystemVersion, useSystemUpdateStore } from '@/stores/modules/system-update' import { useThemeStore } from '@/stores/modules/theme' const props = withDefaults(defineProps<{ @@ -185,9 +186,24 @@ async function handleLogout() { const themeToggleLabel = computed(() => effectiveTheme.value === 'dark' ? t('appearance.switchToLight') : t('appearance.switchToDark')) -const versionText = computed(() => version.value?.version.trim() ?? '') -const hasVersionLabel = computed(() => versionText.value.length > 0) -const versionLabel = computed(() => `v${versionText.value}`) +const runningVersion = computed(() => { + const current = version.value + const number = normalizeSystemVersion(current?.version) + if (!current || !number) + return null + + const channel = current.updateChannel + const full = `v${number}` + return { + full, + short: channel === 'unknown' + ? full + : full.split(/[-+]/, 1)[0], + channelLabel: channel === 'stable' || channel === 'unknown' + ? '' + : systemUpdateChannelLabels[channel], + } +}) const updateButtonLabel = computed(() => hasUpdate.value ? t('navigation.update.available') : t('navigation.update.open')) @@ -217,11 +233,19 @@ onMounted(() => {