@go-wind/admin-react 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin-react.css +1 -1
- package/dist/admin-react.js +32560 -1431
- package/dist/admin-react.js.map +1 -1
- package/dist/components/ListTable/ResizableHeaderCell.d.ts +31 -0
- package/dist/components/ListTable/TableSkeleton.d.ts +25 -0
- package/dist/components/ListTable/index.d.ts +20 -0
- package/dist/constants.d.ts +30 -0
- package/dist/hooks/useClipboard.d.ts +3 -0
- package/dist/hooks/useEcharts.d.ts +10 -0
- package/dist/hooks/useKeyStroke.d.ts +13 -0
- package/dist/hooks/usePageFullscreen.d.ts +9 -0
- package/dist/hooks/useWatermark.d.ts +20 -0
- package/dist/i18n/config/i18n.d.ts +2 -2
- package/dist/index.d.ts +7 -0
- package/package.json +9 -2
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ThHTMLAttributes } from 'react';
|
|
2
|
+
/** 拖拽调整列宽的下限(px),防止把一列拖没 */
|
|
3
|
+
export declare const MIN_COLUMN_WIDTH = 60;
|
|
4
|
+
/**
|
|
5
|
+
* ListTable 经 column.onHeaderCell 注入、随 rc-table 的 additionalProps 铺到表头 th 上的
|
|
6
|
+
* 拖拽参数。只有这些键会被本组件摘走,其余属性原样透传给 <th>(含排序注入的 onClick)。
|
|
7
|
+
*/
|
|
8
|
+
export interface ResizableCellProps {
|
|
9
|
+
'data-resize-key'?: string;
|
|
10
|
+
onResizeStart?: (info: {
|
|
11
|
+
key: string;
|
|
12
|
+
width: number;
|
|
13
|
+
allWidths: Record<string, number>;
|
|
14
|
+
containerWidth: number;
|
|
15
|
+
}) => void;
|
|
16
|
+
onResize?: (key: string, width: number) => void;
|
|
17
|
+
onResizeEnd?: () => void;
|
|
18
|
+
onResizeReset?: () => void;
|
|
19
|
+
resizing?: boolean;
|
|
20
|
+
resizeTitle?: string;
|
|
21
|
+
}
|
|
22
|
+
type HeaderCellProps = ResizableCellProps & ThHTMLAttributes<HTMLTableCellElement>;
|
|
23
|
+
/**
|
|
24
|
+
* 表头单元格的列宽拖拽把手。热区是列右缘的隐形 span:pointerdown 起 pointer capture 全程
|
|
25
|
+
* 接管指针(移出表头也不丢事件),按下时把当前表头行所有列的渲染宽度上报给 ListTable 做
|
|
26
|
+
* 「首拖锁定」,移动中持续回报新宽度,双击把手恢复自适应。
|
|
27
|
+
*
|
|
28
|
+
* 不引第三方库:react-resizable 年久失修不兼容 React 19,指针事件自持足够。
|
|
29
|
+
*/
|
|
30
|
+
export declare function ResizableHeaderCell(props: HeaderCellProps): import("react").JSX.Element;
|
|
31
|
+
export default ResizableHeaderCell;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { TableProps } from 'antd';
|
|
2
|
+
import type { ProColumns } from '@ant-design/pro-components';
|
|
3
|
+
export interface TableSkeletonProps<RecordType extends Record<string, any>> {
|
|
4
|
+
columns?: ProColumns<RecordType>[];
|
|
5
|
+
rows: number;
|
|
6
|
+
size?: TableProps<RecordType>['size'];
|
|
7
|
+
bordered?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* 横向 scroll:决定骨架的列宽能否与真实表格逐列对齐。
|
|
10
|
+
* 纵向 scroll:真实表格有它就必须一起接——那层限高 `.ant-table-body` 是分页器落点的决定者,
|
|
11
|
+
* 骨架少了它就只能按 rows 撑高,首屏→数据到位会让分页器整段跳动。
|
|
12
|
+
*/
|
|
13
|
+
scrollX?: number | string | true;
|
|
14
|
+
scrollY?: number | string;
|
|
15
|
+
pagination?: TableProps<RecordType>['pagination'];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 列表首屏骨架。
|
|
19
|
+
*
|
|
20
|
+
* 直接用 antd Table 当量具:表头底色、列宽、边框、字号、暗色 token 全部由页面自己的
|
|
21
|
+
* columns 与组件主题供给,占位条只替换单元格 render——自画一份灰块会跟真实表格对不齐,
|
|
22
|
+
* 尤其在有 fixed 列 / scroll.x / bordered 的页面上。
|
|
23
|
+
*/
|
|
24
|
+
export declare function TableSkeleton<RecordType extends Record<string, any>>({ columns, rows, size, bordered, scrollX, scrollY, pagination, }: TableSkeletonProps<RecordType>): import("react").JSX.Element;
|
|
25
|
+
export default TableSkeleton;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ProTableProps } from '@ant-design/pro-components';
|
|
2
|
+
import './list-table.css';
|
|
3
|
+
type ListTableProps<RecordType extends Record<string, any>, Params extends Record<string, any> = Record<string, any>> = ProTableProps<RecordType, Params>;
|
|
4
|
+
/**
|
|
5
|
+
* 列表页统一表格:在 ProTable 之上补四件页面各自都没有的事——首屏骨架屏(按页面 columns 生成,
|
|
6
|
+
* 受偏好设置 transition.loading 控制)、快响应不闪的 Spin(delay)、请求失败的错误态与重试、
|
|
7
|
+
* 以及**高度自动撑满**。
|
|
8
|
+
*
|
|
9
|
+
* 高度契约(2026-10-22 起):页面不传 scroll.y 时,本组件自动接管撑满——内部测量容器
|
|
10
|
+
* (.listtable-fill)+ useProTableScrollY 把分页器钉在容器底,要求外层是 ContentContainer
|
|
11
|
+
* 这类 flex 列容器(非 flex 父级时自动退回自然高度,Drawer 内嵌表等场景不误伤)。
|
|
12
|
+
* 页面显式传了 scroll.y 则完全尊重(历史页面的手写样板照常工作,新页面不要再写)。
|
|
13
|
+
* 页面只需:<ContentContainer><ListTable …/></ContentContainer>。
|
|
14
|
+
*
|
|
15
|
+
* 页面把 `<ProTable>` 换成 `<ListTable>` 即可,request / columns / actionRef 用法不变。
|
|
16
|
+
*/
|
|
17
|
+
export declare function ListTable<RecordType extends Record<string, any>, Params extends Record<string, any> = Record<string, any>>(props: ListTableProps<RecordType, Params> & {
|
|
18
|
+
striped?: boolean;
|
|
19
|
+
}): import("react").JSX.Element;
|
|
20
|
+
export default ListTable;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 表格通用默认配置(自 go-wind-admin 的 config/constants.TABLE 迁入——
|
|
3
|
+
* ListTable 的默认分页/高度/滚动参数,宿主可在组件 props 层覆盖具体值)。
|
|
4
|
+
*/
|
|
5
|
+
export declare const TABLE: {
|
|
6
|
+
/** 默认每页条数 */
|
|
7
|
+
readonly DEFAULT_PAGE_SIZE: 20;
|
|
8
|
+
/** 每页条数选项 */
|
|
9
|
+
readonly PAGE_SIZE_OPTIONS: readonly ["10", "20", "50", "100"];
|
|
10
|
+
/** 最大每页条数 */
|
|
11
|
+
readonly MAX_PAGE_SIZE: 100;
|
|
12
|
+
/** 表格组件内部高度 */
|
|
13
|
+
readonly COMPONENT_HEIGHTS: {
|
|
14
|
+
/** 工具栏高度 */
|
|
15
|
+
readonly TOOLBAR: 50;
|
|
16
|
+
/** 分页器高度 */
|
|
17
|
+
readonly PAGINATION: 50;
|
|
18
|
+
/** 表头高度 */
|
|
19
|
+
readonly HEADER: 50;
|
|
20
|
+
/** 搜索表单高度(展开时) */
|
|
21
|
+
readonly SEARCH_FORM: 80;
|
|
22
|
+
};
|
|
23
|
+
/** 表格滚动配置 */
|
|
24
|
+
readonly SCROLL_CONFIG: {
|
|
25
|
+
/** 默认最小高度 */
|
|
26
|
+
readonly MIN_HEIGHT: 300;
|
|
27
|
+
/** 额外边距 */
|
|
28
|
+
readonly OFFSET: 16;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as echarts from 'echarts/core';
|
|
2
|
+
import type { BarSeriesOption, GaugeSeriesOption, LineSeriesOption, PictorialBarSeriesOption, PieSeriesOption, RadarSeriesOption, ScatterSeriesOption } from 'echarts/charts';
|
|
3
|
+
import type { DatasetComponentOption, GridComponentOption, LegendComponentOption, TitleComponentOption, ToolboxComponentOption, TooltipComponentOption } from 'echarts/components';
|
|
4
|
+
export type ECOption = echarts.ComposeOption<BarSeriesOption | LineSeriesOption | PieSeriesOption | ScatterSeriesOption | PictorialBarSeriesOption | RadarSeriesOption | GaugeSeriesOption | TitleComponentOption | LegendComponentOption | TooltipComponentOption | GridComponentOption | ToolboxComponentOption | DatasetComponentOption>;
|
|
5
|
+
/**
|
|
6
|
+
* 使用Echarts
|
|
7
|
+
* @param options - 绘制echarts的参数
|
|
8
|
+
* @param data - 数据
|
|
9
|
+
*/
|
|
10
|
+
export declare const useEcharts: (options: echarts.EChartsCoreOption, data?: unknown) => readonly [import("react").RefObject<HTMLDivElement | null>, import("react").RefObject<echarts.ECharts | null>];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface Options {
|
|
2
|
+
ArrowUp?: () => void;
|
|
3
|
+
ArrowDown?: () => void;
|
|
4
|
+
ArrowLeft?: () => void;
|
|
5
|
+
ArrowRight?: () => void;
|
|
6
|
+
Enter?: () => void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* 键盘按键事件
|
|
10
|
+
* @param options
|
|
11
|
+
*/
|
|
12
|
+
export declare function useKeyStroke(options: Options): readonly [(even: KeyboardEvent) => void];
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 页面级全屏:元素 fullscreen + 进入时补页面底色(fullscreen 元素默认透出 UA 黑底)。
|
|
3
|
+
* 退出(含 ESC)由 fullscreenchange 事件驱动清理内联底色。
|
|
4
|
+
*/
|
|
5
|
+
export declare function usePageFullscreen<T extends HTMLElement>(): {
|
|
6
|
+
rootRef: import("react").RefObject<T | null>;
|
|
7
|
+
isFullscreen: boolean;
|
|
8
|
+
toggle: () => void;
|
|
9
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
interface Option {
|
|
2
|
+
content: string;
|
|
3
|
+
height: number;
|
|
4
|
+
width: number;
|
|
5
|
+
rotate: number;
|
|
6
|
+
color: string;
|
|
7
|
+
fontSize: number;
|
|
8
|
+
opacity: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 水印
|
|
12
|
+
*
|
|
13
|
+
* @deprecated 此 hook 当前在全项目内无任何调用方,且实现存在隐患:
|
|
14
|
+
* 1) 未监听 window resize,窗口尺寸变化后水印不会重绘;
|
|
15
|
+
* 2) 尺寸基于 document.body 计算,body 高度为 0 时(如路由切换瞬间)覆盖不全;
|
|
16
|
+
* 3) 作为普通函数而非 React hook,调用方需自行管理生命周期。
|
|
17
|
+
* 启用前请先补全上述问题,否则按需删除。
|
|
18
|
+
*/
|
|
19
|
+
export declare function useWatermark(): readonly [(options: Option) => void, () => void];
|
|
20
|
+
export {};
|
|
@@ -4,8 +4,8 @@ import { type SupportedLocale } from '../../locales';
|
|
|
4
4
|
* 文案 = 包内置框架命名空间(coreResources)+ 宿主业务命名空间合并后传入。
|
|
5
5
|
*/
|
|
6
6
|
export interface InitI18nOptions {
|
|
7
|
-
/** 合并后的完整语言资源(语言 -> 命名空间 ->
|
|
8
|
-
resources: Record<string,
|
|
7
|
+
/** 合并后的完整语言资源(语言 -> 命名空间 -> 文案;i18next Resource 兼容形状) */
|
|
8
|
+
resources: Record<string, unknown>;
|
|
9
9
|
/** 全部命名空间列表(一般取 merged['zh-CN'] 的键) */
|
|
10
10
|
namespaces: string[];
|
|
11
11
|
/** 支持的语言列表(默认 zh-CN/en-US) */
|
package/dist/index.d.ts
CHANGED
|
@@ -30,5 +30,12 @@ export * from './hooks/useTokenRefresh';
|
|
|
30
30
|
export * from './hooks/useTitle';
|
|
31
31
|
export * from './hooks/useTime';
|
|
32
32
|
export * from './hooks/useProTableScrollY';
|
|
33
|
+
export * from './hooks/useClipboard';
|
|
34
|
+
export * from './hooks/useKeyStroke';
|
|
35
|
+
export * from './hooks/usePageFullscreen';
|
|
36
|
+
export * from './hooks/useEcharts';
|
|
37
|
+
export * from './hooks/useWatermark';
|
|
33
38
|
export * from './utils';
|
|
39
|
+
export * from './constants';
|
|
40
|
+
export * from './components/ListTable';
|
|
34
41
|
export { default as ThemeLoading } from './components/Loading';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@go-wind/admin-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "React 19 admin shell mechanisms extracted from go-wind-admin: axios transport (token rotation/captcha headers), SSE client, auth store with injectable AuthGateway, route factory (frontend/backend access modes), access control, i18n engine, theme/preferences, query client, generic hooks & utils.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,18 +41,23 @@
|
|
|
41
41
|
"@microsoft/fetch-event-source": "^2.0.1",
|
|
42
42
|
"axios": "^1.16.1",
|
|
43
43
|
"dayjs": "^1.11.20",
|
|
44
|
+
"echarts": "^6.1.0",
|
|
45
|
+
"lodash": "^4.17.21",
|
|
44
46
|
"nprogress": "^0.2.0"
|
|
45
47
|
},
|
|
46
48
|
"devDependencies": {
|
|
47
49
|
"@ant-design/icons": "^5.6.1",
|
|
48
50
|
"@ant-design/pro-components": "^2.8.10",
|
|
49
51
|
"@tanstack/react-query": "^5.100.11",
|
|
52
|
+
"@testing-library/react": "^16.3.2",
|
|
53
|
+
"@types/lodash": "^4.17.21",
|
|
50
54
|
"@types/nprogress": "^0.2.3",
|
|
51
55
|
"@types/react": "^19.2.15",
|
|
52
56
|
"@types/react-dom": "^19.2.3",
|
|
53
57
|
"@vitejs/plugin-react": "^5.1.2",
|
|
54
58
|
"antd": "^6.4.3",
|
|
55
59
|
"i18next": "^26.2.0",
|
|
60
|
+
"jsdom": "^29.1.1",
|
|
56
61
|
"less": "^4.6.4",
|
|
57
62
|
"react": "^19.2.6",
|
|
58
63
|
"react-dom": "^19.2.6",
|
|
@@ -60,6 +65,7 @@
|
|
|
60
65
|
"react-router-dom": "^6.26.0",
|
|
61
66
|
"typescript": "^5.9.3",
|
|
62
67
|
"vite": "^8.0.0",
|
|
68
|
+
"vitest": "^4.1.6",
|
|
63
69
|
"zustand": "^5.0.13"
|
|
64
70
|
},
|
|
65
71
|
"publishConfig": {
|
|
@@ -68,6 +74,7 @@
|
|
|
68
74
|
},
|
|
69
75
|
"scripts": {
|
|
70
76
|
"build": "vite build && tsc -p tsconfig.build.json && node ../../scripts/flatten-dts.mjs",
|
|
71
|
-
"typecheck": "tsc --noEmit"
|
|
77
|
+
"typecheck": "tsc --noEmit",
|
|
78
|
+
"test": "vitest run"
|
|
72
79
|
}
|
|
73
80
|
}
|