diff --git a/src/views/manage/TrashView.vue b/src/views/manage/TrashView.vue
index c157781..1844281 100644
--- a/src/views/manage/TrashView.vue
+++ b/src/views/manage/TrashView.vue
@@ -4,7 +4,7 @@
RECYCLE BIN
回收站
-
删除文件会先保留在这里;恢复后将生成新的 8 位取件码。
+
删除文件会先保留在这里;恢复后沿用原取件码。
清理设置
@@ -32,7 +32,7 @@
{{ resultText }}
- #{{ failure.id }}:{{ failure.reason }}
- - #{{ entry.id }} 新取件码:
{{ entry.code }}
+ - #{{ entry.id }} 取件码:
{{ entry.code }}
{{ errorText }}
@@ -80,6 +80,7 @@
将永久清理所选 {{ purgeIds.length }} 条记录的文件本体。此操作不可恢复,审计记录和取件历史仍保留。
+ {{ errorText }}
取消确认清理 {{ purgeIds.length }} 项
@@ -174,7 +175,7 @@ const executeBatch = async (action: TrashBatchRequest['action'], ids: number[],
} catch (error) { errorText.value = getErrorMessage(error, '操作失败,请重试'); return false }
finally { busy.value = false }
}
-const restore = (item: TrashFileItem) => supportsBatch.value ? executeBatch('restore', [item.id]) : runSingle(() => restoreTrashItem(item.id), '已恢复,请到文件管理查看新取件码')
+const restore = (item: TrashFileItem) => supportsBatch.value ? executeBatch('restore', [item.id]) : runSingle(() => restoreTrashItem(item.id), '已恢复,请到文件管理查看取件码')
const makePermanent = (item: TrashFileItem) => supportsBatch.value ? executeBatch('retention', [item.id], { retentionDays: 0 }) : runSingle(() => updateTrashRetention(item.id, { retentionDays: 0 }), '已设为永久保留')
const retentionOpen = ref(false), retentionIds = ref([]), retainForever = ref(false), cleanupTime = ref(''), dialogError = ref('')
const localDateTime = (date: Date) => `${date.getFullYear()}-${String(date.getMonth()+1).padStart(2,'0')}-${String(date.getDate()).padStart(2,'0')}T${String(date.getHours()).padStart(2,'0')}:${String(date.getMinutes()).padStart(2,'0')}`
@@ -196,7 +197,7 @@ const saveRetention = async () => {
} catch (error) { dialogError.value = getErrorMessage(error, '请选择有效的清理时间') }
}
const purgeOpen = ref(false), purgeIds = ref([])
-const askPurge = (ids: number[]) => { purgeIds.value = [...ids]; purgeOpen.value = true }
+const askPurge = (ids: number[]) => { errorText.value = ''; purgeIds.value = [...ids]; purgeOpen.value = true }
const confirmPurge = async () => {
const ok = supportsBatch.value ? await executeBatch('purge', purgeIds.value) : await runSingle(() => purgeTrashItem(purgeIds.value[0]), '文件本体已清理,审计记录已保留')
if (ok || operationResult.value) purgeOpen.value = false
diff --git a/tests/README.md b/tests/README.md
index 0e02908..357bdbf 100644
--- a/tests/README.md
+++ b/tests/README.md
@@ -54,3 +54,10 @@ inner cards and action buttons retain their motion. List rows only fade their
background with no border or box-shadow. Light card shadows are bright at the
upper left and shaded at the lower right; dark mode reverses that direction.
Primary submit actions must not add white/gradient hover overlays.
+
+## 清理失败弹窗
+
+`purgeFailure.browser.mjs` 导出 `runPurgeFailureChecks(page, failure)`,接受独立
+Playwright Page。Vite 固定运行于 `127.0.0.1:5180`;分别传入 `http` 和 `network`
+验证服务端 500、断网时错误显示于弹窗内、原记录保留,以及重新打开时清空旧错误。
+测试拦截全部管理 API,不会修改部署实例。
diff --git a/tests/purgeFailure.browser.mjs b/tests/purgeFailure.browser.mjs
new file mode 100644
index 0000000..caeed2d
--- /dev/null
+++ b/tests/purgeFailure.browser.mjs
@@ -0,0 +1,39 @@
+import assert from 'node:assert/strict'
+
+// Call with a fresh Playwright page and the local Vite fixture; all API calls
+// are intercepted, so this check cannot modify a deployed backend.
+export async function runPurgeFailureChecks(page, failure = 'http') {
+ await page.route('**/*', route => {
+ const url = new URL(route.request().url())
+ return url.hostname === '127.0.0.1' ? route.continue() : route.abort()
+ })
+ await page.route('**/admin/**', async route => {
+ const url = new URL(route.request().url())
+ const headers = { 'access-control-allow-origin': '*', 'access-control-allow-headers': '*', 'access-control-allow-methods': '*' }
+ if (route.request().method() === 'OPTIONS') return route.fulfill({ status: 204, headers })
+ if (url.pathname === '/admin/trash/list') {
+ return route.fulfill({ json: { code: 200, detail: {
+ page: 1, size: 20, total: 1,
+ data: [{ id: 900001, name: 'isolated-check.txt', code: 'CHECK001', size: 16,
+ isTrashPurged: false, isTrashPermanent: true, trashReason: 'manual' }],
+ capabilities: { batch: true, filters: true, customRetention: true },
+ summary: { total: 1, recoverable: 1, purged: 0 }
+ } }, headers })
+ }
+ if (url.pathname === '/admin/trash/batch') {
+ assert.deepEqual(route.request().postDataJSON(), { action: 'purge', ids: [900001] })
+ return failure === 'network' ? route.abort() : route.fulfill({ status: 500, json: { detail: '测试服务暂时不可用' }, headers })
+ }
+ throw new Error(`Unexpected API request: ${url.pathname}`)
+ })
+ await page.goto('http://127.0.0.1:5180/theme-assets/tests/trash-workflow.html')
+ await page.getByRole('button', { name: '彻底删除', exact: true }).click()
+ const dialog = page.getByRole('dialog')
+ await dialog.getByRole('button', { name: '确认清理 1 项' }).click()
+ await dialog.getByRole('alert').waitFor({ state: 'visible', timeout: 4000 })
+ assert.ok((await dialog.getByRole('alert').textContent()).trim())
+ assert.equal(await page.locator('article').count(), 1)
+ await dialog.getByRole('button', { name: '取消', exact: true }).click()
+ await page.getByRole('button', { name: '彻底删除', exact: true }).click()
+ assert.equal(await page.getByRole('dialog').getByRole('alert').count(), 0)
+}
diff --git a/tests/trashWorkflow.browser.mjs b/tests/trashWorkflow.browser.mjs
index 3fcc0a5..b10076a 100644
--- a/tests/trashWorkflow.browser.mjs
+++ b/tests/trashWorkflow.browser.mjs
@@ -48,8 +48,8 @@ export async function runTrashWorkflowChecks() {
const selectable=[...document.querySelectorAll('article input')].filter(e=>!e.disabled)
selectable[0].click();await new Promise(r=>setTimeout(r,0));selectable[1].click();await new Promise(r=>setTimeout(r,0));await wait(()=>button('批量恢复'));assert([...document.querySelectorAll('article input')].filter(e=>e.checked).length===2,'未选中两条记录')
button('批量恢复').click();await wait(()=>document.querySelectorAll('article').length===4)
- assert(document.querySelectorAll('code').length===2,'未展示恢复后的新取件码')
- done('通过:批量恢复、列表刷新和新取件码展示')
+ assert(document.querySelectorAll('code').length===2,'未展示恢复后的取件码')
+ done('通过:批量恢复、列表刷新和取件码展示')
document.querySelector('input[type=checkbox]').click();await wait(()=>button('批量清理'))
button('批量清理').click();await wait(()=>document.querySelector('[role=dialog]'))
modal=document.querySelector('[role=dialog]');assert(modal.textContent.includes('不可恢复')&&modal.textContent.includes('3'),'缺少删除数量或后果提示')