Improve abnormal account cleanup

This commit is contained in:
SmartUp Developer
2026-07-06 13:48:41 +08:00
parent c26bdb766c
commit a62ee00115
6 changed files with 255 additions and 70 deletions
+1
View File
@@ -361,6 +361,7 @@ export interface CleanupInvalidAccountsItem {
reason: string
test_status: string
cleanup_allowed: boolean
cleanup_action: string | null // clear_local_marker | delete_remote_account | delete_remote_and_clear_marker
action_status: string | null
message: string
}
+10 -1
View File
@@ -402,7 +402,7 @@
</el-table-column>
<el-table-column label="状态" width="96">
<template #default="{ row }">
<el-tooltip v-if="row.error" :content="row.error" placement="top" :show-after="300">
<el-tooltip v-if="row.error || (row.status === 'orphaned' && row.imported_account_id)" :content="orphanedKeyTooltip(row)" placement="top" :show-after="300">
<el-tag size="small" :type="keyStatusTagType(row.status)">
{{ keyStatusLabel(row) }}
</el-tag>
@@ -1084,6 +1084,15 @@ const keyStatusTagType = (s: string) => {
return 'info'
}
const orphanedKeyTooltip = (row: GeneratedUpstreamKey) => {
const parts: string[] = []
if (row.error) parts.push(row.error)
if (row.status === 'orphaned' && row.imported_account_id) {
parts.push('可到目标站「清理异常账号」中处理')
}
return parts.join('\n')
}
async function loadList() {
tableLoading.value = true
try {
+21 -14
View File
@@ -160,9 +160,9 @@
text
:disabled="!selectedWebsite"
@click="openCleanupDialog"
title="清理当前网站已导入但失效/孤立的账号"
title="清理当前网站中手动删除残留、已归档 Key 关联、关联不一致等异常账号"
>
清理失效账号
清理异常账号
</el-button>
<el-button
size="small"
@@ -806,7 +806,7 @@
<!-- 清理失效账号弹窗 -->
<el-dialog
v-model="cleanupDialog"
title="清理失效账号候选预览"
title="清理异常账号候选预览"
width="1000px"
destroy-on-close
>
@@ -819,9 +819,11 @@
style="margin-bottom: 15px;"
>
<div style="font-size: 13px; line-height: 1.5;">
系统已自动分析出可能已经失效上游孤立或属于脏数据的账号候选<br />
<strong>是否将删除</strong> 字段是由后端调用目标站账号测试接口的结果判定只有测试明确失败非正常响应 404 的账号才会被允许清理<br />
确认清理后端会重新测试 and 验证所有账号状态只清理最终判定为失效的项 SmartUp 导入备注的手工账号不会被处理
系统已自动分析出三类异常账号候选<br />
<strong>手动删除残留</strong>下游账号已被手动删除 SmartUp 本地仍记录着导入关联<br />
<strong>已归档 Key 关联</strong>本地上游 Key 已归档orphaned但其关联的下游账号仍存在<br />
<strong>关联不一致</strong>下游账号备注引用了不存在的或关联不一致的本地 Key<br />
确认清理时将根据处理动作自动执行清标或删除无需手动判断
</div>
</el-alert>
@@ -852,12 +854,16 @@
<el-tag v-if="row.test_status === 'test_passed'" type="success" size="small">测试通过</el-tag>
<el-tag v-else-if="row.test_status === 'failed'" type="danger" size="small">测试失败</el-tag>
<el-tag v-else-if="row.test_status === '404'" type="warning" size="small">404 不存在</el-tag>
<el-tag v-else-if="row.test_status === 'not_needed'" type="info" size="small">无需测试</el-tag>
<el-tag v-else-if="row.test_status === 'executed'" type="info" size="small">已执行</el-tag>
<el-tag v-else type="info" size="small">未知 / 异常</el-tag>
</template>
</el-table-column>
<el-table-column prop="cleanup_allowed" label="是否将删除" width="100" align="center">
<el-table-column label="处理动作" width="120" align="center">
<template #default="{ row }">
<el-tag v-if="row.cleanup_allowed" type="danger" effect="dark" size="small">将删除</el-tag>
<el-tag v-if="row.cleanup_action === 'clear_local_marker'" type="warning" size="small">清除本地标记</el-tag>
<el-tag v-else-if="row.cleanup_action === 'delete_remote_account'" type="danger" size="small">删除下游账号</el-tag>
<el-tag v-else-if="row.cleanup_action === 'delete_remote_and_clear_marker'" type="danger" size="small">删除并清标记</el-tag>
<el-tag v-else type="info" size="small">跳过</el-tag>
</template>
</el-table-column>
@@ -865,15 +871,16 @@
<template #default="{ row }">
<el-tag v-if="row.action_status === 'deleted'" type="success" effect="dark" size="small">已删除</el-tag>
<el-tag v-else-if="row.action_status === 'already_deleted'" type="warning" effect="dark" size="small">已不存在</el-tag>
<el-tag v-else-if="row.action_status === 'cleared'" type="success" effect="dark" size="small">已清标记</el-tag>
<el-tag v-else-if="row.action_status === 'skipped'" type="info" size="small">已跳过</el-tag>
<el-tag v-else-if="row.action_status === 'failed'" type="danger" effect="dark" size="small">删除失败</el-tag>
<el-tag v-else-if="row.action_status === 'failed'" type="danger" effect="dark" size="small">失败</el-tag>
<span v-else>-</span>
</template>
</el-table-column>
</el-table>
<div v-if="cleanupItems.length === 0" style="padding: 30px; text-align: center; color: var(--el-text-color-secondary);">
没有找到可以清理的失效或孤立账号
没有找到可以清理的异常账号
</div>
</div>
<template #footer>
@@ -885,10 +892,10 @@
v-if="!cleanupHasExecuted"
type="danger"
:loading="cleanupExecuting"
:disabled="cleanupLoading || cleanupItems.filter(i => i.cleanup_allowed).length === 0"
:disabled="cleanupLoading || cleanupItems.length === 0"
@click="executeCleanup"
>
确认清理 ({{ cleanupItems.filter(i => i.cleanup_allowed).length }} )
确认清理 ({{ cleanupItems.length }} )
</el-button>
</div>
</template>
@@ -1956,7 +1963,7 @@ async function organizeWebsiteGroups() {
if (!selectedWebsite.value) return
try {
await ElMessageBox.confirm(
'一键整理分组将根据当前的分组管理绑定关系,自动执行已导入账号的校验补齐,以及未导入账号的自动创建。确认执行?',
'一键整理分组将根据当前的分组管理绑定关系,自动执行已导入账号的校验补齐,以及未导入账号的自动创建。确认执行?',
'一键整理分组',
{ type: 'info' }
)
@@ -2005,7 +2012,7 @@ async function executeCleanup() {
if (!selectedWebsite.value) return
try {
await ElMessageBox.confirm(
'确认清理失效账号?此操作将永久从目标站删除测试失败或不存在的账号,本地 orphaned 键将清空导入关联。',
'确认清理异常账号?此操作将按预览中的处理动作执行:清除本地标记仅清 SmartUp 导入关联(不调远端接口),删除下游账号/删除并清标记会永久从目标站删除对应账号(即使远端测试通过也会删除)。',
'确认清理',
{ type: 'warning' }
)