@quansitech/antd-admin 1.0.1 → 1.1.1

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.
@@ -5,7 +5,7 @@ import {Badge, Flex} from "antd";
5
5
  import {ColumnReadonlyProps} from "./types";
6
6
  import {asyncFilter, handleRules} from "../../../lib/helpers";
7
7
  import {Rules} from "@rc-component/async-validator/lib/interface";
8
- import upperFirst from "lodash/upperFirst";
8
+ import {upperFirst} from "es-toolkit";
9
9
  import {TableColumnActionProps} from "./Action/types";
10
10
 
11
11
  type ComponentType = {
@@ -3,7 +3,7 @@ import {Component} from "react";
3
3
  import {createScript, filterObjectKeys} from "../../lib/helpers";
4
4
  import {Spin} from "antd";
5
5
  import {ModalContext, ModalContextProps} from "../ModalContext";
6
- import uniqueId from "lodash/uniqueId";
6
+ import {uniqueId} from "es-toolkit/compat";
7
7
 
8
8
  declare global {
9
9
  interface Window {
@@ -3,7 +3,7 @@ import {lazy, useEffect, useState} from "react";
3
3
  import {ReactComponentLike} from "prop-types";
4
4
  import {Badge, Space} from "antd";
5
5
  import container from "../../lib/container";
6
- import upperFirst from "lodash/upperFirst";
6
+ import {upperFirst} from "es-toolkit";
7
7
 
8
8
  export default function (props: {
9
9
  actions?: FormActionType[]
@@ -1,19 +1,18 @@
1
1
  import {BetaSchemaForm, ProFormColumnsType, ProFormInstance, ProSkeleton} from "@ant-design/pro-components";
2
2
  import type {FormSchema} from "@ant-design/pro-form/es/components/SchemaForm/typing";
3
3
  import React, {lazy, Suspense, useContext, useEffect, useRef, useState} from "react";
4
- import upperFirst from "lodash/upperFirst";
4
+ import {cloneDeep, upperFirst} from "es-toolkit";
5
5
  import container from "../lib/container";
6
6
  import {FormActionType} from "./Form/Action/types";
7
7
  import Actions from "./Form/Actions";
8
8
  import {FormContext} from "./FormContext";
9
9
  import {Col, Row, Spin} from "antd";
10
10
  import http from "../lib/http";
11
- import {RuleObject} from "rc-field-form/lib/interface";
12
11
  import customRule from "../lib/customRule";
13
- import cloneDeep from "lodash/cloneDeep";
14
12
  import {ModalContext} from "./ModalContext";
15
13
  import {TableContext} from "./TableContext";
16
14
  import {commonHandler} from "../lib/schemaHandler";
15
+ import {Rule} from "antd/es/form";
17
16
 
18
17
  type SubmitRequestType = {
19
18
  url: string,
@@ -42,7 +41,7 @@ export default function (props: FormSchema & {
42
41
  useEffect(() => {
43
42
  setColumns((cloneDeep(props.columns)?.map((c: ProFormColumnsType & {
44
43
  formItemProps?: {
45
- rules?: (RuleObject & {
44
+ rules?: (Rule & {
46
45
  customType?: string
47
46
  })[]
48
47
  }
@@ -55,10 +54,8 @@ export default function (props: FormSchema & {
55
54
  c.formItemProps.rules = []
56
55
  }
57
56
  c.formItemProps.rules = c.formItemProps.rules.map(rule => {
58
- if (rule.customType) {
59
- if (customRule[rule.customType]) {
60
- rule.validator = customRule[rule.customType]
61
- }
57
+ if (rule.customType && customRule[rule.customType]) {
58
+ rule.validator = customRule[rule.customType]
62
59
  }
63
60
  return rule
64
61
  })
@@ -9,7 +9,6 @@ import {MenuInfo} from "rc-menu/lib/interface";
9
9
  import http from "../../lib/http";
10
10
  // @ts-ignore
11
11
  import {Route} from '@ant-design/pro-layout/lib/typing';
12
- import assign from "lodash/assign";
13
12
  import {MoonOutlined, SunOutlined} from "@ant-design/icons";
14
13
 
15
14
  export default function ({children, pageTitle, siteTitle}: {
@@ -39,7 +38,7 @@ export default function ({children, pageTitle, siteTitle}: {
39
38
  const [theme, setTheme] = useState<'light' | 'realDark'>('light')
40
39
 
41
40
  const assignProps = (newProps: LayoutProps) => {
42
- setProps(assign(props, newProps))
41
+ setProps(Object.assign(props, newProps))
43
42
  }
44
43
 
45
44
  const headerContentRender = () => {
@@ -3,7 +3,7 @@ import container from "../../lib/container";
3
3
  import {ReactComponentLike} from "prop-types";
4
4
  import {Badge, Space} from "antd";
5
5
  import {TableActionProps} from "./Action/types";
6
- import upperFirst from "lodash/upperFirst";
6
+ import {upperFirst} from "es-toolkit";
7
7
 
8
8
  export default function ({
9
9
  actions,
@@ -9,8 +9,7 @@ import {
9
9
  } from "@ant-design/pro-components";
10
10
  import type {SortOrder} from "antd/lib/table/interface";
11
11
  import {TablePaginationConfig} from "antd/es/table";
12
- import isArray from "lodash/isArray"
13
- import upperFirst from "lodash/upperFirst"
12
+ import {cloneDeep, isArray, uniqueId, upperFirst} from "es-toolkit/compat"
14
13
  import {TableContext} from "./TableContext";
15
14
  import ToolbarActions from "./Table/ToolbarActions";
16
15
  import container from "../lib/container";
@@ -19,8 +18,6 @@ import http from "../lib/http";
19
18
  import {Spin} from "antd";
20
19
  import "./Table.scss"
21
20
  import {ModalContext} from "./ModalContext";
22
- import cloneDeep from "lodash/cloneDeep";
23
- import uniqueId from "lodash/uniqueId";
24
21
  import {commonHandler} from "../lib/schemaHandler";
25
22
 
26
23
  export type TableProps = ProTableProps<any, any> & {
@@ -3,7 +3,7 @@ import {lazy, Suspense, useEffect, useState} from "react";
3
3
  import type {Tab} from 'rc-tabs/lib/interface';
4
4
  import container from "../lib/container";
5
5
  import {routerNavigateTo} from "../lib/helpers";
6
- import upperFirst from "lodash/upperFirst";
6
+ import {upperFirst} from "es-toolkit";
7
7
  import {ProSkeleton} from "@ant-design/pro-components";
8
8
 
9
9
  type TabProps = {
package/lib/helpers.tsx CHANGED
@@ -5,7 +5,6 @@ import {Rules, ValidateError, ValidateFieldsError, Values} from "@rc-component/a
5
5
  import {Spin} from "antd";
6
6
  import http from "./http";
7
7
  import container from "./container";
8
- import upperFirst from "lodash/upperFirst";
9
8
  import {lazy, Suspense} from "react";
10
9
  import global from "./global";
11
10
  import {ModalContext} from "../components/ModalContext";
@@ -143,4 +142,8 @@ export async function modalShow(options: ModalOptions) {
143
142
  destroy: modal.destroy,
144
143
  update: modal.update,
145
144
  }
145
+ }
146
+
147
+ export function upperFirst(str: string) {
148
+ return str.charAt(0).toUpperCase() + str.slice(1)
146
149
  }
@@ -0,0 +1,31 @@
1
+ import fs from "node:fs"
2
+ import path from "node:path"
3
+ import * as process from "node:process";
4
+
5
+ export default function () {
6
+ // 分析额外组件
7
+ if (!fs.existsSync(process.cwd() + '/vendor')) {
8
+ throw new Error('Please run `composer install` first.');
9
+ }
10
+
11
+ const installed = JSON.parse(fs.readFileSync(process.cwd() + '/vendor/composer/installed.json'))
12
+ const extras = installed.packages.filter(p => !!p.extra?.qscmf?.['antd-admin']).map(p => ({
13
+ name: p.name,
14
+ path: p['install-path'],
15
+ component: p.extra.qscmf['antd-admin'].component,
16
+ }));
17
+
18
+ const extra_script = `
19
+ import container from "@quansitech/antd-admin/lib/container.ts";
20
+
21
+ ${extras.map(e => {
22
+ const cs = [];
23
+ for (const componentKey in e.component) {
24
+ cs.push(`container.register('${componentKey}', () => import('../../../vendor${path.join('/', e.path, e.component[componentKey])}'));`)
25
+ }
26
+ return cs.join('\n');
27
+ })}
28
+ `
29
+
30
+ fs.writeFileSync(process.cwd() + '/resources/js/backend/extra.ts', extra_script);
31
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quansitech/antd-admin",
3
- "version": "1.0.1",
3
+ "version": "1.1.1",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "components",
@@ -12,13 +12,12 @@
12
12
  "antd": "^5.20.5",
13
13
  "antd-img-crop": "^4.23.0",
14
14
  "axios": "^1.7.7",
15
- "lodash": "^4.17.21",
15
+ "es-toolkit": "^1.26.1",
16
16
  "react": "^18.3.0",
17
17
  "react-dom": "^18.3.0",
18
18
  "js-md5": "^0.8.3"
19
19
  },
20
20
  "devDependencies": {
21
- "@types/lodash": "^4.14.193",
22
21
  "@types/react": "^18.3.0",
23
22
  "@types/react-dom": "^18.3.0"
24
23
  },
package/readme.md CHANGED
@@ -126,3 +126,26 @@ container.register('Column.Readonly.Action.组件名', () => import('[组件路
126
126
 
127
127
  - 若要补充组件库,请把组件放``` compontents/Column/Readonly/Action/ ``` 目录下
128
128
 
129
+ ## 更新日志
130
+
131
+ ### 1.1.0
132
+
133
+ #### 1.增加composer包注册组件机制
134
+
135
+ 在包的composer.json中添加如下配置
136
+
137
+ ```json5
138
+ {
139
+ // 省略其它配置
140
+ "extra": {
141
+ "qscmf": {
142
+ "antd-admin": {
143
+ "component": {
144
+ "【container注册位置】": "【目标组件路径】",
145
+ "Column.Extra": "resourses/js/Component/Extra.tsx"
146
+ }
147
+ }
148
+ }
149
+ }
150
+ }
151
+ ```