Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
ujia
/
uj-store
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 57cfc0b6
authored
Oct 10, 2026
by
chenwq
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'v1.0.0' of
http://192.168.3.233:8090/ujia/uj-store
into v1.0.0
2 parents
a19d084f
ff7a4012
Pipeline
#322
for
57cfc0b6
failed
in 0 seconds
Changes
12
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
363 additions
and
146 deletions
.workbuddy/memory/2026-10-10.md
.workbuddy/memory/MEMORY.md
src/access/backend/adapter.ts
src/api/core/http.ts
src/config/menu.json
src/layouts/BasicLayout.tsx
src/main.tsx
src/pages/Dashboard/index.tsx
src/pages/Login/components/LoginForm.tsx
src/store/useAppStore.ts
src/theme/design.css
src/theme/themeConfig.ts
.workbuddy/memory/2026-10-10.md
View file @
57cfc0b
...
@@ -62,3 +62,82 @@
...
@@ -62,3 +62,82 @@
-
`P.STORE_APPROVE_AUDIT`
/
`P.STORE_LISTING_DELETE`
仍挂后端不存在的动作码(见上一节)。
-
`P.STORE_APPROVE_AUDIT`
/
`P.STORE_LISTING_DELETE`
仍挂后端不存在的动作码(见上一节)。
-
**环境限制(非代码问题)**
:
`node_modules`
缺
`vitest`
/
`@testing-library/react`
/
`lossless-json`
(
`package.json`
均已声明)。沙箱内 pnpm 因 shell 缺
`sed/dirname/uname`
跑不起来,需超人在
**本机终端**
执行
`pnpm install`
。缺依赖会导致 39 条
`TS2307`
+ 连带
`TS7006/TS7031 implicit any`
报错。
-
**环境限制(非代码问题)**
:
`node_modules`
缺
`vitest`
/
`@testing-library/react`
/
`lossless-json`
(
`package.json`
均已声明)。沙箱内 pnpm 因 shell 缺
`sed/dirname/uname`
跑不起来,需超人在
**本机终端**
执行
`pnpm install`
。缺依赖会导致 39 条
`TS2307`
+ 连带
`TS7006/TS7031 implicit any`
报错。
-
最终状态:
**真实类型错误 0 条**
,剩余全部为缺依赖所致。
-
最终状态:
**真实类型错误 0 条**
,剩余全部为缺依赖所致。
## 工作台品牌欢迎条重设计(Dashboard hero,配色改浅)
-
目标位置:
`src/pages/Dashboard/index.tsx:94-129`
(品牌欢迎条)。用户反馈"颜色太深太压抑"。
-
**根因**
:该条用了
`themeConfig.ts`
的
`brandGradient = linear-gradient(160deg, #0B1437 0%, #16245A 100%)`
(近黑深藏青大面积铺底)+ 白字强对比 + 重阴影
`0 18px 40px -22px rgba(11,20,55,.7)`
。
-
**改造方向**
:深色整铺 →
**浅色卡片 + 品牌色点睛**
(与 Profile hero 的浅色语言统一)。
-
底色:
`linear-gradient(120deg, #ffffff 0%, #f5f7ff 100%)`
;阴影改为
`0 2px 10px rgba(16,24,64,.04)`
;加
`1px solid rgba(43,92,230,.1)`
边框。
-
品牌感改由
**小面积**
承载:左侧 16px 品牌渐变方块
`.uj-dash-hero-mark`
(原
`RiseOutlined`
图标移除)+ 右上角
`::after`
品牌色 radial 柔光(10% 透明度)。
-
文字由白改为深色:品牌小标
`#2B5CE6`
、标题
`#1D2533`
24px/700、副标题
`#6B7688`
。
-
右侧账号/角色信息由纯文本改为浅蓝芯片
`.uj-dash-meta-item`
(
`rgba(43,92,230,.05)`
底 + 边框)。
-
新增响应式:<1100px 时 hero 纵向堆叠。
-
**清理**
:
`Dashboard`
移除
`RiseOutlined`
、
`brandGradient`
两处失效导入;删除死 CSS
`.uj-dash-hero-actions`
(含
`.ant-btn-ghost`
规则,原 JSX 里从未渲染按钮)。
-
`themeConfig.ts`
:
`brandDeep`
/
`brandGradient`
现已
**无任何代码引用**
(Sider 由
`.uj-sider`
CSS 承接、Dashboard 改浅色、LoginAside 用的是 #2B5CE6/#5B8DEF)。保留常量作品牌资产,注释已标注"暂未引用"。
-
**顺带修复**
:
`BasicLayout.tsx`
清理 4 个未使用导入(
`Badge`
、
`Tooltip`
、
`BellOutlined`
、
`QuestionCircleOutlined`
),其中 BellOutlined 是上次侧边栏重设计时引入的。
-
依赖已在本机装齐(vitest / @testing-library/react / lossless-json),此前 39 条缺依赖报错消失。
-
**全仓库 `tsc --noEmit` EXIT=0,零错误**
。
## 修复「登录后刷新即退出」:两套登录态持久化未打通
-
**根因(硬事实)**
:
`src/access/session.ts`
的
`saveLoginSession()`
**全代码库零调用方**
。登录流程
`LoginForm.doLogin`
只做了两步持久化:
1.
`setToken(res.token)`
→ 写 localStorage
**`uj_token`**
(http 拦截器从这里读 Authorization)
2.
`login({name, account})`
→ 仅改 zustand
**内存**
,
`loggedIn = true`
—
**没有写 localStorage 的 `session` 键**
。
-
而
`useAppStore.ts:13`
是模块顶层
`const savedSession = getLoginSession()`
(读
`session`
键),
`loggedIn: Boolean(savedSession)`
;
`router/index.tsx`
的
`RequireAuth`
订阅该 loggedIn。于是刷新后
`session`
不存在 →
`loggedIn=false`
→
`<Navigate to="/login" replace />`
直接踢回登录页。
-
**两套存储各管一半的现状**
(改前):http 拦截器/AccessProvider 用
`uj_token`
;路由守卫/用户资料/dataScope 用
`session`
。二者必须同时维护。
-
**本次修复**
:
1.
`LoginForm.tsx`
:登录后补
`saveLoginSession({...})`
,把 token/tokenType/expireAt/userId/account/name/orgId/dataScope/roleCodes/permCodes 完整落盘。这是刷新恢复登录态的
**唯一依据**
,同时让
`StoreApprove:250`
、
`StoreListing:156`
的 dataScope、
`Profile`
/
`Dashboard`
的 account 刷新后仍能读到(此前均为空)。
2.
`useAppStore.logout()`
:补
`clearToken()`
。原先只
`clearLoginSession()`
不清令牌 → 登出后
`uj_token`
残留,刷新仍能拉到用户信息。
3.
`http.ts`
:401 分支原只
`clearToken()`
→ 会话残留会造成「能停在内页但所有接口 401」的半吊子状态。改为依赖倒置:新增
`setUnauthorizedHandler(fn)`
注册回调(http 属基础设施层,不反向依赖 store/router),401 时
`clearToken()`
+ 回调;由
`main.tsx`
注册指向
`useAppStore.getState().logout()`
(双清 + loggedIn=false → RequireAuth 自动重定向,无需手动 navigate)。注册必须在
`initSign()`
之前。
-
**注意**
:
`saveLoginSession`
的过期判定在
`session.ts:30`
——
`new Date(expireAt).getTime() <= Date.now()`
。若后端返回秒级时间戳会被判为 1970 年立即过期。自查方法:登录后控制台看
`JSON.parse(localStorage.session).expireAt`
与
`Date.now()`
对比。
-
类型检查
`tsc --noEmit`
EXIT=0。
## 菜单分组支持隐藏标题(hideTitle),工作台不再显示 group title
-
需求:左侧菜单「工作台」分组不想显示
`ant-menu-item-group-title`
。
-
**做法,不用 CSS 隐藏**
:CSS 隐藏会留下
`.ant-menu-item-group-title`
的一行空白占位(它有
`padding-block: 12px 6px`
)。改为在生成 items 时让该分组
**不生成 `type:'group'` 节点**
,children 直接平铺到当前层级,DOM 里真没有标题节点。
-
改动:
-
`adapter.ts`
`MenuGroupDef`
新增可选字段
`hideTitle?: boolean`
(通用能力,非工作台专用硬编码)。后端树不下发该字段,仅前端固定组与兜底 menu.json 标注。
-
`BasicLayout.tsx`
:
`FRONTEND_ONLY_GROUPS`
工作台加
`hideTitle: true`
;items 由
`groups.map`
改为
`groups.flatMap<MenuItemType>`
(泛型必须显式,否则 TS 把返回值推成
`(A[]|B[])[]`
,不兼容
`flatMap`
期望的
`U | readonly U[]`
,报 TS2345)。
-
新增类型别名
`type MenuItemType = NonNullable<MenuProps['items']>[number]`
。
-
`design.css`
:平铺项加
`.uj-menu-item-flat`
(
`margin-block:4px`
;
`:first-child`
再
`margin-top:10px`
),补回失去的标题占位,避免紧贴滚动区顶部/与下方分组挤在一起。
-
`menu.json`
兜底组「工作台」同步加
`hideTitle: true`
,保证接口失败回落时视觉一致。
-
**踩坑(自己的错)**
:Edit 时 old_string 锚点写错,误删了
`import type { MenuProps } from 'antd'`
与
`const { Header, Sider, Content } = Layout`
,已读回恢复。
**教训:改 import 区时 old_string 必须带上足够上下文,且先 Read 确认再改。**
-
**遗留 4 条 TS6133(非本次改动引入,是超人在对话之间改代码留下的孤儿)**
:
`BasicLayout`
的
`Input`
、
`SearchOutlined`
(header 搜索框 JSX 被删后残留);
`StoreApprove:251 dataScope`
、
`StoreListing:157 scopeLabel`
(算出来没渲染)。清理
`dataScope/scopeLabel`
会连锁让
`scope`
及
`getLoginSession/getUserInfo/getDataScopeLabel`
导入也变未使用,需迭代清理。已告知超人,待其决定是否清。
## 【架构约定】antd 组件定制只走 ConfigProvider token,禁止 CSS 覆盖组件内部盒模型
-
超人拍板:
**antd Menu 除主题色外,所有布局相关样式(宽高/内外边距/定位/显示模式)一律沿用组件自身,不用自定义 CSS 覆盖**
。
-
**技术根因(antd 6.6.5 源码实证)**
:
-
`node_modules/antd/es/menu/style/vertical.js`
给 item 设了
`height/lineHeight/paddingInline/marginInline/marginBlock/width`
(width 来自
`itemWidth`
token)。
-
折叠态
`&-inline-collapsed`
用直接子代选择器覆盖
`> .ant-menu-item`
与
`> .ant-menu-item-group > .ant-menu-item-group-list > .ant-menu-item`
,设
`display:flex; justifyContent:flex-start; paddingInline: calc(50% - collapsedIconSize/2 - itemMarginInline)`
。
-
结论:
**布局几何必须由 token 给**
。我们此前写的
`width:auto !important`
+
`padding-inline:18px !important`
+
`justify-content:center`
正好把这三条原生计算全部覆盖掉,折叠态图标居中失衡就是这么来的(一个偏窄的盒子里做 center → 视觉偏左)。
-
**token 清单(`components.Menu`,全部经 tsc 校验可用)**
:
`darkItemBg/darkSubMenuItemBg/darkItemColor/darkItemHoverBg/darkItemHoverColor/darkItemSelectedBg/darkItemSelectedColor/darkGroupTitleColor/darkPopupBg/itemHeight/itemMarginInline/itemPaddingInline/itemMarginBlock/itemBorderRadius/collapsedWidth/collapsedIconSize/iconSize/iconMarginInlineEnd/groupTitleFontSize/groupTitleLineHeight/groupTitleColor/subMenuItemBorderRadius/horizontalItemBorderRadius`
。
-
**本次落地**
:
-
`design.css`
菜单区块从 ~110 行压到 ~28 行,
**只保留**
:根
`background:transparent`
、分组标题三项无 token 的字形(font-weight/letter-spacing/text-transform)、选中态
`inset`
阴影指示条、折叠态隐藏分组标题(唯一非颜色覆盖,已注明可删)。
-
删除的几何覆盖:
`.ant-menu-item-group-list{display:flex}`
、
`.ant-menu-item{position/width/padding-inline/color/transition}`
、
`.ant-menu-item-icon{font-size}`
、整套
`::before`
伪元素画胶囊机制与
`overflow:visible !important`
、
`.uj-menu-item-flat`
全部平移/折叠校准规则、
`.ant-menu-inline-collapsed{width:100%}`
。
-
删除
`.uj-sider`
上失效的
`--uj-menu-inset`
/
`--uj-menu-radius`
自定义变量。
-
`themeConfig.ts`
Menu token 补齐上述颜色与几何;
`collapsedWidth: 68`
**必须与 `<Sider collapsedWidth={68}>` 一致**
(Menu 折叠态有自己的 collapsedWidth,默认 80,不等会溢出或留缝)。
-
`BasicLayout.tsx`
移除已无 CSS 消费的
`className: 'uj-menu-item-flat'`
。
-
**踩坑备忘**
:
`.ant-menu-item`
有 antd 原生
`overflow:hidden`
。做左侧指示条用
`inset box-shadow`
(不占盒模型、不变宽高),不要用
`border-inline-start`
(会改宽度从而破坏折叠居中计算)。
-
类型检查:本次改动零错;仓库仍剩上述 4 条历史 TS6133(非本次引入)。
## 菜单图标:后端 icon 字段取值约定 + 未知图标名告警
-
**机制**
:后端
`/system/menu/tree/current`
的
`icon`
是
**antd 图标名的字符串**
(PascalCase,如
`ShopOutlined`
),前端在
`BasicLayout.tsx`
的
`iconMap`
查表换成 React 节点;查不到或为
`null`
时回落
`DEFAULT_MENU_ICON = <AppstoreOutlined />`
。这就是「所有菜单都是同一个默认图标」的原因(后端 icon 全为 null)。
-
**当前 iconMap 只登记 6 个**
:
`DashboardOutlined`
(仅前端固定工作台用)/
`ShopOutlined`
/
`UploadOutlined`
/
`AuditOutlined`
/
`TeamOutlined`
/
`UserOutlined`
。
-
**后端应下发的值(照抄 menu.json 兜底菜单即可)**
:
| route | 菜单 | icon |
| --------------- | ------------ | ---------------- |
| /store/import | 导入门店信息 |
`UploadOutlined`
|
| /store/approval | 门店审批 |
`AuditOutlined`
|
| /store/listing | 门店列表 |
`ShopOutlined`
|
| /system/role | 角色管理 |
`TeamOutlined`
|
| /system/user | 账号管理 |
`UserOutlined`
|
-
分组节点(nodeType=1)不渲染图标,
`icon`
返回 null 即可;按钮点(nodeType=3)不进菜单,无需配。
-
/dashboard 由前端
`FRONTEND_ONLY_GROUPS`
固定,后端不需要下发。
-
**本次改动**
:
`BasicLayout.tsx`
新增
`resolveIcon(name)`
,未知图标名在
**开发环境告警一次**
(用
`warnedIcons: Set<string>`
去重,避免每项刷屏),取代原先
`(m.icon && iconMap[m.icon]) || DEFAULT_MENU_ICON`
的静默回落;
`import.meta.env.DEV`
可用(
`src/vite-env.d.ts`
已 reference
`vite/client`
)。
-
注意
`tsconfig.json`
开了
`noUnusedLocals`
/
`noUnusedParameters`
—— 未使用的局部变量与参数会直接报 TS6133。
-
类型检查:本次改动零错;仓库仍剩上述 4 条历史 TS6133。
.workbuddy/memory/MEMORY.md
0 → 100644
View file @
57cfc0b
# uj-store 长期项目约定
## UI 定制原则:antd 组件只用 ConfigProvider token,不用 CSS 覆盖组件内部盒模型
超人 2026-10-10 拍板,适用于全项目所有 antd 组件(先在 Menu 上执行):
-
**允许**
:主题色、透明度、字号/字重/字距/大小写这类
**不影响布局**
的属性,可写在
`src/theme/design.css`
。
-
**禁止**
:覆盖组件内部节点的
`width / height / padding / margin / display / position / justify-content`
等几何属性。
-
**正解**
:几何一律从
`src/theme/themeConfig.ts`
的
`components.<Comp>`
token 下发。token 是 antd 官方认可的定制入口,组件内部的宽度与居中计算会跟着 token 重算,不会互相打架。
**为什么这条不是洁癖而是硬约束**
(antd 6.6.5 源码实证):
-
`antd/es/menu/style/vertical.js`
给 item 设了完整的
`height / lineHeight / paddingInline / marginInline / marginBlock / width`
(均来自 token)。
-
折叠态
`&-inline-collapsed`
用直接子代选择器重写
`> .ant-menu-item`
及
`> .ant-menu-item-group > .ant-menu-item-group-list > .ant-menu-item`
,设
`paddingInline: calc(50% - collapsedIconSize/2 - itemMarginInline)`
、
`justifyContent: flex-start`
。
-
一旦用 CSS 把
`width`
/
`padding-inline`
改成自己的值,这条 calc 就失准,表现为折叠态图标不居中(视觉偏左)。历史上为此连续迭代 4 版 CSS 方案均未解决,改回 token 后一次到位。
**配套注意**
:
-
`Menu.collapsedWidth`
必须与
`<Sider collapsedWidth>`
保持一致(Menu 折叠态有自己的 collapsedWidth,默认 80)。
-
做选中态左侧指示条用
`inset box-shadow`
(不占盒模型),不要用
`border-inline-start`
(会改宽度,破坏上面的居中计算)。antd item 原生是
`overflow: hidden`
。
-
antd 折叠态
**不隐藏**
`ant-menu-item-group-title`
(只做 text-overflow 省略)。若要隐藏,这是目前唯一保留的非颜色 CSS 覆盖,已在 design.css 注释里标注可删。
## 技术栈与环境
-
React + Vite + TypeScript + antd 6 + zustand + React Router 7(数据路由)。
-
自定义组件库
`@uj/ui`
(前缀
`U*`
,workspace package),多数是 antd 薄封装,通常
**没有**
自己的 Props 类型导出(如无
`UTableProps`
,用 antd 的
`TableProps`
)。
-
tsc 校验命令(沙箱内 shell 缺
`sed/dirname/uname`
,npm/pnpm CLI 起不来,必须这样跑):
`C:\Users\Limin\.workbuddy\binaries\node\versions\22.22.2-3\node.exe ./node_modules/typescript/bin/tsc --noEmit > d:/work/uj-store/_tsc.log 2>&1`
临时日志统一用托管 node 的
`fs.unlinkSync`
删(
`rm`
会被 shell shim 挡住)。
## 权限模型
-
后端真源:
`/system/menu/tree/current`
下发按角色装配的菜单树(含
`route`
/
`icon`
);
`auth.info()`
下发
`permCodes`
(冒号格式)。
-
前端
**不做任何权限码映射**
:
`toFrontendPoint`
是 identity。所有
`ResourceKey`
(
`store:list`
/
`store:import`
/
`store:approve`
/
`system:role`
/
`system:user`
)、
`P.*`
常量、
`menu.json`
resource 均为后端冒号格式。
-
权限按钮 JSX 一律按
`P.*`
常量名引用,改值即生效,组件层不用动。
-
判定两条路径:页面级
`can(resource)`
有三段兜底(
`points.has(resource)`
→
`:manage`
→
`startsWith(resource + ':')`
);按钮级
`canPoint(point)`
严格
`points.has()`
,
**无兜底**
,必须与后端码逐字符一致。
## 登录态持久化(两套存储,必须同时维护)
-
`uj_token`
(localStorage):http 拦截器取 Authorization 的来源。
-
`session`
:路由守卫
`RequireAuth`
读
`useAppStore.loggedIn`
的依据,同时承载 name/account/dataScope/roleCodes/permCodes。
-
写入方在
`LoginForm.doLogin`
:必须
**同时**
`setToken()`
和
`saveLoginSession()`
。登出必须
**同时**
`clearToken()`
和
`clearLoginSession()`
。
-
401 通过
`setUnauthorizedHandler()`
回调统一登出,http 层不反向依赖 store。
## 未决事项
-
`P.STORE_APPROVE_AUDIT`
/
`P.STORE_LISTING_DELETE`
挂了后端不存在的动作码(后端审批只有
`pass`
/
`reject`
,列表只有
`export`
),按钮当前隐藏,等超人指定挂哪个权限点。
-
`store.test.ts:191`
断言
`templateVersion === 'V1.0.1'`
,但
`store.ts`
的
`uploadImport`
不 append 该字段 —— 断言必失败,等超人决定改实现还是删断言。
-
4 条历史 TS6133 孤儿(
`BasicLayout`
的
`Input`
/
`SearchOutlined`
,
`StoreApprove`
的
`dataScope`
,
`StoreListing`
的
`scopeLabel`
),超人未决定是否清理。
-
`themeConfig.ts`
的
`brandDeep`
/
`brandGradient`
已无引用,保留作品牌资产备查。
src/access/backend/adapter.ts
View file @
57cfc0b
...
@@ -32,6 +32,12 @@ export interface MenuItemDef {
...
@@ -32,6 +32,12 @@ export interface MenuItemDef {
export
interface
MenuGroupDef
{
export
interface
MenuGroupDef
{
group
:
string
;
group
:
string
;
children
:
MenuItemDef
[];
children
:
MenuItemDef
[];
/**
* true:不渲染分组标题,children 直接平铺为该层级的菜单项。
* 用于「工作台」这类只有一个入口的分组——挂一个独占一行的标题纯属噪音。
* 后端菜单树不会下发该字段,仅由前端固定组与兜底 menu.json 标注意图。
*/
hideTitle
?:
boolean
;
}
}
/**
/**
...
...
src/api/core/http.ts
View file @
57cfc0b
...
@@ -121,6 +121,18 @@ http.interceptors.request.use((config: any) => {
...
@@ -121,6 +121,18 @@ http.interceptors.request.use((config: any) => {
return
config
;
return
config
;
});
});
// ---------- 令牌失效(401)的上层处理回调 ----------
// http 属于基础设施层,不应反向依赖 store / 路由。
// 采用回调注册:由 main.tsx 在启动时注入统一的登出入口。
// 未注册时退化为「仅清除令牌」,不会崩,但也无法触发跳转。
type
UnauthorizedHandler
=
()
=>
void
;
let
_unauthorizedHandler
:
UnauthorizedHandler
|
null
=
null
;
/** 注册令牌失效的统一处理(应指向 store 的 logout) */
export
function
setUnauthorizedHandler
(
fn
:
UnauthorizedHandler
)
{
_unauthorizedHandler
=
fn
;
}
// ---------- 响应拦截:服务端验签 + 统一错误 ----------
// ---------- 响应拦截:服务端验签 + 统一错误 ----------
// 生产置 VITE_STRICT_VERIFY=true:响应声明签名却无法校验时直接拒绝;
// 生产置 VITE_STRICT_VERIFY=true:响应声明签名却无法校验时直接拒绝;
// 开发默认放行(仅告警),避免因公钥未加载/后端未对全部响应加签而阻断业务。
// 开发默认放行(仅告警),避免因公钥未加载/后端未对全部响应加签而阻断业务。
...
@@ -171,8 +183,13 @@ http.interceptors.response.use(
...
@@ -171,8 +183,13 @@ http.interceptors.response.use(
const
body
=
raw
?
JSON
.
parse
(
raw
)
:
null
;
const
body
=
raw
?
JSON
.
parse
(
raw
)
:
null
;
if
(
body
&&
typeof
body
===
'object'
&&
'code'
in
body
&&
body
.
code
!==
200
)
{
if
(
body
&&
typeof
body
===
'object'
&&
'code'
in
body
&&
body
.
code
!==
200
)
{
// 令牌失效/未登录:清除本地令牌,交由调用方引导重新登录
// 令牌失效/未登录:先自清除令牌,保证后续请求不再携带已失效凭据;
if
(
body
.
code
===
401
)
clearToken
();
// 再通知上层统一登出——必须同时清掉会话 session 并把 loggedIn 置 false,
// 否则会出现「能停在页面上但所有接口都 401」的半吊子状态。
if
(
body
.
code
===
401
)
{
clearToken
();
_unauthorizedHandler
?.();
}
const
err
:
any
=
new
Error
(
body
.
message
||
'请求失败'
);
const
err
:
any
=
new
Error
(
body
.
message
||
'请求失败'
);
err
.
code
=
body
.
code
;
err
.
code
=
body
.
code
;
err
.
data
=
'data'
in
body
?
body
.
data
:
undefined
;
err
.
data
=
'data'
in
body
?
body
.
data
:
undefined
;
...
...
src/config/menu.json
View file @
57cfc0b
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
"menus"
:
[
"menus"
:
[
{
{
"group"
:
"工作台"
,
"group"
:
"工作台"
,
"hideTitle"
:
true
,
"children"
:
[
"children"
:
[
{
{
"path"
:
"/dashboard"
,
"path"
:
"/dashboard"
,
...
...
src/layouts/BasicLayout.tsx
View file @
57cfc0b
import { Layout, Menu, Avatar, Dropdown,
Badge, Tooltip,
Input, Button, Breadcrumb } from 'antd';
import { Layout, Menu, Avatar, Dropdown, Input, Button, Breadcrumb } from 'antd';
import { Suspense, useEffect, useState } from 'react';
import { Suspense, useEffect, useState } from 'react';
import { Outlet, useLocation, useNavigate } from 'react-router-dom';
import { Outlet, useLocation, useNavigate } from 'react-router-dom';
import {
import {
...
@@ -11,10 +11,8 @@ import {
...
@@ -11,10 +11,8 @@ import {
TeamOutlined,
TeamOutlined,
AuditOutlined,
AuditOutlined,
AppstoreOutlined,
AppstoreOutlined,
BellOutlined,
MenuFoldOutlined,
MenuFoldOutlined,
MenuUnfoldOutlined,
MenuUnfoldOutlined,
QuestionCircleOutlined,
} from '@ant-design/icons';
} from '@ant-design/icons';
import { useAccess, buildMenus, type MenuGroupDef } from '@/access';
import { useAccess, buildMenus, type MenuGroupDef } from '@/access';
import { useAppStore } from '@/store/useAppStore';
import { useAppStore } from '@/store/useAppStore';
...
@@ -27,6 +25,9 @@ import type { MenuProps } from 'antd';
...
@@ -27,6 +25,9 @@ import type { MenuProps } from 'antd';
const { Header, Sider, Content } = Layout;
const { Header, Sider, Content } = Layout;
/** antd Menu 的单条目类型:MenuProps['items'] 联合里的成员(普通项 / 分组 / 分割线…) */
type MenuItemType = NonNullable<MenuProps['items']>[number];
/* ---------- 菜单数据:以后端 /system/menu/tree/current 为准,menu.json 仅作接口未就绪时的兜底 ---------- */
/* ---------- 菜单数据:以后端 /system/menu/tree/current 为准,menu.json 仅作接口未就绪时的兜底 ---------- */
// 前端专属菜单:后端菜单树不下发「工作台」(它是所有角色的落地页,不该被权限挡),
// 前端专属菜单:后端菜单树不下发「工作台」(它是所有角色的落地页,不该被权限挡),
...
@@ -35,6 +36,8 @@ const { Header, Sider, Content } = Layout;
...
@@ -35,6 +36,8 @@ const { Header, Sider, Content } = Layout;
const FRONTEND_ONLY_GROUPS: MenuGroupDef[] = [
const FRONTEND_ONLY_GROUPS: MenuGroupDef[] = [
{
{
group: '工作台',
group: '工作台',
// 无标题组:菜单项平铺到顶层,不挂「工作台」标题
hideTitle: true,
children: [
children: [
{ path: '/dashboard', label: '工作台', icon: 'DashboardOutlined', resource: 'dashboard' },
{ path: '/dashboard', label: '工作台', icon: 'DashboardOutlined', resource: 'dashboard' },
],
],
...
@@ -55,9 +58,26 @@ const iconMap: Record<string, React.ReactNode> = {
...
@@ -55,9 +58,26 @@ const iconMap: Record<string, React.ReactNode> = {
AuditOutlined: <AuditOutlined />,
AuditOutlined: <AuditOutlined />,
UserOutlined: <UserOutlined />,
UserOutlined: <UserOutlined />,
};
};
/** 后端未下发图标(icon 为 null)时的兜底图标 */
/** 后端未下发图标(icon 为 null)
或图标名未登记
时的兜底图标 */
const DEFAULT_MENU_ICON: React.ReactNode = <AppstoreOutlined />;
const DEFAULT_MENU_ICON: React.ReactNode = <AppstoreOutlined />;
// 后端下发的 icon 是「antd 图标名字符串」,这里查表换成 React 节点。
// 未登记的图标名会静默回落默认图标 —— 这正是之前「菜单全是同一个图标」排查起来很痛苦的原因,
// 故开发环境对未知图标名告警一次(同名只报一次,避免菜单每项刷屏)。
const warnedIcons = new Set<string>();
function resolveIcon(name: string | null | undefined): React.ReactNode {
const hit = name ? iconMap[name] : undefined;
if (hit) return hit;
if (name && import.meta.env.DEV && !warnedIcons.has(name)) {
warnedIcons.add(name);
console.warn(
`[menu] 图标「${name}」未在 src/layouts/BasicLayout.tsx 的 iconMap 中登记,已回落默认图标。` +
`请在 iconMap 补一行,或让后端改发已支持的值。`,
);
}
return DEFAULT_MENU_ICON;
}
// 兜底菜单:接口失败/尚未返回时使用(与 src/config/menu.json 对应)
// 兜底菜单:接口失败/尚未返回时使用(与 src/config/menu.json 对应)
const fallbackGroups: MenuGroupDef[] = (() => {
const fallbackGroups: MenuGroupDef[] = (() => {
const raw = (menuJson as { menus?: unknown }).menus;
const raw = (menuJson as { menus?: unknown }).menus;
...
@@ -98,17 +118,18 @@ export default function BasicLayout() {
...
@@ -98,17 +118,18 @@ export default function BasicLayout() {
: fallbackGroups;
: fallbackGroups;
// -> antd Menu items(后端树已在 buildMenus 内与 permCodes 取过交集;兜底菜单按权限过滤)
// -> antd Menu items(后端树已在 buildMenus 内与 permCodes 取过交集;兜底菜单按权限过滤)
const items: MenuProps['items'] = groups.map((g) => ({
// hideTitle 的分组不生成 type:'group',改由 children 平铺到当前层级——
type: 'group' as const,
// 这样是真没有标题节点,而不是用 CSS 把标题藏起来(藏起来会留下一行空白占位)。
label: g.group,
const items: MenuItemType[] = groups.flatMap<MenuItemType>((g) => {
c
hildren:
g.children
c
onst children =
g.children
.filter((m) => !m.resource || can(m.resource))
.filter((m) => !m.resource || can(m.resource))
.map((m) => ({
.map((m) => ({
key: m.path,
key: m.path,
icon:
(m.icon && iconMap[m.icon]) || DEFAULT_MENU_ICON
,
icon:
resolveIcon(m.icon)
,
label: m.label,
label: m.label,
})),
}));
}));
return g.hideTitle ? children : [{ type: 'group' as const, label: g.group, children }];
});
const flat = groups.flatMap((g) => g.children);
const flat = groups.flatMap((g) => g.children);
// 非菜单页面(如 /profile)不匹配任何菜单项:菜单不高亮,页题走 EXTRA_TITLES。
// 非菜单页面(如 /profile)不匹配任何菜单项:菜单不高亮,页题走 EXTRA_TITLES。
...
@@ -206,13 +227,13 @@ export default function BasicLayout() {
...
@@ -206,13 +227,13 @@ export default function BasicLayout() {
{/* 中:全局搜索 */}
{/* 中:全局搜索 */}
<div className="uj-header-search">
<div className="uj-header-search">
<Input
{/*
<Input
prefix={<SearchOutlined style={{ color: '#8A94A6' }} />}
prefix={<SearchOutlined style={{ color: '#8A94A6' }} />}
placeholder="搜索门店 / 任务…"
placeholder="搜索门店 / 任务…"
variant="borderless"
variant="borderless"
allowClear
allowClear
/>
/>
<span className="uj-header-search-kbd">⌘K</span>
<span className="uj-header-search-kbd">⌘K</span>
*/}
</div>
</div>
{/* 右:通知 / 帮助 / 用户 */}
{/* 右:通知 / 帮助 / 用户 */}
...
...
src/main.tsx
View file @
57cfc0b
...
@@ -6,12 +6,18 @@ import { ConfigProvider, App as AntApp } from 'antd';
...
@@ -6,12 +6,18 @@ import { ConfigProvider, App as AntApp } from 'antd';
import zhCN from 'antd/locale/zh_CN';
import zhCN from 'antd/locale/zh_CN';
import { router } from '@/router';
import { router } from '@/router';
import { queryClient } from '@/queryClient';
import { queryClient } from '@/queryClient';
import { useAppStore } from '@/store/useAppStore';
import { themeConfig } from '@/theme/themeConfig';
import { themeConfig } from '@/theme/themeConfig';
import { AccessProvider } from '@/access';
import { AccessProvider } from '@/access';
import { initSign } from '@/api';
import { initSign
, setUnauthorizedHandler
} from '@/api';
import './index.css';
import './index.css';
import './theme/design.css';
import './theme/design.css';
// 令牌失效(401)的统一处理出口。必须在任何请求发出(含下面的 initSign)之前注册。
// logout 会双清 uj_token 与 session 并把 loggedIn 置 false;
// RequireAuth 订阅了 loggedIn,状态翻转即自动重定向到 /login,无需手动跳转。
setUnauthorizedHandler(() => useAppStore.getState().logout());
// 拉取服务端公钥用于响应验签(本环境公钥接口需签名鉴权);失败仅告警,
// 拉取服务端公钥用于响应验签(本环境公钥接口需签名鉴权);失败仅告警,
// 真正的阻断逻辑在各调用方(如登录)通过 ensureSignReady 自行判断。
// 真正的阻断逻辑在各调用方(如登录)通过 ensureSignReady 自行判断。
void initSign().catch(() => {});
void initSign().catch(() => {});
...
...
src/pages/Dashboard/index.tsx
View file @
57cfc0b
...
@@ -10,11 +10,9 @@ import {
...
@@ -10,11 +10,9 @@ import {
UserOutlined,
UserOutlined,
ArrowRightOutlined,
ArrowRightOutlined,
SafetyOutlined,
SafetyOutlined,
RiseOutlined,
} from '@ant-design/icons';
} from '@ant-design/icons';
import type { ReactNode } from 'react';
import type { ReactNode } from 'react';
import { UCard, UButton, UText } from '@uj/ui';
import { UCard, UButton, UText } from '@uj/ui';
import { brandGradient } from '@/theme/themeConfig';
import { useAppStore } from '@/store/useAppStore';
import { useAppStore } from '@/store/useAppStore';
import { useAccess, roleLabels, type ResourceKey } from '@/access';
import { useAccess, roleLabels, type ResourceKey } from '@/access';
...
@@ -91,39 +89,26 @@ export default function Dashboard() {
...
@@ -91,39 +89,26 @@ export default function Dashboard() {
return (
return (
<div className="uj-dash">
<div className="uj-dash">
{/* 品牌欢迎条 */}
{/* 品牌欢迎条:浅色卡片 + 品牌色点睛(不再大面积铺深色,避免压抑) */}
<div className="uj-dash-hero" style={{ background: brandGradient }}>
<div className="uj-dash-hero">
<div>
<div className="uj-dash-hero-id">
<div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
<div className="uj-dash-hero-brand">
<RiseOutlined style={{ color: '#5B8DEF', fontSize: 18 }} />
<span className="uj-dash-hero-mark" />
<span style={{ color: 'rgba(255,255,255,.55)', fontSize: 13, letterSpacing: 1 }}>
STORE LAUNCH PLATFORM
STORE LAUNCH PLATFORM
</span>
</div>
</div>
<h1
style={{ color: '#fff', fontSize: 26, fontWeight: 700, margin: '10px 0 6px' }}
>
<h1
className="uj-dash-hero-title"
>
{greeting()},{currentUser.name || '欢迎回来'}
{greeting()},{currentUser.name || '欢迎回来'}
</h1>
</h1>
<p style={{ color: 'rgba(255,255,255,.62)', fontSize: 13, margin: 0 }}>
<p className="uj-dash-hero-sub">{dateText} · 欢迎回到优加门店上架系统</p>
{dateText} · 欢迎回到优加门店上架系统
</p>
</div>
</div>
<div className="uj-dash-hero-actions">
<div className="uj-dash-hero-meta">
<div
<div className="uj-dash-meta-item">
style={{
<span className="uj-dash-meta-label">账号</span>
textAlign: 'right',
<span className="uj-dash-meta-value">{currentUser.account || '-'}</span>
color: 'rgba(255,255,255,.88)',
</div>
fontSize: 13,
<div className="uj-dash-meta-item">
lineHeight: 1.9,
<span className="uj-dash-meta-label">角色</span>
}}
<span className="uj-dash-meta-value">{roleText}</span>
>
<div>
<span style={{ opacity: 0.6 }}>账号 </span>
<span style={{ fontWeight: 600 }}>{currentUser.account || '-'}</span>
</div>
<div>
<span style={{ opacity: 0.6 }}>角色 </span>
<span style={{ fontWeight: 600 }}>{roleText}</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
...
...
src/pages/Login/components/LoginForm.tsx
View file @
57cfc0b
...
@@ -11,7 +11,7 @@ import { useNavigate } from 'react-router-dom';
...
@@ -11,7 +11,7 @@ import { useNavigate } from 'react-router-dom';
import { App } from 'antd';
import { App } from 'antd';
import { LockOutlined, UserOutlined } from '@ant-design/icons';
import { LockOutlined, UserOutlined } from '@ant-design/icons';
import { useAppStore } from '@/store/useAppStore';
import { useAppStore } from '@/store/useAppStore';
import { useAccess } from '@/access';
import { useAccess
, saveLoginSession
} from '@/access';
import { auth, menu as menuApi, ensureSignReady } from '@/api';
import { auth, menu as menuApi, ensureSignReady } from '@/api';
import { setToken } from '@/api/core/token';
import { setToken } from '@/api/core/token';
import { UButton, UForm, UFormItem, UInput, UTitle, UText } from '@uj/ui';
import { UButton, UForm, UFormItem, UInput, UTitle, UText } from '@uj/ui';
...
@@ -34,8 +34,25 @@ export function LoginForm() {
...
@@ -34,8 +34,25 @@ export function LoginForm() {
return;
return;
}
}
const res = await auth.login({ account, password });
const res = await auth.login({ account, password });
// 1) 持久化令牌(后续请求由 http 拦截器
自动
注入 Authorization)
// 1) 持久化令牌(后续请求由 http 拦截器
从 uj_token 读取并
注入 Authorization)
setToken(res.token);
setToken(res.token);
// 2) 持久化完整会话(localStorage 的 session)。
// 这是「刷新 / 重进」恢复登录态的唯一依据:useAppStore 的 loggedIn 初值由
// getLoginSession() 推导,RequireAuth 据此决定是否放行;路由守卫不看 uj_token。
// 缺这一步 → 刷新后 loggedIn=false,被直接踢回登录页。
// 同时承载 name/account/roleCodes/dataScope,供 StoreApprove、StoreListing 等页面刷新后仍可读。
saveLoginSession({
token: res.token,
tokenType: res.tokenType || 'Bearer',
expireAt: res.expireAt,
userId: res.userId,
account: res.account,
name: res.name,
orgId: res.orgId,
dataScope: res.dataScope,
roleCodes: res.roleCodes ?? [],
permCodes: res.permCodes ?? [],
});
// 菜单树与用户信息都按角色/账号下发:登录即视为账号切换点,旧缓存必须作废
// 菜单树与用户信息都按角色/账号下发:登录即视为账号切换点,旧缓存必须作废
menuApi.clearCache();
menuApi.clearCache();
auth.clearCache();
auth.clearCache();
...
...
src/store/useAppStore.ts
View file @
57cfc0b
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
*/
*/
import
{
create
}
from
'zustand'
;
import
{
create
}
from
'zustand'
;
import
{
clearLoginSession
,
getLoginSession
}
from
'@/access/session'
;
import
{
clearLoginSession
,
getLoginSession
}
from
'@/access/session'
;
import
{
clearToken
}
from
'@/api/core/token'
;
import
{
queryClient
}
from
'@/queryClient'
;
import
{
queryClient
}
from
'@/queryClient'
;
const
savedSession
=
getLoginSession
();
const
savedSession
=
getLoginSession
();
...
@@ -39,6 +40,10 @@ export const useAppStore = create<AppState>((set) => ({
...
@@ -39,6 +40,10 @@ export const useAppStore = create<AppState>((set) => ({
set
({
loggedIn
:
true
,
currentUser
:
u
});
set
({
loggedIn
:
true
,
currentUser
:
u
});
},
},
logout
:
()
=>
{
logout
:
()
=>
{
// 令牌(uj_token,http 拦截器读取)与会话(session,路由守卫读取)必须同时清:
// 只清一边会留下半吊子状态——令牌还在则刷新后仍能拉到用户信息,
// 会话还在则刷新后 loggedIn 仍为 true(尽管所有接口 401)。
clearToken
();
clearLoginSession
();
clearLoginSession
();
queryClient
.
clear
();
queryClient
.
clear
();
set
({
loggedIn
:
false
});
set
({
loggedIn
:
false
});
...
...
src/theme/design.css
View file @
57cfc0b
...
@@ -179,10 +179,8 @@
...
@@ -179,10 +179,8 @@
/* 垂直、低饱和、matte 深蓝:比原 160° 对角渐变更稳重、更有层次但不「动」。 */
/* 垂直、低饱和、matte 深蓝:比原 160° 对角渐变更稳重、更有层次但不「动」。 */
background
:
linear-gradient
(
180deg
,
#0e1736
0%
,
#111b3d
55%
,
#0e1631
100%
);
background
:
linear-gradient
(
180deg
,
#0e1736
0%
,
#111b3d
55%
,
#0e1631
100%
);
box-shadow
:
4px
0
24px
-12px
rgba
(
6
,
12
,
38
,
0.55
);
box-shadow
:
4px
0
24px
-12px
rgba
(
6
,
12
,
38
,
0.55
);
/* 侧边菜单的水平几何只由这一个旋钮决定:
/* 侧边菜单不再有 CSS 旋钮:高度 / 左右留白 / 圆角 / 图标尺寸 / 折叠宽度
--uj-menu-inset 胶囊左右留白;--uj-menu-radius 胶囊圆角。改这两处,展开态同步生效。 */
全部写在 themeConfig.ts 的 components.Menu token 里,由组件自身参与计算。 */
--uj-menu-inset
:
10px
;
--uj-menu-radius
:
10px
;
}
}
.uj-sider
>
.ant-layout-sider-children
{
.uj-sider
>
.ant-layout-sider-children
{
display
:
flex
;
display
:
flex
;
...
@@ -224,9 +222,9 @@
...
@@ -224,9 +222,9 @@
text-transform
:
uppercase
;
text-transform
:
uppercase
;
}
}
/* 菜单
区:接管滚动,
隐藏滚动条。
/* 菜单
滚动区:只负责接管滚动与
隐藏滚动条。
横向
安全区不再由容器 padding 承担 —— 由菜单项自身的对称 margin 承担(见下方 --uj-menu-inset
)。
横向
留白不再由这里承担 —— 由 Menu 的 itemMarginInline token 承担(见 themeConfig.ts
)。
另外
加 scrollbar-gutter: stable both-edges:即使滚动条真的占了宽度,
加 scrollbar-gutter: stable both-edges:即使滚动条真的占了宽度,
浏览器也会在**两侧同时**预留相同空间,左右不会因此失对称。 */
浏览器也会在**两侧同时**预留相同空间,左右不会因此失对称。 */
.uj-sider-menu
{
.uj-sider-menu
{
flex
:
1
;
flex
:
1
;
...
@@ -242,93 +240,34 @@
...
@@ -242,93 +240,34 @@
height
:
0
;
height
:
0
;
}
}
/* 菜单质感:分组标题 / 圆角选中态 / 悬浮 */
/* 菜单:本文件**只做主题着色**。
所有几何量(高度、左右留白、内间距、圆角、图标尺寸、折叠宽度)都不在此覆盖,
改由 ConfigProvider 的 Menu token 下发(见 src/theme/themeConfig.ts 的 components.Menu)——
那是 antd 官方认可的定制入口,组件内部的宽度/居中计算会跟着 token 一起重算,不会互相打架。
折叠态的图标居中尤其依赖这一点:antd 原生用 marginInline + paddingInline:calc(50% - 图标宽/2 - margin),
任何对 width / padding-inline 的 CSS 覆盖都会把它算歪。 */
.uj-menu.ant-menu-dark
{
.uj-menu.ant-menu-dark
{
background
:
transparent
;
background
:
transparent
;
}
}
/* 分组标题:只有字重/字距/大小写没有对应 token,故保留这三项;
字号与颜色已移到 themeConfig 的 groupTitleFontSize / darkGroupTitleColor。
间距一律不写——antd 自身会让标题与菜单项对齐,手动设 padding 反而容易错位。 */
.uj-menu.ant-menu-dark
.ant-menu-item-group-title
{
.uj-menu.ant-menu-dark
.ant-menu-item-group-title
{
color
:
rgba
(
255
,
255
,
255
,
0.32
);
font-size
:
10.5px
;
font-weight
:
600
;
font-weight
:
600
;
letter-spacing
:
2px
;
letter-spacing
:
2px
;
text-transform
:
uppercase
;
text-transform
:
uppercase
;
padding-block
:
12px
6px
;
/* 与菜单项文字左对齐:item 的外边距 10 + 内边距 18 = 28 */
padding-inline
:
28px
;
}
}
/* 分组列表改为 flex 列容器:子项在交叉轴上 stretch,
/* 选中态左侧指示条:用 inset 阴影画,不占盒模型空间,
此时 width:auto 必然撑满 content box,不依赖百分比对其包含块的解算结果。 */
因此不会改变组件的宽高,也不会干扰折叠态的居中计算。 */
.uj-menu.ant-menu-dark
.ant-menu-item-group-list
{
display
:
flex
;
flex-direction
:
column
;
}
.uj-menu.ant-menu-dark
.ant-menu-item
{
position
:
relative
;
border-radius
:
var
(
--uj-menu-radius
);
/* 宽度由 flex 容器的交叉轴拉伸得到(宽度永远是「容器内容宽 - 两侧 margin」),
不需要与任何数值配对;左右留白只由这一条 margin 决定,天然对称。 */
width
:
auto
!important
;
/* margin-inline: var(--uj-menu-inset) !important; */
/* antd 给「分组内」item 的是非对称 padding:paddingInline: 28px 16px
(见 antd/es/menu/style/index.js 的 -item-group-list 规则),必须抹平为对称值。 */
padding-inline
:
18px
!important
;
color
:
rgba
(
255
,
255
,
255
,
0.62
);
transition
:
all
0.25s
ease
;
}
.uj-menu.ant-menu-dark
.ant-menu-item
.ant-menu-item-icon
{
font-size
:
15px
;
}
/* 胶囊统一用具名 ::before 画:inset 四边归零 + 圆角继承宿主,
不使用 left/right 分写,避免出现某一边被后续规则覆盖而失衡。 */
.uj-menu.ant-menu-dark
.ant-menu-item
::before
{
content
:
''
;
position
:
absolute
;
inset
:
0
;
border-radius
:
inherit
;
opacity
:
0
;
transition
:
opacity
0.25s
ease
;
pointer-events
:
none
;
}
/* 悬浮态 */
.uj-menu.ant-menu-dark
.ant-menu-item
:not
(
.ant-menu-item-selected
)
:hover
{
color
:
#fff
;
background
:
transparent
!important
;
}
.uj-menu.ant-menu-dark
.ant-menu-item
:not
(
.ant-menu-item-selected
)
:hover::before
{
opacity
:
1
;
background
:
rgba
(
255
,
255
,
255
,
0.06
);
}
/* 选中态:克制品牌色淡填充 + 左侧细指示条(无发光,企业级稳重感)。
淡填充让人看清「当前位置」,但不过分跳;细条在收起态仍保留,指向更明确。 */
.uj-menu.ant-menu-dark
.ant-menu-item-selected
{
.uj-menu.ant-menu-dark
.ant-menu-item-selected
{
background
:
transparent
!important
;
box-shadow
:
inset
3px
0
0
0
#5b8def
;
color
:
#fff
!important
;
overflow
:
visible
!important
;
}
.uj-menu.ant-menu-dark
.ant-menu-item-selected
::before
{
opacity
:
1
;
background
:
rgba
(
43
,
92
,
230
,
0.22
)
!important
;
box-shadow
:
inset
3px
0
0
0
#5b8def
!important
;
}
.uj-menu.ant-menu-dark
.ant-menu-item-selected
>
*
{
position
:
relative
;
z-index
:
1
;
}
/* 收缩态:隐藏分组标题;图标居中改用 flex(antd 原用 paddingInline 计算,被上面的对称 padding 覆盖掉了) */
.uj-menu.ant-menu-inline-collapsed
{
width
:
100%
;
}
}
/* 收起态隐藏分组标题 —— 这是本区块唯一一处非颜色覆盖:
antd 折叠时并不隐藏分组标题,只做 text-overflow 省略(会留下比如「门…」这样的小字),
企业后台通常选择直接隐藏。若你想要组件原生行为,删掉这三条即可。 */
.uj-menu.ant-menu-inline-collapsed
.ant-menu-item-group-title
{
.uj-menu.ant-menu-inline-collapsed
.ant-menu-item-group-title
{
display
:
none
;
display
:
none
;
}
}
.uj-menu.ant-menu-inline-collapsed
.ant-menu-item
{
/* 外边距与宽度无需为收起态另写一套:沿用上面的对称 margin + 拉伸宽度,
收起态自动同样居中(68 - 10×2 = 48)。仅把内边距归零,让图标在窄胶囊里居中
(antd 原本用 paddingInline 的 calc 值居中,被上面的对称 padding 覆盖掉了)。 */
padding-inline
:
0
!important
;
justify-content
:
center
;
border-radius
:
var
(
--uj-menu-radius
);
}
/* ============ 应用骨架:Header ============ */
/* ============ 应用骨架:Header ============ */
.uj-header
{
.uj-header
{
...
@@ -477,29 +416,94 @@
...
@@ -477,29 +416,94 @@
gap
:
18px
;
gap
:
18px
;
}
}
/* 品牌欢迎条 */
/* 品牌欢迎条:浅色卡片 + 品牌色点睛。
旧版用 brandGradient(#0B1437→#16245A) 整条铺底,明度过低显得压抑;
现改为高明度底色,品牌感交给「小面积渐变方块 + 右上角柔光」承载。 */
.uj-dash-hero
{
.uj-dash-hero
{
border-radius
:
18px
;
position
:
relative
;
overflow
:
hidden
;
border-radius
:
16px
;
padding
:
26px
30px
;
padding
:
26px
30px
;
display
:
flex
;
display
:
flex
;
align-items
:
center
;
align-items
:
center
;
justify-content
:
space-between
;
justify-content
:
space-between
;
gap
:
20px
;
gap
:
20px
;
box-shadow
:
0
18px
40px
-22px
rgba
(
11
,
20
,
55
,
0.7
);
background
:
linear-gradient
(
120deg
,
#ffffff
0%
,
#f5f7ff
100%
);
border
:
1px
solid
rgba
(
43
,
92
,
230
,
0.1
);
box-shadow
:
0
2px
10px
rgba
(
16
,
24
,
64
,
0.04
);
}
/* 右上角品牌柔光:给浅底加层次,不占大面积 */
.uj-dash-hero
::after
{
content
:
''
;
position
:
absolute
;
right
:
-60px
;
top
:
-80px
;
width
:
260px
;
height
:
260px
;
border-radius
:
50%
;
background
:
radial-gradient
(
circle
,
rgba
(
43
,
92
,
230
,
0.1
)
0%
,
rgba
(
43
,
92
,
230
,
0
)
70%
);
pointer-events
:
none
;
}
.uj-dash-hero-id
{
position
:
relative
;
z-index
:
1
;
min-width
:
0
;
}
}
.uj-dash-hero-
actions
{
.uj-dash-hero-
brand
{
display
:
flex
;
display
:
flex
;
gap
:
12px
;
align-items
:
center
;
gap
:
8px
;
font-size
:
12px
;
letter-spacing
:
1.4px
;
font-weight
:
500
;
color
:
#2b5ce6
;
}
.uj-dash-hero-mark
{
width
:
16px
;
height
:
16px
;
border-radius
:
5px
;
flex
:
none
;
flex
:
none
;
background
:
linear-gradient
(
135deg
,
#2b5ce6
,
#5b8def
);
box-shadow
:
0
4px
10px
rgba
(
43
,
92
,
230
,
0.3
);
}
}
.uj-dash-hero-actions
.ant-btn-ghost
{
.uj-dash-hero-title
{
color
:
#fff
;
font-size
:
24px
;
border-color
:
rgba
(
255
,
255
,
255
,
0.4
);
font-weight
:
700
;
color
:
#1d2533
;
line-height
:
1.25
;
margin
:
12px
0
6px
;
}
.uj-dash-hero-sub
{
font-size
:
13px
;
color
:
#6b7688
;
margin
:
0
;
}
.uj-dash-hero-meta
{
position
:
relative
;
z-index
:
1
;
display
:
flex
;
gap
:
10px
;
flex
:
none
;
}
}
.uj-dash-hero-actions
.ant-btn-ghost
:hover
{
.uj-dash-meta-item
{
color
:
#fff
!important
;
display
:
flex
;
border-color
:
#fff
!important
;
flex-direction
:
column
;
background
:
rgba
(
255
,
255
,
255
,
0.12
)
!important
;
gap
:
3px
;
min-width
:
132px
;
padding
:
10px
14px
;
border-radius
:
10px
;
background
:
rgba
(
43
,
92
,
230
,
0.05
);
border
:
1px
solid
rgba
(
43
,
92
,
230
,
0.08
);
}
.uj-dash-meta-label
{
font-size
:
11px
;
color
:
#8a94a6
;
}
.uj-dash-meta-value
{
font-size
:
13px
;
font-weight
:
600
;
color
:
#1d2533
;
word-break
:
break-all
;
}
}
/* KPI 行 */
/* KPI 行 */
...
@@ -795,6 +799,14 @@
...
@@ -795,6 +799,14 @@
.uj-dash-main
{
.uj-dash-main
{
grid-template-columns
:
1
fr
;
grid-template-columns
:
1
fr
;
}
}
.uj-dash-hero
{
flex-direction
:
column
;
align-items
:
flex-start
;
padding
:
22px
20px
;
}
.uj-dash-hero-meta
{
width
:
100%
;
}
.uj-profile-grid
{
.uj-profile-grid
{
grid-template-columns
:
1
fr
;
grid-template-columns
:
1
fr
;
}
}
...
...
src/theme/themeConfig.ts
View file @
57cfc0b
import
type
{
ThemeConfig
}
from
'antd'
;
import
type
{
ThemeConfig
}
from
'antd'
;
// 品牌色板(稳重内敛 · 企业级)
// 品牌色板(稳重内敛 · 企业级)
export
const
brandDeep
=
'#0B1437'
;
// 墨蓝导航底(深色态)
// 说明:brandDeep / brandGradient 原用于 Sider 与工作台欢迎条底;
export
const
brandGradient
=
'linear-gradient(160deg, #0B1437 0%, #16245A 100%)'
;
// Sider / 登录品牌区
// 现将两处明度过低的深色底均已弃用(Sider 改由 design.css 的 .uj-sider 垂直 matte 深蓝承接,
// 工作台欢迎条改为浅色卡片 + 品牌色点睛)。这两个色值暂无代码引用,保留作品牌资产备查。
export
const
brandDeep
=
'#0B1437'
;
// 墨蓝导航底(深色态,暂未引用)
export
const
brandGradient
=
'linear-gradient(160deg, #0B1437 0%, #16245A 100%)'
;
// 暂未引用
export
const
brandAccent
=
'#2B5CE6'
;
// 主操作蓝
export
const
brandAccent
=
'#2B5CE6'
;
// 主操作蓝
export
const
themeConfig
:
ThemeConfig
=
{
export
const
themeConfig
:
ThemeConfig
=
{
...
@@ -41,13 +44,28 @@ export const themeConfig: ThemeConfig = {
...
@@ -41,13 +44,28 @@ export const themeConfig: ThemeConfig = {
bodyBg
:
'#F4F6FA'
,
bodyBg
:
'#F4F6FA'
,
},
},
Menu
:
{
Menu
:
{
// —— 颜色(暗色模式)——
darkItemBg
:
'transparent'
,
darkItemBg
:
'transparent'
,
darkSubMenuItemBg
:
'transparent'
,
darkSubMenuItemBg
:
'transparent'
,
darkItemColor
:
'rgba(255,255,255,.62)'
,
darkItemHoverBg
:
'rgba(255,255,255,.06)'
,
darkItemHoverColor
:
'#FFFFFF'
,
darkItemSelectedBg
:
'rgba(43,92,230,.22)'
,
darkItemSelectedBg
:
'rgba(43,92,230,.22)'
,
darkItemSelectedColor
:
'#FFFFFF'
,
darkItemSelectedColor
:
'#FFFFFF'
,
darkGroupTitleColor
:
'rgba(255,255,255,.32)'
,
// 折叠态弹出的子菜单底:与 .uj-sider 中段色一致,避免弹出层露出 antd 默认的深蓝黑
darkPopupBg
:
'#111B3D'
,
// —— 几何:全部走 token,不在 design.css 里用 CSS 覆盖组件内部盒模型 ——
// antd 会用 itemMarginInline 参与折叠态居中计算(paddingInline: calc(50% - 图标宽/2 - itemMarginInline)),
// 所以「胶囊左右留白」必须由这个 token 给,不能用 CSS margin 顶替。
itemMarginInline
:
10
,
itemBorderRadius
:
10
,
itemHeight
:
44
,
itemHeight
:
44
,
itemMarginInline
:
8
,
iconSize
:
15
,
iconSize
:
16
,
groupTitleFontSize
:
10.5
,
// 必须与 <Sider collapsedWidth={68}> 保持一致:Menu 折叠态有自己的 collapsedWidth,
// 两者不等会让菜单比侧栏宽(溢出)或窄(留缝)。
collapsedWidth
:
68
,
},
},
Card
:
{
Card
:
{
borderRadiusLG
:
12
,
borderRadiusLG
:
12
,
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment