mirror of
https://github.com/zyycn/codex-proxy-rs.git
synced 2026-12-03 16:01:22 +00:00
fix(ui): clarify update actions and align dashboard empty state
Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
+3
-3
@@ -1003,10 +1003,10 @@ alpha、beta、rc、exp 在 GitHub 标记为 Pre-release,不覆盖 GitHub Late
|
||||
|
||||
在线更新要求官方构建且起始版本不低于 **v3.18.1**,版本选择遵循上述规则;源码等非官方构建返回不支持原因,不提供可用更新。
|
||||
不满足在线更新条件时,使用完整发行包或镜像[手动部署](#镜像升级与源码构建)。
|
||||
点击「下载更新」后,操作日志显示下载、校验与安装过程,完成后显示「待重启」及待生效版本。点击「重启服务」并确认后才使用新程序。
|
||||
检查到可用版本后,右侧的「检查更新」切换为「下载更新」。操作日志显示下载、校验与安装过程,完成后显示待生效版本,点击右侧「重启服务」后生效。重启前检查目标版本和插件兼容性,目标变化或有不兼容插件时需要确认。
|
||||
「当前版本」表示正在运行的版本,「通道最新」显示所选通道已发布的版本。通道版本较低时仍显示其版本号,并提示无可用更新
|
||||
|
||||
启用在线重启的部署,在没有更新时也可点击「检查更新」左侧的「重启服务」。确认框提示请求中断影响,有不兼容插件时同时展示清单;取消不执行重启。服务恢复后页面自动刷新,未启用在线重启时按钮不可用
|
||||
没有待生效版本时,可点击「重启服务」并确认。重启会中断正在进行的请求,服务恢复后页面自动刷新。未启用在线重启时按钮不可用
|
||||
|
||||
手动更换镜像或程序后,更新器会核对安装文件并校准历史状态,不以旧成功记录推断需要重启。
|
||||
运行期间检测到外部文件变动或文件缺失时会报告异常,需要核对完整发行包并重启服务后再检查。
|
||||
@@ -1025,7 +1025,7 @@ host:
|
||||
```
|
||||
|
||||
`executable_path` 为可选项:未指定时,服务在启动时解析并固定当前程序路径;
|
||||
显式配置时,将示例改为实际程序的绝对路径。`self_restart_enabled` 控制管理端的「立即重启」操作;
|
||||
显式配置时,将示例改为实际程序的绝对路径。`self_restart_enabled` 控制管理端的在线重启;
|
||||
修改配置后需手动重启当前服务一次才会生效。
|
||||
以上三个字段也可分别通过 `CPR_DEPLOYMENT_MODE`、`CPR_ENABLE_SELF_RESTART` 和 `CPR_UPDATE_EXE_PATH` 设置,
|
||||
YAML 中显式配置的值优先于对应环境变量
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
},
|
||||
"errors": {
|
||||
"preRestartCheck": "Pre-restart check failed",
|
||||
"restart": "Restart failed, please check again",
|
||||
"unconfirmed": "Update task has not been confirmed, check its status and try again",
|
||||
"updateFailed": "Update failed",
|
||||
"startTimeout": "Timed out waiting for v{version} to restart. Refresh the page to check the running version.",
|
||||
@@ -52,6 +51,7 @@
|
||||
"restarting": "Restarting",
|
||||
"checking": "Checking",
|
||||
"restartRequired": "Restart required",
|
||||
"pendingVersion": "Restart for v{version}",
|
||||
"available": "Update available",
|
||||
"upToDate": "No updates available",
|
||||
"notChecked": "Not checked",
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
},
|
||||
"errors": {
|
||||
"preRestartCheck": "重启前检查失败",
|
||||
"restart": "重启失败,请重新检查",
|
||||
"unconfirmed": "尚未确认更新任务,请检查状态后重试",
|
||||
"updateFailed": "更新失败",
|
||||
"startTimeout": "等待 v{version} 重启确认超时,请刷新页面查看运行版本",
|
||||
@@ -52,6 +51,7 @@
|
||||
"restarting": "重启中",
|
||||
"checking": "检查中",
|
||||
"restartRequired": "待重启",
|
||||
"pendingVersion": "待重启 · v{version}",
|
||||
"available": "有可用更新",
|
||||
"upToDate": "无可用更新",
|
||||
"notChecked": "未检查",
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
},
|
||||
"errors": {
|
||||
"preRestartCheck": "重啓前檢查失敗",
|
||||
"restart": "重啓失敗,請重新檢查",
|
||||
"unconfirmed": "尚未確認更新任務,請檢查狀態後重試",
|
||||
"updateFailed": "更新失敗",
|
||||
"startTimeout": "等待 v{version} 重新啟動確認逾時,請重新整理頁面查看執行版本",
|
||||
@@ -52,6 +51,7 @@
|
||||
"restarting": "重啓中",
|
||||
"checking": "檢查中",
|
||||
"restartRequired": "待重啓",
|
||||
"pendingVersion": "待重啓 · v{version}",
|
||||
"available": "有可用更新",
|
||||
"upToDate": "無可用更新",
|
||||
"notChecked": "未檢查",
|
||||
|
||||
@@ -20,9 +20,10 @@ import { storeToRefs } from 'pinia'
|
||||
import { computed, nextTick, shallowRef, useTemplateRef, watch } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { checkSystemRestart } from '@/api'
|
||||
import { useRequestState } from '@/composables/useRequestState'
|
||||
import { systemUpdateChannelLabels } from '@/layout/constants/system-update-channels'
|
||||
import { notification as ZNotification } from '@/plugins/notification'
|
||||
import { useSystemUpdateStore } from '@/stores/modules/system-update'
|
||||
import { normalizeSystemVersion, useSystemUpdateStore } from '@/stores/modules/system-update'
|
||||
import { errorMessage } from '@/utils/operation'
|
||||
import {
|
||||
resolveSystemUpdateLogClasses,
|
||||
@@ -48,6 +49,7 @@ const {
|
||||
updateError,
|
||||
lastFailedOperation,
|
||||
needRestart,
|
||||
pendingVersion,
|
||||
updateLogs,
|
||||
updateStreaming,
|
||||
updateStreamError,
|
||||
@@ -57,9 +59,15 @@ const {
|
||||
} = storeToRefs(systemUpdateStore)
|
||||
const { loadSystem, checkUpdates, changeChannel, updateNow, restartNow } = systemUpdateStore
|
||||
|
||||
const updateDialog = useTemplateRef<InstanceType<typeof ZDialog>>('updateDialog')
|
||||
const updateLogScrollbar = useTemplateRef<InstanceType<typeof ZScrollbar>>('updateLogScrollbar')
|
||||
const restartButton = useTemplateRef<InstanceType<typeof ZButton>>('restartButton')
|
||||
const checkingRestart = shallowRef(false)
|
||||
const restartCheck = useRequestState((error) => {
|
||||
ZNotification.error({
|
||||
message: errorMessage(error, t('systemUpdate.errors.preRestartCheck')),
|
||||
})
|
||||
})
|
||||
const { loading: checkingRestart } = restartCheck
|
||||
const restartConfirmOpen = shallowRef(false)
|
||||
const restartPlan = shallowRef<SystemRestartPlan | null>(null)
|
||||
|
||||
@@ -68,10 +76,11 @@ const presentation = computed(() => resolveSystemUpdatePresentation({
|
||||
updateInfo: updateInfo.value,
|
||||
loading: loading.value,
|
||||
checking: checking.value || changingChannel.value,
|
||||
restarting: restarting.value,
|
||||
restarting: restarting.value && !restartConfirmOpen.value,
|
||||
updating: updating.value,
|
||||
updateError: updateError.value,
|
||||
needRestart: needRestart.value,
|
||||
pendingVersion: pendingVersion.value,
|
||||
hasUpdate: hasUpdate.value,
|
||||
updateStreaming: updateStreaming.value,
|
||||
updateStreamError: updateStreamError.value,
|
||||
@@ -169,48 +178,57 @@ async function handleUpdateRequest() {
|
||||
}
|
||||
|
||||
async function handleRestart() {
|
||||
if (checkingRestart.value || !canRestart.value)
|
||||
if (checkingRestart.value || restartConfirmOpen.value || !canRestart.value)
|
||||
return
|
||||
checkingRestart.value = true
|
||||
const activationVersion = pendingVersion.value
|
||||
const requestId = restartCheck.start()
|
||||
// 按钮在检查期间禁用,焦点留在弹窗内才能继续用 Escape 取消
|
||||
updateDialog.value?.focus()
|
||||
let plan: SystemRestartPlan
|
||||
try {
|
||||
restartPlan.value = await checkSystemRestart({ silent: true })
|
||||
if (!open.value)
|
||||
return
|
||||
checkingRestart.value = false
|
||||
await nextTick()
|
||||
// 检查期间按钮暂时禁用,恢复焦点后再让确认框记录返回位置
|
||||
restartButton.value?.focus()
|
||||
restartConfirmOpen.value = true
|
||||
plan = await checkSystemRestart({ silent: true, signal: restartCheck.signal })
|
||||
}
|
||||
catch (error: unknown) {
|
||||
ZNotification.error({
|
||||
message: errorMessage(error, t('systemUpdate.errors.preRestartCheck')),
|
||||
})
|
||||
restartCheck.fail(requestId, error)
|
||||
return
|
||||
}
|
||||
finally {
|
||||
checkingRestart.value = false
|
||||
restartCheck.finish(requestId)
|
||||
}
|
||||
if (!open.value || !restartCheck.isCurrent(requestId) || !canRestart.value)
|
||||
return
|
||||
|
||||
// 只有检查结果与点击时的待生效版本一致,才可直接继续升级
|
||||
if (activationVersion && activationVersion === pendingVersion.value
|
||||
&& activationVersion === normalizeSystemVersion(plan.targetVersion) && !plan.incompatiblePlugins.length) {
|
||||
await restartNow(plan).catch(() => undefined)
|
||||
return
|
||||
}
|
||||
|
||||
restartPlan.value = plan
|
||||
await nextTick()
|
||||
if (!open.value || !restartCheck.isCurrent(requestId))
|
||||
return
|
||||
// 检查期间按钮暂时禁用,恢复焦点后再让确认框记录返回位置
|
||||
restartButton.value?.focus()
|
||||
restartConfirmOpen.value = true
|
||||
}
|
||||
|
||||
async function handleConfirmRestart() {
|
||||
if (!restartPlan.value)
|
||||
return
|
||||
try {
|
||||
await restartNow(restartPlan.value)
|
||||
restartConfirmOpen.value = false
|
||||
}
|
||||
catch (error: unknown) {
|
||||
restartConfirmOpen.value = false
|
||||
ZNotification.error({
|
||||
message: errorMessage(error, t('systemUpdate.errors.restart')),
|
||||
})
|
||||
}
|
||||
await restartNow(restartPlan.value).catch(() => undefined)
|
||||
restartConfirmOpen.value = false
|
||||
}
|
||||
|
||||
watch(open, (visible) => {
|
||||
if (visible) {
|
||||
void loadSystem(false).catch(() => undefined)
|
||||
}
|
||||
else {
|
||||
restartCheck.invalidate()
|
||||
restartConfirmOpen.value = false
|
||||
}
|
||||
})
|
||||
|
||||
watch(
|
||||
@@ -227,6 +245,7 @@ watch(
|
||||
|
||||
<template>
|
||||
<ZDialog
|
||||
ref="updateDialog"
|
||||
v-model="open"
|
||||
:title="t('systemUpdate.title')"
|
||||
:description="t('systemUpdate.description')"
|
||||
@@ -434,7 +453,7 @@ watch(
|
||||
:options="channelOptions"
|
||||
:aria-label="t('systemUpdate.channels.label')"
|
||||
size="small"
|
||||
:disabled="!canChangeChannel"
|
||||
:disabled="!canChangeChannel || checkingRestart"
|
||||
@update:model-value="handleChannelChange"
|
||||
/>
|
||||
<ZPopover placement="top-start">
|
||||
@@ -459,7 +478,9 @@ watch(
|
||||
<span class="inline-flex" :tabindex="version?.restartSupported === false ? 0 : undefined">
|
||||
<ZButton
|
||||
ref="restartButton"
|
||||
:disabled="!canRestart || checkingRestart"
|
||||
:type="needRestart ? 'primary' : 'default'"
|
||||
:loading="checkingRestart || (restarting && !restartConfirmOpen)"
|
||||
:disabled="!canRestart"
|
||||
@click="handleRestart"
|
||||
>
|
||||
<template #icon>
|
||||
@@ -474,8 +495,21 @@ watch(
|
||||
</p>
|
||||
</ZPopover>
|
||||
<ZButton
|
||||
v-if="!needRestart && !checking && (hasUpdate || updating)"
|
||||
type="primary"
|
||||
:loading="updating"
|
||||
:disabled="!canUpdate || checkingRestart"
|
||||
@click="handleUpdateRequest"
|
||||
>
|
||||
<template #icon>
|
||||
<Download class="size-4" />
|
||||
</template>
|
||||
{{ updating ? t('systemUpdate.status.updating') : t('systemUpdate.actions.install') }}
|
||||
</ZButton>
|
||||
<ZButton
|
||||
v-else-if="!needRestart"
|
||||
:loading="checking"
|
||||
:disabled="loading || updating || restarting || changingChannel"
|
||||
:disabled="loading || restarting || changingChannel || checkingRestart"
|
||||
@click="handleCheckUpdates(true)"
|
||||
>
|
||||
<template #loading>
|
||||
@@ -486,18 +520,6 @@ watch(
|
||||
</template>
|
||||
{{ t('systemUpdate.actions.check') }}
|
||||
</ZButton>
|
||||
<ZButton
|
||||
v-if="!needRestart && (hasUpdate || updating)"
|
||||
type="primary"
|
||||
:loading="updating"
|
||||
:disabled="!canUpdate"
|
||||
@click="handleUpdateRequest"
|
||||
>
|
||||
<template #icon>
|
||||
<Download class="size-4" />
|
||||
</template>
|
||||
{{ updating ? t('systemUpdate.status.updating') : t('systemUpdate.actions.install') }}
|
||||
</ZButton>
|
||||
</template>
|
||||
</ZDialog>
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ interface SystemUpdatePresentationInput {
|
||||
updating: boolean
|
||||
updateError: string
|
||||
needRestart: boolean
|
||||
pendingVersion: string
|
||||
hasUpdate: boolean
|
||||
updateStreaming: boolean
|
||||
updateStreamError: string
|
||||
@@ -74,7 +75,9 @@ function resolveStatus(input: SystemUpdatePresentationInput) {
|
||||
if (input.needRestart || input.hasUpdate || input.updateInfo) {
|
||||
return {
|
||||
label: input.needRestart
|
||||
? t('systemUpdate.status.restartRequired')
|
||||
? input.pendingVersion
|
||||
? t('systemUpdate.status.pendingVersion', { version: input.pendingVersion })
|
||||
: t('systemUpdate.status.restartRequired')
|
||||
: input.hasUpdate
|
||||
? t('systemUpdate.status.available')
|
||||
: t('systemUpdate.status.upToDate'),
|
||||
|
||||
@@ -107,6 +107,9 @@ export const useSystemUpdateStore = defineStore('system-update', () => {
|
||||
})
|
||||
|
||||
const needRestart = computed(() => Boolean(updateStatus.value?.needRestart))
|
||||
const pendingVersion = computed(() => needRestart.value
|
||||
? normalizeSystemVersion(updateStatus.value?.currentVersion)
|
||||
: '')
|
||||
const canRestart = computed(() => version.value?.restartSupported === true
|
||||
&& statusAvailable.value && !UPDATE_BUSY_PHASES.has(phaseKind.value))
|
||||
const selectedChannel = computed(() => policy.value?.channel ?? 'stable')
|
||||
@@ -446,6 +449,8 @@ export const useSystemUpdateStore = defineStore('system-update', () => {
|
||||
updateStreamError.value = t('systemUpdate.status.confirmingStart')
|
||||
return null
|
||||
}
|
||||
if (error instanceof ApiError && error.status === 409)
|
||||
updateInfo.value = null
|
||||
updateError.value = errorMessage(error)
|
||||
setPhase({ kind: 'failed' })
|
||||
disconnectUpdateEvents()
|
||||
@@ -539,6 +544,7 @@ export const useSystemUpdateStore = defineStore('system-update', () => {
|
||||
updateError,
|
||||
lastFailedOperation,
|
||||
needRestart,
|
||||
pendingVersion,
|
||||
updateLogs,
|
||||
updateStreaming,
|
||||
updateStreamError,
|
||||
|
||||
@@ -276,7 +276,7 @@ const statusBars = computed(() => {
|
||||
v-if="accounts.length === 0"
|
||||
:title="t('dashboard.activeAccounts.empty')"
|
||||
surface="inset"
|
||||
class="min-h-40 place-content-center xl:h-full"
|
||||
class="min-h-40 place-content-center xl:min-h-82.5"
|
||||
/>
|
||||
<TransitionGroup
|
||||
v-else
|
||||
|
||||
Reference in New Issue
Block a user