Issue#2: 管理前端多标签导航+页签缓存(Gitea 工单:可独立关闭/一次全部关闭/切换后缓存)—— ①多标签导航=stores/tabs.ts(tab 身份=fullPath,参数页每实例一 tab 带 #id 后缀;home 固定不可关;登出 $reset 防跨角色残留;close 关当前回退相邻右邻优先/closeOthers/closeAll)+TagsBar.vue(纯原生元素守 G2 断言语义;✕独立关闭+中键关闭[auxclick button===1,@click.middle 对中键永不触发]+关闭其他+全部关闭;aurora token 风格 primary-soft 激活/圆角10px);②keep-alive 页签缓存=MainLayout router-view v-slot+include=cachedNames+key=fullPath;**29 个业务视图 defineOptions name=路由名**(28 新增+stats/profit 由 StatsProfitView 对齐——script setup 文件名推断名永不命中 include:15 个 index.vue 全叫 index/PascalCase≠kebab);ComingSoon(11 路由共用)刻意豁免(无本地状态,不缓存零副作用);③守门=view-cache-name.spec.ts 固化组件名=路由名约定(漏写=缓存静默失效,测试红而非线上)+verify-layout.mjs +5 项 tags-bar 断言(18→23)且凭据 env 化(SHOT_USER/SHOT_PASS 缺省 s2demo——admin 原密码首启打印一次不可知,硬编码 admin123 已不可登录 ISC:401);④门禁=eslint0/vue-tsc0/vitest 165(+17:tabs-store 7+守门 4+tags-bar 6)/build 9.99s chunk 剖面不变;verify-layout 23/23;Chrome 157 实机走查 17/17 含两项核心状态保留实证(结算页内 Tab 选中+筛选账号ID=2 切走切回均保留;截图 /tmp/issue2-*.png);验收单 issue2-frontend-tabs.md+CHANGELOG+memory-bank 回填
This commit is contained in:
@@ -3,14 +3,18 @@
|
||||
import { chromium } from 'playwright'
|
||||
|
||||
const BASE = process.env.SHOT_BASE ?? 'http://127.0.0.1:5173'
|
||||
// 凭据 env 可传(勿硬编码,同 chrome-session.mjs 惯例):内置 admin 原密码首启
|
||||
// 仅打印一次已不可知,缺省走 S2 种子的 s2demo(role=admin,scripts/seed_settle_demo.sql)。
|
||||
const USER = process.env.SHOT_USER ?? 's2demo'
|
||||
const PASS = process.env.SHOT_PASS ?? 'S2demo@2026'
|
||||
const fails = []
|
||||
const ok = (cond, msg) => { console.log(`${cond ? '✓' : '✗'} ${msg}`); if (!cond) fails.push(msg) }
|
||||
|
||||
const browser = await chromium.launch()
|
||||
const page = await browser.newPage({ viewport: { width: 1440, height: 900 } })
|
||||
await page.goto(BASE + '/login', { waitUntil: 'networkidle' })
|
||||
await page.getByTestId('login-username').fill('admin')
|
||||
await page.getByTestId('login-password').fill('admin123')
|
||||
await page.getByTestId('login-username').fill(USER)
|
||||
await page.getByTestId('login-password').fill(PASS)
|
||||
await page.getByTestId('login-submit').click()
|
||||
await page.waitForURL('**/home', { timeout: 15000 })
|
||||
|
||||
@@ -48,6 +52,17 @@ ok(sw === 'none', `侧栏滚动区 scrollbar-width === none(实际 ${sw})`)
|
||||
const gs = await page.evaluate(() => getComputedStyle(document.documentElement).scrollbarWidth)
|
||||
ok(gs === 'thin', `html scrollbar-width === thin(实际 ${gs})`)
|
||||
|
||||
// I2 · Issue#2 多标签导航断言(桌面视口,先于移动端断点切换)
|
||||
ok(await page.locator('.tags-bar').count() === 1, 'tags-bar 存在且唯一')
|
||||
ok(await page.locator('.tags-bar .tag-chip').count() >= 1, `登录后至少 1 个 chip(home,实际 ${await page.locator('.tags-bar .tag-chip').count()})`)
|
||||
ok(await page.locator('[data-testid="tag-home-close"]').count() === 0, '固定 home 无关闭按钮')
|
||||
await page.getByTestId('menu-channel').click()
|
||||
await page.waitForTimeout(500)
|
||||
ok(await page.locator('.tags-bar .tag-chip').count() === 2, `点菜单开新标签 chip=2(实际 ${await page.locator('.tags-bar .tag-chip').count()})`)
|
||||
await page.getByTestId('tag-channel-close').click()
|
||||
await page.waitForTimeout(500)
|
||||
ok(await page.locator('.tags-bar .tag-chip').count() === 1, `独立关闭生效并回退 home chip=1(实际 ${await page.locator('.tags-bar .tag-chip').count()})`)
|
||||
|
||||
// 6) 移动端汉堡抽屉(375×812)
|
||||
await page.setViewportSize({ width: 375, height: 812 })
|
||||
await page.waitForTimeout(300)
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
<template>
|
||||
<!-- Issue#2:多标签导航条——独立关闭(✕/中键)+关闭其他+全部关闭。
|
||||
纯原生元素(遵守 G2 断言语义:EP 导航壳不进布局壳);视觉对齐
|
||||
aurora nav-item(primary-soft 激活底/圆角 10px/hover 过渡)。 -->
|
||||
<nav class="tags-bar" data-testid="tags-bar" aria-label="已打开页面">
|
||||
<div class="tags-scroll">
|
||||
<button
|
||||
v-for="t in tabs.visited" :key="t.path" type="button"
|
||||
class="tag-chip" :class="{ active: t.path === route.fullPath }"
|
||||
:data-testid="`tag-${t.name}`" :title="t.title"
|
||||
@click="go(t.path)" @auxclick="onAuxClick(t, $event)"
|
||||
>
|
||||
<span class="tag-txt">{{ t.title }}</span>
|
||||
<span
|
||||
v-if="!t.affix" class="tag-close" role="button" :aria-label="`关闭 ${t.title}`"
|
||||
:data-testid="`tag-${t.name}-close`" @click.stop="close(t)"
|
||||
>✕</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="tags-actions">
|
||||
<button type="button" class="tag-act" data-testid="tags-close-others" @click="closeOthers">关闭其他</button>
|
||||
<button type="button" class="tag-act" data-testid="tags-close-all" @click="closeAll">全部关闭</button>
|
||||
</div>
|
||||
</nav>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { useTabsStore, type TabItem } from '@/stores/tabs'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const tabs = useTabsStore()
|
||||
|
||||
function go(path: string) {
|
||||
void router.push(path)
|
||||
}
|
||||
|
||||
function close(t: Pick<TabItem, 'path'>) {
|
||||
const next = tabs.close(t.path, route.fullPath)
|
||||
if (next) void router.push(next)
|
||||
}
|
||||
|
||||
function closeOthers() {
|
||||
tabs.closeOthers(route.fullPath)
|
||||
}
|
||||
|
||||
function closeAll() {
|
||||
void router.push(tabs.closeAll())
|
||||
}
|
||||
|
||||
// 中键关闭:中键不派发 click 事件,须挂 auxclick 并自判 button===1
|
||||
// (Vue 的 @click.middle 编译为 click+button 守卫,对中键永不触发)。
|
||||
function onAuxClick(t: TabItem, e: MouseEvent) {
|
||||
if (e.button !== 1 || t.affix) return
|
||||
e.preventDefault()
|
||||
close(t)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.tags-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; min-width: 0; }
|
||||
.tags-scroll {
|
||||
display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0;
|
||||
overflow-x: auto; scrollbar-width: none; padding: 2px;
|
||||
}
|
||||
.tags-scroll::-webkit-scrollbar { display: none; }
|
||||
.tag-chip {
|
||||
display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
|
||||
padding: 4px 10px; border-radius: 10px; border: 1px solid transparent;
|
||||
background: var(--gosms-card-veil); color: var(--gosms-text);
|
||||
font-size: 12px; line-height: 1.4; cursor: pointer; transition: all 0.2s; white-space: nowrap;
|
||||
}
|
||||
.tag-chip:hover { background: var(--gosms-card-hover); color: var(--gosms-text-bright); }
|
||||
.tag-chip.active { background: var(--gosms-primary-soft); color: var(--gosms-primary); font-weight: 600; }
|
||||
.tag-close {
|
||||
display: inline-grid; place-items: center; width: 14px; height: 14px;
|
||||
border-radius: 4px; font-size: 10px; color: var(--gosms-text-muted); transition: all 0.15s;
|
||||
}
|
||||
.tag-close:hover { color: var(--gosms-red); background: rgba(248, 113, 113, 0.12); }
|
||||
.tags-actions { display: flex; gap: 6px; flex-shrink: 0; }
|
||||
.tag-act {
|
||||
font-size: 11px; color: var(--gosms-text-muted); background: none;
|
||||
border: 1px solid var(--gosms-border); border-radius: 8px; padding: 4px 10px;
|
||||
cursor: pointer; transition: all 0.2s; white-space: nowrap;
|
||||
}
|
||||
.tag-act:hover { color: var(--gosms-primary); border-color: var(--gosms-primary); }
|
||||
@media (max-width: 900px) {
|
||||
/* 移动端收紧:动作按钮保留,chip 区横向滚动已由 tags-scroll 承接 */
|
||||
.tags-bar { gap: 6px; margin-bottom: 10px; }
|
||||
.tag-act { padding: 4px 8px; }
|
||||
}
|
||||
</style>
|
||||
@@ -54,12 +54,21 @@
|
||||
|
||||
<!-- ===== 主区(demo main 原文) ===== -->
|
||||
<main class="main">
|
||||
<!-- Issue#2:多标签导航(独立关闭/关闭其他/全部关闭) -->
|
||||
<TagsBar />
|
||||
<div class="page-head">
|
||||
<h2>{{ route.meta.title ?? '' }}</h2>
|
||||
<span v-if="pageSub" class="sub">{{ pageSub }}</span>
|
||||
<span id="page-head-extra" class="page-head-extra"></span>
|
||||
</div>
|
||||
<router-view />
|
||||
<!-- Issue#2:keep-alive 页签缓存——include=打开中 tab 的路由名(各视图
|
||||
defineOptions name=路由名,守门 tests/view-cache-name.spec.ts);
|
||||
key=fullPath:参数页/查询变体各自独立实例(tab 身份同口径)。 -->
|
||||
<router-view v-slot="{ Component, route: viewRoute }">
|
||||
<keep-alive :include="tabs.cachedNames">
|
||||
<component :is="Component" :key="viewRoute.fullPath" />
|
||||
</keep-alive>
|
||||
</router-view>
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
@@ -68,11 +77,14 @@
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { useTabsStore } from '@/stores/tabs'
|
||||
import { accessibleRoutes } from '@/router/guard'
|
||||
import TagsBar from '@/components/TagsBar.vue'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const userStore = useUserStore()
|
||||
const tabs = useTabsStore()
|
||||
|
||||
// ===== 暗色模式(html.dark;demo data-theme 的项目语义映射) =====
|
||||
const isDark = ref(document.documentElement.classList.contains('dark'))
|
||||
@@ -126,9 +138,18 @@ watch(
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
// Issue#2:路由到达即登记标签(tab 身份=fullPath;store 内过滤错误页/redirect;
|
||||
// watch fullPath 而非 path——查询变体亦独立成 tab,与 keep-alive key 同口径)
|
||||
watch(
|
||||
() => route.fullPath,
|
||||
() => tabs.addTab(route),
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
function onCommand(cmd: string) {
|
||||
if (cmd === 'logout') {
|
||||
userStore.logout()
|
||||
tabs.$reset() // Issue#2:标签与缓存随登出清空(防跨角色残留)
|
||||
router.push('/login')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
// stores/tabs.ts — Issue#2 多标签导航(tags-view)状态。
|
||||
//
|
||||
// 设计口径(tab 身份=route.fullPath,缓存身份=组件名=路由名):
|
||||
// - keep-alive :include 按**组件名**匹配,而 script setup 的文件名推断名
|
||||
// (15 个 index.vue 全叫 "index";PascalCase 文件名 ≠ kebab 路由名)永不
|
||||
// 命中——各业务视图必须 defineOptions({ name: <路由名> }),守门测试
|
||||
// tests/view-cache-name.spec.ts 防新增页面漏写导致"缓存静默失效"。
|
||||
// - tab 身份用 fullPath:参数页(account/:id、channel/edit/:id?)每实例
|
||||
// 一 tab;query 变体亦独立成 tab(口径如此,验收单有记)。
|
||||
// - ComingSoon 占位页(11 条路由共用)**豁免缓存**:无本地状态可保,
|
||||
// 不写 defineOptions → include 永不命中 → 每次进入重挂载,零副作用。
|
||||
// - 同名多实例(如 account/1 与 account/2)关闭其一时缓存条目随名保留,
|
||||
// 最后一个同名 tab 关闭才真正释放(keep-alive 按名驱逐,有限驻留可接受)。
|
||||
import { defineStore } from 'pinia'
|
||||
import type { RouteLocationNormalizedLoaded } from 'vue-router'
|
||||
|
||||
export interface TabItem {
|
||||
path: string // fullPath(tab 身份:去重锚+跳转目标)
|
||||
name: string // 路由名(=组件名,keep-alive include 锚)
|
||||
title: string // 标签文案(meta.title + 参数后缀)
|
||||
affix?: boolean // 固定标签(home,不可关闭)
|
||||
}
|
||||
|
||||
/** 固定标签:运营总览(五角色可达;刷新后的最小恢复集)。 */
|
||||
const AFFIX_HOME: TabItem = { path: '/home', name: 'home', title: '运营总览', affix: true }
|
||||
|
||||
/** 参数页标题后缀:账号详情 #12 / 通道编辑 #7(无 id 的新建态不加后缀)。 */
|
||||
function tabTitle(route: RouteLocationNormalizedLoaded): string {
|
||||
const base = String(route.meta.title ?? '')
|
||||
const id = route.params?.id
|
||||
return id ? `${base} #${String(id)}` : base
|
||||
}
|
||||
|
||||
/** 开标签判据:业务页(有 title+group);错误页(403/500/404)无 group 不开,
|
||||
* 登录页在布局外、redirect 路由永不成为 resolved 终路由,均天然排除。 */
|
||||
function isTabbed(route: RouteLocationNormalizedLoaded): boolean {
|
||||
return typeof route.name === 'string' && !!route.meta.title && !!route.meta.group
|
||||
}
|
||||
|
||||
interface TabsState {
|
||||
visited: TabItem[]
|
||||
}
|
||||
|
||||
export const useTabsStore = defineStore('tabs', {
|
||||
state: (): TabsState => ({ visited: [{ ...AFFIX_HOME }] }),
|
||||
getters: {
|
||||
/** keep-alive include 列表:打开中的 tab 的路由名(=组件名,去重)。 */
|
||||
cachedNames: (s): string[] => [...new Set(s.visited.map((t) => t.name))],
|
||||
},
|
||||
actions: {
|
||||
/** 路由到达即登记(按 fullPath 去重;标题随参数刷新)。 */
|
||||
addTab(route: RouteLocationNormalizedLoaded) {
|
||||
if (!isTabbed(route)) return
|
||||
const exists = this.visited.find((t) => t.path === route.fullPath)
|
||||
if (exists) {
|
||||
exists.title = tabTitle(route)
|
||||
return
|
||||
}
|
||||
this.visited.push({ path: route.fullPath, name: String(route.name), title: tabTitle(route) })
|
||||
},
|
||||
/** 关闭单个标签;若关的是当前页则返回应跳转的相邻 tab path
|
||||
* (右邻优先,末位取左邻),否则返回 null(无需导航)。固定标签不可关。 */
|
||||
close(path: string, activePath: string): string | null {
|
||||
const idx = this.visited.findIndex((t) => t.path === path)
|
||||
if (idx < 0 || this.visited[idx]!.affix) return null
|
||||
this.visited.splice(idx, 1)
|
||||
if (path !== activePath) return null
|
||||
const neighbor = this.visited[Math.min(idx, this.visited.length - 1)]
|
||||
return neighbor ? neighbor.path : '/home'
|
||||
},
|
||||
/** 关闭其他(固定标签与当前页保留)。 */
|
||||
closeOthers(keepPath: string) {
|
||||
this.visited = this.visited.filter((t) => t.affix || t.path === keepPath)
|
||||
},
|
||||
/** 全部关闭(仅固定标签保留);返回回退目标。 */
|
||||
closeAll(): string {
|
||||
this.visited = this.visited.filter((t) => t.affix)
|
||||
return this.visited[0]?.path ?? '/home'
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -33,6 +33,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
// Issue#2:keep-alive 缓存锚点——组件名必须=路由 name(守门 tests/view-cache-name.spec.ts)
|
||||
defineOptions({ name: 'account-create' })
|
||||
import { computed, reactive, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
|
||||
|
||||
@@ -138,6 +138,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
// Issue#2:keep-alive 缓存锚点——组件名必须=路由 name(守门 tests/view-cache-name.spec.ts)
|
||||
defineOptions({ name: 'account-detail' })
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
|
||||
@@ -51,6 +51,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
// Issue#2:keep-alive 缓存锚点——组件名必须=路由 name(守门 tests/view-cache-name.spec.ts)
|
||||
defineOptions({ name: 'account-list' })
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import ProTable from '@/components/ProTable.vue'
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
// Issue#2:keep-alive 缓存锚点——组件名必须=路由 name(守门 tests/view-cache-name.spec.ts)
|
||||
defineOptions({ name: 'account-recharge' })
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
// Issue#2:keep-alive 缓存锚点——组件名必须=路由 name(守门 tests/view-cache-name.spec.ts)
|
||||
defineOptions({ name: 'account-roles' })
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { accountApi, type Role } from '@/api/account'
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
// Issue#2:keep-alive 缓存锚点——组件名必须=路由 name(守门 tests/view-cache-name.spec.ts)
|
||||
defineOptions({ name: 'audit-login' })
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { accountApi, type LoginAuditRow } from '@/api/account'
|
||||
|
||||
|
||||
@@ -86,6 +86,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
// Issue#2:keep-alive 缓存锚点——组件名必须=路由 name(守门 tests/view-cache-name.spec.ts)
|
||||
defineOptions({ name: 'audit' })
|
||||
// D21 审核中心:五类审核态 Tab 聚合+计数徽标(counts 端点)/批量通过拒绝(已审跳过幂等)/
|
||||
// 48h 临期标红(待审剩 ≤12h)与超时行样式区分;操作后列表与徽标联动刷新。
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
|
||||
@@ -319,6 +319,8 @@
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
// Issue#2:keep-alive 缓存锚点——组件名必须=路由 name(守门 tests/view-cache-name.spec.ts)
|
||||
defineOptions({ name: 'channel-edit' })
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { ElMessage, ElMessageBox, type FormInstance } from 'element-plus'
|
||||
|
||||
@@ -85,6 +85,8 @@
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
// Issue#2:keep-alive 缓存锚点——组件名必须=路由 name(守门 tests/view-cache-name.spec.ts)
|
||||
defineOptions({ name: 'channel-group' })
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { channelApi, ROUTE_STEPS, type ChannelGroup, type Channel } from '@/api/channel'
|
||||
|
||||
@@ -105,6 +105,8 @@
|
||||
</el-drawer>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
// Issue#2:keep-alive 缓存锚点——组件名必须=路由 name(守门 tests/view-cache-name.spec.ts)
|
||||
defineOptions({ name: 'channel' })
|
||||
import { onBeforeUnmount, onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import ProTable from '@/components/ProTable.vue'
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
// Issue#2:keep-alive 缓存锚点——组件名必须=路由 name(守门 tests/view-cache-name.spec.ts)
|
||||
defineOptions({ name: 'channel-upstream' })
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from 'element-plus'
|
||||
import ProTable from '@/components/ProTable.vue'
|
||||
|
||||
@@ -158,6 +158,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
// Issue#2:keep-alive 缓存锚点——组件名必须=路由 name(守门 tests/view-cache-name.spec.ts)
|
||||
defineOptions({ name: 'home' })
|
||||
// P1 信息密度重构(2026-11-13):删除三处 demo 假数据(rateNow 随机速率/静态通道表/
|
||||
// 快捷卡死文案),拆三条独立加载管线;P2 图标统一 EP;P3 count-up + 走势 hover。
|
||||
// 设计基线 demo-c-aurora 的 token/卡片/徽章体系不变。
|
||||
|
||||
@@ -71,6 +71,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
// Issue#2:keep-alive 缓存锚点——组件名必须=路由 name(守门 tests/view-cache-name.spec.ts)
|
||||
defineOptions({ name: 'ops-callback' })
|
||||
/** 回调管理页(S4·C1):callback_task 列表 + 状态面板 + 死信重派。
|
||||
* 口径:PushWorker 在 consumer 进程投递(2s 扫描/2^n 秒退避/10 次耗尽死信);
|
||||
* 本页仅管理面——列表查询 + 死信重派(POST /ops/callback/:id/resend)。 */
|
||||
|
||||
@@ -107,6 +107,8 @@
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
// Issue#2:keep-alive 缓存锚点——组件名必须=路由 name(守门 tests/view-cache-name.spec.ts)
|
||||
defineOptions({ name: 'policy' })
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { policyApi, KEYWORD_LEVELS, type NumberList, type Keyword, type FrequencyPolicy, type BlockedCode } from '@/api/policy'
|
||||
|
||||
@@ -52,6 +52,8 @@
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
// Issue#2:keep-alive 缓存锚点——组件名必须=路由 name(守门 tests/view-cache-name.spec.ts)
|
||||
defineOptions({ name: 'policy-report' })
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { policyApi, REPORT_TYPES, type Report } from '@/api/policy'
|
||||
|
||||
@@ -50,6 +50,8 @@
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
// Issue#2:keep-alive 缓存锚点——组件名必须=路由 name(守门 tests/view-cache-name.spec.ts)
|
||||
defineOptions({ name: 'policy-route' })
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { policyApi, RULE_TYPES, type RouteRule } from '@/api/policy'
|
||||
|
||||
@@ -103,6 +103,8 @@
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
// Issue#2:keep-alive 缓存锚点——组件名必须=路由 name(守门 tests/view-cache-name.spec.ts)
|
||||
defineOptions({ name: 'record-down' })
|
||||
// D24 下行批次记录(方案 A 开工,2026-09-13):筛选/进度占比/拦截号码下载。
|
||||
// 契约先行——接口走 api/record.ts,msw fe4-handlers 承载,Day60 后端
|
||||
// api/v1/record.go 就绪后切 real 模式联调(A-5.x 验收口径:分页 100/页流畅;
|
||||
|
||||
@@ -96,6 +96,8 @@
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
// Issue#2:keep-alive 缓存锚点——组件名必须=路由 name(守门 tests/view-cache-name.spec.ts)
|
||||
defineOptions({ name: 'record-history' })
|
||||
// D26 历史记录(2026-09-13):>5 天全量冷数据查询+异步导出→下载中心。
|
||||
// 契约先行——接口走 api/record.ts,msw fe4-handlers 承载,Day61 后端
|
||||
// ClickHouse 历史域(冷热切换)+Day62 MinIO 异步下载落地后切 real 联调。
|
||||
|
||||
@@ -147,6 +147,8 @@
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
// Issue#2:keep-alive 缓存锚点——组件名必须=路由 name(守门 tests/view-cache-name.spec.ts)
|
||||
defineOptions({ name: 'record-repush' })
|
||||
// D28 回执工具(2026-09-14):回执重推(30 天窗口)+手动配对(四方式,3h 外)。
|
||||
// 契约先行——接口走 api/record.ts(fetchRepushReports/createRepush/
|
||||
// fetchPendingDetails/createManualPair),msw fe4RepushHandlers 承载;
|
||||
|
||||
@@ -73,6 +73,8 @@
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
// Issue#2:keep-alive 缓存锚点——组件名必须=路由 name(守门 tests/view-cache-name.spec.ts)
|
||||
defineOptions({ name: 'record-up' })
|
||||
// D27 上行记录(2026-09-14):码号/手机号查询+匹配态筛选+权限导出。
|
||||
// 契约先行——接口走 api/record.ts(fetchUplinkRecords/createUplinkExport),
|
||||
// msw fe4UplinkHandlers 承载;后端 message_uplink 查询域 Day60 record API
|
||||
|
||||
@@ -182,6 +182,8 @@
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
// Issue#2:keep-alive 缓存锚点——组件名必须=路由 name(守门 tests/view-cache-name.spec.ts)
|
||||
defineOptions({ name: 'settle' })
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import {
|
||||
|
||||
@@ -56,6 +56,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
// Issue#2:keep-alive 缓存锚点——组件名必须=路由 name(守门 tests/view-cache-name.spec.ts)
|
||||
defineOptions({ name: 'sms-batch' })
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
|
||||
@@ -120,6 +120,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
// Issue#2:keep-alive 缓存锚点——组件名必须=路由 name(守门 tests/view-cache-name.spec.ts)
|
||||
defineOptions({ name: 'sms-downlink-detail' })
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { ArrowDown } from '@element-plus/icons-vue'
|
||||
|
||||
@@ -76,6 +76,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
// Issue#2:keep-alive 缓存锚点——组件名必须=路由 name(守门 tests/view-cache-name.spec.ts)
|
||||
defineOptions({ name: 'sms-home' })
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
@@ -76,6 +76,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
// Issue#2:keep-alive 缓存锚点——组件名必须=路由 name(守门 tests/view-cache-name.spec.ts)
|
||||
defineOptions({ name: 'sms-personal' })
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { smsApi, type PrecheckResp, type SmsTemplate } from '@/api/sms'
|
||||
|
||||
@@ -103,6 +103,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
// Issue#2:keep-alive 缓存锚点——组件名必须=路由 name(守门 tests/view-cache-name.spec.ts)
|
||||
defineOptions({ name: 'sms-result' })
|
||||
// D22 发送结果反馈页(Day 46):任务检索→汇总卡→逐号明细核对。
|
||||
// 错误码 tooltip 中文走 ISC_CN 字典(codegen 与后端码表双向锁定);
|
||||
// 通道原始码(非 ISC:)原样展示,tooltip 提示「通道原始码」。
|
||||
|
||||
@@ -87,6 +87,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
// Issue#2:keep-alive 缓存锚点——组件名必须=路由 name(守门 tests/view-cache-name.spec.ts)
|
||||
defineOptions({ name: 'sms-template' })
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { smsApi, type SmsTemplate } from '@/api/sms'
|
||||
|
||||
@@ -110,6 +110,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
// Issue#2:keep-alive 缓存锚点——组件名必须=路由 name(守门 tests/view-cache-name.spec.ts)
|
||||
defineOptions({ name: 'sms-timer' })
|
||||
// D19 定时任务列表:状态 Tab/类型与审核态过滤/分页/取消/改期(仅定时待发可改期,
|
||||
// 仅待发可取消——后端原子状态机,冲突 ISC:038)。
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
|
||||
@@ -91,7 +91,7 @@ import { onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { settleApi, type UserProfitRow, type UserProfitSummary, type ChannelProfitRow } from '@/api/settle'
|
||||
|
||||
defineOptions({ name: 'StatsProfitView' })
|
||||
defineOptions({ name: 'stats-profit' })
|
||||
|
||||
const tab = ref<'users' | 'channels'>('users')
|
||||
const parentId = ref(0)
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
// tabs-store.spec.ts Issue#2:多标签导航状态机(登记去重/关闭导航语义/固定标签/缓存名去重)。
|
||||
import { createPinia, setActivePinia } from 'pinia'
|
||||
import { beforeEach, describe, expect, it } from 'vitest'
|
||||
import type { RouteLocationNormalizedLoaded } from 'vue-router'
|
||||
import { useTabsStore } from '@/stores/tabs'
|
||||
|
||||
/** 构造路由壳(测试专用,不依赖真 router 实例)。 */
|
||||
function r(
|
||||
fullPath: string,
|
||||
name: string,
|
||||
title: string,
|
||||
group = '运营管理',
|
||||
params: Record<string, string> = {},
|
||||
): RouteLocationNormalizedLoaded {
|
||||
return { fullPath, name, params, meta: { title, group } } as unknown as RouteLocationNormalizedLoaded
|
||||
}
|
||||
|
||||
describe('tabs store(Issue#2 多标签导航)', () => {
|
||||
beforeEach(() => {
|
||||
setActivePinia(createPinia())
|
||||
})
|
||||
|
||||
it('初始态:仅固定 home 标签(不可关)', () => {
|
||||
const s = useTabsStore()
|
||||
expect(s.visited).toHaveLength(1)
|
||||
expect(s.visited[0]).toMatchObject({ path: '/home', name: 'home', affix: true })
|
||||
expect(s.close('/home', '/home')).toBeNull()
|
||||
expect(s.visited).toHaveLength(1)
|
||||
})
|
||||
|
||||
it('addTab:登记 + 按 fullPath 去重 + 参数页标题带 #id 后缀', () => {
|
||||
const s = useTabsStore()
|
||||
s.addTab(r('/channel', 'channel', '通道配置', '通道与策略'))
|
||||
s.addTab(r('/settle', 'settle', '结算管理', '统计结算'))
|
||||
s.addTab(r('/settle', 'settle', '结算管理', '统计结算')) // 重复到达不去重登记
|
||||
s.addTab(r('/account/12', 'account-detail', '账号详情', '运营管理', { id: '12' }))
|
||||
expect(s.visited.map((t) => t.path)).toEqual(['/home', '/channel', '/settle', '/account/12'])
|
||||
expect(s.visited[3]!.title).toBe('账号详情 #12')
|
||||
})
|
||||
|
||||
it('addTab 过滤:错误页(无 group)/无 title/无名路由不进标签', () => {
|
||||
const s = useTabsStore()
|
||||
s.addTab({ fullPath: '/403', name: 'forbidden', params: {}, meta: { title: '无权限' } } as unknown as RouteLocationNormalizedLoaded)
|
||||
s.addTab({ fullPath: '/x', name: 'x', params: {}, meta: { group: '运营管理' } } as unknown as RouteLocationNormalizedLoaded)
|
||||
s.addTab({ fullPath: '/y', params: {}, meta: { title: 't', group: 'g' } } as unknown as RouteLocationNormalizedLoaded)
|
||||
expect(s.visited).toHaveLength(1) // 仅初始 home
|
||||
})
|
||||
|
||||
it('close:关后台 tab 返回 null 不导航;关当前 tab 返回右邻(末位取左邻)', () => {
|
||||
const s = useTabsStore()
|
||||
s.addTab(r('/channel', 'channel', '通道配置', '通道与策略'))
|
||||
s.addTab(r('/settle', 'settle', '结算管理', '统计结算'))
|
||||
s.addTab(r('/policy', 'policy', '规则策略', '通道与策略'))
|
||||
// 关后台(settle 非当前)
|
||||
expect(s.close('/settle', '/policy')).toBeNull()
|
||||
expect(s.visited.map((t) => t.path)).toEqual(['/home', '/channel', '/policy'])
|
||||
// 关当前且在末位 → 左邻
|
||||
expect(s.close('/policy', '/policy')).toBe('/channel')
|
||||
// 关当前在中间 → 右邻
|
||||
s.addTab(r('/settle', 'settle', '结算管理', '统计结算'))
|
||||
s.addTab(r('/policy', 'policy', '规则策略', '通道与策略')) // [home, channel, settle, policy]
|
||||
expect(s.close('/settle', '/settle')).toBe('/policy')
|
||||
expect(s.visited.map((t) => t.path)).toEqual(['/home', '/channel', '/policy'])
|
||||
})
|
||||
|
||||
it('closeOthers:保固定标签与当前页', () => {
|
||||
const s = useTabsStore()
|
||||
s.addTab(r('/channel', 'channel', '通道配置', '通道与策略'))
|
||||
s.addTab(r('/settle', 'settle', '结算管理', '统计结算'))
|
||||
s.closeOthers('/channel')
|
||||
expect(s.visited.map((t) => t.path)).toEqual(['/home', '/channel'])
|
||||
})
|
||||
|
||||
it('closeAll:仅固定标签保留并返回回退目标', () => {
|
||||
const s = useTabsStore()
|
||||
s.addTab(r('/channel', 'channel', '通道配置', '通道与策略'))
|
||||
s.addTab(r('/settle', 'settle', '结算管理', '统计结算'))
|
||||
expect(s.closeAll()).toBe('/home')
|
||||
expect(s.visited.map((t) => t.path)).toEqual(['/home'])
|
||||
})
|
||||
|
||||
it('cachedNames:同名多实例(参数页)去重——keep-alive include 粒度=组件名', () => {
|
||||
const s = useTabsStore()
|
||||
s.addTab(r('/account/1', 'account-detail', '账号详情', '运营管理', { id: '1' }))
|
||||
s.addTab(r('/account/2', 'account-detail', '账号详情', '运营管理', { id: '2' }))
|
||||
s.addTab(r('/account/create', 'account-create', '开户'))
|
||||
expect(s.cachedNames).toEqual(['home', 'account-detail', 'account-create'])
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,97 @@
|
||||
// tags-bar.spec.ts Issue#2:标签条组件(渲染/独立关闭/关闭导航/全部关闭/固定标签)。
|
||||
// 惯例同 login-view.spec:vi.mock vue-router(useRoute 可变 fullPath + push mock)。
|
||||
import { mount } from '@vue/test-utils'
|
||||
import { createPinia, setActivePinia } from 'pinia'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import TagsBar from '@/components/TagsBar.vue'
|
||||
import { useTabsStore } from '@/stores/tabs'
|
||||
import type { RouteLocationNormalizedLoaded } from 'vue-router'
|
||||
|
||||
let currentPath = '/home'
|
||||
const pushMock = vi.fn()
|
||||
vi.mock('vue-router', async () => {
|
||||
const actual = await vi.importActual<typeof import('vue-router')>('vue-router')
|
||||
return {
|
||||
...actual,
|
||||
useRoute: () => ({ fullPath: currentPath }),
|
||||
useRouter: () => ({ push: pushMock }),
|
||||
}
|
||||
})
|
||||
|
||||
function r(fullPath: string, name: string, title: string): RouteLocationNormalizedLoaded {
|
||||
return { fullPath, name, params: {}, meta: { title, group: '运营管理' } } as unknown as RouteLocationNormalizedLoaded
|
||||
}
|
||||
|
||||
function mountBar() {
|
||||
const router = createRouter({ history: createWebHistory(), routes: [] })
|
||||
return mount(TagsBar, { global: { plugins: [router] } })
|
||||
}
|
||||
|
||||
describe('TagsBar(Issue#2 多标签导航条)', () => {
|
||||
beforeEach(() => {
|
||||
setActivePinia(createPinia())
|
||||
pushMock.mockClear()
|
||||
currentPath = '/home'
|
||||
})
|
||||
|
||||
it('渲染:chips 来自 store,当前页 active,固定 home 无关闭按钮', () => {
|
||||
const s = useTabsStore()
|
||||
s.addTab(r('/channel', 'channel', '通道配置'))
|
||||
s.addTab(r('/settle', 'settle', '结算管理'))
|
||||
const w = mountBar()
|
||||
expect(w.findAll('.tag-chip')).toHaveLength(3)
|
||||
expect(w.get('[data-testid="tag-home"]').classes()).toContain('active')
|
||||
expect(w.find('[data-testid="tag-home-close"]').exists()).toBe(false)
|
||||
expect(w.find('[data-testid="tag-channel-close"]').exists()).toBe(true)
|
||||
})
|
||||
|
||||
it('点击 chip 切换页面(push 该 fullPath)', async () => {
|
||||
const s = useTabsStore()
|
||||
s.addTab(r('/settle', 'settle', '结算管理'))
|
||||
const w = mountBar()
|
||||
await w.get('[data-testid="tag-settle"]').trigger('click')
|
||||
expect(pushMock).toHaveBeenCalledWith('/settle')
|
||||
})
|
||||
|
||||
it('独立关闭后台 tab:store 移除且不导航', async () => {
|
||||
const s = useTabsStore()
|
||||
s.addTab(r('/channel', 'channel', '通道配置'))
|
||||
s.addTab(r('/settle', 'settle', '结算管理'))
|
||||
const w = mountBar() // 当前= /home
|
||||
await w.get('[data-testid="tag-settle-close"]').trigger('click')
|
||||
expect(s.visited.map((t) => t.path)).toEqual(['/home', '/channel'])
|
||||
expect(pushMock).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('独立关闭当前 tab:跳右邻(工单核心诉求:可独立关闭)', async () => {
|
||||
const s = useTabsStore()
|
||||
s.addTab(r('/channel', 'channel', '通道配置'))
|
||||
s.addTab(r('/settle', 'settle', '结算管理'))
|
||||
currentPath = '/channel'
|
||||
const w = mountBar()
|
||||
await w.get('[data-testid="tag-channel-close"]').trigger('click')
|
||||
expect(pushMock).toHaveBeenCalledWith('/settle')
|
||||
expect(s.visited.map((t) => t.path)).toEqual(['/home', '/settle'])
|
||||
})
|
||||
|
||||
it('全部关闭:仅保 home 并回退(工单核心诉求:一次全部关闭)', async () => {
|
||||
const s = useTabsStore()
|
||||
s.addTab(r('/channel', 'channel', '通道配置'))
|
||||
s.addTab(r('/settle', 'settle', '结算管理'))
|
||||
const w = mountBar()
|
||||
await w.get('[data-testid="tags-close-all"]').trigger('click')
|
||||
expect(s.visited.map((t) => t.path)).toEqual(['/home'])
|
||||
expect(pushMock).toHaveBeenCalledWith('/home')
|
||||
})
|
||||
|
||||
it('关闭其他:保固定标签与当前页', async () => {
|
||||
const s = useTabsStore()
|
||||
s.addTab(r('/channel', 'channel', '通道配置'))
|
||||
s.addTab(r('/settle', 'settle', '结算管理'))
|
||||
currentPath = '/settle'
|
||||
const w = mountBar()
|
||||
await w.get('[data-testid="tags-close-others"]').trigger('click')
|
||||
expect(s.visited.map((t) => t.path)).toEqual(['/home', '/settle'])
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,55 @@
|
||||
// view-cache-name.spec.ts Issue#2 守门:keep-alive :include 按**组件名**匹配,
|
||||
// 组件名必须=路由 name——新增业务页漏写 defineOptions 会让缓存**静默失效**
|
||||
// (页面照常工作,仅切 tab 丢状态),此类回归必须在本测试红,而不是线上被发现。
|
||||
// 豁免:ComingSoon 占位页(11 条路由共用,无本地状态可保,刻意不缓存)。
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { dirname, join, resolve } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { asyncRoutes } from '@/router/routes'
|
||||
|
||||
const webRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..')
|
||||
|
||||
// 从 routes.ts 源码提取 路由名 → 视图文件 映射(name 与 component 动态 import
|
||||
// 相邻的行内模式;redirect 路由天然无 component 不会入表)。
|
||||
const routesSrc = readFileSync(join(webRoot, 'src/router/routes.ts'), 'utf8')
|
||||
const viewFile = new Map<string, string>()
|
||||
for (const m of routesSrc.matchAll(/name:\s*'([\w-]+)',\s*component:\s*\(\)\s*=>\s*import\('([^']+)'\)/g)) {
|
||||
viewFile.set(m[1]!, m[2]!)
|
||||
}
|
||||
|
||||
describe('Issue#2 视图缓存命名守门(组件名=路由名)', () => {
|
||||
it('路由→文件映射提取成功(≥40,防正则/结构漂移静默跳检)', () => {
|
||||
expect(viewFile.size).toBeGreaterThanOrEqual(40)
|
||||
})
|
||||
|
||||
it('每个业务视图 SFC 含 defineOptions({ name: <路由名> })', () => {
|
||||
const children = asyncRoutes[0]!.children!
|
||||
const business = children.filter(
|
||||
(c) => c.name && c.meta?.title && c.meta?.group && viewFile.has(String(c.name)),
|
||||
)
|
||||
expect(business.length).toBeGreaterThanOrEqual(40)
|
||||
const missing: string[] = []
|
||||
for (const c of business) {
|
||||
const name = String(c.name)
|
||||
const rel = viewFile.get(name)!
|
||||
// 豁免:ComingSoon 占位页(共用组件,刻意不参与缓存)
|
||||
if (rel.endsWith('ComingSoon.vue')) continue
|
||||
const sfc = readFileSync(join(webRoot, rel.replace('@/', 'src/')), 'utf8')
|
||||
if (!sfc.includes(`defineOptions({ name: '${name}' })`)) missing.push(`${name} → ${rel}`)
|
||||
}
|
||||
expect(missing, `缺缓存命名(keep-alive 会静默失效):\n${missing.join('\n')}`).toEqual([])
|
||||
})
|
||||
|
||||
it('豁免口径固化:ComingSoon 不写 defineOptions(每次进入重挂载,零状态可丢)', () => {
|
||||
const sfc = readFileSync(join(webRoot, 'src/views/coming/ComingSoon.vue'), 'utf8')
|
||||
expect(sfc).not.toContain('defineOptions')
|
||||
})
|
||||
|
||||
it('MainLayout 已挂 keep-alive(include=tabs.cachedNames,key=fullPath)', () => {
|
||||
const sfc = readFileSync(join(webRoot, 'src/layouts/MainLayout.vue'), 'utf8')
|
||||
expect(sfc).toContain(':include="tabs.cachedNames"')
|
||||
expect(sfc).toContain(':key="viewRoute.fullPath"')
|
||||
expect(sfc).toContain('<TagsBar />')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user