feat(账号到期+公司超管): 级联过期判定、过期停任务巡检与两端续费提醒弹窗

需求两条:站点超管可开设其他公司的超级管理员(站点超管看全站、公司超管只看本公司、
组内管理员仍只看本组);账号要有过期时间,管理员过期后名下普通账户一并停用、
正在跑的任务也要停掉。落库只有 users.expires_at(V146,NULL=永不过期),级联一律现算,
不写"上级过期就把下级置成过期"那种续费也救不回来的数据。

- AccountExpiryService:生效到期 = min(自身, 本公司公司超管, 成员表组长, 创建人)。
  登录拦 403(文案给续费提示)、每次请求鉴权拦 401(前端按下线踢回登录页),super_admin
  永不适用。级联口径与数据可见范围同源(成员表基本未用、实际按 created_by_id 派生)。
- ExpiredAccountTaskStopService:每分钟把过期账号(含级联成员)名下 biz_file_task
  PENDING/SCHEDULED/RUNNING → FAILED,含未领取的 PENDING(防内部通道继续派发)。原因文案
  刻意不以「客户端异常中断」开头,否则会被 TaskResumeService 自动复活。品牌采集与跟价循环
  不在那张表上,经 ExpiredAccountTaskStopSpi 由各自模块停:品牌 pending/running→cancelled
  且 UPDATE 的 WHERE 二次核对状态(抢到行后被客户端推进成完成的行不得误杀),跟价循环只置
  stop_requested=1、沿用用户点「停止循环」那条收尾路径,绝不动 status。任务心跳接口保持匿名
  不走 requireUser,所以过期账号的客户端仍能拿到 alive=false 协作停止。
- 角色 company_super_admin:由站点超管开设(唯一要显式选公司的建号场景),建号/授菜单/改用户/
  看数据四条链路都按"本公司"收口;公司超管之间、以及公司超管与站点超管互相碰不得。
- 续费提醒:剩余 <5 天在数富后台与用户端弹窗,只能收起不能关闭(无关闭按钮,收起态是右下角
  浮标),续费到 ≥5 天自动消失。后台读 /api/admin/current-user 的 expiresAt/daysToExpire;
  用户端无 Pinia,走 localStorage 的 account_expires_at(登录/check_login 落键、被顶下线清键,
  换账号不残留)。只反映账号自身到期,弹窗不做任何级联推断。
- V146 撞掉了 V145 那批的一条护栏:它按"db/ 里不许出现 V146__ 前缀"编死号位,被一条正常的
  前向迁移占用就红。改成钉动作——剥注释后的可执行 SQL 不得写 flyway_schema_history(回滚
  一律是扫描路径外的人工补丁),并把盘点文档改 V146 时丢掉的 V145 文件名补回去。

验证(本会话亲跑,不是转述):后端定向 14 类 123/0(同一轮 mvn 里连批次③的 4 类 53 例、以及既有 ShopDataCrawl/SimilarAsin 两条回归对照 21 例一起跑,合计 197 例 0 红);admin-frontend-vue 本批定向 44/0(弹窗 7 +
公司建号/列表/入口/日期默认 21 + 角色 task-48/task-251 16),全量 1726 例里那 1 支红是另一条
会话刻意留的「公司 tab 接线缺口」尺子(点名 admin_task_center 等 6 页,与本批无关);
frontend-vue 弹窗 9/0、全量 710/0。变异自证两批共 34 点:弹窗语义 16 点全杀(阈值 5、只能收起
不能关闭、挂载点含"注释掉挂载"、落键/清键链路),本批 SPI+迁移护栏 17 点全杀(含 G2 反向:
前向迁移只在注释里提 flyway_schema_history 必须照样绿),注入文件还原 dirty=0、探针残留 0。
This commit is contained in:
2026-10-05 11:51:33 +08:00
parent 5e721cb255
commit 271e98543b
62 changed files with 2866 additions and 112 deletions
+2
View File
@@ -1,6 +1,7 @@
<template>
<el-config-provider :locale="zhCn">
<router-view />
<ExpiryNotice />
</el-config-provider>
</template>
@@ -11,4 +12,5 @@
// app.use(ElementPlus, { locale }) 全局注入,改由 ConfigProvider 提供;
// 否则分页/日期选择器/上传等组件的内置文案会退回英文。
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import ExpiryNotice from '@/shared/components/ExpiryNotice.vue'
</script>
@@ -113,6 +113,7 @@ import { useRouter } from 'vue-router'
import { loginWithDevice } from '@/shared/api/user'
import { KICK_NOTICE_KEY } from '@/shared/auth/kick-handler'
import { COMPANY_NAME_STORAGE_KEY, writeCompanyIdentity } from '@/shared/auth/company-identity'
import { clearAccountExpiry, writeAccountExpiry } from '@/shared/auth/account-expiry'
import { useVersionUpdate } from '@/shared/composables/useVersionUpdate'
import { clearApiSecretCache } from '@/shared/utils/api-secret-store'
import UpdateProgressBar from '@/shared/components/UpdateProgressBar.vue'
@@ -435,6 +436,8 @@ async function submitLogin() {
}
// 公司名随后端可选返回:没有就删键,顶栏不显示该段(见 shared/auth/company-identity)
writeCompanyIdentity(data)
// 到期时间随后端可选返回:没有就删键(续费提醒弹窗的数据源,见 shared/auth/account-expiry)
writeAccountExpiry(data)
// 登录成功即持久化记住/自动登录凭据(桌面与网页均可,密码 AES 加密落 localStorage)
void saveCredentials(account)
// 桌面端 Flask cookie 同步已随瘦身下线:登录态只存 localStorage(JWT 走 Bearer),无 cookie 依赖
@@ -457,6 +460,7 @@ onMounted(() => {
window.localStorage.removeItem('uid')
window.localStorage.removeItem('username')
window.localStorage.removeItem(COMPANY_NAME_STORAGE_KEY)
clearAccountExpiry()
} catch {
/* 忽略 */
}
+2
View File
@@ -20,6 +20,8 @@ export interface LoginData {
/** 所属公司(company.id,V143 新增;旧 jar 不返回该字段) */
companyId?: number | string
companyName?: string
/** 自身账号到期时间(yyyy-MM-dd HH:mm,V146);缺省 = 永不过期,续费提醒用 */
expiresAt?: string
[key: string]: unknown
}
@@ -0,0 +1,66 @@
/**
* 用户端账号到期信息(V146,2026-10-05)
*
* app-web 无 Pinia,登录态走 localStorage;到期时间同理:登录 / check_login 的 data 里带
* expiresAt(yyyy-MM-dd HH:mm)就落键,没有就删键——换账号登录时不能残留上一个账号的到期值。
* 只反映账号自身 expires_at(续费提醒用),级联停用判定全部在服务端,这里不做任何本地推断。
*/
export const ACCOUNT_EXPIRY_STORAGE_KEY = 'account_expires_at'
function storage(): Storage | null {
if (typeof window === 'undefined') return null
try {
return window.localStorage
} catch {
return null
}
}
/** 从登录/check_login 的 data 段落到期时间;缺字段或空白一律清键(= 永不过期/未知)。 */
export function writeAccountExpiry(data: unknown): void {
const db = storage()
if (!db) return
const raw =
data && typeof data === 'object'
? (data as { expiresAt?: unknown; expires_at?: unknown }).expiresAt ??
(data as { expires_at?: unknown }).expires_at
: undefined
const value = typeof raw === 'string' ? raw.trim() : ''
if (value) db.setItem(ACCOUNT_EXPIRY_STORAGE_KEY, value)
else db.removeItem(ACCOUNT_EXPIRY_STORAGE_KEY)
}
/** 当前账号到期时间字符串(yyyy-MM-dd HH:mm);无到期/未知返回空串。 */
export function readAccountExpiry(): string {
const db = storage()
if (!db) return ''
try {
return (db.getItem(ACCOUNT_EXPIRY_STORAGE_KEY) || '').trim()
} catch {
return ''
}
}
/** 登出/切号/被顶下线时清键。 */
export function clearAccountExpiry(): void {
const db = storage()
if (!db) return
try {
db.removeItem(ACCOUNT_EXPIRY_STORAGE_KEY)
} catch {
/* 忽略 */
}
}
/**
* 距到期还剩整天数(floor);无到期返回 null,已过期返回负数。
* 续费提醒按 0 ≤ days < 5 判定(剩余不足 5 天开始提醒,续到 ≥5 天消失)。
*/
export function daysToAccountExpiry(): number | null {
const raw = readAccountExpiry()
if (!raw) return null
const parsed = new Date(raw.replace(' ', 'T'))
if (Number.isNaN(parsed.getTime())) return null
return Math.floor((parsed.getTime() - Date.now()) / 86400_000)
}
@@ -10,6 +10,7 @@
import { get } from '@/shared/api/http'
import { writeCompanyIdentity } from './company-identity'
import { writeAccountExpiry } from './account-expiry'
const AUTH_TOKEN_KEY = 'aiimage_auth_token'
const UID_KEY = 'uid'
@@ -42,6 +43,7 @@ export async function ensureAuth(): Promise<boolean> {
window.localStorage.setItem('username', String(response.data.username))
}
writeCompanyIdentity(response.data)
writeAccountExpiry(response.data)
return true
} catch {
// token 失效:清掉本地登录态(跳转交给路由守卫)
@@ -79,6 +81,7 @@ export async function restoreLoginUser(): Promise<{ username?: string } | null>
window.localStorage.setItem('username', String(response.data.username))
}
writeCompanyIdentity(response.data)
writeAccountExpiry(response.data)
return { username: response.data.username }
} catch {
return null
@@ -9,6 +9,7 @@
*/
import { COMPANY_NAME_STORAGE_KEY } from './company-identity.ts'
import { ACCOUNT_EXPIRY_STORAGE_KEY } from './account-expiry.ts'
const AUTH_TOKEN_KEY = 'aiimage_auth_token'
const UID_KEY = 'uid'
@@ -72,6 +73,7 @@ export function handleKicked(): void {
storage.removeItem(UID_KEY)
storage.removeItem(USERNAME_KEY)
storage.removeItem(COMPANY_NAME_STORAGE_KEY)
storage.removeItem(ACCOUNT_EXPIRY_STORAGE_KEY)
storage.setItem(AUTO_LOGIN_KEY, '0')
storage.setItem(KICK_NOTICE_KEY, '1')
} catch {
@@ -0,0 +1,153 @@
<script setup lang="ts">
/**
* 用户端到期续费提醒(V146,2026-10-05 需求):
* 「管理员快过期的时候(仅剩 5 天不到开始)要在数富界面上有个弹窗去提醒,
* 只能缩小但是不能关闭,直到续费超过 5 天才消失。」
*
* - 数据源:localStorage 的 account_expires_at(登录/check_login 落键,见 shared/auth/account-expiry);
* 只反映账号自身 expires_at,级联停用判定全部在服务端。
* - 触发:0 ≤ 剩余天数 < 5。刷新页面按当前时间重算;续费到 ≥5 天自动消失。
* - 只能缩小不能关闭:无关闭按钮;缩小态是右下角常驻浮标,点开即恢复。
* - 未登录(无 uid)不渲染。
*/
import { computed, onUnmounted, ref } from 'vue'
import { daysToAccountExpiry, readAccountExpiry } from '@/shared/auth/account-expiry'
const props = defineProps<{
/** 展示阈值(天):剩余天数 < EXPIRY_NOTICE_DAYS 时展示。需求口径 = 5(不足 5 天)。 */
threshold?: number
}>()
const THRESHOLD = props.threshold ?? 5
const uid = typeof window !== 'undefined' ? window.localStorage.getItem('uid') || '' : ''
const expiresAt = ref(readAccountExpiry())
// 剩余天数随时间流逝而变小:每分钟重算一次(页面常开也会在跨过阈值时出现提醒)
const now = ref(Date.now())
const timer = typeof window !== 'undefined' ? window.setInterval(() => { now.value = Date.now() }, 60_000) : null
onUnmounted(() => {
if (timer !== null) window.clearInterval(timer)
})
const days = computed(() => {
const raw = expiresAt.value
if (!raw) return null
const parsed = new Date(raw.replace(' ', 'T'))
if (Number.isNaN(parsed.getTime())) return null
return Math.floor((parsed.getTime() - now.value) / 86400_000)
})
const visible = computed(() => Boolean(uid) && days.value !== null && days.value >= 0 && days.value < THRESHOLD)
const minimized = ref(false)
const minimizedKey = computed(() => `expiry-notice-min:${uid}:${expiresAt.value}`)
if (typeof window !== 'undefined') {
minimized.value = window.localStorage.getItem(minimizedKey.value) === '1'
}
function minimize(): void {
minimized.value = true
try {
window.localStorage.setItem(minimizedKey.value, '1')
} catch {
/* localStorage 不可用时仅本次会话生效 */
}
}
function restore(): void {
minimized.value = false
try {
window.localStorage.removeItem(minimizedKey.value)
} catch {
/* 同上 */
}
}
const daysText = computed(() => {
const value = days.value
if (value === null) return ''
return value <= 0 ? '不足 1 天' : `还剩 ${value} 天`
})
</script>
<template>
<template v-if="visible">
<div v-if="!minimized" class="expiry-notice" role="alert" aria-live="assertive">
<div class="expiry-notice-body">
<strong>服务即将到期</strong>
<span>
您的账号{{ expiresAt ? `(${expiresAt})` : '' }}即将到期,{{ daysText }}。
到期后账号将无法登录,名下账号与正在执行的任务也会一并停止,请联系管理员续费。
</span>
</div>
<button class="expiry-notice-min" type="button" title="收起(不可关闭,续费前会一直提醒)" @click="minimize">
收起
</button>
</div>
<button
v-else
class="expiry-notice-chip"
type="button"
:title="`服务即将到期:${daysText},点击展开`"
@click="restore"
>
⏰ {{ daysText }}
</button>
</template>
</template>
<style scoped>
.expiry-notice {
position: fixed;
right: 24px;
bottom: 24px;
z-index: 3000;
display: flex;
align-items: center;
gap: 12px;
max-width: 420px;
padding: 14px 16px;
border: 1px solid #e4b363;
border-radius: 12px;
background: #fffaf0;
color: #7a4d0b;
box-shadow: 0 12px 32px -18px rgba(122, 77, 11, 0.55);
}
.expiry-notice-body {
display: flex;
flex-direction: column;
gap: 4px;
font-size: 13px;
line-height: 1.55;
}
.expiry-notice-body strong {
font-size: 14px;
}
.expiry-notice-min {
flex-shrink: 0;
padding: 6px 12px;
border: 1px solid #e4b363;
border-radius: 8px;
background: #ffffff;
color: #7a4d0b;
font-size: 12.5px;
cursor: pointer;
}
.expiry-notice-min:hover {
background: #fdf3dd;
}
.expiry-notice-chip {
position: fixed;
right: 24px;
bottom: 24px;
z-index: 3000;
padding: 8px 14px;
border: 1px solid #e4b363;
border-radius: 999px;
background: #fffaf0;
color: #7a4d0b;
font-size: 13px;
cursor: pointer;
box-shadow: 0 8px 20px -12px rgba(122, 77, 11, 0.5);
}
</style>
+201
View File
@@ -0,0 +1,201 @@
import { test } from 'node:test'
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import { join } from 'node:path'
/**
* 用户端(app-web / 桌面壳内页)「服务即将到期」续费提醒护栏(V146,2026-10-05 需求)。
*
* 需求原话:仅剩不到 5 天开始提醒、只能缩小不能关闭、续费到超过 5 天才消失。
* 用户端与后台不同:后端只在登录/check_login 时下发 expiresAt,剩余天数由页面自己按
* 当前时间算——所以分两层钉:
* ① 行为层:account-expiry.ts 的落键/清键/算天数(可真跑,用 window 桩);
* ② 源码层:ExpiryNotice.vue 的阈值、按钮、收起态键(SFC 编译不了,断言打在实际源码上)。
* 链路断言(登录写键、恢复会话写键、被顶下线清键、挂载点)防的是"数据源断了但界面静默不弹"。
*/
const COMPONENT = 'src/shared/components/ExpiryNotice.vue'
const APP = 'src/App.vue'
const LOGIN = 'src/pages/login/DesktopLoginPage.vue'
const ENSURE = 'src/shared/auth/ensure-auth.ts'
const KICK = 'src/shared/auth/kick-handler.ts'
function read(rel: string): string {
return readFileSync(join(process.cwd(), rel), 'utf8')
}
/** 非重叠子串计数。不走 execSync('grep'):node 在 Windows 上交给 cmd.exe,那里没 grep,命令会「成功返回空串」而不是报错——正是恒绿的形状。 */
function occurrences(text: string, token: string): number {
if (!token) return 0
let count = 0
let index = text.indexOf(token)
while (index !== -1) {
count += 1
index = text.indexOf(token, index + token.length)
}
return count
}
function templateOf(source: string): string {
const start = source.indexOf('<template>')
const end = source.lastIndexOf('</template>')
assert.ok(start !== -1 && end > start, `${COMPONENT} 没有 <template> 段`)
return source.slice(start, end)
}
function scriptOf(source: string): string {
const start = source.indexOf('<script setup')
const end = source.indexOf('</script>')
assert.ok(start !== -1 && end > start, `${COMPONENT} 没有 <script setup> 段`)
return source.slice(start, end)
}
/** 剥掉 HTML 注释:注释掉的 `<ExpiryNotice />` 在源码里照样匹配得上,挂载点断言必须是活代码。 */
function withoutComments(source: string): string {
return source.replace(/<!--[\s\S]*?-->/g, '')
}
// ---------------------------------------------------------------- 行为层:window.localStorage 桩
interface Store {
[k: string]: string
}
/** 装一个最小 localStorage 桩跑一遍,跑完还原 globalThis.window。 */
function withStorage(run: (store: Store) => void): void {
const store: Store = {}
const localStorageStub = {
getItem: (k: string) => (Object.prototype.hasOwnProperty.call(store, k) ? store[k] : null),
setItem: (k: string, v: string) => {
store[k] = String(v)
},
removeItem: (k: string) => {
delete store[k]
},
}
const hadWindow = 'window' in globalThis
const previous = (globalThis as Record<string, unknown>).window
;(globalThis as Record<string, unknown>).window = { localStorage: localStorageStub }
try {
run(store)
} finally {
if (hadWindow) (globalThis as Record<string, unknown>).window = previous
else delete (globalThis as Record<string, unknown>).window
}
}
const DAY = 86_400_000
/** 把「距今 msFromNow 毫秒」写成后端的 yyyy-MM-dd HH:mm(分钟精度,秒被截掉)。 */
function stamp(msFromNow: number): string {
const d = new Date(Date.now() + msFromNow)
const p = (n: number) => String(n).padStart(2, '0')
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`
}
test('落键:带 expiresAt 就存(trim 后),缺字段/空白一律清键,snake_case 也认', async () => {
const expiry = await import('../src/shared/auth/account-expiry.ts')
withStorage((store) => {
const key = expiry.ACCOUNT_EXPIRY_STORAGE_KEY
expiry.writeAccountExpiry({ expiresAt: ' 2026-12-31 23:59 ' })
assert.equal(store[key], '2026-12-31 23:59', '到期值没 trim 落键')
expiry.writeAccountExpiry({ expires_at: '2026-11-01 08:00' })
assert.equal(store[key], '2026-11-01 08:00', 'snake_case 也要认(老接口形状)')
expiry.writeAccountExpiry({})
assert.equal(Object.prototype.hasOwnProperty.call(store, key), false, '缺字段必须删键')
expiry.writeAccountExpiry({ expiresAt: '2026-12-31 23:59' })
expiry.writeAccountExpiry({ expiresAt: ' ' })
assert.equal(Object.prototype.hasOwnProperty.call(store, key), false, '空白一律清键')
expiry.writeAccountExpiry(null)
expiry.writeAccountExpiry(undefined)
assert.equal(expiry.readAccountExpiry(), '', '无键读出来是空串,不是 undefined')
})
})
test('换账号不残留:清键后读不到上一账号的到期值,天数返回 null 而不是 0', async () => {
const expiry = await import('../src/shared/auth/account-expiry.ts')
withStorage(() => {
expiry.writeAccountExpiry({ expiresAt: '2026-12-31 23:59' })
assert.equal(expiry.readAccountExpiry(), '2026-12-31 23:59')
expiry.clearAccountExpiry()
assert.equal(expiry.readAccountExpiry(), '', '登出/切号/被顶下线后必须读不到')
assert.equal(expiry.daysToAccountExpiry(), null, '无到期返回 null,弹窗不得按 0 天渲染')
})
})
test('剩余天数 floor 取整:4 天 12 小时算 4 天,已过期给负数,非法值给 null', async () => {
const expiry = await import('../src/shared/auth/account-expiry.ts')
withStorage(() => {
expiry.writeAccountExpiry({ expiresAt: stamp(4.5 * DAY) })
assert.equal(expiry.daysToAccountExpiry(), 4, '必须 floor,四舍五入会把 4.5 天报成 5 天而漏掉提醒')
expiry.writeAccountExpiry({ expiresAt: stamp(-1.5 * DAY) })
assert.ok((expiry.daysToAccountExpiry() ?? 0) < 0, '已过期要返回负数,由弹窗的 >=0 分支挡掉')
expiry.writeAccountExpiry({ expiresAt: '不是日期' })
assert.equal(expiry.daysToAccountExpiry(), null, '解析失败必须 null,不能当成今天到期')
})
})
// ---------------------------------------------------------------- 源码层:弹窗口径
const source = read(COMPONENT)
const template = templateOf(source)
const script = scriptOf(source)
test('提醒阈值 5 天,渲染条件 0 ≤ 剩余 < 5(整 5 天不弹,已过期不弹)', () => {
assert.match(script, /const THRESHOLD = props\.threshold \?\? 5\b/, '阈值没写成 5 的兜底')
const numericFallbacks = script.match(/\?\?\s*\d+/g) ?? []
assert.deepEqual(numericFallbacks, ['?? 5'], '数字兜底只能有阈值 5 这一个')
assert.match(script, /days\.value >= 0 && days\.value < THRESHOLD/, '没按「未过期且不足阈值」判定')
assert.doesNotMatch(script, /days\.value <= THRESHOLD/, '写成 <= 则整 5 天也弹')
})
test('只能缩小不能关闭:模板里恰好「收起 + 浮标」两个可点项,没有任何关闭件', () => {
assert.equal(occurrences(template, '@click="'), 2, '可点项必须恰好两个:minimize 与 restore')
assert.match(template, /@click="minimize"/, '收起按钮没接 minimize')
assert.match(template, /@click="restore"/, '缩小态浮标没接 restore')
assert.match(template, /收起\s*<\/button>/, '收起动作文案是「收起」')
assert.equal(occurrences(source, 'el-dialog'), 0, '对话框会带来关闭件')
assert.doesNotMatch(source, /@click="[^"]*close/i, '存在 close 点击处理器')
assert.doesNotMatch(source, /show-close|close-on-click-modal|close-on-press-escape|:closable/, '存在任何关闭开关')
})
test('收起态按「uid + 到期值」记键:续费换了到期值,新键没记录,回到展开', () => {
assert.equal(occurrences(script, 'expiry-notice-min:'), 1, '收起态键名只应有一处定义')
assert.match(script, /`expiry-notice-min:\$\{uid\}:\$\{expiresAt\.value\}`/, '键必须同时带 uid 与到期值')
assert.equal(occurrences(script, 'window.localStorage.setItem('), 1, '持久化写入只能有收起态这一处')
assert.equal(occurrences(script, 'window.localStorage.removeItem('), 1, '只有恢复展开时清键')
assert.match(
script,
/minimized\.value = window\.localStorage\.getItem\(minimizedKey\.value\) === '1'/,
'初值必须由「当前键」读出,键含到期值才会在续费后自动展开',
)
})
test('页面常开也要跨阈值出现:按分钟重算剩余,卸载时清计时器,未登录不渲染', () => {
assert.match(script, /window\.setInterval\(\(\) => \{ now\.value = Date\.now\(\) \}, 60_000\)/, '没有按分钟重算剩余天数')
assert.match(script, /onUnmounted\(\(\) => \{[\s\S]*?window\.clearInterval\(timer\)/, '卸载没清计时器')
assert.match(script, /Boolean\(uid\)/, '未登录(无 uid)不该渲染')
})
test('挂在 App.vue:桌面壳与网页共用同一个根组件,不挂就整站看不见', () => {
const app = withoutComments(read(APP))
assert.match(app, /import ExpiryNotice from '@\/shared\/components\/ExpiryNotice\.vue'/, 'App.vue 没引组件')
assert.match(app, /<ExpiryNotice\s*\/>/, 'App.vue 没渲染组件(注释掉等于没挂)')
})
test('数据源链路:登录写键、恢复会话两处写键、被顶下线清键,断了就静默不弹', () => {
const login = read(LOGIN)
const ensure = read(ENSURE)
const kick = read(KICK)
assert.equal(occurrences(login, 'writeAccountExpiry(data)'), 1, '登录成功没落到期键')
assert.equal(occurrences(login, 'clearAccountExpiry()'), 1, '登录页挂载清理没接上')
assert.equal(occurrences(ensure, 'writeAccountExpiry(response.data)'), 2, 'ensure-auth 两条恢复路径都要落键')
assert.match(kick, /storage\.removeItem\(ACCOUNT_EXPIRY_STORAGE_KEY\)/, '被顶下线没清到期键,换账号会残留')
})