开发者指令(原话):「将市场价格监控界面隐藏,当前供应商系统不需要使用这个功能。」
只删菜单项不够(直接敲 URL 仍能打开),四处一起摘:
① src/config/menuCatalog.ts:删除 market-monitor 条目
—— 运行时菜单树只渲染目录里有的 key ⇒ **老布局(库里存过该项)也不会再显示**
② src/utils/menuLayout.ts:从「基础数据」规范条目删除
—— 否则归位逻辑会把它塞回分组(规范条目是权威顺序表)
③ src/modules/businessModules.ts:删除 ops 模块的 route 与 menuKeys ⇒ /market-monitor 不再可达
④ src/utils/authRouting.ts:删除「只有 market_monitor 权限 ⇒ 落 /market-monitor」兜底
—— 否则这类账号登录后被送到已隐藏的页面
有意保留(避免动到权限体系与将来恢复成本):
· 权限码 market_monitor(permissionCatalog / permissionLabels / 角色目录 / 后端都在用)
· 页面文件 MarketMonitor.tsx 与 AI 副驾合同(不删代码,恢复只需把①②③④加回去)
· i18n 三语文案(无入口即不可见)
未动(开发者未要求,需单独裁决):后台「市场监控每日刷新」调度(每日 03:00,调外部行情接口)
与后端只读行情接口 —— 本轮只隐藏界面。
验证:新增 src/utils/hiddenFeatures.marketMonitor.test.ts 5 例(逐条钉 ①②③④ + 老布局不显示 +
同组其它菜单项不受影响);前端全量 722 用例(新增 5),失败仅另一条工作线遗留的
SystemConfig.allowZeroCost 2 条;tsc 通过;门禁同基线。
设计:docs/design/20261027-隐藏市场价格监控功能.md
73 lines
3.2 KiB
TypeScript
73 lines
3.2 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
||
import { readFileSync } from 'node:fs';
|
||
import { MENU_CATALOG } from '../config/menuCatalog';
|
||
import { buildRuntimeMenuTree, mergeNavMenuLayout } from './menuLayout';
|
||
|
||
/**
|
||
* 本产品的**功能收窄**:隐藏「市场价格监控」(开发者 2026-10-10:
|
||
* 「将市场价格监控界面隐藏,当前供应商系统不需要使用这个功能」)。
|
||
*
|
||
* 四处一起摘才算真隐藏(只删菜单项的话,直接敲 URL 仍能打开):
|
||
* ① 菜单目录 `MENU_CATALOG`(运行时菜单树的唯一数据源);
|
||
* ② 基础数据分组的规范条目(否则归位逻辑会把它塞回分组);
|
||
* ③ 模块注册表 `businessModules` 的 **route** 与 `menuKeys`(URL 不再可达);
|
||
* ④ 落地路径兜底(否则"只有 market_monitor 权限"的账号会被送到已隐藏的页面)。
|
||
*
|
||
* ⚠️ 权限码 `market_monitor` **保留**(角色/权限目录与后端仍在用,删了会动到角色同步);
|
||
* 页面文件与 AI 副驾合同也保留(将来要恢复只需把 ①②③④ 加回去)。
|
||
*/
|
||
describe('市场价格监控已在本产品隐藏', () => {
|
||
const catalog = readFileSync(new URL('../config/menuCatalog.ts', import.meta.url), 'utf8');
|
||
const layout = readFileSync(new URL('./menuLayout.ts', import.meta.url), 'utf8');
|
||
const modules = readFileSync(new URL('../modules/businessModules.ts', import.meta.url), 'utf8');
|
||
const routing = readFileSync(new URL('./authRouting.ts', import.meta.url), 'utf8');
|
||
|
||
it('① 菜单目录里没有它', () => {
|
||
expect(MENU_CATALOG.some((entry) => entry.menuKey === 'market-monitor')).toBe(false);
|
||
expect(catalog).not.toContain("menuKey: 'market-monitor'");
|
||
});
|
||
|
||
it('② 基础数据规范条目里没有它(不会被归位逻辑塞回分组)', () => {
|
||
expect(layout).not.toContain("menuKey: 'market-monitor'");
|
||
});
|
||
|
||
it('③ 模块注册表没有它的路由与 menuKey', () => {
|
||
expect(modules).not.toContain("'market-monitor'");
|
||
expect(modules).not.toContain('MarketMonitor');
|
||
});
|
||
|
||
it('④ 落地路径兜底不再指向它', () => {
|
||
expect(routing).not.toContain("hasPermission('market_monitor')");
|
||
});
|
||
|
||
it('老布局(库里存过该项)加载后侧边栏也不显示它', () => {
|
||
const saved = {
|
||
version: 1,
|
||
order: [
|
||
{ kind: 'standalone', menuKey: 'dashboard' },
|
||
{ kind: 'group', groupId: 'grp-master-data' },
|
||
],
|
||
standalone: [{ menuKey: 'dashboard', visible: true }],
|
||
groups: [
|
||
{
|
||
id: 'grp-master-data',
|
||
label: '基础数据',
|
||
icon: 'Store',
|
||
visible: true,
|
||
items: [
|
||
{ menuKey: 'customers-list', visible: true },
|
||
{ menuKey: 'market-monitor', label: '市场价格监控', visible: true },
|
||
{ menuKey: 'products-units', visible: true },
|
||
],
|
||
},
|
||
],
|
||
};
|
||
const tree = buildRuntimeMenuTree(mergeNavMenuLayout(saved));
|
||
const flat = JSON.stringify(tree);
|
||
expect(flat).not.toContain('市场价格监控');
|
||
expect(flat).not.toContain('/market-monitor');
|
||
// 同组的其它菜单项不受影响
|
||
expect(flat).toContain('/customers');
|
||
});
|
||
});
|