Commit 051e16c5 by liimin

chore(工程化): 接入 ESLint + Prettier + Husky 并统一代码格式化

1 parent d01aa596
Pipeline #296 for 051e16c5 failed in 0 seconds
# GitLab CI —— 权限模块 lint 卡点(pre-commit 之后的第二道防线)
# 仅在 MR 与默认分支上运行;只校验 src/access,无需构建 @uj/ui。
stages:
- verify
lint:
stage: verify
image: node:20
cache:
key:
files:
- pnpm-lock.yaml
paths:
- .pnpm-store
before_script:
- corepack enable
- corepack prepare pnpm@10.8.1 --activate
- pnpm config set store-dir .pnpm-store
- pnpm install --frozen-lockfile
script:
- pnpm lint
- pnpm format:check
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
pnpm lint-staged
pnpm-lock.yaml
node_modules
dist
**/dist
.husky/_
.codebuddy
coverage
*.log
{
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"printWidth": 100,
"tabWidth": 2,
"arrowParens": "always"
}
......@@ -4,11 +4,11 @@
## 评审纪要中的开放项(已按决策落定)
| 开放项(原纪要第五部分) | 落定决策 |
|---|---|
| 构建/路由分叉(Vite vs Umi Max) | **Vite + React Router 7**(自建、轻量、可控;布局/权限自接) |
| Excel 库(SheetJS vs ExcelJS) | **不引前端 Excel 库**,前端仅上传文件,解析 + 模板版本校验由后端完成 |
| 权限库(CASL vs access.ts) | **自研 `src/access` 三态模型**(`ck.on`/`half`/`na`),零依赖、AI 易扩展 |
| 开放项(原纪要第五部分) | 落定决策 |
| -------------------------------- | ------------------------------------------------------------------------ |
| 构建/路由分叉(Vite vs Umi Max) | **Vite + React Router 7**(自建、轻量、可控;布局/权限自接) |
| Excel 库(SheetJS vs ExcelJS) | **不引前端 Excel 库**,前端仅上传文件,解析 + 模板版本校验由后端完成 |
| 权限库(CASL vs access.ts) | **自研 `src/access` 三态模型**(`ck.on`/`half`/`na`),零依赖、AI 易扩展 |
## 与纪要事实的偏差(已就地修正)
......
......@@ -2,10 +2,10 @@
本目录存放项目级开发文档。组件库本身的约定与用法见 `packages/ui/README.md`(与 `.codebuddy/skills/uj-ui/SKILL.md` 同步)。
| 文档 | 说明 |
|---|---|
| 文档 | 说明 |
| ------------------------------------------ | --------------------------------------------------------------------------------------------- |
| [权限按钮使用指南](./permission-button.md) | 页面内按钮级权限:`Perm` vs `PermButton` 区别、权限点命名、用法、后端接入适配器、原则与反模式 |
| [组件库使用指南](../packages/ui/README.md) | `@uj/ui` 组件库约定、组件清单、用法、如何新增组件(团队版,与 AI 协作版 SKILL.md 同步) |
| [组件库使用指南](../packages/ui/README.md) | `@uj/ui` 组件库约定、组件清单、用法、如何新增组件(团队版,与 AI 协作版 SKILL.md 同步) |
## 约定
......
......@@ -7,10 +7,10 @@
## 一、`Perm` 与 `PermButton` 的区别
| 组件 | 渲染什么 | 适用场景 |
|---|---|---|
| `PermButton` | 一个 `UButton`(按钮) | 独立的操作按钮:`导出`、`删除`、`审核`、`驳回` |
| `Perm` | 任意子节点(链接 / 区块 / 菜单项) | 非按钮元素按权限渲染:`<a>查看</a>`、整块操作区、下拉菜单项、表格里一组操作 |
| 组件 | 渲染什么 | 适用场景 |
| ------------ | ---------------------------------- | --------------------------------------------------------------------------- |
| `PermButton` | 一个 `UButton`(按钮) | 独立的操作按钮:`导出`、`删除`、`审核`、`驳回` |
| `Perm` | 任意子节点(链接 / 区块 / 菜单项) | 非按钮元素按权限渲染:`<a>查看</a>`、整块操作区、下拉菜单项、表格里一组操作 |
记忆法:**要按钮用 `PermButton`;要包裹任意内容按权限显示用 `Perm`。**
......@@ -30,21 +30,21 @@ import { Perm, PermButton, P } from '@/access';
权限点是以 `资源:动作` 命名的扁平字符串:
| 写法 | 含义 |
|---|---|
| `store.approve` | 门店审批页可见(等价于 view) |
| `store.approve:manage` | 该页完全操作权 |
| `store.approve:audit` | 审核按钮 |
| `store.approve:reject` | 驳回按钮 |
| `store.listing:export` | 门店列表导出 |
| `store.listing:delete` | 门店列表删除 |
| 写法 | 含义 |
| ---------------------- | ----------------------------- |
| `store.approve` | 门店审批页可见(等价于 view) |
| `store.approve:manage` | 该页完全操作权 |
| `store.approve:audit` | 审核按钮 |
| `store.approve:reject` | 驳回按钮 |
| `store.listing:export` | 门店列表导出 |
| `store.listing:delete` | 门店列表删除 |
用 `P` 常量引用,**不要手写字符串**(避免拼错无提示):
```ts
import { P } from '@/access';
P.STORE_APPROVE_AUDIT; // 'store.approve:audit'
P.STORE_LISTING_EXPORT; // 'store.listing:export'
P.STORE_APPROVE_AUDIT; // 'store.approve:audit'
P.STORE_LISTING_EXPORT; // 'store.listing:export'
// 动态构造:point('store.approve', 'audit') => 'store.approve:audit'
```
......@@ -57,10 +57,14 @@ P.STORE_LISTING_EXPORT; // 'store.listing:export'
```tsx
import { PermButton, P } from '@/access';
{/* 无权限默认不渲染(hide) */}
<PermButton permission={P.STORE_LISTING_EXPORT}>导出</PermButton>
{
/* 无权限默认不渲染(hide) */
}
<PermButton permission={P.STORE_LISTING_EXPORT}>导出</PermButton>;
{/* 无权限时渲染禁用态 + 悬浮提示 */}
{
/* 无权限时渲染禁用态 + 悬浮提示 */
}
<PermButton
permission={P.STORE_LISTING_DELETE}
type="link"
......@@ -69,52 +73,60 @@ import { PermButton, P } from '@/access';
unauthorizedTip="无删除权限"
>
删除
</PermButton>
</PermButton>;
```
Props(`permission` 必填,其余透传给 `UButton`):
| Prop | 类型 | 默认 | 说明 |
|---|---|---|---|
| `permission` | `string` | — | 所需权限点,如 `P.STORE_APPROVE_AUDIT` |
| `fallback` | `'hide' \| 'disabled'` | `'hide'` | 无权限时的表现 |
| `unauthorizedTip` | `string` | — | `fallback="disabled"` 时的悬浮提示 |
| Prop | 类型 | 默认 | 说明 |
| ----------------- | ---------------------- | -------- | -------------------------------------- |
| `permission` | `string` | — | 所需权限点,如 `P.STORE_APPROVE_AUDIT` |
| `fallback` | `'hide' \| 'disabled'` | `'hide'` | 无权限时的表现 |
| `unauthorizedTip` | `string` | — | `fallback="disabled"` 时的悬浮提示 |
### `Perm`(任意元素包裹)
```tsx
import { Perm, P } from '@/access';
{/* 链接:无权限则不渲染 */}
{
/* 链接:无权限则不渲染 */
}
<Perm permission={P.STORE_APPROVE_VIEW}>
<a onClick={openDetail}>查看</a>
</Perm>
</Perm>;
{/* 整块操作区:无权限渲染空(或自定义 fallback) */}
{
/* 整块操作区:无权限渲染空(或自定义 fallback) */
}
<Perm permission={P.STORE_APPROVE_MANAGE} fallback={<span>无操作权限</span>}>
<Button.Group>
<PermButton permission={P.STORE_APPROVE_AUDIT} type="link">审核</PermButton>
<PermButton permission={P.STORE_APPROVE_REJECT} type="link" danger>驳回</PermButton>
<PermButton permission={P.STORE_APPROVE_AUDIT} type="link">
审核
</PermButton>
<PermButton permission={P.STORE_APPROVE_REJECT} type="link" danger>
驳回
</PermButton>
</Button.Group>
</Perm>
</Perm>;
```
Props:
| Prop | 类型 | 默认 | 说明 |
|---|---|---|---|
| `permission` | `string` | — | 所需权限点 |
| `fallback` | `ReactNode` | `null` | 无权限时渲染的内容 |
| `children` | `ReactNode` | — | 有权限时渲染的内容 |
| Prop | 类型 | 默认 | 说明 |
| ------------ | ----------- | ------ | ------------------ |
| `permission` | `string` | — | 所需权限点 |
| `fallback` | `ReactNode` | `null` | 无权限时渲染的内容 |
| `children` | `ReactNode` | — | 有权限时渲染的内容 |
---
## 五、与页面级权限的关系
| 层级 | 判定 API | 数据源 | 控制什么 |
|---|---|---|---|
| 页面级 | `useAccess().can(resource, 'view'\|'full')` | 角色矩阵(开发期)/ 后端 | 菜单、路由是否可见 |
| 操作级 | `useAccess().canPoint(point)` | 后端返回的权限点集合 | 按钮 / 元素是否显示 |
| 层级 | 判定 API | 数据源 | 控制什么 |
| ------ | ------------------------------------------- | ------------------------ | ------------------- |
| 页面级 | `useAccess().can(resource, 'view'\|'full')` | 角色矩阵(开发期)/ 后端 | 菜单、路由是否可见 |
| 操作级 | `useAccess().canPoint(point)` | 后端返回的权限点集合 | 按钮 / 元素是否显示 |
`Perm` / `PermButton` 内部调用的是 `canPoint`。**两者数据源独立**:页面级当前走矩阵,操作级走后端权限点;后端接入后建议统一由后端返回,避免两套来源不一致。
......@@ -128,14 +140,14 @@ Props:
后端返回 → normalizePermissions(raw) → Set<string> → useAccess().points → canPoint(point)
```
- **当前为 mock**:`src/access/permissionsSource.ts` 的 `fetchPermissions(role)` 按角色返回 `string[]`,登录成功后由 `setRole` 调用加载。
- **当前为 mock**:`src/access/backend/permissionsSource.ts` 的 `fetchPermissions(role)` 按角色返回 `string[]`,登录成功后由 `setRole` 调用加载。
- **接真实后端只改这一个文件**,上层(`Perm` / `PermButton` / 页面)不动:
```ts
// 方案 A:权限随登录接口一起返回
export async function fetchPermissions(role: RoleKey) {
const res = await loginApi(/* ... */);
return res.permissions; // 直接交给 loadPermissions
return res.permissions; // 直接交给 loadPermissions
}
// 方案 B:权限是独立接口
......@@ -145,7 +157,7 @@ Props:
}
```
- **返回结构变了**:改 `src/access/adapter.ts` 的 `normalizePermissions`(目前已支持扁平数组、`{permissions}`、`{list}`、`{data:{permissions}}` 几种形态),同样不影响上层。
- **返回结构变了**:改 `src/access/backend/adapter.ts` 的 `normalizePermissions`(目前已支持扁平数组、`{permissions}`、`{list}`、`{data:{permissions}}` 几种形态),同样不影响上层。
---
......
// ESLint 扁平配置(ESM)。项目此前无 ESLint,本配置只承载一条自定义规则,
// 用于约束「权限模块」不得直接从 antd 引入组件,统一走 @uj/ui。
//
// 作用域:仅 src/access/**(业务/权限层)。其余代码(如主题 ConfigProvider、
// antd 静态 message、Layout/Menu 等尚未封装进 @uj/ui 的组件)暂不约束,避免误伤;
// 后续更多组件被 @uj/ui 封装后,再把 files 的 glob 放宽到 'src/**'。
import tsParser from '@typescript-eslint/parser';
import prettier from 'eslint-config-prettier';
/** 禁止从 antd 直接引入「值/组件」,类型导入(import type / 内联 type)放行。 */
const noAntdComponentImport = {
meta: {
type: 'problem',
docs: {
description: '禁止权限模块直接从 antd 引入组件,统一使用 @uj/ui(类型导入不受影响)',
},
messages: {
forbidden: "不要直接从 'antd' 引入组件/值,请改用 '@uj/ui'(类型导入除外)。",
},
schema: [],
},
create(context) {
return {
ImportDeclaration(node) {
if (node.source.value !== 'antd') return;
// 整条 import type { ... } from 'antd' 放行
if (node.importKind === 'type') return;
const hasValue = node.specifiers.some((s) => {
if (s.type === 'ImportDefaultSpecifier') return true;
if (s.type === 'ImportNamespaceSpecifier') return true;
if (s.type === 'ImportSpecifier') return s.importKind !== 'type';
return false;
});
if (hasValue) {
context.report({ node, messageId: 'forbidden' });
}
},
};
},
};
export default [
{ ignores: ['dist', 'node_modules', '**/*.d.ts', 'packages/**'] },
{
// 基础块:仅为所有 TS/TSX 提供解析能力,默认不启用任何规则
files: ['**/*.{ts,tsx}'],
languageOptions: {
parser: tsParser,
sourceType: 'module',
ecmaVersion: 'latest',
},
rules: {},
},
{
// 约束块:仅权限模块强制走 @uj/ui
files: ['src/access/**/*.{ts,tsx}'],
plugins: { uj: { rules: { 'no-antd-component-import': noAntdComponentImport } } },
rules: { 'uj/no-antd-component-import': 'error' },
},
prettier,
];
......@@ -11,7 +11,11 @@
"dev": "vite",
"build": "tsc --noEmit && vite build",
"preview": "vite preview",
"typecheck": "tsc --noEmit"
"typecheck": "tsc --noEmit",
"lint": "eslint src/access",
"format": "prettier --write .",
"format:check": "prettier --check .",
"prepare": "husky"
},
"dependencies": {
"@ant-design/icons": "^6.3.4",
......@@ -29,8 +33,22 @@
"@types/jsrsasign": "^10.5.15",
"@types/react": "^19.0.0",
"@types/react-dom": "^19.0.0",
"@typescript-eslint/parser": "^8",
"@vitejs/plugin-react": "^4.3.4",
"eslint": "^9",
"eslint-config-prettier": "^9",
"husky": "^9",
"lint-staged": "^15",
"prettier": "^3",
"typescript": "^5.6.3",
"vite": "^6.0.0"
},
"lint-staged": {
"src/access/**/*.{ts,tsx}": [
"eslint --fix"
],
"**/*.{ts,tsx,js,jsx,json,css,less,scss,md}": [
"prettier --write"
]
}
}
......@@ -37,31 +37,31 @@ components/
## 当前组件清单
| 组件 | 基于 | 项目约定默认值 / 说明 |
|---|---|---|
| `UButton` | antd `Button` | `type="primary"`、`size="middle"`(可覆盖) |
| `UInput` | antd `Input` | `allowClear` 默认开;复合形态 `UInput.Password` / `UInput.TextArea` / `UInput.Search` |
| `USelect` | antd `Select` | `allowClear` 默认开 |
| `UCard` | antd `Card` | 统一命名入口(后续加默认样式) |
| `UTag` | antd `Tag` | 统一命名入口 |
| `UAlert` | antd `Alert` | 统一命名入口 |
| `UModal` | antd `Modal` | 默认 `centered`、`destroyOnClose`、`okButtonProps.type="primary"` |
| `UTable` | antd `Table` | `size="middle"` 默认 |
| `UUpload` | antd `Upload` | 统一命名入口;`UUpload.Dragger` 可用 |
| `UForm` | antd `Form` | 默认 `layout="vertical"`;保留 `UForm.Item`/`UForm.List`/`UForm.useForm`/`UForm.useWatch` |
| `UTypography` | antd `Typography` | 透传;另有 `UTitle`/`UText`/`UParagraph` 命名导出 |
| `UTabs` | antd `Tabs` | 透传 |
| `UCheckbox` | antd `Checkbox` | 透传 |
| `UList` | antd `List` | 透传 |
| `UTooltip` | antd `Tooltip` | 透传 |
| `UResult` | antd `Result` | 透传 |
| 组件 | 基于 | 项目约定默认值 / 说明 |
| ------------- | ----------------- | ----------------------------------------------------------------------------------------- |
| `UButton` | antd `Button` | `type="primary"`、`size="middle"`(可覆盖) |
| `UInput` | antd `Input` | `allowClear` 默认开;复合形态 `UInput.Password` / `UInput.TextArea` / `UInput.Search` |
| `USelect` | antd `Select` | `allowClear` 默认开 |
| `UCard` | antd `Card` | 统一命名入口(后续加默认样式) |
| `UTag` | antd `Tag` | 统一命名入口 |
| `UAlert` | antd `Alert` | 统一命名入口 |
| `UModal` | antd `Modal` | 默认 `centered`、`destroyOnClose`、`okButtonProps.type="primary"` |
| `UTable` | antd `Table` | `size="middle"` 默认 |
| `UUpload` | antd `Upload` | 统一命名入口;`UUpload.Dragger` 可用 |
| `UForm` | antd `Form` | 默认 `layout="vertical"`;保留 `UForm.Item`/`UForm.List`/`UForm.useForm`/`UForm.useWatch` |
| `UTypography` | antd `Typography` | 透传;另有 `UTitle`/`UText`/`UParagraph` 命名导出 |
| `UTabs` | antd `Tabs` | 透传 |
| `UCheckbox` | antd `Checkbox` | 透传 |
| `UList` | antd `List` | 透传 |
| `UTooltip` | antd `Tooltip` | 透传 |
| `UResult` | antd `Result` | 透传 |
### 专用组件(非 U 前缀)
| 组件 | 说明 |
|---|---|
| `FillTable` | 自动铺满父容器剩余高度的表格。用 `ResizeObserver` 测量外层高度,扣除表头/分页后作为 antd `Table` 的 `scroll.y`,表体精确填满、表头吸顶、内部滚动。须置于有确定高度的 flex 容器内。 |
| `Skeleton` | 统一页面骨架屏(页面级加载态)。`variant`:`'default'`(卡片概览,如 Dashboard)/ `'table'`(列表表格,如门店列表、审批、权限矩阵)/ `'detail'`(表单详情)。所有含异步数据的页面 loading 期间必须渲染 `<Skeleton variant="…" />`,保证加载态与最终布局结构一致。 |
| 组件 | 说明 |
| ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `FillTable` | 自动铺满父容器剩余高度的表格。用 `ResizeObserver` 测量外层高度,扣除表头/分页后作为 antd `Table` 的 `scroll.y`,表体精确填满、表头吸顶、内部滚动。须置于有确定高度的 flex 容器内。 |
| `Skeleton` | 统一页面骨架屏(页面级加载态)。`variant`:`'default'`(卡片概览,如 Dashboard)/ `'table'`(列表表格,如门店列表、审批、权限矩阵)/ `'detail'`(表单详情)。所有含异步数据的页面 loading 期间必须渲染 `<Skeleton variant="…" />`,保证加载态与最终布局结构一致。 |
> 未列出的 antd 组件(如 `Row/Col/Typography/Menu/Layout/Result`)目前仍直接 import antd;如高频出现,应补对应 U 封装。
......@@ -91,7 +91,7 @@ import { UButton, UTable, UCard, UTag, Skeleton, FillTable } from '@uj/ui';
## 页面内按钮级权限(应用层)
> 列表里"有页面权限但没有某个按钮/操作"的场景,由应用层的 `Perm` / `PermButton` 组件处理(位于 `src/components/`,统一经 `@/access` 导出)。完整用法见 [`../../docs/permission-button.md`](../../docs/permission-button.md)。
> 列表里"有页面权限但没有某个按钮/操作"的场景,由应用层的 `Perm` / `PermButton` 组件处理(实现位于 `src/access/`,与权限逻辑同模块,统一经 `@/access` 导出)。完整用法见 [`../../docs/permission-button.md`](../../docs/permission-button.md)。
核心要点:
......
......@@ -14,17 +14,12 @@ import { useFillHeight } from './tools/useFillHeight';
* <FillTable columns={cols} dataSource={data} rowKey="id" />
* </div>
*/
export function FillTable<T extends object = Record<string, unknown>>(
props: TableProps<T>,
) {
export function FillTable<T extends object = Record<string, unknown>>(props: TableProps<T>) {
const { wrapRef, bodyHeight } = useFillHeight();
return (
<div ref={wrapRef} className="uj-table-fill">
<Table
{...props}
scroll={{ ...props.scroll, y: bodyHeight ?? props.scroll?.y }}
/>
<Table {...props} scroll={{ ...props.scroll, y: bodyHeight ?? props.scroll?.y }} />
</div>
);
}
......@@ -4,11 +4,9 @@ import { forwardRef } from 'react';
export type UInputProps = InputProps;
/** 项目统一输入框,默认开启 allowClear。 */
const UInputBase = forwardRef<InputRef, UInputProps>(
({ allowClear = true, ...rest }, ref) => (
<Input ref={ref} allowClear={allowClear} {...rest} />
),
);
const UInputBase = forwardRef<InputRef, UInputProps>(({ allowClear = true, ...rest }, ref) => (
<Input ref={ref} allowClear={allowClear} {...rest} />
));
UInputBase.displayName = 'UInput';
/** 复合形态均沿用 antd 同名子组件;Password/TextArea/Search 默认不开 allowClear。 */
......
import { Skeleton } from 'antd';
export function DefaultSkeleton({ active = true, cards = 4 }: { active?: boolean; cards?: number }) {
export function DefaultSkeleton({
active = true,
cards = 4,
}: {
active?: boolean;
cards?: number;
}) {
return (
<div
style={{
......
......@@ -4,7 +4,7 @@
* 当前后端契约未定,这里实现几种常见形态;将来后端返回格式变化,
* 只需改本文件(或新增 normalizeXxx 并切换调用),上层 PermButton / canPoint 不受影响。
*/
import type { PermissionMatrix, ResourceKey, RoleKey, PermissionState } from './index';
import type { PermissionMatrix, ResourceKey, RoleKey, PermissionState } from '../model';
/** 把任意后端返回归一为扁平权限点数组 */
export function normalizePermissions(raw: unknown): string[] {
......
import type { RoleKey } from './index';
import type { RoleKey } from '../model';
/**
* 权限点【来源】抽象:登录流程与权限接口尚未确定,这里用 mock 按角色返回权限点。
......@@ -28,7 +28,12 @@ function mockPermissions(role: RoleKey): string[] {
return ALL;
case 'YJ_FINANCE_MGR':
// 有审批页权限,但仅有"审核/驳回",没有独立"查看"、没有列表导出
return ['store.approve', 'store.approve:manage', 'store.approve:audit', 'store.approve:reject'];
return [
'store.approve',
'store.approve:manage',
'store.approve:audit',
'store.approve:reject',
];
case 'OPS_LEADER':
return ['store.approve', 'store.approve:audit', 'store.listing', 'store.listing:export'];
case 'ONLINE_OPS':
......
// 三态权限模型(自研,零依赖,AI 易扩展)
// ck.on -> 完全(可读可写)
// half -> 部分(仅查看)
// na -> 无
export type PermissionState = 'ck.on' | 'half' | 'na';
// 权限领域模块统一出口:逻辑 / 常量 / 适配器 / Provider / UI 组件全部从 @/access 引入。
// 子模块按职责分组:model(领域模型)/ points(权限点)/ runtime(上下文)/ backend(来源+适配)/ ui(权限组件)。
export type ResourceKey =
| 'dashboard'
| 'store.listing'
| 'store.import'
| 'store.approve'
| 'system.role'
| 'system.account'
| 'access.manage';
// 领域模型:类型、角色标签、默认矩阵、页面级判定
export { defaultMatrix, checkAccess, roleLabels } from './model';
export type { PermissionState, ResourceKey, RoleKey, PermissionMatrix } from './model';
// PRD §3.2 内置角色(RBAC0 + 组织数据域),编码与 PRD 角色编码保持一致
export type RoleKey =
| 'SYS_ADMIN' // 超级管理员
| 'YJ_FINANCE_MGR' // 优加财务经理
| 'ONLINE_OPS' // 线上运营
| 'OPS_LEADER' // 运营主管
| 'VIEWER'; // 只读观察者
// 按钮/操作级权限:权限点定义
export { P, point } from './points';
export type { PermissionPoint } from './points';
export const roleLabels: Record<RoleKey, string> = {
SYS_ADMIN: '超级管理员',
YJ_FINANCE_MGR: '优加财务经理',
ONLINE_OPS: '线上运营',
OPS_LEADER: '运营主管',
VIEWER: '只读观察者',
};
export type PermissionMatrix = Record<ResourceKey, Record<RoleKey, PermissionState>>;
// 默认权限矩阵(按 PRD §2.1 / §3.2 角色能力推导)
export const defaultMatrix: PermissionMatrix = {
dashboard: { SYS_ADMIN: 'ck.on', YJ_FINANCE_MGR: 'na', ONLINE_OPS: 'na', OPS_LEADER: 'na', VIEWER: 'na' },
'store.listing': { SYS_ADMIN: 'ck.on', YJ_FINANCE_MGR: 'ck.on', ONLINE_OPS: 'half', OPS_LEADER: 'ck.on', VIEWER: 'half' },
'store.import': { SYS_ADMIN: 'ck.on', YJ_FINANCE_MGR: 'na', ONLINE_OPS: 'ck.on', OPS_LEADER: 'ck.on', VIEWER: 'na' },
'store.approve': { SYS_ADMIN: 'ck.on', YJ_FINANCE_MGR: 'ck.on', ONLINE_OPS: 'na', OPS_LEADER: 'na', VIEWER: 'na' },
'system.role': { SYS_ADMIN: 'ck.on', YJ_FINANCE_MGR: 'na', ONLINE_OPS: 'na', OPS_LEADER: 'na', VIEWER: 'na' },
'system.account': { SYS_ADMIN: 'ck.on', YJ_FINANCE_MGR: 'na', ONLINE_OPS: 'na', OPS_LEADER: 'na', VIEWER: 'na' },
'access.manage': { SYS_ADMIN: 'ck.on', YJ_FINANCE_MGR: 'na', ONLINE_OPS: 'na', OPS_LEADER: 'na', VIEWER: 'na' },
};
/**
* 判定权限。
* @param required 'view'(默认,half 即可)| 'full'(需 ck.on)
*/
export function checkAccess(
matrix: PermissionMatrix,
role: RoleKey,
resource: ResourceKey,
required: 'view' | 'full' = 'view',
): boolean {
const state = matrix[resource]?.[role] ?? 'na';
if (state === 'na') return false;
if (required === 'full') return state === 'ck.on';
return true;
}
// 按钮/操作级权限:权限点定义与后端适配层
export { P, point, type PermissionPoint } from './points';
export { normalizePermissions, matrixToPoints } from './adapter';
// 后端接入:权限来源 + 归一化适配器
export { fetchPermissions } from './backend/permissionsSource';
export { normalizePermissions, matrixToPoints } from './backend/adapter';
// 运行时:权限上下文 Provider 与 Hook
export { AccessProvider, useAccess } from './AccessProvider';
// 权限点来源(mock / 真实后端接入点)
export { fetchPermissions } from './permissionsSource';
// 权限 UI 组件:与权限点配套,统一从 @/access 引入
export { PermButton, Perm } from '@/components';
export { AccessProvider, useAccess } from './runtime/AccessProvider';
// 权限 UI 组件:与权限点配套
export { PermButton } from './ui/PermButton';
export { Perm } from './ui/Perm';
// 三态权限模型(自研,零依赖,AI 易扩展)
// ck.on -> 完全(可读可写)
// half -> 部分(仅查看)
// na -> 无
export type PermissionState = 'ck.on' | 'half' | 'na';
export type ResourceKey =
| 'dashboard'
| 'store.listing'
| 'store.import'
| 'store.approve'
| 'system.role'
| 'system.account'
| 'access.manage';
// PRD §3.2 内置角色(RBAC0 + 组织数据域),编码与 PRD 角色编码保持一致
export type RoleKey =
| 'SYS_ADMIN' // 超级管理员
| 'YJ_FINANCE_MGR' // 优加财务经理
| 'ONLINE_OPS' // 线上运营
| 'OPS_LEADER' // 运营主管
| 'VIEWER'; // 只读观察者
export const roleLabels: Record<RoleKey, string> = {
SYS_ADMIN: '超级管理员',
YJ_FINANCE_MGR: '优加财务经理',
ONLINE_OPS: '线上运营',
OPS_LEADER: '运营主管',
VIEWER: '只读观察者',
};
export type PermissionMatrix = Record<ResourceKey, Record<RoleKey, PermissionState>>;
// 默认权限矩阵(按 PRD §2.1 / §3.2 角色能力推导)
export const defaultMatrix: PermissionMatrix = {
dashboard: {
SYS_ADMIN: 'ck.on',
YJ_FINANCE_MGR: 'na',
ONLINE_OPS: 'na',
OPS_LEADER: 'na',
VIEWER: 'na',
},
'store.listing': {
SYS_ADMIN: 'ck.on',
YJ_FINANCE_MGR: 'ck.on',
ONLINE_OPS: 'half',
OPS_LEADER: 'ck.on',
VIEWER: 'half',
},
'store.import': {
SYS_ADMIN: 'ck.on',
YJ_FINANCE_MGR: 'na',
ONLINE_OPS: 'ck.on',
OPS_LEADER: 'ck.on',
VIEWER: 'na',
},
'store.approve': {
SYS_ADMIN: 'ck.on',
YJ_FINANCE_MGR: 'ck.on',
ONLINE_OPS: 'na',
OPS_LEADER: 'na',
VIEWER: 'na',
},
'system.role': {
SYS_ADMIN: 'ck.on',
YJ_FINANCE_MGR: 'na',
ONLINE_OPS: 'na',
OPS_LEADER: 'na',
VIEWER: 'na',
},
'system.account': {
SYS_ADMIN: 'ck.on',
YJ_FINANCE_MGR: 'na',
ONLINE_OPS: 'na',
OPS_LEADER: 'na',
VIEWER: 'na',
},
'access.manage': {
SYS_ADMIN: 'ck.on',
YJ_FINANCE_MGR: 'na',
ONLINE_OPS: 'na',
OPS_LEADER: 'na',
VIEWER: 'na',
},
};
/**
* 判定权限。
* @param required 'view'(默认,half 即可)| 'full'(需 ck.on)
*/
export function checkAccess(
matrix: PermissionMatrix,
role: RoleKey,
resource: ResourceKey,
required: 'view' | 'full' = 'view',
): boolean {
const state = matrix[resource]?.[role] ?? 'na';
if (state === 'na') return false;
if (required === 'full') return state === 'ck.on';
return true;
}
......@@ -2,12 +2,12 @@ import { createContext, useContext, useMemo, useState, type ReactNode } from 're
import {
checkAccess,
defaultMatrix,
fetchPermissions,
normalizePermissions,
type PermissionMatrix,
type ResourceKey,
type RoleKey,
} from './index';
} from '../model';
import { fetchPermissions } from '../backend/permissionsSource';
import { normalizePermissions } from '../backend/adapter';
interface AccessContextValue {
role: RoleKey;
......@@ -29,7 +29,7 @@ export function AccessProvider({ children }: { children: ReactNode }) {
const [matrix] = useState<PermissionMatrix>(defaultMatrix);
const [points, setPoints] = useState<Set<string>>(new Set());
// 角色变化 → 重新拉取该角色的权限点(来源见 src/access/permissionsSource.ts,目前为 mock)
// 角色变化 → 重新拉取该角色的权限点(来源见 src/access/backend/permissionsSource.ts,目前为 mock)
const setRole = async (r: RoleKey) => {
setRoleState(r);
const perms = await fetchPermissions(r);
......@@ -45,8 +45,7 @@ export function AccessProvider({ children }: { children: ReactNode }) {
role,
setRole,
matrix,
can: (resource, required = 'view') =>
checkAccess(matrix, role, resource, required),
can: (resource, required = 'view') => checkAccess(matrix, role, resource, required),
points,
canPoint: (p: string) => points.has(p),
loadPermissions,
......
import type { ReactNode } from 'react';
import { useAccess } from '@/access';
import { useAccess } from '../runtime/AccessProvider';
interface PermProps {
/** 所需权限点 */
......
import { forwardRef } from 'react';
import { Tooltip } from 'antd';
import { UButton } from '@uj/ui';
import { useAccess } from '@/access';
import type { ButtonProps } from 'antd';
import { UButton, UTooltip, type UButtonProps } from '@uj/ui';
import { useAccess } from '../runtime/AccessProvider';
interface PermButtonProps extends ButtonProps {
interface PermButtonProps extends UButtonProps {
/** 所需权限点,如 'store.approve:audit';无该权限时按 fallback 处理 */
permission: string;
/** 无权限时的表现:'hide' 不渲染(默认)| 'disabled' 渲染禁用态 */
......@@ -27,7 +25,7 @@ export const PermButton = forwardRef<HTMLButtonElement, PermButtonProps>(
const btn = <UButton ref={ref} disabled={!ok || rest.disabled} {...rest} />;
if (!ok && fallback === 'disabled' && unauthorizedTip) {
return <Tooltip title={unauthorizedTip}>{btn}</Tooltip>;
return <UTooltip title={unauthorizedTip}>{btn}</UTooltip>;
}
return btn;
},
......
......@@ -55,14 +55,11 @@ http.interceptors.request.use((config: any) => {
const existingCt = headers['Content-Type'] || headers['content-type'];
const media = isForm
? 'multipart/form-data'
: (existingCt || (config.data ? 'application/json' : ''))
.split(';')[0]
.trim()
.toLowerCase();
: (existingCt || (config.data ? 'application/json' : '')).split(';')[0].trim().toLowerCase();
const timestamp = String(Date.now());
const nonce = uuid();
const bodyStr = isForm ? '' : (config.data || '');
const bodyStr = isForm ? '' : config.data || '';
// 待签名原文:8 行 \n 连接,末尾不加换行(§3.1)
const canonical = [
......
......@@ -51,7 +51,10 @@ export interface ApproveRow {
class Store extends ApiClient {
listStores(params: ListingPageParams = {}) {
return this.get<PageResult<StoreListingRow>>('/store/listing/page', params as Record<string, unknown>);
return this.get<PageResult<StoreListingRow>>(
'/store/listing/page',
params as Record<string, unknown>,
);
}
/** 上传模板文件做五级校验(FormData,请求体不参与签名,§3.1/§9.6) */
......
export { Logo } from './Logo';
export { StatusTag } from './StatusTag';
export { default as PagePlaceholder } from './PagePlaceholder';
export { PermButton } from './PermButton';
export { Perm } from './Perm';
......@@ -3,23 +3,58 @@
{
"group": "工作台",
"children": [
{ "path": "/dashboard", "label": "工作台", "icon": "DashboardOutlined", "resource": "dashboard" }
{
"path": "/dashboard",
"label": "工作台",
"icon": "DashboardOutlined",
"resource": "dashboard"
}
]
},
{
"group": "门店上架",
"children": [
{ "path": "/store/import", "label": "导入门店信息", "icon": "UploadOutlined", "resource": "store.import" },
{ "path": "/store/approve", "label": "门店审批", "icon": "AuditOutlined", "resource": "store.approve" },
{ "path": "/store/listing", "label": "门店列表", "icon": "ShopOutlined", "resource": "store.listing" }
{
"path": "/store/import",
"label": "导入门店信息",
"icon": "UploadOutlined",
"resource": "store.import"
},
{
"path": "/store/approve",
"label": "门店审批",
"icon": "AuditOutlined",
"resource": "store.approve"
},
{
"path": "/store/listing",
"label": "门店列表",
"icon": "ShopOutlined",
"resource": "store.listing"
}
]
},
{
"group": "系统设置",
"children": [
{ "path": "/system/access", "label": "权限管理", "icon": "SafetyOutlined", "resource": "access.manage" },
{ "path": "/system/roles", "label": "角色管理", "icon": "TeamOutlined", "resource": "system.role" },
{ "path": "/system/accounts", "label": "账号管理", "icon": "UserOutlined", "resource": "system.account" }
{
"path": "/system/access",
"label": "权限管理",
"icon": "SafetyOutlined",
"resource": "access.manage"
},
{
"path": "/system/roles",
"label": "角色管理",
"icon": "TeamOutlined",
"resource": "system.role"
},
{
"path": "/system/accounts",
"label": "账号管理",
"icon": "UserOutlined",
"resource": "system.account"
}
]
}
]
......
......@@ -26,8 +26,15 @@ body,
}
body {
font-family: 'PingFang', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
'PingFang SC', 'Microsoft YaHei', sans-serif;
font-family:
'PingFang',
-apple-system,
BlinkMacSystemFont,
'Segoe UI',
Roboto,
'PingFang SC',
'Microsoft YaHei',
sans-serif;
}
/* 彻底关掉 antd Table 内层容器的横向滚动条(亚像素/列宽导致)。
......
......@@ -16,7 +16,7 @@ import {
MenuUnfoldOutlined,
QuestionCircleOutlined,
} from '@ant-design/icons';
import { useAccess } from '@/access/AccessProvider';
import { useAccess } from '@/access';
import { useAppStore } from '@/store/useAppStore';
import { brandGradient } from '@/theme/themeConfig';
import { Logo } from '@/components/Logo';
......@@ -121,7 +121,7 @@ export default function BasicLayout() {
onClick={({ key }) => navigate(key)}
/>
</div>
</Sider>
</Sider>
<Layout style={{ minWidth: 0 }}>
<Header className="uj-header">
......@@ -192,9 +192,7 @@ export default function BasicLayout() {
/>
<div className="uj-header-user-text">
<span className="n">{currentUser.name}</span>
<span className="r">
{roleLabels[role]}
</span>
<span className="r">{roleLabels[role]}</span>
</div>
</button>
</Dropdown>
......
......@@ -7,7 +7,7 @@ import zhCN from 'antd/locale/zh_CN';
import { router } from '@/router';
import { queryClient } from '@/queryClient';
import { themeConfig } from '@/theme/themeConfig';
import { AccessProvider } from '@/access/AccessProvider';
import { AccessProvider } from '@/access';
import { initSign } from '@/api';
import './index.css';
import './theme/design.css';
......
import { useState } from 'react';
import { useAccess } from '@/access/AccessProvider';
import { useAccess } from '@/access';
import type { PermissionMatrix, PermissionState, ResourceKey, RoleKey } from '@/access';
import { roleLabels } from '@/access';
import { MatrixTable } from './components/MatrixTable';
......
......@@ -29,8 +29,12 @@ export function Donut() {
<svg width={132} height={132} viewBox="0 0 132 132">
<circle cx={66} cy={66} r={r} fill="none" stroke="#F0F2F7" strokeWidth="14" />
{circles}
<text x={66} y={62} fontSize="22" fontWeight={700} fill="#1D2533" textAnchor="middle">{total}</text>
<text x={66} y={80} fontSize="11" fill="#8A94A6" textAnchor="middle">门店总数</text>
<text x={66} y={62} fontSize="22" fontWeight={700} fill="#1D2533" textAnchor="middle">
{total}
</text>
<text x={66} y={80} fontSize="11" fill="#8A94A6" textAnchor="middle">
门店总数
</text>
</svg>
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
{dist.map((d) => (
......@@ -38,7 +42,9 @@ export function Donut() {
<span style={{ width: 9, height: 9, borderRadius: 3, background: d.color }} />
<span style={{ fontSize: 13, color: '#4A5568', minWidth: 72 }}>{d.label}</span>
<span style={{ fontSize: 13, fontWeight: 600, color: '#1D2533' }}>{d.value}</span>
<span style={{ fontSize: 12, color: '#AAB3C2' }}>{Math.round((d.value / total) * 100)}%</span>
<span style={{ fontSize: 12, color: '#AAB3C2' }}>
{Math.round((d.value / total) * 100)}%
</span>
</div>
))}
</div>
......
......@@ -4,11 +4,26 @@ export function Spark({ data, color }: { data: number[]; color: string }) {
const max = Math.max(...data);
const min = Math.min(...data);
const span = max - min || 1;
const pts = data.map((v, i) => [8 + (i / (data.length - 1)) * (w - 16), h - 6 - ((v - min) / span) * (h - 12)]);
const pts = data.map((v, i) => [
8 + (i / (data.length - 1)) * (w - 16),
h - 6 - ((v - min) / span) * (h - 12),
]);
const line = pts.map((p, i) => `${i ? 'L' : 'M'}${p[0].toFixed(1)} ${p[1].toFixed(1)}`).join(' ');
return (
<svg viewBox={`0 0 ${w} ${h}`} width={w} height={h} style={{ display: 'block', overflow: 'visible' }}>
<path d={line} fill="none" stroke={color} strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
<svg
viewBox={`0 0 ${w} ${h}`}
width={w}
height={h}
style={{ display: 'block', overflow: 'visible' }}
>
<path
d={line}
fill="none"
stroke={color}
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
<circle cx={pts[pts.length - 1][0]} cy={pts[pts.length - 1][1]} r="2.6" fill={color} />
</svg>
);
......
export function TrendChart() {
const data = [30, 42, 38, 55, 60, 48, 72, 80, 68, 90, 85, 98];
const labels = ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'];
const labels = [
'1月',
'2月',
'3月',
'4月',
'5月',
'6月',
'7月',
'8月',
'9月',
'10月',
'11月',
'12月',
];
const w = 720;
const h = 240;
const padL = 16;
......@@ -11,7 +24,9 @@ export function TrendChart() {
const step = (w - padL - padR) / (data.length - 1);
const px = (i: number) => padL + i * step;
const py = (v: number) => padT + (1 - v / max) * (h - padT - padB);
const line = data.map((v, i) => `${i ? 'L' : 'M'}${px(i).toFixed(1)} ${py(v).toFixed(1)}`).join(' ');
const line = data
.map((v, i) => `${i ? 'L' : 'M'}${px(i).toFixed(1)} ${py(v).toFixed(1)}`)
.join(' ');
const area = `${line} L${px(data.length - 1).toFixed(1)} ${(h - padB).toFixed(1)} L${px(0).toFixed(1)} ${(h - padB).toFixed(1)} Z`;
const grid = [0, 25, 50, 75, 100];
return (
......@@ -25,16 +40,34 @@ export function TrendChart() {
{grid.map((g) => (
<g key={g}>
<line x1={padL} x2={w - padR} y1={py(g)} y2={py(g)} stroke="#EEF1F6" strokeWidth="1" />
<text x={2} y={py(g) + 4} fontSize="10" fill="#AAB3C2">{g}</text>
<text x={2} y={py(g) + 4} fontSize="10" fill="#AAB3C2">
{g}
</text>
</g>
))}
<path d={area} fill="url(#ujArea)" />
<path d={line} fill="none" stroke="#2B5CE6" strokeWidth="2.6" strokeLinejoin="round" strokeLinecap="round" />
<path
d={line}
fill="none"
stroke="#2B5CE6"
strokeWidth="2.6"
strokeLinejoin="round"
strokeLinecap="round"
/>
{data.map((v, i) =>
i === data.length - 1 ? (
<g key={i}>
<circle cx={px(i)} cy={py(v)} r="5" fill="#fff" stroke="#2B5CE6" strokeWidth="2.6" />
<text x={px(i)} y={py(v) - 12} fontSize="12" fontWeight={700} fill="#2B5CE6" textAnchor="middle">{v}</text>
<text
x={px(i)}
y={py(v) - 12}
fontSize="12"
fontWeight={700}
fill="#2B5CE6"
textAnchor="middle"
>
{v}
</text>
</g>
) : null,
)}
......
......@@ -35,8 +35,14 @@ export default function Dashboard() {
</p>
</div>
<div className="uj-dash-hero-actions">
<UButton ghost icon={<DownloadOutlined />}>导出报表</UButton>
<UButton type="primary" icon={<PlusOutlined />} style={{ background: '#fff', color: '#16245A', borderColor: '#fff' }}>
<UButton ghost icon={<DownloadOutlined />}>
导出报表
</UButton>
<UButton
type="primary"
icon={<PlusOutlined />}
style={{ background: '#fff', color: '#16245A', borderColor: '#fff' }}
>
新建上架任务
</UButton>
</div>
......@@ -59,8 +65,8 @@ export default function Dashboard() {
className="uj-kpi-delta"
style={{ color: k.delta > 0 ? '#16A34A' : k.delta < 0 ? '#E5484D' : '#8A94A6' }}
>
{k.delta > 0 && <ArrowUpOutlined />} {k.delta < 0 && <ArrowDownOutlined />} {Math.abs(k.delta)}%
<span style={{ color: '#AAB3C2', marginLeft: 6 }}>较上周</span>
{k.delta > 0 && <ArrowUpOutlined />} {k.delta < 0 && <ArrowDownOutlined />}{' '}
{Math.abs(k.delta)}%<span style={{ color: '#AAB3C2', marginLeft: 6 }}>较上周</span>
</div>
</UCard>
))}
......@@ -78,12 +84,19 @@ export default function Dashboard() {
</UCard>
<div className="uj-dash-side">
<UCard title={<span style={{ fontWeight: 600 }}>门店状态分布</span>} styles={{ body: { padding: 16 } }}>
<UCard
title={<span style={{ fontWeight: 600 }}>门店状态分布</span>}
styles={{ body: { padding: 16 } }}
>
<Donut />
</UCard>
<UCard
title={<span style={{ fontWeight: 600 }}>待办事项</span>}
extra={<UText type="secondary" style={{ fontSize: 12 }}>4</UText>}
extra={
<UText type="secondary" style={{ fontSize: 12 }}>
4
</UText>
}
styles={{ body: { padding: '4px 8px' } }}
>
<UList
......@@ -91,7 +104,15 @@ export default function Dashboard() {
renderItem={(it) => (
<UList.Item style={{ paddingInline: 8 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 10, width: '100%' }}>
<span style={{ width: 7, height: 7, borderRadius: '50%', background: it.color, flex: 'none' }} />
<span
style={{
width: 7,
height: 7,
borderRadius: '50%',
background: it.color,
flex: 'none',
}}
/>
<span style={{ fontSize: 13, color: '#4A5568', flex: 1 }}>{it.t}</span>
<span
style={{
......
......@@ -12,10 +12,42 @@ export interface Kpi {
}
export const kpis: Kpi[] = [
{ label: '待上架门店', value: '12', delta: 8.2, icon: <ShopOutlined />, tint: 'rgba(43,92,230,.10)', color: '#2B5CE6', spark: [4, 6, 5, 7, 9, 8, 10, 12] },
{ label: '营业中门店', value: '86', delta: 3.1, icon: <SyncOutlined />, tint: 'rgba(22,163,74,.10)', color: '#16A34A', spark: [70, 72, 75, 74, 80, 82, 84, 86] },
{ label: '本月导入批次', value: '5', delta: -1.0, icon: <DownloadOutlined />, tint: 'rgba(217,119,6,.10)', color: '#D97706', spark: [6, 5, 7, 6, 8, 7, 6, 5] },
{ label: '异常 / 下架', value: '4', delta: -2.4, icon: <WarningOutlined />, tint: 'rgba(229,72,77,.10)', color: '#E5484D', spark: [9, 8, 7, 6, 6, 5, 5, 4] },
{
label: '待上架门店',
value: '12',
delta: 8.2,
icon: <ShopOutlined />,
tint: 'rgba(43,92,230,.10)',
color: '#2B5CE6',
spark: [4, 6, 5, 7, 9, 8, 10, 12],
},
{
label: '营业中门店',
value: '86',
delta: 3.1,
icon: <SyncOutlined />,
tint: 'rgba(22,163,74,.10)',
color: '#16A34A',
spark: [70, 72, 75, 74, 80, 82, 84, 86],
},
{
label: '本月导入批次',
value: '5',
delta: -1.0,
icon: <DownloadOutlined />,
tint: 'rgba(217,119,6,.10)',
color: '#D97706',
spark: [6, 5, 7, 6, 8, 7, 6, 5],
},
{
label: '异常 / 下架',
value: '4',
delta: -2.4,
icon: <WarningOutlined />,
tint: 'rgba(229,72,77,.10)',
color: '#E5484D',
spark: [9, 8, 7, 6, 6, 5, 5, 4],
},
];
export const dist = [
......
......@@ -28,10 +28,30 @@ export function LoginAside() {
</li>
</ul>
<div
style={{ position: 'absolute', width: 280, height: 280, right: -60, top: -40, background: '#2B5CE6', borderRadius: '50%', filter: 'blur(70px)', opacity: 0.45 }}
style={{
position: 'absolute',
width: 280,
height: 280,
right: -60,
top: -40,
background: '#2B5CE6',
borderRadius: '50%',
filter: 'blur(70px)',
opacity: 0.45,
}}
/>
<div
style={{ position: 'absolute', width: 220, height: 220, left: -40, bottom: -30, background: '#5B8DEF', borderRadius: '50%', filter: 'blur(70px)', opacity: 0.35 }}
style={{
position: 'absolute',
width: 220,
height: 220,
left: -40,
bottom: -30,
background: '#5B8DEF',
borderRadius: '50%',
filter: 'blur(70px)',
opacity: 0.35,
}}
/>
</aside>
);
......
......@@ -11,7 +11,7 @@ import { useNavigate } from 'react-router-dom';
import { App } from 'antd';
import { LockOutlined, UserOutlined } from '@ant-design/icons';
import { useAppStore } from '@/store/useAppStore';
import { useAccess } from '@/access/AccessProvider';
import { useAccess } from '@/access';
import { UButton, UForm, UFormItem, UInput, UTitle, UText } from '@uj/ui';
import type { RoleKey } from '@/access';
......@@ -46,7 +46,13 @@ export function LoginForm() {
欢迎登录
</UTitle>
<UText type="secondary">请输入账号信息以继续</UText>
<UForm form={form} layout="vertical" onFinish={onFinish} style={{ marginTop: 24 }} requiredMark={false}>
<UForm
form={form}
layout="vertical"
onFinish={onFinish}
style={{ marginTop: 24 }}
requiredMark={false}
>
<UFormItem name="account" label="账号" rules={[{ required: true, message: '请输入账号' }]}>
<UInput prefix={<UserOutlined />} placeholder="请输入账号" size="large" />
</UFormItem>
......
......@@ -64,11 +64,7 @@ export function ApproveTable({ tab, data }: { tab: string; data: ApproveRow[] })
fixed: 'right',
render: () => (
<>
<PermButton
permission={P.STORE_APPROVE_AUDIT}
type="link"
unauthorizedTip="无审批权限"
>
<PermButton permission={P.STORE_APPROVE_AUDIT} type="link" unauthorizedTip="无审批权限">
审核
</PermButton>
<Perm permission={P.STORE_APPROVE_VIEW}>
......@@ -90,6 +86,11 @@ export function ApproveTable({ tab, data }: { tab: string; data: ApproveRow[] })
}, [tab]);
return (
<FillTable<ApproveRow> rowKey="id" columns={columns} dataSource={data} pagination={{ pageSize: 10 }} />
<FillTable<ApproveRow>
rowKey="id"
columns={columns}
dataSource={data}
pagination={{ pageSize: 10 }}
/>
);
}
......@@ -35,7 +35,11 @@ export default function StoreApprove() {
<UInput placeholder="提交人" style={{ width: 140 }} />
</div>
<UTabs activeKey={tab} onChange={setTab} items={tabDefs.map((t) => ({ key: t.key, label: t.label }))} />
<UTabs
activeKey={tab}
onChange={setTab}
items={tabDefs.map((t) => ({ key: t.key, label: t.label }))}
/>
<div style={{ flex: 1, minHeight: 0 }}>
<ApproveTable tab={tab} data={EMPTY} />
......
// PRD §5.2 业务场景枚举(单选):售后会员权益升级 / 售前延保
export const SCENES = ['售后会员权益升级', '售前延保'];
// PRD §6.1 产品分类枚举(6 值)
export const CATEGORIES = ['太阳膜-原厂', '车衣-原厂', '精品-小桌板', '精品-脚垫', '踏板', '车衣-副厂'];
export const CATEGORIES = [
'太阳膜-原厂',
'车衣-原厂',
'精品-小桌板',
'精品-脚垫',
'踏板',
'车衣-副厂',
];
export interface ApproveRow {
id: string;
......
......@@ -479,7 +479,9 @@
position: relative;
overflow: hidden;
border-radius: 14px;
transition: transform 0.2s ease, box-shadow 0.2s ease;
transition:
transform 0.2s ease,
box-shadow 0.2s ease;
}
.uj-kpi:hover {
transform: translateY(-3px);
......@@ -579,4 +581,3 @@
grid-template-columns: 1fr;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!