- 分公司类型模板:超管配置隐藏路由/菜单 + 中文文案覆盖,仅对挂类型的分公司生效(后端 service/routes、前端 Provider/守卫/配置页) - 超管模板 iframe 真还原预览:28 个业务页注册、白名单点选编辑、空/示例数据 fixture、白名单漂移检测工具 - 商品/SKU 下拉远程搜索:服务端关键词搜索 + 前端 useRemoteOptionSearch/SearchableSelect 接入(订单/采购/商品等页) - 主系统联调:子系统主动解绑主系统授权(幂等重试/本地兜底)、追加修改 price_amend 视图代理与 amend-price 转发 - 修复:仓内加工重复建单幂等(已完成需求单 guard、order 任务一商品一单 guard) - 修复:出入库记录只取前 100 条 → 服务端分页 + 真实总数 - 其它:库存/订单若干修复、分公司管理响应式布局、i18n 文案、设计文档与回归测试
40 lines
1.8 KiB
TypeScript
40 lines
1.8 KiB
TypeScript
import { useMemo } from 'react';
|
|
import { useLocation } from 'react-router-dom';
|
|
import { MENU_CATALOG_MAP, resolveMenuKeyFromPath } from '../config/menuCatalog';
|
|
import { useI18n } from '../i18n/I18nProvider';
|
|
import {
|
|
getRuntimeOverrideForLocale,
|
|
useRuntimeOverridesVersion,
|
|
} from '../i18n/runtimeOverrides';
|
|
import { resolveNavCustomLabel } from '../utils/menuLayout';
|
|
import { useMenuLayout } from './useMenuLayout';
|
|
|
|
/**
|
|
* 模块显示名称(页面 H1 标题通道,设计 §9.2 第 4 条接线)。
|
|
*
|
|
* 优先级(F4 收敛到这里,Dashboard / CustomerOrder 等直接调用方自动生效):
|
|
* ① 分公司「导航菜单」自定义名;
|
|
* ② 运行时文字覆盖 `menu.<menuKey>`(仅 zh-CN 生效);
|
|
* ③ 调用方传入 fallback(页面专属 i18n 文案);
|
|
* ④ MENU_CATALOG.defaultLabel。
|
|
*/
|
|
export function useMenuItemLabel(menuKey?: string, fallback?: string): string {
|
|
const { layout } = useMenuLayout();
|
|
const location = useLocation();
|
|
const { locale } = useI18n();
|
|
// 覆盖注册表变化(Provider 拉到 effective 后写入)时触发重渲染
|
|
const overridesVersion = useRuntimeOverridesVersion();
|
|
|
|
return useMemo(() => {
|
|
const key = menuKey || resolveMenuKeyFromPath(location.pathname);
|
|
if (!key) return fallback || '';
|
|
const custom = resolveNavCustomLabel(layout, key);
|
|
if (custom) return custom;
|
|
const override = getRuntimeOverrideForLocale(`menu.${key}`, locale);
|
|
if (override !== undefined) return override;
|
|
return fallback || MENU_CATALOG_MAP[key]?.defaultLabel || key;
|
|
// overridesVersion 只作缓存失效信号(覆盖值来自模块级注册表)
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
}, [layout, menuKey, fallback, location.pathname, locale, overridesVersion]);
|
|
}
|