feat: Vue SPA 添加 KDocs 在线状态显示 + 清理废弃模板
功能更新: - AccountsPage.vue: 工具栏显示 KDocs 在线状态(就绪/离线) - settings.js: 添加 fetchKdocsStatus API 函数 - 每60秒自动刷新状态 代码清理: - 删除废弃的 legacy 模板文件(约170KB) - templates/index.html - templates/login.html - templates/register.html - templates/reset_password.html 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -39,3 +39,8 @@ export async function updateKdocsSettings(payload) {
|
||||
const { data } = await publicApi.post('/user/kdocs', payload)
|
||||
return data
|
||||
}
|
||||
|
||||
export async function fetchKdocsStatus() {
|
||||
const { data } = await publicApi.get('/kdocs/status')
|
||||
return data
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
updateAccount,
|
||||
updateAccountRemark,
|
||||
} from '../api/accounts'
|
||||
import { fetchKdocsSettings, updateKdocsSettings } from '../api/settings'
|
||||
import { fetchKdocsSettings, fetchKdocsStatus, updateKdocsSettings } from '../api/settings'
|
||||
import { fetchRunStats } from '../api/stats'
|
||||
import { useSocket } from '../composables/useSocket'
|
||||
import { useUserStore } from '../stores/user'
|
||||
@@ -61,6 +61,14 @@ watch(batchEnableScreenshot, (value) => {
|
||||
const kdocsAutoUpload = ref(false)
|
||||
const kdocsSettingsLoading = ref(false)
|
||||
|
||||
// KDocs 在线状态
|
||||
const kdocsStatus = reactive({
|
||||
enabled: false,
|
||||
online: false,
|
||||
message: '',
|
||||
})
|
||||
const kdocsStatusLoading = ref(false)
|
||||
|
||||
const addOpen = ref(false)
|
||||
const editOpen = ref(false)
|
||||
const upgradeOpen = ref(false)
|
||||
@@ -205,6 +213,22 @@ async function loadKdocsSettings() {
|
||||
}
|
||||
}
|
||||
|
||||
async function loadKdocsStatus() {
|
||||
kdocsStatusLoading.value = true
|
||||
try {
|
||||
const data = await fetchKdocsStatus()
|
||||
kdocsStatus.enabled = Boolean(data?.enabled)
|
||||
kdocsStatus.online = Boolean(data?.online)
|
||||
kdocsStatus.message = data?.message || ''
|
||||
} catch {
|
||||
kdocsStatus.enabled = false
|
||||
kdocsStatus.online = false
|
||||
kdocsStatus.message = ''
|
||||
} finally {
|
||||
kdocsStatusLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function onToggleKdocsAutoUpload(value) {
|
||||
kdocsSettingsLoading.value = true
|
||||
try {
|
||||
@@ -542,6 +566,8 @@ watch(shouldPollStats, (running, prevRunning) => {
|
||||
syncStatsPolling(prevRunning)
|
||||
})
|
||||
|
||||
let kdocsStatusTimer = null
|
||||
|
||||
onMounted(async () => {
|
||||
if (!userStore.vipInfo) {
|
||||
userStore.refreshVipInfo().catch(() => {
|
||||
@@ -553,13 +579,18 @@ onMounted(async () => {
|
||||
|
||||
await refreshAccounts()
|
||||
await loadKdocsSettings()
|
||||
await loadKdocsStatus()
|
||||
await refreshStats()
|
||||
syncStatsPolling()
|
||||
|
||||
// 每60秒刷新 KDocs 状态
|
||||
kdocsStatusTimer = window.setInterval(() => loadKdocsStatus(), 60_000)
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
if (unbindSocket) unbindSocket()
|
||||
stopStatsPolling()
|
||||
if (kdocsStatusTimer) window.clearInterval(kdocsStatusTimer)
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -650,6 +681,9 @@ onBeforeUnmount(() => {
|
||||
@change="onToggleKdocsAutoUpload"
|
||||
/>
|
||||
<span class="app-muted">表格(测试)</span>
|
||||
<el-tag v-if="kdocsStatus.enabled" :type="kdocsStatus.online ? 'success' : 'warning'" size="small" effect="plain">
|
||||
{{ kdocsStatus.online ? '✅ 就绪' : '⚠️ 离线' }}
|
||||
</el-tag>
|
||||
</div>
|
||||
|
||||
<div class="toolbar-right">
|
||||
|
||||
Reference in New Issue
Block a user