@_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.
Files changed (164) hide show
  1. package/cjs/bundler/utils.js +13 -5
  2. package/cjs/packages/core/index.js +1 -1
  3. package/cjs/packages/core/loader/config.js +4 -2
  4. package/cjs/packages/core/loader/controller.js +2 -3
  5. package/cjs/packages/core/loader/extend.js +1 -2
  6. package/cjs/packages/core/loader/middleware.js +2 -3
  7. package/cjs/packages/core/loader/model.js +7 -3
  8. package/cjs/packages/core/loader/router-schema.js +4 -2
  9. package/cjs/packages/core/loader/router.js +10 -6
  10. package/cjs/packages/core/loader/service.js +2 -2
  11. package/cjs/packages/utils/runFileFn.js +46 -1
  12. package/esm/bundler/utils.js +13 -5
  13. package/esm/packages/core/index.js +1 -2
  14. package/esm/packages/core/loader/config.js +4 -3
  15. package/esm/packages/core/loader/controller.js +2 -4
  16. package/esm/packages/core/loader/extend.js +1 -3
  17. package/esm/packages/core/loader/middleware.js +2 -4
  18. package/esm/packages/core/loader/model.js +7 -4
  19. package/esm/packages/core/loader/router-schema.js +4 -3
  20. package/esm/packages/core/loader/router.js +10 -7
  21. package/esm/packages/core/loader/service.js +2 -3
  22. package/esm/packages/utils/runFileFn.js +47 -1
  23. package/fe/frontend/dash/Dashboard.js +11 -1
  24. package/fe/frontend/dash/dash.entry.js +19 -1
  25. package/fe/frontend/main.js +2 -0
  26. package/fe/frontend/widgets/common/CRUD/CRUD.js +1 -0
  27. package/fe/frontend/widgets/common/importComponent.js +1 -0
  28. package/fe/frontend/widgets/common/language.js +1 -0
  29. package/fe/frontend/widgets/common/menu.d.ts +12 -0
  30. package/fe/frontend/widgets/common/menu.js +21 -0
  31. package/fe/frontend/widgets/common/request.d.ts +3 -0
  32. package/fe/frontend/widgets/common/request.js +6 -0
  33. package/fe/frontend/widgets/components/BasePage/HeaderView.js +3 -1
  34. package/fe/frontend/widgets/defaultPages/Schema/components/CallCom/PopFrom.js +15 -0
  35. package/fe/frontend/widgets/defaultPages/Schema/components/SchemaSearch/index.js +5 -0
  36. package/fe/frontend/widgets/defaultPages/Schema/components/SchemaTable/index.js +13 -1
  37. package/fe/frontend/widgets/defaultPages/Schema/data/eventInfo.js +4 -4
  38. package/fe/frontend/widgets/defaultPages/Schema/index.js +7 -0
  39. package/fe/frontend/widgets/defaultPages/Schema/schemaType.d.ts +9 -0
  40. package/fe/frontend/widgets/defaultPages/Schema/stores/schemaEventBus.d.ts +19 -0
  41. package/fe/frontend/widgets/defaultPages/Schema/stores/schemaEventBus.js +4 -0
  42. package/fe/frontend/widgets/defaultPages/Schema/stores/schemaStore.d.ts +14 -0
  43. package/fe/frontend/widgets/defaultPages/Schema/stores/schemaStore.js +2 -0
  44. package/fe/frontend/widgets/defaultPages/Schema/utils/schemaConversion.js +43 -0
  45. package/fe/frontend/widgets/defaultPages/Schema/utils/validator.d.ts +3 -0
  46. package/fe/frontend/widgets/defaultPages/Schema/utils/validator.js +5 -0
  47. package/fe/frontend/widgets/defaultPages/SidebarSlotPage/SidebarSlotContainer.js +7 -0
  48. package/fe/frontend/widgets/defaultPages/SidebarSlotPage/index.js +1 -0
  49. package/fe/frontend/widgets/defaultPages/SlotPage/index.js +2 -0
  50. package/fe/frontend/widgets/hooks/useCurrentMenuData.d.ts +8 -0
  51. package/fe/frontend/widgets/hooks/useCurrentMenuData.js +8 -0
  52. package/fe/frontend/widgets/store/mode.d.ts +3 -0
  53. package/fe/frontend/widgets/store/mode.js +1 -0
  54. package/fe/model/types/data/button.d.ts +9 -0
  55. package/fe/model/types/data/button.js +15 -0
  56. package/fe/model/types/data/component.d.ts +24 -0
  57. package/fe/model/types/data/component.js +10 -0
  58. package/fe/model/types/data/fetchInfo.d.ts +12 -0
  59. package/fe/model/types/data/schema.d.ts +51 -0
  60. package/fe/model/types/menuType.d.ts +29 -0
  61. package/fe/model/types/model.d.ts +13 -0
  62. package/fe/packages/common/i18n/default.d.ts +5 -0
  63. package/fe/packages/common/i18n/default.js +5 -0
  64. package/fe/packages/common/i18n/en-US.d.ts +5 -0
  65. package/fe/packages/common/i18n/en-US.js +5 -0
  66. package/fe/packages/common/i18n/index.d.ts +24 -0
  67. package/fe/packages/common/i18n/index.js +31 -0
  68. package/fe/packages/common/i18n/types.d.ts +24 -0
  69. package/fe/packages/ui/react/components/Button/Button.d.ts +33 -0
  70. package/fe/packages/ui/react/components/Button/Button.js +3 -0
  71. package/fe/packages/ui/react/components/Button/SumbitButton.d.ts +4 -0
  72. package/fe/packages/ui/react/components/Button/SumbitButton.js +4 -0
  73. package/fe/packages/ui/react/components/ConfirmDialog/ConfirmDialog.d.ts +8 -0
  74. package/fe/packages/ui/react/components/DataTable/index.d.ts +19 -0
  75. package/fe/packages/ui/react/components/DataTable/index.js +4 -0
  76. package/fe/packages/ui/react/components/Date/Calendar.d.ts +13 -0
  77. package/fe/packages/ui/react/components/Date/Calendar.js +10 -1
  78. package/fe/packages/ui/react/components/Date/Date.d.ts +11 -0
  79. package/fe/packages/ui/react/components/Date/Date.js +19 -0
  80. package/fe/packages/ui/react/components/Date/LocaleContext.d.ts +4 -0
  81. package/fe/packages/ui/react/components/Date/LocaleContext.js +4 -0
  82. package/fe/packages/ui/react/components/Date/LocaleProvider.d.ts +11 -0
  83. package/fe/packages/ui/react/components/Date/LocaleProvider.js +11 -0
  84. package/fe/packages/ui/react/components/Date/TimePicker.js +1 -0
  85. package/fe/packages/ui/react/components/Date/dateLocaleStore.d.ts +6 -0
  86. package/fe/packages/ui/react/components/Date/locales.d.ts +19 -0
  87. package/fe/packages/ui/react/components/Date/locales.js +9 -0
  88. package/fe/packages/ui/react/components/Drawer/Drawer.d.ts +6 -0
  89. package/fe/packages/ui/react/components/Dropdown/Dropdown.d.ts +1 -0
  90. package/fe/packages/ui/react/components/Form/Form.d.ts +6 -0
  91. package/fe/packages/ui/react/components/Form/FormItem.d.ts +21 -0
  92. package/fe/packages/ui/react/components/Form/FormItem.js +8 -1
  93. package/fe/packages/ui/react/components/Form/SchemaForm/data.js +1 -0
  94. package/fe/packages/ui/react/components/Form/SchemaForm/index.d.ts +93 -0
  95. package/fe/packages/ui/react/components/Form/SchemaForm/index.js +5 -1
  96. package/fe/packages/ui/react/components/ImagePreview/ImagePreview.js +8 -0
  97. package/fe/packages/ui/react/components/ImagePreview/PreviewImage.d.ts +3 -0
  98. package/fe/packages/ui/react/components/Input/Input.d.ts +22 -0
  99. package/fe/packages/ui/react/components/Input/Input.js +3 -0
  100. package/fe/packages/ui/react/components/InputNumber/InputNumber.d.ts +2 -0
  101. package/fe/packages/ui/react/components/Label/Label.d.ts +29 -0
  102. package/fe/packages/ui/react/components/Label/Label.js +2 -0
  103. package/fe/packages/ui/react/components/Menu/Menu.js +4 -0
  104. package/fe/packages/ui/react/components/Menu/SubMenu.d.ts +7 -0
  105. package/fe/packages/ui/react/components/Menu/SubMenu.js +46 -1
  106. package/fe/packages/ui/react/components/Menu/menuTypes.d.ts +1 -0
  107. package/fe/packages/ui/react/components/Message/Message.d.ts +7 -0
  108. package/fe/packages/ui/react/components/Message/Message.js +3 -0
  109. package/fe/packages/ui/react/components/Message/MessageManager.js +8 -0
  110. package/fe/packages/ui/react/components/Modal/Modal.d.ts +6 -0
  111. package/fe/packages/ui/react/components/Modal/Modal.js +1 -0
  112. package/fe/packages/ui/react/components/Modal/ModalManager.d.ts +12 -0
  113. package/fe/packages/ui/react/components/Modal/ModalManager.js +4 -1
  114. package/fe/packages/ui/react/components/Overlay/Overlay.d.ts +3 -0
  115. package/fe/packages/ui/react/components/Pagination/Pagination.d.ts +7 -0
  116. package/fe/packages/ui/react/components/Pagination/Pagination.js +8 -1
  117. package/fe/packages/ui/react/components/Popup/Popup.js +14 -2
  118. package/fe/packages/ui/react/components/Search/Search.d.ts +3 -0
  119. package/fe/packages/ui/react/components/Select/Select.d.ts +5 -0
  120. package/fe/packages/ui/react/components/Select/Select.js +4 -0
  121. package/fe/packages/ui/react/components/Skeleton/Skeleton.d.ts +15 -0
  122. package/fe/packages/ui/react/components/Skeleton/Skeleton.js +1 -1
  123. package/fe/packages/ui/react/components/TableSearch/TableSearch.d.ts +37 -0
  124. package/fe/packages/ui/react/components/TableSearch/TableSearch.js +4 -1
  125. package/fe/packages/ui/react/components/Textarea/Textarea.d.ts +46 -0
  126. package/fe/packages/ui/react/components/Textarea/Textarea.js +1 -0
  127. package/fe/packages/ui/react/components/Tooltip/Tooltip.d.ts +16 -0
  128. package/fe/packages/ui/react/components/Tooltip/Tooltip.js +8 -0
  129. package/fe/packages/ui/react/components/TreeSelect/TreeSelect.d.ts +6 -0
  130. package/fe/packages/ui/react/components/TreeSelect/TreeSelect.js +6 -0
  131. package/fe/packages/ui/react/components/Upload/Upload.d.ts +27 -0
  132. package/fe/packages/ui/react/components/breadcrumb/breadcrumb.js +9 -0
  133. package/fe/packages/ui/react/components/hooks/useDropdownPositioning.d.ts +6 -0
  134. package/fe/packages/ui/react/components/hooks/useDropdownPositioning.js +14 -0
  135. package/fe/packages/ui/react/components/hooks/useInputController.d.ts +3 -0
  136. package/fe/packages/ui/react/components/hooks/useInputController.js +7 -0
  137. package/fe/packages/ui/react/components/testPage/MenuTestPage.js +3 -0
  138. package/fe/packages/ui/react/components/testPage/index.js +26 -0
  139. package/fe/packages/ui/react/hooks/useExecuteOnce.d.ts +19 -1
  140. package/fe/packages/ui/react/hooks/useExecuteOnce.js +22 -1
  141. package/fe/packages/ui/react/hooks/useRefState.d.ts +12 -0
  142. package/fe/packages/ui/react/hooks/useRefState.js +1 -0
  143. package/fe/packages/ui/react/hooks/useWatch.d.ts +8 -0
  144. package/fe/packages/ui/react/i18n/I18nProvider.d.ts +18 -0
  145. package/fe/packages/ui/react/i18n/useI18n.d.ts +4 -0
  146. package/fe/packages/ui/react/i18n/useI18n.js +4 -0
  147. package/fe/packages/ui/react/index.js +2 -0
  148. package/fe/packages/ui/react/lib/export.d.ts +44 -0
  149. package/fe/packages/ui/react/lib/export.js +40 -0
  150. package/fe/packages/ui/react/lib/utils.d.ts +24 -0
  151. package/fe/packages/ui/react/lib/utils.js +25 -0
  152. package/fe/packages/ui/react/stores/breadcrumb.js +2 -0
  153. package/model/index.d.ts +2 -0
  154. package/model/types/data/button.d.ts +32 -0
  155. package/model/types/data/component.d.ts +61 -0
  156. package/model/types/data/fetchInfo.d.ts +20 -0
  157. package/model/types/data/schema.d.ts +98 -0
  158. package/model/types/data/search.d.ts +7 -0
  159. package/model/types/index.d.ts +2 -0
  160. package/model/types/menuType.d.ts +73 -0
  161. package/model/types/model.d.ts +33 -0
  162. package/model/types/test.d.ts +2 -0
  163. package/package.json +10 -7
  164. package/types/packages/utils/runFileFn.d.ts +5 -3
@@ -1,3 +1,24 @@
1
+ /**
2
+ * 导出 Excel 工具方法
3
+ *
4
+ * 功能:
5
+ * - 支持导出「当前页」或「当前查询条件下的全部页数据」
6
+ * - 通过 DataTable 的 columns 控制导出列及顺序
7
+ *
8
+ * 使用方式(示例):
9
+ * ```ts
10
+ * await exportToExcel({
11
+ * fetchData: (pageNum, pageSize) => getWithdrawList({ ...searchParams, pageNum, pageSize }),
12
+ * columns, // 直接复用 DataTable 的 columns
13
+ * exportType: 'all', // 'all' 导出全部页;'current' 仅导出当前页
14
+ * currentPage,
15
+ * pageSize,
16
+ * total,
17
+ * currentPageData: tableData, // 可选,导出当前页时直接使用现有数据,避免重复请求
18
+ * fileName: '提币记录',
19
+ * })
20
+ * ```
21
+ */
1
22
  import { message } from '../components';
2
23
  import * as XLSX from 'xlsx';
3
24
  const getTextFromReactNode = (node) => {
@@ -14,20 +35,31 @@ const getTextFromReactNode = (node) => {
14
35
  return String(node);
15
36
  };
16
37
  export const ExportType = {
38
+ /**
39
+ * 当前查询条件下所有页
40
+ */
17
41
  all: 0,
42
+ /**
43
+ * 当前页
44
+ */
18
45
  current: 1,
19
46
  };
47
+ /** 读取嵌套字段值,支持 a.b.c 形式 */
20
48
  const getValue = (row, dataIndex) => {
21
49
  const key = String(dataIndex);
22
50
  if (!key.includes('.'))
23
51
  return row?.[key];
24
52
  return key.split('.').reduce((acc, cur) => (acc == null ? acc : acc[cur]), row);
25
53
  };
54
+ /**
55
+ * 通用导出 Excel 方法
56
+ */
26
57
  export async function exportToExcel(options) {
27
58
  const { fetchData, exportType, currentPage = 1, pageSize = 2000, maxCount = 10000, currentPageData, fileName, } = options;
28
59
  const defaultSearchParams = { export: true };
29
60
  const cols = options.columns;
30
61
  const fieldConfigs = cols
62
+ // 过滤掉操作列
31
63
  .filter((col) => !col.isAction && col.key !== 'action')
32
64
  .map((col) => ({
33
65
  title: col.title,
@@ -42,6 +74,7 @@ export async function exportToExcel(options) {
42
74
  try {
43
75
  let allData = [];
44
76
  if (exportType === ExportType.current) {
77
+ // 优先使用已存在的当前页数据,避免重复请求
45
78
  if (currentPageData && currentPageData.length) {
46
79
  allData = currentPageData;
47
80
  }
@@ -51,6 +84,7 @@ export async function exportToExcel(options) {
51
84
  }
52
85
  }
53
86
  else {
87
+ // 导出所有页:按页拉取,直到数据不足一整页或达到最大条数
54
88
  const list = [];
55
89
  for (let page = 1;; page += 1) {
56
90
  const res = await fetchData(page, pageSize, defaultSearchParams);
@@ -58,10 +92,12 @@ export async function exportToExcel(options) {
58
92
  if (!records.length)
59
93
  break;
60
94
  list.push(...records);
95
+ // 达到最大条数后直接截断并停止
61
96
  if (list.length >= maxCount) {
62
97
  list.length = maxCount;
63
98
  break;
64
99
  }
100
+ // 本页数据不足 pageSize,说明已到最后一页
65
101
  if (records.length < pageSize)
66
102
  break;
67
103
  }
@@ -72,9 +108,13 @@ export async function exportToExcel(options) {
72
108
  message.close(infoMessageId);
73
109
  return;
74
110
  }
111
+ // 构建表头
75
112
  const header = fieldConfigs.map((f) => f.title);
113
+ // 构建数据行
76
114
  const dataRows = allData.map((row, index) => fieldConfigs.map((f) => {
77
115
  const v = f.render ? f.render(getValue(row, f.dataIndex), row, index) : getValue(row, f.dataIndex);
116
+ // 如果v是ReactNode
117
+ // 需要获取最深层的text
78
118
  if (v && typeof v === 'object' && 'props' in v && 'children' in v.props) {
79
119
  return getTextFromReactNode(v);
80
120
  }
@@ -1,8 +1,32 @@
1
1
  import { type ClassValue } from "clsx";
2
2
  export declare function cn(...inputs: ClassValue[]): string;
3
+ /**
4
+ * 日期时间格式化工具
5
+ */
6
+ /**
7
+ * 格式化日期时间
8
+ * @param date 日期字符串或 Date 对象
9
+ * @param format 格式化模板,默认 'YYYY-MM-DD HH:mm:ss'
10
+ * @returns 格式化后的字符串
11
+ */
3
12
  export declare function formatDateTime(date: string | Date | null | undefined | number, format?: string): string;
13
+ /**
14
+ * 格式化日期
15
+ * @param date 日期字符串或 Date 对象
16
+ * @returns 格式化后的字符串 YYYY-MM-DD
17
+ */
4
18
  export declare function formatDate(date: string | Date | null | undefined): string;
19
+ /**
20
+ * 格式化时间
21
+ * @param date 日期字符串或 Date 对象
22
+ * @returns 格式化后的字符串 HH:mm:ss
23
+ */
5
24
  export declare function formatTime(date: string | Date | null | undefined): string;
25
+ /**
26
+ * 生成开始结束时间
27
+ * @param dates 日期字符串或 Date 对象数组
28
+ * @returns 开始结束时间对象 { start: string; end: string }
29
+ */
6
30
  export declare function generateStartEndTime(dates: string[] | Date[] | null | undefined): {
7
31
  start: string;
8
32
  end: string;
@@ -3,10 +3,20 @@ import { twMerge } from "tailwind-merge";
3
3
  export function cn(...inputs) {
4
4
  return twMerge(clsx(inputs));
5
5
  }
6
+ /**
7
+ * 日期时间格式化工具
8
+ */
9
+ /**
10
+ * 格式化日期时间
11
+ * @param date 日期字符串或 Date 对象
12
+ * @param format 格式化模板,默认 'YYYY-MM-DD HH:mm:ss'
13
+ * @returns 格式化后的字符串
14
+ */
6
15
  export function formatDateTime(date, format = "YYYY-MM-DD HH:mm:ss") {
7
16
  if (!date)
8
17
  return "-";
9
18
  let d = new Date(date);
19
+ // 接口返回的时间戳为 秒
10
20
  const tmpY = d.getFullYear();
11
21
  if (typeof date === "number" && tmpY === 1970) {
12
22
  d = new Date(date * 1000);
@@ -27,12 +37,27 @@ export function formatDateTime(date, format = "YYYY-MM-DD HH:mm:ss") {
27
37
  .replace("mm", minutes)
28
38
  .replace("ss", seconds);
29
39
  }
40
+ /**
41
+ * 格式化日期
42
+ * @param date 日期字符串或 Date 对象
43
+ * @returns 格式化后的字符串 YYYY-MM-DD
44
+ */
30
45
  export function formatDate(date) {
31
46
  return formatDateTime(date, "YYYY-MM-DD");
32
47
  }
48
+ /**
49
+ * 格式化时间
50
+ * @param date 日期字符串或 Date 对象
51
+ * @returns 格式化后的字符串 HH:mm:ss
52
+ */
33
53
  export function formatTime(date) {
34
54
  return formatDateTime(date, "HH:mm:ss");
35
55
  }
56
+ /**
57
+ * 生成开始结束时间
58
+ * @param dates 日期字符串或 Date 对象数组
59
+ * @returns 开始结束时间对象 { start: string; end: string }
60
+ */
36
61
  export function generateStartEndTime(dates) {
37
62
  if (!dates)
38
63
  return { start: "", end: "" };
@@ -16,6 +16,7 @@ const loadBreadcrumbFromStorage = () => {
16
16
  }
17
17
  }
18
18
  catch {
19
+ // ignore
19
20
  }
20
21
  return [];
21
22
  };
@@ -24,6 +25,7 @@ const saveBreadcrumbToStorage = (items) => {
24
25
  localStorage.setItem(BREADCRUMB_STORAGE_KEY, JSON.stringify(items));
25
26
  }
26
27
  catch {
28
+ // ignore
27
29
  }
28
30
  };
29
31
  export const breadcrumbStore = create((set) => ({
@@ -0,0 +1,2 @@
1
+ export type { ModelDataType } from './types';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,32 @@
1
+ import type { ButtonProps } from '../../../fe/packages/ui/react';
2
+ import { ComponentNames } from './component';
3
+ type ButtonTemplates = {
4
+ /**
5
+ * 按钮名
6
+ */
7
+ label?: string;
8
+ } & ButtonProps;
9
+ type ParamsValueData = 'schema::tableKey' | string | number;
10
+ type RemoveBtn = {
11
+ eventKey: 'remove';
12
+ /**
13
+ * 事件配置 (参数配置)
14
+ */
15
+ eventOption: {
16
+ params: {
17
+ /**
18
+ * @example user_id: 'schema::tableKey' | '123' | 123
19
+ */
20
+ [paramKey: string]: ParamsValueData;
21
+ };
22
+ };
23
+ };
24
+ type HandlerBtn = {
25
+ eventKey: 'callComponent';
26
+ eventOption: {
27
+ comName: ComponentNames;
28
+ };
29
+ };
30
+ export type BaseButton = ButtonTemplates & (RemoveBtn | HandlerBtn);
31
+ export {};
32
+ //# sourceMappingURL=button.d.ts.map
@@ -0,0 +1,61 @@
1
+ import { FormItemProps, InputNumberProps, InputProps, SelectProps } from '../../../fe/packages/ui/react';
2
+ import { FetchInfo } from './fetchInfo';
3
+ export type ComponentConfig = {
4
+ createForm?: {
5
+ /**
6
+ * 表单标题
7
+ */
8
+ title: string;
9
+ /**
10
+ * 保存按钮文案
11
+ */
12
+ saveBtnText?: string;
13
+ } & Pick<FetchInfo, 'fetchConfig'>;
14
+ editForm?: {
15
+ /**
16
+ * 表单标题
17
+ */
18
+ title: string;
19
+ /**
20
+ * 保存按钮文案
21
+ */
22
+ saveBtnText?: string;
23
+ } & FetchInfo;
24
+ detailPanel?: {
25
+ /**
26
+ * 表单标题
27
+ */
28
+ title: string;
29
+ } & FetchInfo;
30
+ };
31
+ export type ComponentNames = keyof ComponentConfig;
32
+ export type ComponentsOption = {
33
+ createForm: FormItemProps & {
34
+ /**
35
+ * 是否展示 默认为true
36
+ */
37
+ visible?: boolean;
38
+ /**
39
+ * 是否禁用
40
+ */
41
+ disbaled?: boolean;
42
+ /**
43
+ * 默认值
44
+ */
45
+ default?: any;
46
+ } & ComponentOption;
47
+ editForm: ComponentsOption['createForm'];
48
+ detailPanel: {};
49
+ };
50
+ export type ComponentOption = InputOption | SelectOption | InputNumberOption;
51
+ type InputOption = {
52
+ comType: 'input';
53
+ } & InputProps;
54
+ type InputNumberOption = {
55
+ comType: 'inputNumber';
56
+ } & InputNumberProps;
57
+ type SelectOption = {
58
+ comType: 'select';
59
+ } & SelectProps;
60
+ export {};
61
+ //# sourceMappingURL=component.d.ts.map
@@ -0,0 +1,20 @@
1
+ export type FetchInfo = {
2
+ /**
3
+ * 表单主键, 获取数据源的key
4
+ */
5
+ fetchKey: string;
6
+ /**
7
+ * 请求配置 如果不配置则使用 统一的 [get] api 内容
8
+ */
9
+ fetchConfig?: {
10
+ /**
11
+ * 获取数据的
12
+ */
13
+ url: string;
14
+ /**
15
+ * 请求方式
16
+ */
17
+ method?: 'get' | 'post';
18
+ };
19
+ };
20
+ //# sourceMappingURL=fetchInfo.d.ts.map
@@ -0,0 +1,98 @@
1
+ import { TableColumnDef } from '../../../fe/packages/ui/react';
2
+ import type { JSONSchema7 } from 'json-schema';
3
+ import { MOmit } from '../../../fe/typings/type';
4
+ import { BaseButton } from './button';
5
+ import { ComponentConfig, ComponentNames, ComponentsOption } from './component';
6
+ import { SearchOption } from './search';
7
+ export type TableColumnsSchema = {
8
+ tableOption?: MOmit<TableColumnDef, 'key' | 'title'> & {
9
+ /**
10
+ * 是否显示
11
+ */
12
+ visible?: boolean;
13
+ /**
14
+ * 保留几位小数
15
+ */
16
+ toFixed?: number;
17
+ };
18
+ };
19
+ export type TableSearchOption = {
20
+ /**
21
+ * 不配置则不在 search 中显示
22
+ */
23
+ searchOption?: {
24
+ /**
25
+ * 控件默认值
26
+ */
27
+ default?: any;
28
+ } & SearchOption;
29
+ };
30
+ export type TableConfig = {
31
+ /**
32
+ * table 头部按钮
33
+ */
34
+ headerButtons?: BaseButton[];
35
+ /**
36
+ * 每一行的按钮
37
+ */
38
+ rowButtons?: BaseButton[];
39
+ };
40
+ export type SearchConfig = {};
41
+ export type BaseOption<O> = {
42
+ option: O;
43
+ };
44
+ export type UsedConfigSchema<T = {}> = {
45
+ type: 'object' | 'string' | 'array' | 'number' | 'boolean';
46
+ properties: {
47
+ /**
48
+ * [字段 key]: 字段描述
49
+ */
50
+ [key: string]: T & MOmit<UsedConfigSchema, 'properties'> & {
51
+ /**
52
+ * 展示 字符
53
+ */
54
+ label: string;
55
+ /**
56
+ * 原数据 序列化后 会丢失编写时的顺序
57
+ * 字段层级 默认10
58
+ *
59
+ */
60
+ level?: number;
61
+ };
62
+ };
63
+ required?: string[];
64
+ } & Omit<JSONSchema7, 'properties'>;
65
+ export type TableComponentConfig = {
66
+ [K in ComponentNames as `${K & string}Option`]?: ComponentsOption[K];
67
+ };
68
+ export type ConfigSchema = UsedConfigSchema<TableColumnsSchema & TableSearchOption & TableComponentConfig>;
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
+ */
80
+ api: string;
81
+ /**
82
+ * 板块数据结构
83
+ */
84
+ schema?: ConfigSchema;
85
+ /**
86
+ * 表格 (展示) 配置
87
+ */
88
+ tableConfig?: TableConfig;
89
+ /**
90
+ * 搜索 配置
91
+ */
92
+ searchConfig?: SearchConfig;
93
+ /**
94
+ * 模块组件
95
+ */
96
+ componentConfig?: ComponentConfig;
97
+ }
98
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1,7 @@
1
+ import type { SchemaFormComponentPropsMap, SchemaFormFieldType } from '../../../fe/packages/ui/react';
2
+ export type SearchOption = {
3
+ [K in SchemaFormFieldType]: {
4
+ comType: K;
5
+ } & SchemaFormComponentPropsMap[K];
6
+ }[SchemaFormFieldType];
7
+ //# sourceMappingURL=search.d.ts.map
@@ -0,0 +1,2 @@
1
+ export type { ModelDataType } from './model';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,73 @@
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
+ */
8
+ export type MenuLayout = "left" | "top";
9
+ interface BaseMenu {
10
+ key: string;
11
+ icon?: string;
12
+ /**
13
+ * 菜单名称
14
+ */
15
+ name: string;
16
+ }
17
+ interface GroupMenuType<T extends MenuLayout> extends BaseMenu {
18
+ menuType: "group";
19
+ subMenu: T extends "top" ? TopMenuType[] : LeftMenuType[];
20
+ }
21
+ interface ModuleMenuType extends BaseMenu {
22
+ menuType: "module";
23
+ }
24
+ /**
25
+ *
26
+ * ----------------------------- moduletype -----------------------------
27
+ *
28
+ */
29
+ interface IframeModuleType {
30
+ moduleType: "iframe";
31
+ iframeConfig: {
32
+ /**
33
+ * iframe 路径
34
+ */
35
+ path: string;
36
+ };
37
+ }
38
+ interface CustomModuleType {
39
+ moduleType: "custom";
40
+ customConfig: {
41
+ /**
42
+ * 自定义路由路径
43
+ */
44
+ path: string;
45
+ };
46
+ }
47
+ interface SchemaModuleType {
48
+ moduleType: "schema";
49
+ schemaConfig: SchemaDataType;
50
+ }
51
+ export interface SidebarModuleType {
52
+ moduleType: "sidebar";
53
+ sidebarConfig: {
54
+ menu: BaseMenuType[];
55
+ /**
56
+ * 只能为left
57
+ */
58
+ menuLayout?: "left";
59
+ };
60
+ }
61
+ export type BasicModuleType = SchemaModuleType | CustomModuleType | IframeModuleType;
62
+ export type BaseMenuType = GroupMenuType<"left"> | (ModuleMenuType & BasicModuleType);
63
+ type ModuleType = BasicModuleType | SidebarModuleType;
64
+ /**
65
+ * top 包含所有
66
+ */
67
+ export type TopMenuType = GroupMenuType<"top"> | (ModuleMenuType & ModuleType);
68
+ /**
69
+ * left 不包含 sidebar
70
+ */
71
+ export type LeftMenuType = GroupMenuType<"left"> | BaseMenuType;
72
+ export {};
73
+ //# sourceMappingURL=menuType.d.ts.map
@@ -0,0 +1,33 @@
1
+ import { TopMenuType, LeftMenuType } from "./menuType";
2
+ type MTopMenuType = {
3
+ /**
4
+ * 默认为 left
5
+ */
6
+ menuLayout: "top";
7
+ menu: TopMenuType[];
8
+ };
9
+ type MLeftMenuType = {
10
+ /**
11
+ * 默认为 left
12
+ */
13
+ menuLayout?: "left";
14
+ menu: LeftMenuType[];
15
+ };
16
+ export type ModeMenuType = MTopMenuType | MLeftMenuType;
17
+ export type ModelDataType = {
18
+ /**
19
+ * - 使用哪一块的模型数据 内置 MB
20
+ * - MB = 管理后台
21
+ */
22
+ mode: "MB";
23
+ key?: string;
24
+ name: string;
25
+ desc: string;
26
+ icon: string;
27
+ /**
28
+ * 首页(项目配置)
29
+ */
30
+ homePage: string;
31
+ } & ModeMenuType;
32
+ export {};
33
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=test.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@_tc/template-core",
3
- "version": "0.0.1-bate.37",
3
+ "version": "0.0.1-bate.39",
4
4
  "description": "A TypeScript Koa framework template - Monorepo root",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
@@ -8,27 +8,27 @@
8
8
  ".": {
9
9
  "import": "./esm/index.js",
10
10
  "require": "./cjs/index.js",
11
- "types": "./types/index.d.js"
11
+ "types": "./types/index.d.ts"
12
12
  },
13
13
  "./bundler": {
14
14
  "import": "./esm/bundler/index.js",
15
15
  "require": "./cjs/bundler/index.js",
16
- "types": "./types/bundler/index.d.js"
16
+ "types": "./types/bundler/index.d.ts"
17
17
  },
18
18
  "./fe/main": {
19
19
  "import": "./fe/frontend/main.js",
20
20
  "require": "./fe/frontend/main.js",
21
- "types": "./fe/frontend/main.d.js"
21
+ "types": "./fe/frontend/main.d.ts"
22
22
  },
23
23
  "./fe": {
24
24
  "import": "./fe/frontend/index.js",
25
25
  "require": "./fe/frontend/index.js",
26
- "types": "./fe/frontend/index.d.js"
26
+ "types": "./fe/frontend/index.d.ts"
27
27
  },
28
28
  "./fe/rc": {
29
29
  "import": "./fe/packages/ui/react/index.js",
30
30
  "require": "./fe/packages/ui/react/index.js",
31
- "types": "./fe/packages/ui/react/index.d.js"
31
+ "types": "./fe/packages/ui/react/index.d.ts"
32
32
  },
33
33
  "./fe/rc/*": {
34
34
  "import": "./fe/packages/ui/react/*",
@@ -40,7 +40,10 @@
40
40
  "require": "./fe/frontend/*",
41
41
  "types": "./fe/frontend/*"
42
42
  },
43
- "./fe/tailwind_ui.css": "./fe/frontend/main.css"
43
+ "./fe/tailwind_ui.css": "./fe/frontend/main.css",
44
+ "./model": {
45
+ "types": "./model/index.d.ts"
46
+ }
44
47
  },
45
48
  "dependencies": {
46
49
  "@babel/runtime": "^7.27.6",
@@ -1,5 +1,7 @@
1
1
  type AnyFun = (...p: any[]) => any;
2
- export declare const runFileFn: (fn: {
3
- default: AnyFun;
4
- } | AnyFun) => AnyFun;
2
+ type DefaultExport<T> = {
3
+ default?: T;
4
+ };
5
+ export declare function runFileFn<T = AnyFun>(file: string): T;
6
+ export declare function runFileFn<T = AnyFun>(fileModule: DefaultExport<T> | T): T;
5
7
  export {};