@_tc/template-core 0.0.1-bate.37 → 0.0.1-bate.39
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/cjs/bundler/utils.js +13 -5
- package/cjs/packages/core/index.js +1 -1
- package/cjs/packages/core/loader/config.js +4 -2
- package/cjs/packages/core/loader/controller.js +2 -3
- package/cjs/packages/core/loader/extend.js +1 -2
- package/cjs/packages/core/loader/middleware.js +2 -3
- package/cjs/packages/core/loader/model.js +7 -3
- package/cjs/packages/core/loader/router-schema.js +4 -2
- package/cjs/packages/core/loader/router.js +10 -6
- package/cjs/packages/core/loader/service.js +2 -2
- package/cjs/packages/utils/runFileFn.js +46 -1
- package/esm/bundler/utils.js +13 -5
- package/esm/packages/core/index.js +1 -2
- package/esm/packages/core/loader/config.js +4 -3
- package/esm/packages/core/loader/controller.js +2 -4
- package/esm/packages/core/loader/extend.js +1 -3
- package/esm/packages/core/loader/middleware.js +2 -4
- package/esm/packages/core/loader/model.js +7 -4
- package/esm/packages/core/loader/router-schema.js +4 -3
- package/esm/packages/core/loader/router.js +10 -7
- package/esm/packages/core/loader/service.js +2 -3
- package/esm/packages/utils/runFileFn.js +47 -1
- package/fe/frontend/dash/Dashboard.js +11 -1
- package/fe/frontend/dash/dash.entry.js +19 -1
- package/fe/frontend/main.js +2 -0
- package/fe/frontend/widgets/common/CRUD/CRUD.js +1 -0
- package/fe/frontend/widgets/common/importComponent.js +1 -0
- package/fe/frontend/widgets/common/language.js +1 -0
- package/fe/frontend/widgets/common/menu.d.ts +12 -0
- package/fe/frontend/widgets/common/menu.js +21 -0
- package/fe/frontend/widgets/common/request.d.ts +3 -0
- package/fe/frontend/widgets/common/request.js +6 -0
- package/fe/frontend/widgets/components/BasePage/HeaderView.js +3 -1
- package/fe/frontend/widgets/defaultPages/Schema/components/CallCom/PopFrom.js +15 -0
- package/fe/frontend/widgets/defaultPages/Schema/components/SchemaSearch/index.js +5 -0
- package/fe/frontend/widgets/defaultPages/Schema/components/SchemaTable/index.js +13 -1
- package/fe/frontend/widgets/defaultPages/Schema/data/eventInfo.js +4 -4
- package/fe/frontend/widgets/defaultPages/Schema/index.js +7 -0
- package/fe/frontend/widgets/defaultPages/Schema/schemaType.d.ts +9 -0
- package/fe/frontend/widgets/defaultPages/Schema/stores/schemaEventBus.d.ts +19 -0
- package/fe/frontend/widgets/defaultPages/Schema/stores/schemaEventBus.js +4 -0
- package/fe/frontend/widgets/defaultPages/Schema/stores/schemaStore.d.ts +14 -0
- package/fe/frontend/widgets/defaultPages/Schema/stores/schemaStore.js +2 -0
- package/fe/frontend/widgets/defaultPages/Schema/utils/schemaConversion.js +43 -0
- package/fe/frontend/widgets/defaultPages/Schema/utils/validator.d.ts +3 -0
- package/fe/frontend/widgets/defaultPages/Schema/utils/validator.js +5 -0
- package/fe/frontend/widgets/defaultPages/SidebarSlotPage/SidebarSlotContainer.js +7 -0
- package/fe/frontend/widgets/defaultPages/SidebarSlotPage/index.js +1 -0
- package/fe/frontend/widgets/defaultPages/SlotPage/index.js +2 -0
- package/fe/frontend/widgets/hooks/useCurrentMenuData.d.ts +8 -0
- package/fe/frontend/widgets/hooks/useCurrentMenuData.js +8 -0
- package/fe/frontend/widgets/store/mode.d.ts +3 -0
- package/fe/frontend/widgets/store/mode.js +1 -0
- package/fe/model/types/data/button.d.ts +9 -0
- package/fe/model/types/data/button.js +15 -0
- package/fe/model/types/data/component.d.ts +24 -0
- package/fe/model/types/data/component.js +10 -0
- package/fe/model/types/data/fetchInfo.d.ts +12 -0
- package/fe/model/types/data/schema.d.ts +51 -0
- package/fe/model/types/menuType.d.ts +29 -0
- package/fe/model/types/model.d.ts +13 -0
- package/fe/packages/common/i18n/default.d.ts +5 -0
- package/fe/packages/common/i18n/default.js +5 -0
- package/fe/packages/common/i18n/en-US.d.ts +5 -0
- package/fe/packages/common/i18n/en-US.js +5 -0
- package/fe/packages/common/i18n/index.d.ts +24 -0
- package/fe/packages/common/i18n/index.js +31 -0
- package/fe/packages/common/i18n/types.d.ts +24 -0
- package/fe/packages/ui/react/components/Button/Button.d.ts +33 -0
- package/fe/packages/ui/react/components/Button/Button.js +3 -0
- package/fe/packages/ui/react/components/Button/SumbitButton.d.ts +4 -0
- package/fe/packages/ui/react/components/Button/SumbitButton.js +4 -0
- package/fe/packages/ui/react/components/ConfirmDialog/ConfirmDialog.d.ts +8 -0
- package/fe/packages/ui/react/components/DataTable/index.d.ts +19 -0
- package/fe/packages/ui/react/components/DataTable/index.js +4 -0
- package/fe/packages/ui/react/components/Date/Calendar.d.ts +13 -0
- package/fe/packages/ui/react/components/Date/Calendar.js +10 -1
- package/fe/packages/ui/react/components/Date/Date.d.ts +11 -0
- package/fe/packages/ui/react/components/Date/Date.js +19 -0
- package/fe/packages/ui/react/components/Date/LocaleContext.d.ts +4 -0
- package/fe/packages/ui/react/components/Date/LocaleContext.js +4 -0
- package/fe/packages/ui/react/components/Date/LocaleProvider.d.ts +11 -0
- package/fe/packages/ui/react/components/Date/LocaleProvider.js +11 -0
- package/fe/packages/ui/react/components/Date/TimePicker.js +1 -0
- package/fe/packages/ui/react/components/Date/dateLocaleStore.d.ts +6 -0
- package/fe/packages/ui/react/components/Date/locales.d.ts +19 -0
- package/fe/packages/ui/react/components/Date/locales.js +9 -0
- package/fe/packages/ui/react/components/Drawer/Drawer.d.ts +6 -0
- package/fe/packages/ui/react/components/Dropdown/Dropdown.d.ts +1 -0
- package/fe/packages/ui/react/components/Form/Form.d.ts +6 -0
- package/fe/packages/ui/react/components/Form/FormItem.d.ts +21 -0
- package/fe/packages/ui/react/components/Form/FormItem.js +8 -1
- package/fe/packages/ui/react/components/Form/SchemaForm/data.js +1 -0
- package/fe/packages/ui/react/components/Form/SchemaForm/index.d.ts +93 -0
- package/fe/packages/ui/react/components/Form/SchemaForm/index.js +5 -1
- package/fe/packages/ui/react/components/ImagePreview/ImagePreview.js +8 -0
- package/fe/packages/ui/react/components/ImagePreview/PreviewImage.d.ts +3 -0
- package/fe/packages/ui/react/components/Input/Input.d.ts +22 -0
- package/fe/packages/ui/react/components/Input/Input.js +3 -0
- package/fe/packages/ui/react/components/InputNumber/InputNumber.d.ts +2 -0
- package/fe/packages/ui/react/components/Label/Label.d.ts +29 -0
- package/fe/packages/ui/react/components/Label/Label.js +2 -0
- package/fe/packages/ui/react/components/Menu/Menu.js +4 -0
- package/fe/packages/ui/react/components/Menu/SubMenu.d.ts +7 -0
- package/fe/packages/ui/react/components/Menu/SubMenu.js +46 -1
- package/fe/packages/ui/react/components/Menu/menuTypes.d.ts +1 -0
- package/fe/packages/ui/react/components/Message/Message.d.ts +7 -0
- package/fe/packages/ui/react/components/Message/Message.js +3 -0
- package/fe/packages/ui/react/components/Message/MessageManager.js +8 -0
- package/fe/packages/ui/react/components/Modal/Modal.d.ts +6 -0
- package/fe/packages/ui/react/components/Modal/Modal.js +1 -0
- package/fe/packages/ui/react/components/Modal/ModalManager.d.ts +12 -0
- package/fe/packages/ui/react/components/Modal/ModalManager.js +4 -1
- package/fe/packages/ui/react/components/Overlay/Overlay.d.ts +3 -0
- package/fe/packages/ui/react/components/Pagination/Pagination.d.ts +7 -0
- package/fe/packages/ui/react/components/Pagination/Pagination.js +8 -1
- package/fe/packages/ui/react/components/Popup/Popup.js +14 -2
- package/fe/packages/ui/react/components/Search/Search.d.ts +3 -0
- package/fe/packages/ui/react/components/Select/Select.d.ts +5 -0
- package/fe/packages/ui/react/components/Select/Select.js +4 -0
- package/fe/packages/ui/react/components/Skeleton/Skeleton.d.ts +15 -0
- package/fe/packages/ui/react/components/Skeleton/Skeleton.js +1 -1
- package/fe/packages/ui/react/components/TableSearch/TableSearch.d.ts +37 -0
- package/fe/packages/ui/react/components/TableSearch/TableSearch.js +4 -1
- package/fe/packages/ui/react/components/Textarea/Textarea.d.ts +46 -0
- package/fe/packages/ui/react/components/Textarea/Textarea.js +1 -0
- package/fe/packages/ui/react/components/Tooltip/Tooltip.d.ts +16 -0
- package/fe/packages/ui/react/components/Tooltip/Tooltip.js +8 -0
- package/fe/packages/ui/react/components/TreeSelect/TreeSelect.d.ts +6 -0
- package/fe/packages/ui/react/components/TreeSelect/TreeSelect.js +6 -0
- package/fe/packages/ui/react/components/Upload/Upload.d.ts +27 -0
- package/fe/packages/ui/react/components/breadcrumb/breadcrumb.js +9 -0
- package/fe/packages/ui/react/components/hooks/useDropdownPositioning.d.ts +6 -0
- package/fe/packages/ui/react/components/hooks/useDropdownPositioning.js +14 -0
- package/fe/packages/ui/react/components/hooks/useInputController.d.ts +3 -0
- package/fe/packages/ui/react/components/hooks/useInputController.js +7 -0
- package/fe/packages/ui/react/components/testPage/MenuTestPage.js +3 -0
- package/fe/packages/ui/react/components/testPage/index.js +26 -0
- package/fe/packages/ui/react/hooks/useExecuteOnce.d.ts +19 -1
- package/fe/packages/ui/react/hooks/useExecuteOnce.js +22 -1
- package/fe/packages/ui/react/hooks/useRefState.d.ts +12 -0
- package/fe/packages/ui/react/hooks/useRefState.js +1 -0
- package/fe/packages/ui/react/hooks/useWatch.d.ts +8 -0
- package/fe/packages/ui/react/i18n/I18nProvider.d.ts +18 -0
- package/fe/packages/ui/react/i18n/useI18n.d.ts +4 -0
- package/fe/packages/ui/react/i18n/useI18n.js +4 -0
- package/fe/packages/ui/react/index.js +2 -0
- package/fe/packages/ui/react/lib/export.d.ts +44 -0
- package/fe/packages/ui/react/lib/export.js +40 -0
- package/fe/packages/ui/react/lib/utils.d.ts +24 -0
- package/fe/packages/ui/react/lib/utils.js +25 -0
- package/fe/packages/ui/react/stores/breadcrumb.js +2 -0
- package/model/index.d.ts +2 -0
- package/model/types/data/button.d.ts +32 -0
- package/model/types/data/component.d.ts +61 -0
- package/model/types/data/fetchInfo.d.ts +20 -0
- package/model/types/data/schema.d.ts +98 -0
- package/model/types/data/search.d.ts +7 -0
- package/model/types/index.d.ts +2 -0
- package/model/types/menuType.d.ts +73 -0
- package/model/types/model.d.ts +33 -0
- package/model/types/test.d.ts +2 -0
- package/package.json +10 -7
- package/types/packages/utils/runFileFn.d.ts +5 -3
|
@@ -10,7 +10,12 @@ const SidebarSlotContainer = (props) => {
|
|
|
10
10
|
const params = useRouterParams();
|
|
11
11
|
const [SK, uSK] = useState(params[QK.sk]);
|
|
12
12
|
const nav = useNavigate();
|
|
13
|
+
// menu 初始化选中
|
|
13
14
|
useEffect(() => {
|
|
15
|
+
/**
|
|
16
|
+
* 如果没有 sidebar key 说明当前是 自定义路由
|
|
17
|
+
* 则需要获取 query 中的 ck 来查找 menuinfo
|
|
18
|
+
*/
|
|
14
19
|
if (!params[QK.sk]) {
|
|
15
20
|
if (params[QK.ck]) {
|
|
16
21
|
const m = findMenuItem(rawMenuData, params[QK.ck]);
|
|
@@ -19,6 +24,8 @@ const SidebarSlotContainer = (props) => {
|
|
|
19
24
|
return;
|
|
20
25
|
}
|
|
21
26
|
}
|
|
27
|
+
// 运行到这 说明
|
|
28
|
+
// 异常路径
|
|
22
29
|
logPageNotFound();
|
|
23
30
|
}
|
|
24
31
|
}, [rawMenuData, params]);
|
|
@@ -7,6 +7,7 @@ import { useParams } from "react-router-dom";
|
|
|
7
7
|
import SidebarSlotContainer from "./SidebarSlotContainer";
|
|
8
8
|
const SidebarSlotPage = () => {
|
|
9
9
|
const params = useParams();
|
|
10
|
+
// top left 从当前路由中获取到 sidebarConfig中的数据
|
|
10
11
|
const { menu: parentMenuInfo } = useCurrentMenuData();
|
|
11
12
|
const prefixPath = useMemo(() => `/${params[QK.k]}`, [params[QK.k]]);
|
|
12
13
|
const menuItem = generateMenuItemData(parentMenuInfo?.sidebarConfig?.menu ?? []);
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { BasicModuleType, SidebarModuleType } from "../../../model/types/menuType";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* 自定义路由直接交由路由器渲染
|
|
5
|
+
*
|
|
6
|
+
* 也就是说 这里找不到 自定义相关的菜单数据
|
|
7
|
+
*
|
|
8
|
+
* @param useSibe 使用侧边数据
|
|
9
|
+
*/
|
|
2
10
|
declare const useCurrentMenuData: <T = {
|
|
3
11
|
moduleType: BasicModuleType["moduleType"];
|
|
4
12
|
sidebarConfig: SidebarModuleType["sidebarConfig"];
|
|
@@ -2,6 +2,14 @@ import { findMenuItem, QK } from "../../widgets/common/menu";
|
|
|
2
2
|
import { useModeStore } from "../../widgets/store/mode";
|
|
3
3
|
import { useMemo } from "react";
|
|
4
4
|
import { useParams } from "react-router-dom";
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* 自定义路由直接交由路由器渲染
|
|
8
|
+
*
|
|
9
|
+
* 也就是说 这里找不到 自定义相关的菜单数据
|
|
10
|
+
*
|
|
11
|
+
* @param useSibe 使用侧边数据
|
|
12
|
+
*/
|
|
5
13
|
const useCurrentMenuData = (useSibe = false) => {
|
|
6
14
|
const params = useParams();
|
|
7
15
|
const projestInfo = useModeStore((s) => s.projestInfo);
|
|
@@ -3,6 +3,7 @@ import { deserializationUrlSearch } from '../../widgets/common/menu';
|
|
|
3
3
|
import { createStoreHook } from '../../../packages/ui/react/lib/createStoreHook';
|
|
4
4
|
import { createStore } from 'zustand';
|
|
5
5
|
import { setApiAuth } from '../common/auth';
|
|
6
|
+
// create Store 可在任意地方使用
|
|
6
7
|
export const modeStore = createStore((set, get) => ({
|
|
7
8
|
modeList: [],
|
|
8
9
|
projestInfo: null,
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import type { ButtonProps } from '../../../packages/ui/react';
|
|
2
2
|
import { ComponentNames } from './component';
|
|
3
3
|
type ButtonTemplates = {
|
|
4
|
+
/**
|
|
5
|
+
* 按钮名
|
|
6
|
+
*/
|
|
4
7
|
label?: string;
|
|
5
8
|
} & ButtonProps;
|
|
6
9
|
type ParamsValueData = 'schema::tableKey' | string | number;
|
|
7
10
|
type RemoveBtn = {
|
|
8
11
|
eventKey: 'remove';
|
|
12
|
+
/**
|
|
13
|
+
* 事件配置 (参数配置)
|
|
14
|
+
*/
|
|
9
15
|
eventOption: {
|
|
10
16
|
params: {
|
|
17
|
+
/**
|
|
18
|
+
* @example user_id: 'schema::tableKey' | '123' | 123
|
|
19
|
+
*/
|
|
11
20
|
[paramKey: string]: ParamsValueData;
|
|
12
21
|
};
|
|
13
22
|
};
|
|
@@ -1 +1,16 @@
|
|
|
1
1
|
export {};
|
|
2
|
+
// & {
|
|
3
|
+
// /**
|
|
4
|
+
// * 按钮事件名
|
|
5
|
+
// */
|
|
6
|
+
// eventKey: 'romve' | 'showComponent';
|
|
7
|
+
// /**
|
|
8
|
+
// * 事件配置 (参数配置)
|
|
9
|
+
// */
|
|
10
|
+
// params: {
|
|
11
|
+
// /**
|
|
12
|
+
// * @example user_id: 'schema::tableKey' | '123' | 123
|
|
13
|
+
// */
|
|
14
|
+
// [paramKey: string]: ParamsValueData;
|
|
15
|
+
// };
|
|
16
|
+
// };
|
|
@@ -2,22 +2,46 @@ import { FormItemProps, InputNumberProps, InputProps, SelectProps } from '../../
|
|
|
2
2
|
import { FetchInfo } from './fetchInfo';
|
|
3
3
|
export type ComponentConfig = {
|
|
4
4
|
createForm?: {
|
|
5
|
+
/**
|
|
6
|
+
* 表单标题
|
|
7
|
+
*/
|
|
5
8
|
title: string;
|
|
9
|
+
/**
|
|
10
|
+
* 保存按钮文案
|
|
11
|
+
*/
|
|
6
12
|
saveBtnText?: string;
|
|
7
13
|
} & Pick<FetchInfo, 'fetchConfig'>;
|
|
8
14
|
editForm?: {
|
|
15
|
+
/**
|
|
16
|
+
* 表单标题
|
|
17
|
+
*/
|
|
9
18
|
title: string;
|
|
19
|
+
/**
|
|
20
|
+
* 保存按钮文案
|
|
21
|
+
*/
|
|
10
22
|
saveBtnText?: string;
|
|
11
23
|
} & FetchInfo;
|
|
12
24
|
detailPanel?: {
|
|
25
|
+
/**
|
|
26
|
+
* 表单标题
|
|
27
|
+
*/
|
|
13
28
|
title: string;
|
|
14
29
|
} & FetchInfo;
|
|
15
30
|
};
|
|
16
31
|
export type ComponentNames = keyof ComponentConfig;
|
|
17
32
|
export type ComponentsOption = {
|
|
18
33
|
createForm: FormItemProps & {
|
|
34
|
+
/**
|
|
35
|
+
* 是否展示 默认为true
|
|
36
|
+
*/
|
|
19
37
|
visible?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* 是否禁用
|
|
40
|
+
*/
|
|
20
41
|
disbaled?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* 默认值
|
|
44
|
+
*/
|
|
21
45
|
default?: any;
|
|
22
46
|
} & ComponentOption;
|
|
23
47
|
editForm: ComponentsOption['createForm'];
|
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
export type FetchInfo = {
|
|
2
|
+
/**
|
|
3
|
+
* 表单主键, 获取数据源的key
|
|
4
|
+
*/
|
|
2
5
|
fetchKey: string;
|
|
6
|
+
/**
|
|
7
|
+
* 请求配置 如果不配置则使用 统一的 [get] api 内容
|
|
8
|
+
*/
|
|
3
9
|
fetchConfig?: {
|
|
10
|
+
/**
|
|
11
|
+
* 获取数据的
|
|
12
|
+
*/
|
|
4
13
|
url: string;
|
|
14
|
+
/**
|
|
15
|
+
* 请求方式
|
|
16
|
+
*/
|
|
5
17
|
method?: 'get' | 'post';
|
|
6
18
|
};
|
|
7
19
|
};
|
|
@@ -6,17 +6,35 @@ import { ComponentConfig, ComponentNames, ComponentsOption } from './component';
|
|
|
6
6
|
import { SearchOption } from './search';
|
|
7
7
|
export type TableColumnsSchema = {
|
|
8
8
|
tableOption?: MOmit<TableColumnDef, 'key' | 'title'> & {
|
|
9
|
+
/**
|
|
10
|
+
* 是否显示
|
|
11
|
+
*/
|
|
9
12
|
visible?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* 保留几位小数
|
|
15
|
+
*/
|
|
10
16
|
toFixed?: number;
|
|
11
17
|
};
|
|
12
18
|
};
|
|
13
19
|
export type TableSearchOption = {
|
|
20
|
+
/**
|
|
21
|
+
* 不配置则不在 search 中显示
|
|
22
|
+
*/
|
|
14
23
|
searchOption?: {
|
|
24
|
+
/**
|
|
25
|
+
* 控件默认值
|
|
26
|
+
*/
|
|
15
27
|
default?: any;
|
|
16
28
|
} & SearchOption;
|
|
17
29
|
};
|
|
18
30
|
export type TableConfig = {
|
|
31
|
+
/**
|
|
32
|
+
* table 头部按钮
|
|
33
|
+
*/
|
|
19
34
|
headerButtons?: BaseButton[];
|
|
35
|
+
/**
|
|
36
|
+
* 每一行的按钮
|
|
37
|
+
*/
|
|
20
38
|
rowButtons?: BaseButton[];
|
|
21
39
|
};
|
|
22
40
|
export type SearchConfig = {};
|
|
@@ -26,8 +44,19 @@ export type BaseOption<O> = {
|
|
|
26
44
|
export type UsedConfigSchema<T = {}> = {
|
|
27
45
|
type: 'object' | 'string' | 'array' | 'number' | 'boolean';
|
|
28
46
|
properties: {
|
|
47
|
+
/**
|
|
48
|
+
* [字段 key]: 字段描述
|
|
49
|
+
*/
|
|
29
50
|
[key: string]: T & MOmit<UsedConfigSchema, 'properties'> & {
|
|
51
|
+
/**
|
|
52
|
+
* 展示 字符
|
|
53
|
+
*/
|
|
30
54
|
label: string;
|
|
55
|
+
/**
|
|
56
|
+
* 原数据 序列化后 会丢失编写时的顺序
|
|
57
|
+
* 字段层级 默认10
|
|
58
|
+
*
|
|
59
|
+
*/
|
|
31
60
|
level?: number;
|
|
32
61
|
};
|
|
33
62
|
};
|
|
@@ -38,10 +67,32 @@ export type TableComponentConfig = {
|
|
|
38
67
|
};
|
|
39
68
|
export type ConfigSchema = UsedConfigSchema<TableColumnsSchema & TableSearchOption & TableComponentConfig>;
|
|
40
69
|
export interface SchemaDataType {
|
|
70
|
+
/**
|
|
71
|
+
* 数据源地址 遵循 RESTFUL 规范
|
|
72
|
+
* *[参考地址](https://www.ruanyifeng.com/blog/2014/05/restful_api.html)*
|
|
73
|
+
*
|
|
74
|
+
* 即:
|
|
75
|
+
*
|
|
76
|
+
* - 获取数据 GET [api]
|
|
77
|
+
* - 新增数据 POST [api]
|
|
78
|
+
* - ...
|
|
79
|
+
*/
|
|
41
80
|
api: string;
|
|
81
|
+
/**
|
|
82
|
+
* 板块数据结构
|
|
83
|
+
*/
|
|
42
84
|
schema?: ConfigSchema;
|
|
85
|
+
/**
|
|
86
|
+
* 表格 (展示) 配置
|
|
87
|
+
*/
|
|
43
88
|
tableConfig?: TableConfig;
|
|
89
|
+
/**
|
|
90
|
+
* 搜索 配置
|
|
91
|
+
*/
|
|
44
92
|
searchConfig?: SearchConfig;
|
|
93
|
+
/**
|
|
94
|
+
* 模块组件
|
|
95
|
+
*/
|
|
45
96
|
componentConfig?: ComponentConfig;
|
|
46
97
|
}
|
|
47
98
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { SchemaDataType } from "./data/schema";
|
|
2
|
+
/**
|
|
3
|
+
* - parent menuLaout === 'top'
|
|
4
|
+
* - child menuLayout === 'top' | 'left'
|
|
5
|
+
* - parent menuLayout === 'left'
|
|
6
|
+
* - child menuLayout === 'left'
|
|
7
|
+
*/
|
|
2
8
|
export type MenuLayout = "left" | "top";
|
|
3
9
|
interface BaseMenu {
|
|
4
10
|
key: string;
|
|
5
11
|
icon?: string;
|
|
12
|
+
/**
|
|
13
|
+
* 菜单名称
|
|
14
|
+
*/
|
|
6
15
|
name: string;
|
|
7
16
|
}
|
|
8
17
|
interface GroupMenuType<T extends MenuLayout> extends BaseMenu {
|
|
@@ -12,15 +21,26 @@ interface GroupMenuType<T extends MenuLayout> extends BaseMenu {
|
|
|
12
21
|
interface ModuleMenuType extends BaseMenu {
|
|
13
22
|
menuType: "module";
|
|
14
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* ----------------------------- moduletype -----------------------------
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
15
29
|
interface IframeModuleType {
|
|
16
30
|
moduleType: "iframe";
|
|
17
31
|
iframeConfig: {
|
|
32
|
+
/**
|
|
33
|
+
* iframe 路径
|
|
34
|
+
*/
|
|
18
35
|
path: string;
|
|
19
36
|
};
|
|
20
37
|
}
|
|
21
38
|
interface CustomModuleType {
|
|
22
39
|
moduleType: "custom";
|
|
23
40
|
customConfig: {
|
|
41
|
+
/**
|
|
42
|
+
* 自定义路由路径
|
|
43
|
+
*/
|
|
24
44
|
path: string;
|
|
25
45
|
};
|
|
26
46
|
}
|
|
@@ -32,13 +52,22 @@ export interface SidebarModuleType {
|
|
|
32
52
|
moduleType: "sidebar";
|
|
33
53
|
sidebarConfig: {
|
|
34
54
|
menu: BaseMenuType[];
|
|
55
|
+
/**
|
|
56
|
+
* 只能为left
|
|
57
|
+
*/
|
|
35
58
|
menuLayout?: "left";
|
|
36
59
|
};
|
|
37
60
|
}
|
|
38
61
|
export type BasicModuleType = SchemaModuleType | CustomModuleType | IframeModuleType;
|
|
39
62
|
export type BaseMenuType = GroupMenuType<"left"> | (ModuleMenuType & BasicModuleType);
|
|
40
63
|
type ModuleType = BasicModuleType | SidebarModuleType;
|
|
64
|
+
/**
|
|
65
|
+
* top 包含所有
|
|
66
|
+
*/
|
|
41
67
|
export type TopMenuType = GroupMenuType<"top"> | (ModuleMenuType & ModuleType);
|
|
68
|
+
/**
|
|
69
|
+
* left 不包含 sidebar
|
|
70
|
+
*/
|
|
42
71
|
export type LeftMenuType = GroupMenuType<"left"> | BaseMenuType;
|
|
43
72
|
export {};
|
|
44
73
|
//# sourceMappingURL=menuType.d.ts.map
|
|
@@ -1,19 +1,32 @@
|
|
|
1
1
|
import { TopMenuType, LeftMenuType } from "./menuType";
|
|
2
2
|
type MTopMenuType = {
|
|
3
|
+
/**
|
|
4
|
+
* 默认为 left
|
|
5
|
+
*/
|
|
3
6
|
menuLayout: "top";
|
|
4
7
|
menu: TopMenuType[];
|
|
5
8
|
};
|
|
6
9
|
type MLeftMenuType = {
|
|
10
|
+
/**
|
|
11
|
+
* 默认为 left
|
|
12
|
+
*/
|
|
7
13
|
menuLayout?: "left";
|
|
8
14
|
menu: LeftMenuType[];
|
|
9
15
|
};
|
|
10
16
|
export type ModeMenuType = MTopMenuType | MLeftMenuType;
|
|
11
17
|
export type ModelDataType = {
|
|
18
|
+
/**
|
|
19
|
+
* - 使用哪一块的模型数据 内置 MB
|
|
20
|
+
* - MB = 管理后台
|
|
21
|
+
*/
|
|
12
22
|
mode: "MB";
|
|
13
23
|
key?: string;
|
|
14
24
|
name: string;
|
|
15
25
|
desc: string;
|
|
16
26
|
icon: string;
|
|
27
|
+
/**
|
|
28
|
+
* 首页(项目配置)
|
|
29
|
+
*/
|
|
17
30
|
homePage: string;
|
|
18
31
|
} & ModeMenuType;
|
|
19
32
|
export {};
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI component library default English language resources.
|
|
3
|
+
*
|
|
4
|
+
* Only built-in component copy belongs here. Applications can override or extend it with I18nProvider.resources.
|
|
5
|
+
*/
|
|
1
6
|
export declare const defaultEnglishResources: {
|
|
2
7
|
readonly common: {
|
|
3
8
|
readonly tip: "Prompt";
|
|
@@ -2,10 +2,30 @@ import type { I18nDictionary, I18nInterpolationValues, I18nMessage, I18nResource
|
|
|
2
2
|
export * from './types';
|
|
3
3
|
export * from './locales';
|
|
4
4
|
export declare const isPlainI18nDictionary: (value: I18nMessage) => value is I18nDictionary;
|
|
5
|
+
/**
|
|
6
|
+
* 深合并单个语言包。
|
|
7
|
+
* 嵌套对象递归合并,字符串、数组、数字等叶子节点直接以 patch 覆盖 base。
|
|
8
|
+
*/
|
|
5
9
|
export declare const mergeI18nDictionary: (base?: I18nDictionary, patch?: I18nDictionary) => I18nDictionary;
|
|
10
|
+
/**
|
|
11
|
+
* 合并多语言资源。
|
|
12
|
+
* 结构示例:{ 'zh-CN': { common: { ok: '确定' } }, 'en-US': { common: { ok: 'OK' } } }
|
|
13
|
+
*/
|
|
6
14
|
export declare const mergeI18nResources: (base?: I18nResources, patch?: I18nResources) => I18nResources;
|
|
15
|
+
/**
|
|
16
|
+
* 根据点分 key 从语言包中取值。
|
|
17
|
+
* 例如 common.submit 会读取 resources[language].common.submit。
|
|
18
|
+
*/
|
|
7
19
|
export declare const getI18nPathValue: (dictionary: I18nDictionary | undefined, key: string) => I18nMessage | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* 替换文案中的插值占位符。
|
|
22
|
+
* 例如 "Hello, {name}" + { name: "Tom" } => "Hello, Tom"。
|
|
23
|
+
*/
|
|
8
24
|
export declare const interpolateI18nMessage: (value: string, data?: I18nInterpolationValues) => string;
|
|
25
|
+
/**
|
|
26
|
+
* 纯翻译函数:只依赖传入的 state。
|
|
27
|
+
* 优先级:指定语言 -> 兜底语言 -> options.fallback -> 原 key。
|
|
28
|
+
*/
|
|
9
29
|
export declare const translate: <T = string>(state: I18nTranslateState, key: string, fillingData?: I18nInterpolationValues, options?: I18nTranslateOptions) => T | string;
|
|
10
30
|
export declare const i18nStore: {
|
|
11
31
|
getState: () => I18nStore;
|
|
@@ -13,6 +33,10 @@ export declare const i18nStore: {
|
|
|
13
33
|
setState: (partial: Partial<I18nStore> | ((state: I18nStore) => Partial<I18nStore>)) => void;
|
|
14
34
|
subscribe: (listener: I18nStoreListener) => () => void;
|
|
15
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* 对外使用的 i18n 函数。
|
|
38
|
+
* 每次调用都会读取最新 state,适合在非 React 代码中直接使用。
|
|
39
|
+
*/
|
|
16
40
|
export declare const i18n: <T = string>(key: string, fillingData?: I18nInterpolationValues, options?: I18nTranslateOptions) => string | T;
|
|
17
41
|
export declare const t: <T = string>(key: string, fillingData?: I18nInterpolationValues, options?: I18nTranslateOptions) => string | T;
|
|
18
42
|
export declare const getLanguage: <T = string>(key: string, fillingData?: I18nInterpolationValues, options?: I18nTranslateOptions) => string | T;
|
|
@@ -4,6 +4,10 @@ export * from './locales';
|
|
|
4
4
|
export const isPlainI18nDictionary = (value) => {
|
|
5
5
|
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* 深合并单个语言包。
|
|
9
|
+
* 嵌套对象递归合并,字符串、数组、数字等叶子节点直接以 patch 覆盖 base。
|
|
10
|
+
*/
|
|
7
11
|
export const mergeI18nDictionary = (base = {}, patch = {}) => {
|
|
8
12
|
const next = { ...base };
|
|
9
13
|
Object.entries(patch).forEach(([key, value]) => {
|
|
@@ -16,6 +20,10 @@ export const mergeI18nDictionary = (base = {}, patch = {}) => {
|
|
|
16
20
|
});
|
|
17
21
|
return next;
|
|
18
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* 合并多语言资源。
|
|
25
|
+
* 结构示例:{ 'zh-CN': { common: { ok: '确定' } }, 'en-US': { common: { ok: 'OK' } } }
|
|
26
|
+
*/
|
|
19
27
|
export const mergeI18nResources = (base = {}, patch = {}) => {
|
|
20
28
|
const next = { ...base };
|
|
21
29
|
Object.entries(patch).forEach(([language, messages]) => {
|
|
@@ -25,6 +33,10 @@ export const mergeI18nResources = (base = {}, patch = {}) => {
|
|
|
25
33
|
});
|
|
26
34
|
return next;
|
|
27
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* 根据点分 key 从语言包中取值。
|
|
38
|
+
* 例如 common.submit 会读取 resources[language].common.submit。
|
|
39
|
+
*/
|
|
28
40
|
export const getI18nPathValue = (dictionary, key) => {
|
|
29
41
|
if (!dictionary)
|
|
30
42
|
return undefined;
|
|
@@ -34,6 +46,10 @@ export const getI18nPathValue = (dictionary, key) => {
|
|
|
34
46
|
return value[currentKey];
|
|
35
47
|
}, dictionary);
|
|
36
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* 替换文案中的插值占位符。
|
|
51
|
+
* 例如 "Hello, {name}" + { name: "Tom" } => "Hello, Tom"。
|
|
52
|
+
*/
|
|
37
53
|
export const interpolateI18nMessage = (value, data) => {
|
|
38
54
|
if (!data)
|
|
39
55
|
return value;
|
|
@@ -42,6 +58,10 @@ export const interpolateI18nMessage = (value, data) => {
|
|
|
42
58
|
return typeof nextValue === 'undefined' || nextValue === null ? match : String(nextValue);
|
|
43
59
|
});
|
|
44
60
|
};
|
|
61
|
+
/**
|
|
62
|
+
* 纯翻译函数:只依赖传入的 state。
|
|
63
|
+
* 优先级:指定语言 -> 兜底语言 -> options.fallback -> 原 key。
|
|
64
|
+
*/
|
|
45
65
|
export const translate = (state, key, fillingData, options) => {
|
|
46
66
|
const language = options?.language || state.language;
|
|
47
67
|
const fallbackLanguage = options?.fallbackLanguage || state.fallbackLanguage;
|
|
@@ -54,6 +74,10 @@ export const translate = (state, key, fillingData, options) => {
|
|
|
54
74
|
const getBrowserWindow = () => {
|
|
55
75
|
return globalThis.window;
|
|
56
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* 初始化时优先读取本地缓存语言。
|
|
79
|
+
* SSR 环境没有 window,直接回退到默认语言。
|
|
80
|
+
*/
|
|
57
81
|
const getStoredLanguage = (storageKey) => {
|
|
58
82
|
const windowRef = getBrowserWindow();
|
|
59
83
|
if (!windowRef) {
|
|
@@ -61,6 +85,9 @@ const getStoredLanguage = (storageKey) => {
|
|
|
61
85
|
}
|
|
62
86
|
return windowRef.localStorage.getItem(storageKey) || defaultLanguage;
|
|
63
87
|
};
|
|
88
|
+
/**
|
|
89
|
+
* 持久化当前语言,用于刷新页面后保持用户选择。
|
|
90
|
+
*/
|
|
64
91
|
const persistLanguage = (storageKey, language) => {
|
|
65
92
|
const windowRef = getBrowserWindow();
|
|
66
93
|
if (!windowRef)
|
|
@@ -135,6 +162,10 @@ const createI18nStore = () => {
|
|
|
135
162
|
};
|
|
136
163
|
};
|
|
137
164
|
export const i18nStore = createI18nStore();
|
|
165
|
+
/**
|
|
166
|
+
* 对外使用的 i18n 函数。
|
|
167
|
+
* 每次调用都会读取最新 state,适合在非 React 代码中直接使用。
|
|
168
|
+
*/
|
|
138
169
|
export const i18n = (key, fillingData, options) => {
|
|
139
170
|
return translate(i18nStore.getState(), key, fillingData, options);
|
|
140
171
|
};
|
|
@@ -12,28 +12,52 @@ export interface I18nTranslateState {
|
|
|
12
12
|
resources: I18nResources;
|
|
13
13
|
}
|
|
14
14
|
export interface I18nState extends I18nTranslateState {
|
|
15
|
+
/** 持久化语言时使用的 localStorage key。 */
|
|
15
16
|
storageKey: string;
|
|
17
|
+
/** 是否把 setLanguage 的结果写入 localStorage。 */
|
|
16
18
|
persist: boolean;
|
|
17
19
|
}
|
|
18
20
|
export interface I18nTranslateOptions {
|
|
21
|
+
/**
|
|
22
|
+
* 指定本次翻译使用的语言,不传则使用全局 language。
|
|
23
|
+
*/
|
|
19
24
|
language?: I18nLanguage;
|
|
25
|
+
/**
|
|
26
|
+
* 当前语言未命中时使用的兜底语言,不传则使用全局 fallbackLanguage。
|
|
27
|
+
*/
|
|
20
28
|
fallbackLanguage?: I18nLanguage;
|
|
29
|
+
/**
|
|
30
|
+
* 当前语言和兜底语言都未命中时返回的兜底值。
|
|
31
|
+
*/
|
|
21
32
|
fallback?: I18nMessage;
|
|
22
33
|
}
|
|
23
34
|
export interface I18nSetResourcesOptions {
|
|
35
|
+
/**
|
|
36
|
+
* 是否和现有资源深合并。默认 false,直接替换 resources。
|
|
37
|
+
*/
|
|
24
38
|
merge?: boolean;
|
|
25
39
|
}
|
|
26
40
|
export interface I18nAddResourcesOptions {
|
|
41
|
+
/**
|
|
42
|
+
* 是否和当前语言资源深合并。默认 true。
|
|
43
|
+
*/
|
|
27
44
|
merge?: boolean;
|
|
28
45
|
}
|
|
29
46
|
export type I18nTranslator = <T = string>(key: string, fillingData?: I18nInterpolationValues, options?: I18nTranslateOptions) => T | string;
|
|
30
47
|
export interface I18nActions {
|
|
48
|
+
/** 设置当前展示语言。 */
|
|
31
49
|
setLanguage: (language: I18nLanguage) => void;
|
|
50
|
+
/** 设置兜底语言。 */
|
|
32
51
|
setFallbackLanguage: (language: I18nLanguage) => void;
|
|
52
|
+
/** 批量设置多语言资源,可选择替换或合并。 */
|
|
33
53
|
setResources: (resources: I18nResources, options?: I18nSetResourcesOptions) => void;
|
|
54
|
+
/** 为指定语言追加资源,默认和已有资源深合并。 */
|
|
34
55
|
addResources: (language: I18nLanguage, messages: I18nDictionary, options?: I18nAddResourcesOptions) => void;
|
|
56
|
+
/** 配置存储行为,主要由 I18nProvider 同步外部 props 使用。 */
|
|
35
57
|
configureI18n: (config: Partial<Pick<I18nState, 'storageKey' | 'persist'>>) => void;
|
|
58
|
+
/** 重置为默认语言、默认资源和默认存储配置。 */
|
|
36
59
|
resetI18n: () => void;
|
|
60
|
+
/** 挂在 store 上的翻译函数,方便直接读取。 */
|
|
37
61
|
t: I18nTranslator;
|
|
38
62
|
}
|
|
39
63
|
export type I18nStore = I18nState & I18nActions;
|
|
@@ -3,21 +3,54 @@ export type ButtonVariant = 'default' | 'primary' | 'dashed' | 'text' | 'link';
|
|
|
3
3
|
export type ButtonState = 'danger' | 'ghost';
|
|
4
4
|
export type ButtonSize = 'sm' | 'md' | 'lg';
|
|
5
5
|
type ButtonCommonProps = {
|
|
6
|
+
/**
|
|
7
|
+
* 按钮尺寸
|
|
8
|
+
* @default 'md'
|
|
9
|
+
*/
|
|
6
10
|
size?: ButtonSize;
|
|
11
|
+
/**
|
|
12
|
+
* 按钮状态
|
|
13
|
+
*/
|
|
7
14
|
state?: ButtonState;
|
|
15
|
+
/**
|
|
16
|
+
* 是否禁用
|
|
17
|
+
*/
|
|
8
18
|
disabled?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* 是否显示加载状态
|
|
21
|
+
*/
|
|
9
22
|
loading?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* 左侧图标
|
|
25
|
+
*/
|
|
10
26
|
leftIcon?: ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* 右侧图标
|
|
29
|
+
*/
|
|
11
30
|
rightIcon?: ReactNode;
|
|
31
|
+
/**
|
|
32
|
+
* 是否去除下划线(仅对 variant="link" 有效)
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
12
35
|
noUnderline?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* 作为子元素,用于更灵活的布局
|
|
38
|
+
*/
|
|
13
39
|
children?: ReactNode;
|
|
14
40
|
};
|
|
15
41
|
type ButtonElementVariant = Exclude<ButtonVariant, 'link'>;
|
|
16
42
|
export type ButtonProps = ButtonElementProps | ButtonLinkProps;
|
|
17
43
|
export type ButtonElementProps = ButtonCommonProps & Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'disabled'> & {
|
|
44
|
+
/**
|
|
45
|
+
* 按钮变体
|
|
46
|
+
* @default 'default'
|
|
47
|
+
*/
|
|
18
48
|
variant?: ButtonElementVariant;
|
|
19
49
|
};
|
|
20
50
|
export type ButtonLinkProps = ButtonCommonProps & AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
51
|
+
/**
|
|
52
|
+
* 链接变体,渲染为 a 标签
|
|
53
|
+
*/
|
|
21
54
|
variant: 'link';
|
|
22
55
|
};
|
|
23
56
|
declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
|