feat(功能收窄): 隐藏「市场价格监控」—— 供应商系统不需要该功能
开发者指令(原话):「将市场价格监控界面隐藏,当前供应商系统不需要使用这个功能。」
只删菜单项不够(直接敲 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
This commit is contained in:
@@ -68,7 +68,6 @@ export const MENU_CATALOG: MenuCatalogEntry[] = [
|
||||
{ menuKey: 'after-sales', path: '/after-sales', defaultLabel: '售后管理', icon: 'Package', permission: 'aftersales_manage' },
|
||||
{ menuKey: 'exceptions', path: '/exceptions', defaultLabel: '异常管理', icon: 'AlertTriangle', permission: 'exception_manage' },
|
||||
{ menuKey: 'picking', path: '/picking', defaultLabel: '分拣出库', icon: 'ClipboardCheck', permission: 'picking_manage' },
|
||||
{ menuKey: 'market-monitor', path: '/market-monitor', defaultLabel: '市场价格监控', icon: 'TrendingUp', permission: 'market_monitor', secondary: true },
|
||||
{ menuKey: 'system-config', path: '/system/config', defaultLabel: '系统配置', icon: 'ChevronRight', permission: 'system_manage', roles: ['super_admin', 'admin'], secondary: true },
|
||||
{ menuKey: 'system-ai-models', path: '/system/ai-models', defaultLabel: 'AI 模型', icon: 'ChevronRight', permission: 'system_manage', roles: ['super_admin'], secondary: true },
|
||||
{ menuKey: 'system-ai-prompts', path: '/system/ai-prompts', defaultLabel: 'AI 提示词', icon: 'ChevronRight', permission: 'system_manage', roles: ['super_admin'], secondary: true },
|
||||
|
||||
@@ -231,17 +231,11 @@ export const BUSINESS_MODULES: BusinessModuleDef[] = [
|
||||
{
|
||||
id: 'ops',
|
||||
name: '运营',
|
||||
permissions: ['aftersales_manage', 'exception_manage', 'market_monitor'],
|
||||
menuKeys: ['after-sales', 'exceptions', 'market-monitor'],
|
||||
permissions: ['aftersales_manage', 'exception_manage'],
|
||||
menuKeys: ['after-sales', 'exceptions'],
|
||||
routes: [
|
||||
{ path: 'after-sales', page: 'AfterSalesManagement', permission: 'aftersales_manage' },
|
||||
{ path: 'exceptions', page: 'ExceptionManagement', permission: 'exception_manage' },
|
||||
{
|
||||
path: 'market-monitor',
|
||||
page: 'MarketMonitor',
|
||||
permission: 'market_monitor',
|
||||
tabChildren: ['', 'index', 'trend', 'recommend'],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
+53
-54
@@ -1,54 +1,53 @@
|
||||
import type { UserRole } from '../hooks/useAuth';
|
||||
|
||||
type HasRole = (role: UserRole | UserRole[]) => boolean;
|
||||
type HasPermission = (permission: string | string[]) => boolean;
|
||||
|
||||
interface ProfileAccess {
|
||||
roles: UserRole[];
|
||||
permissions: string[];
|
||||
}
|
||||
|
||||
export function createAccessCheckers(profile: ProfileAccess) {
|
||||
const hasRole: HasRole = (role) => {
|
||||
if (Array.isArray(role)) return role.some((r) => profile.roles.includes(r));
|
||||
return profile.roles.includes(role);
|
||||
};
|
||||
|
||||
const hasPermission: HasPermission = (permission) => {
|
||||
if (Array.isArray(permission)) {
|
||||
return permission.some((p) => profile.permissions.includes(p));
|
||||
}
|
||||
return profile.permissions.includes(permission);
|
||||
};
|
||||
|
||||
return { hasRole, hasPermission };
|
||||
}
|
||||
|
||||
export function getDefaultHomePath(hasRole: HasRole, hasPermission: HasPermission): string {
|
||||
// 与后端统一登录入口 accountLoginService.resolveWebHomePath 保持一致:
|
||||
// 超管落地「系统设置」,而非数据看板 —— /dashboard 的路由守卫只放行 admin(roles: ['admin']),
|
||||
// 超管的 roles 只有 'super_admin'(不会被补成 admin),落过去会命中 App.tsx 的
|
||||
// 「无权限 → 跳回默认首页」而自环。超管现有权限为 system_manage / branch_manage / data_import_export。
|
||||
if (hasRole('super_admin')) return '/system/config';
|
||||
if (hasRole('admin')) return '/dashboard';
|
||||
if (hasRole('purchaser')) return '/purchaser/dashboard';
|
||||
if (hasPermission('order_entry')) return '/customer-order';
|
||||
if (hasPermission('order_manage')) return '/orders';
|
||||
if (hasPermission('customer_manage')) return '/customers';
|
||||
if (hasPermission('supplier_manage')) return '/suppliers';
|
||||
if (hasPermission('preparation_manage')) return '/purchase/preparations';
|
||||
if (hasPermission('purchase_manage')) return '/purchase';
|
||||
if (hasPermission('picking_manage')) return '/picking';
|
||||
if (hasPermission('inventory_manage')) return '/inventory';
|
||||
if (hasPermission('delivery_manage')) return '/delivery';
|
||||
if (hasPermission('finance_manage')) return '/finance';
|
||||
if (hasPermission('inspection_manage')) return '/inspection';
|
||||
if (hasPermission('processing_manage')) return '/inspection/processing';
|
||||
if (hasPermission('market_monitor')) return '/market-monitor';
|
||||
if (hasPermission(['system_manage', 'user_manage', 'role_manage', 'log_view'])) return '/system/config';
|
||||
// 兜底必须是「不需要任何权限就能进」的页面。
|
||||
// 原为 '/customer-order',但该路由守卫要求 order_entry,
|
||||
// 无角色/无权限的账号落过去会被 App.tsx「无权限 → 回默认首页」打回这里 → 自环。
|
||||
// 见 src/pages/auth/NoAccess.tsx 顶部说明。
|
||||
return '/no-access';
|
||||
}
|
||||
import type { UserRole } from '../hooks/useAuth';
|
||||
|
||||
type HasRole = (role: UserRole | UserRole[]) => boolean;
|
||||
type HasPermission = (permission: string | string[]) => boolean;
|
||||
|
||||
interface ProfileAccess {
|
||||
roles: UserRole[];
|
||||
permissions: string[];
|
||||
}
|
||||
|
||||
export function createAccessCheckers(profile: ProfileAccess) {
|
||||
const hasRole: HasRole = (role) => {
|
||||
if (Array.isArray(role)) return role.some((r) => profile.roles.includes(r));
|
||||
return profile.roles.includes(role);
|
||||
};
|
||||
|
||||
const hasPermission: HasPermission = (permission) => {
|
||||
if (Array.isArray(permission)) {
|
||||
return permission.some((p) => profile.permissions.includes(p));
|
||||
}
|
||||
return profile.permissions.includes(permission);
|
||||
};
|
||||
|
||||
return { hasRole, hasPermission };
|
||||
}
|
||||
|
||||
export function getDefaultHomePath(hasRole: HasRole, hasPermission: HasPermission): string {
|
||||
// 与后端统一登录入口 accountLoginService.resolveWebHomePath 保持一致:
|
||||
// 超管落地「系统设置」,而非数据看板 —— /dashboard 的路由守卫只放行 admin(roles: ['admin']),
|
||||
// 超管的 roles 只有 'super_admin'(不会被补成 admin),落过去会命中 App.tsx 的
|
||||
// 「无权限 → 跳回默认首页」而自环。超管现有权限为 system_manage / branch_manage / data_import_export。
|
||||
if (hasRole('super_admin')) return '/system/config';
|
||||
if (hasRole('admin')) return '/dashboard';
|
||||
if (hasRole('purchaser')) return '/purchaser/dashboard';
|
||||
if (hasPermission('order_entry')) return '/customer-order';
|
||||
if (hasPermission('order_manage')) return '/orders';
|
||||
if (hasPermission('customer_manage')) return '/customers';
|
||||
if (hasPermission('supplier_manage')) return '/suppliers';
|
||||
if (hasPermission('preparation_manage')) return '/purchase/preparations';
|
||||
if (hasPermission('purchase_manage')) return '/purchase';
|
||||
if (hasPermission('picking_manage')) return '/picking';
|
||||
if (hasPermission('inventory_manage')) return '/inventory';
|
||||
if (hasPermission('delivery_manage')) return '/delivery';
|
||||
if (hasPermission('finance_manage')) return '/finance';
|
||||
if (hasPermission('inspection_manage')) return '/inspection';
|
||||
if (hasPermission('processing_manage')) return '/inspection/processing';
|
||||
if (hasPermission(['system_manage', 'user_manage', 'role_manage', 'log_view'])) return '/system/config';
|
||||
// 兜底必须是「不需要任何权限就能进」的页面。
|
||||
// 原为 '/customer-order',但该路由守卫要求 order_entry,
|
||||
// 无角色/无权限的账号落过去会被 App.tsx「无权限 → 回默认首页」打回这里 → 自环。
|
||||
// 见 src/pages/auth/NoAccess.tsx 顶部说明。
|
||||
return '/no-access';
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
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');
|
||||
});
|
||||
});
|
||||
@@ -69,7 +69,6 @@ const MASTER_DATA_CANONICAL_ITEMS: NavSecondaryItemConfig[] = [
|
||||
{ menuKey: 'suppliers-list', visible: true },
|
||||
{ menuKey: 'orders-bids', visible: false },
|
||||
{ menuKey: 'inventory', label: '仓库管理', visible: true },
|
||||
{ menuKey: 'market-monitor', label: '市场价格监控', visible: true },
|
||||
{ menuKey: 'product-trace', visible: true },
|
||||
{ menuKey: 'quality-reports', visible: true },
|
||||
{ menuKey: 'products-units', visible: true },
|
||||
|
||||
Reference in New Issue
Block a user