feat(frontend): show compact release channel badges in the sidebar

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Zyy
2026-12-01 17:17:35 +08:00
co-authored by Codex
parent 82cb91e1af
commit f57a375407
6 changed files with 50 additions and 18 deletions
@@ -4,7 +4,9 @@
## 领域必读
确定页面方案或审查结论前,读取[前端职责](../../../../docs/architecture.md#34-前端模块职责)、[文案与信息层级](../../../../docs/theme.md#界面文案与信息层级)和[界面验证](../../../../CONTRIBUTING.md#界面验证)的完整章节,局部修改同样读取。明确本次用户操作、原页面、最接近的同类实现及可复用基础组件,沿用既有设计与请求层,按本轮验收分工留存所需截图
确定页面方案或审查结论前,读取[前端职责](../../../../docs/architecture.md#34-前端模块职责)、[文案与信息层级](../../../../docs/theme.md#界面文案与信息层级)和[界面验证](../../../../CONTRIBUTING.md#界面验证)的完整章节,局部修改同样读取。新增或移动文件时,页面与布局按同一套目录规则,根据调用范围和导出内容区分组件私有实现、共享常量和共享纯函数
明确本次用户操作、原页面、最接近的同类实现及可复用基础组件,沿用既有设计与请求层,按本轮验收分工留存所需截图
## 按改动补齐规范
+3 -2
View File
@@ -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/` 只放页面内共享的纯函数,组件私有计算留在组件内
+1 -1
View File
@@ -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
+32 -7
View File
@@ -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(() => {
</ZMotionIcon>
</template>
<template #brand>
<strong class="text-base leading-[1.1] font-heavy text-z-text"> Codex Proxy </strong>
<div class="flex items-center gap-1.5">
<strong class="text-base leading-[1.1] font-heavy text-z-text">Codex Proxy</strong>
<span
v-if="runningVersion?.channelLabel"
class="shrink-0 rounded bg-z-warning-container-active px-1.25 text-[10px] leading-[15px] font-semibold text-z-warning-on-container"
>
{{ runningVersion.channelLabel }}
</span>
</div>
<span class="mt-1.5 flex h-4.5 min-w-0 items-center gap-2">
<span class="shrink-0 text-xs leading-none font-emphasis text-z-text-secondary"> Rust build </span>
<button
v-if="hasVersionLabel"
v-if="runningVersion"
type="button"
class="inline-flex h-4.5 min-w-0 cursor-pointer items-center gap-1 rounded-z-sm border-0 px-1.5 font-mono text-[10px] leading-none font-bold transition-colors outline-none focus-visible:ring-2 focus-visible:ring-z-control-outline focus-visible:ring-offset-2 focus-visible:ring-offset-z-bg-container"
:class="[
@@ -230,9 +254,10 @@ onMounted(() => {
: 'bg-z-fill-quaternary text-z-text-quaternary hover:bg-z-fill-tertiary hover:text-z-text-secondary',
]"
:aria-label="updateButtonLabel"
:aria-description="runningVersion.full"
@click="openSystemUpdate"
>
<span>{{ versionLabel }}</span>
<span class="truncate">{{ runningVersion.short }}</span>
<ArrowUpCircle v-if="hasUpdate" class="size-3 shrink-0 text-z-success" />
</button>
</span>
@@ -20,6 +20,7 @@ import { storeToRefs } from 'pinia'
import { computed, nextTick, shallowRef, useTemplateRef, watch } from 'vue'
import { useI18n } from 'vue-i18n'
import { checkSystemRestart } from '@/api'
import { systemUpdateChannelLabels } from '@/layout/constants/system-update-channels'
import { notification as ZNotification } from '@/plugins/notification'
import { useSystemUpdateStore } from '@/stores/modules/system-update'
import { errorMessage } from '@/utils/operation'
@@ -107,13 +108,7 @@ const channelLabels = computed(() => ({
}))
const channelOptions = computed(() => availableChannels.value.map(value => ({
value,
label: {
stable: 'Stable',
rc: 'RC',
beta: 'Beta',
alpha: 'Alpha',
exp: 'Exp',
}[value],
label: systemUpdateChannelLabels[value],
})))
async function handleChannelChange(value: string) {
@@ -0,0 +1,9 @@
import type { SystemUpdateChannel } from '@/api'
export const systemUpdateChannelLabels: Record<SystemUpdateChannel, string> = {
stable: 'Stable',
rc: 'RC',
beta: 'Beta',
alpha: 'Alpha',
exp: 'Exp',
}