From a7cdb0031ab72af31b579402dc065798cf6f1f7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E8=87=AA=E8=BE=BE?= <980324341@qq.com> Date: Sat, 5 Sep 2026 22:02:30 +0800 Subject: [PATCH] =?UTF-8?q?task-262(admin.html=E8=A7=82=E6=84=9F=E5=AF=B9?= =?UTF-8?q?=E9=BD=90):=20=E5=BA=97=E9=93=BA=E5=AF=86=E9=92=A5=E9=A1=B5?= =?UTF-8?q?=E5=AF=B9=E9=BD=90=EF=BC=88=E4=B8=89=E6=80=81=E7=99=BD=E5=90=8D?= =?UTF-8?q?=E5=8D=95=E8=8D=AF=E4=B8=B8+=E6=82=AC=E5=81=9C=E8=AF=A6?= =?UTF-8?q?=E6=83=85/=E4=BF=AE=E6=94=B9=E6=97=B6=E9=97=B4=E5=88=97/?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E4=BB=A4=E7=89=8C=E7=95=99=E7=A9=BA=E6=B2=BF?= =?UTF-8?q?=E7=94=A8/=E5=88=A0=E9=99=A4=E6=96=87=E6=A1=88=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/shop/ShopKeysPage.vue | 57 +++++++++++++---- .../src/pages/shop/shop-key-model.ts | 20 ++++++ admin-frontend-vue/tests/task-262.test.ts | 61 +++++++++++++++++++ 3 files changed, 125 insertions(+), 13 deletions(-) create mode 100644 admin-frontend-vue/tests/task-262.test.ts diff --git a/admin-frontend-vue/src/pages/shop/ShopKeysPage.vue b/admin-frontend-vue/src/pages/shop/ShopKeysPage.vue index 9dd5be15..3e3d285c 100644 --- a/admin-frontend-vue/src/pages/shop/ShopKeysPage.vue +++ b/admin-frontend-vue/src/pages/shop/ShopKeysPage.vue @@ -4,9 +4,9 @@ import { formatDateTime } from '@/utils/datetime' import { onMounted, reactive, ref } from 'vue' import { ElMessage, ElMessageBox } from 'element-plus' import { fetchShopKeyList, submitCreateShopKey, updateShopKey, deleteShopKey } from './shop-key-api.ts' -import { emptyShopKeyForm } from './shop-key-form-model.ts' +import { emptyShopKeyForm, normalizeZiniaoToken } from './shop-key-form-model.ts' import type { ShopKeyItem } from './shop-dto.ts' -import { toSensitiveString, type IpWhitelistStatus } from './shop-dto.ts' +import { whitelistStatusMeta } from './shop-key-model.ts' const loading = ref(false) const rows = ref([]) @@ -25,8 +25,16 @@ function maskToken(token: string): string { return `${value.slice(0, 4)}••••••••${value.slice(-4)}` } -function statusText(status: IpWhitelistStatus): string { - return status === 'ALLOWED' ? '已白名单' : status === 'BLOCKED' ? '被拦截' : '未知' +/** 编辑时保留原令牌的内存引用:令牌不落页面明文展示,留空提交则沿用原令牌。 */ +const originalToken = ref('') + +/** 白名单状态药丸悬停详情:检测时间 + 检测消息(对齐 admin)。 */ +function whitelistTooltip(row: ShopKeyItem): string { + const parts: string[] = [] + if (row.ipWhitelistCheckedAt) parts.push(`检测时间:${formatDateTime(row.ipWhitelistCheckedAt)}`) + if (row.ipWhitelistMessage) parts.push(row.ipWhitelistMessage) + if (parts.length === 0) parts.push(`白名单状态:${whitelistStatusMeta(row.ipWhitelistStatus).label}`) + return parts.join('\n') } async function load() { @@ -51,6 +59,7 @@ function openCreate() { function openEdit(row: ShopKeyItem) { editingId.value = row.id + originalToken.value = row.ziniaoToken Object.assign(form, emptyShopKeyForm()) form.remarkName = row.remarkName form.ziniaoAccountName = row.ziniaoAccountName @@ -58,14 +67,26 @@ function openEdit(row: ShopKeyItem) { } async function submit() { + const token = normalizeZiniaoToken(form.ziniaoToken) + const creating = editingId.value == null + if (creating && !token) { + ElMessage.warning('请完整填写紫鸟账号名称、紫鸟令牌') + return + } + if (!(form.ziniaoAccountName || '').trim()) { + ElMessage.warning('请完整填写紫鸟账号名称、紫鸟令牌') + return + } + // 编辑留空令牌 = 沿用原令牌(令牌不明文展示)。 + form.ziniaoToken = creating ? token : token || originalToken.value saving.value = true try { - if (editingId.value == null) { + if (creating) { await submitCreateShopKey({ ...form }) } else { - await updateShopKey(editingId.value, { ...form }) + await updateShopKey(editingId.value as number, { ...form }) } - ElMessage.success(editingId.value == null ? '已新增' : '已保存') + ElMessage.success(creating ? '已新增' : '已保存') dialogVisible.value = false load() } catch (error) { @@ -77,7 +98,7 @@ async function submit() { async function remove(row: ShopKeyItem) { try { - await ElMessageBox.confirm(`确认删除密钥「${row.ziniaoAccountName}」?`, '删除密钥', { type: 'warning' }) + await ElMessageBox.confirm(`确定删除店铺密钥“${row.ziniaoAccountName}”吗?`, '删除确认', { type: 'warning' }) } catch { return } @@ -117,16 +138,21 @@ onMounted(load) - + + + +