feat(web): 设置中心缓存管理与文件预览资产工具

- 新增 documentPreviewAssets 工具,统一从 URL/Blob/File 推断预览类型(image/pdf/file/unsupported)
- SettingsView/SettingsView.js/settingsModelHelper 新增系统缓存管理区块,调用 /settings/cache/clear 并展示清理结果;useSettings/services 适配
- WorkbenchAiFilePreviewDialog/useWorkbenchAiFilePreview 接入预览资产工具,workbenchAiComposerModel 调整文件处理
- ReceiptFolder/LogDetailView/DigitalEmployeeWorkRecords/travelReimbursementAttachmentModel 配套适配
- 新增 settings-cache-management-section 测试,更新 settings-llm/rendering/receipt-folder-view/composer-components/attachment-association 测试
This commit is contained in:
caoxiaozhu
2026-06-24 12:35:59 +08:00
parent 9a5ed0e94a
commit 8417a9f542
20 changed files with 815 additions and 102 deletions

View File

@@ -3,7 +3,7 @@ import { useRoute, useRouter } from 'vue-router'
import { useSystemState } from './useSystemState.js'
import { useThemeSkin } from './useThemeSkin.js'
import { fetchSettings, saveSettings } from '../services/settings.js'
import { clearSystemCaches, fetchSettings, saveSettings } from '../services/settings.js'
import { useToast } from './useToast.js'
import {
isHermesEmployeeSettingsReady
@@ -56,6 +56,10 @@ export function useSettings() {
const sessionRetentionPickerOpen = ref(false)
const sessionRetentionPickerRef = ref(null)
const logoInputRef = ref(null)
const cacheClearing = ref(false)
const cacheClearItems = ref([])
const cacheClearMessage = ref('')
const cacheClearFailed = ref(false)
const sections = SECTION_DEFINITIONS
const logLevels = LOG_LEVELS
@@ -433,6 +437,46 @@ export function useSettings() {
})
}
function normalizeCacheClearErrorMessage(error) {
const message = String(error?.message || '').trim()
if (!message || /^not found$/i.test(message)) {
return '缓存清理接口暂不可用,请确认后端服务已加载最新路由后重试。'
}
return message
}
async function clearAllCaches() {
if (cacheClearing.value) {
return
}
cacheClearing.value = true
cacheClearMessage.value = ''
cacheClearItems.value = []
cacheClearFailed.value = false
try {
const payload = await clearSystemCaches()
const items = Array.isArray(payload?.items) ? payload.items : []
const totalCleared = Number(payload?.totalCleared || 0)
cacheClearItems.value = items
cacheClearMessage.value = totalCleared > 0
? `已清理 ${totalCleared} 条缓存。`
: '当前没有可清理的缓存。'
cacheClearFailed.value = false
toast(cacheClearMessage.value)
} catch (error) {
const message = normalizeCacheClearErrorMessage(error)
cacheClearFailed.value = true
cacheClearMessage.value = message
toast(message)
} finally {
cacheClearing.value = false
}
}
async function saveMailSection() {
const mailForm = pageState.value.mailForm
@@ -494,6 +538,10 @@ export function useSettings() {
return
}
if (activeSection.value === 'cacheManagement') {
return
}
if (activeSection.value === 'rendering') {
await saveRenderingSection()
return
@@ -557,6 +605,11 @@ export function useSettings() {
activeThemeSkinId,
archiveCycleOptions,
activateSection,
cacheClearFailed,
cacheClearItems,
cacheClearMessage,
cacheClearing,
clearAllCaches,
clearRenderSecretMask,
completedSectionCount,
logLevels,