Commit c2590cbfb596aac5045b982e3be51c54c506bcb6
Merge branch 'main' of https://github.com/anncwb/vue-vben-admin
Showing
4 changed files
with
25 additions
and
24 deletions
package.json
@@ -17,9 +17,9 @@ | @@ -17,9 +17,9 @@ | ||
17 | }, | 17 | }, |
18 | "scripts": { | 18 | "scripts": { |
19 | "bootstrap": "pnpm install", | 19 | "bootstrap": "pnpm install", |
20 | - "build": "cross-env NODE_ENV=production vite build && esno ./build/script/postBuild.ts", | 20 | + "build": "cross-env NODE_OPTIONS=--max-old-space-size=8192 NODE_ENV=production vite build && esno ./build/script/postBuild.ts", |
21 | "build:no-cache": "pnpm clean:cache && npm run build", | 21 | "build:no-cache": "pnpm clean:cache && npm run build", |
22 | - "build:test": "cross-env vite build --mode test && esno ./build/script/postBuild.ts", | 22 | + "build:test": "cross-env NODE_OPTIONS=--max-old-space-size=8192 vite build --mode test && esno ./build/script/postBuild.ts", |
23 | "clean:cache": "rimraf node_modules/.cache/ && rimraf node_modules/.vite", | 23 | "clean:cache": "rimraf node_modules/.cache/ && rimraf node_modules/.vite", |
24 | "clean:lib": "rimraf node_modules", | 24 | "clean:lib": "rimraf node_modules", |
25 | "commit": "czg", | 25 | "commit": "czg", |
src/components/Form/src/hooks/useFormEvents.ts
@@ -14,7 +14,7 @@ import { | @@ -14,7 +14,7 @@ import { | ||
14 | import { deepMerge } from '/@/utils'; | 14 | import { deepMerge } from '/@/utils'; |
15 | import { dateItemType, handleInputNumberValue, defaultValueComponents } from '../helper'; | 15 | import { dateItemType, handleInputNumberValue, defaultValueComponents } from '../helper'; |
16 | import { dateUtil } from '/@/utils/dateUtil'; | 16 | import { dateUtil } from '/@/utils/dateUtil'; |
17 | -import { cloneDeep, set, uniqBy } from 'lodash-es'; | 17 | +import { cloneDeep, set, uniqBy, get } from 'lodash-es'; |
18 | import { error } from '/@/utils/log'; | 18 | import { error } from '/@/utils/log'; |
19 | 19 | ||
20 | interface UseFormActionContext { | 20 | interface UseFormActionContext { |
@@ -112,9 +112,8 @@ export function useFormEvents({ | @@ -112,9 +112,8 @@ export function useFormEvents({ | ||
112 | const validKeys: string[] = []; | 112 | const validKeys: string[] = []; |
113 | fields.forEach((key) => { | 113 | fields.forEach((key) => { |
114 | const schema = unref(getSchema).find((item) => item.field === key); | 114 | const schema = unref(getSchema).find((item) => item.field === key); |
115 | - let value = values[key]; | ||
116 | - | ||
117 | - const hasKey = Reflect.has(values, key); | 115 | + let value = get(values, key); |
116 | + const hasKey = !!get(values, key); | ||
118 | 117 | ||
119 | value = handleInputNumberValue(schema?.component, value); | 118 | value = handleInputNumberValue(schema?.component, value); |
120 | const { componentProps } = schema || {}; | 119 | const { componentProps } = schema || {}; |
src/utils/index.ts
@@ -3,7 +3,7 @@ import type { App, Component } from 'vue'; | @@ -3,7 +3,7 @@ import type { App, Component } from 'vue'; | ||
3 | 3 | ||
4 | import { unref } from 'vue'; | 4 | import { unref } from 'vue'; |
5 | import { isArray, isObject } from '/@/utils/is'; | 5 | import { isArray, isObject } from '/@/utils/is'; |
6 | -import { cloneDeep, mergeWith } from 'lodash-es'; | 6 | +import { cloneDeep, isEqual, mergeWith, unionWith } from 'lodash-es'; |
7 | 7 | ||
8 | export const noop = () => {}; | 8 | export const noop = () => {}; |
9 | 9 | ||
@@ -48,7 +48,8 @@ export function deepMerge<T extends object | null | undefined, U extends object | @@ -48,7 +48,8 @@ export function deepMerge<T extends object | null | undefined, U extends object | ||
48 | return mergeWith(cloneDeep(target), source, (objValue, srcValue) => { | 48 | return mergeWith(cloneDeep(target), source, (objValue, srcValue) => { |
49 | if (isObject(objValue) && isObject(srcValue)) { | 49 | if (isObject(objValue) && isObject(srcValue)) { |
50 | return mergeWith(cloneDeep(objValue), srcValue, (prevValue, nextValue) => { | 50 | return mergeWith(cloneDeep(objValue), srcValue, (prevValue, nextValue) => { |
51 | - return isArray(prevValue) ? prevValue.concat(nextValue) : undefined; | 51 | + // 如果是数组,合并数组(去重) If it is an array, merge the array (remove duplicates) |
52 | + return isArray(prevValue) ? unionWith(prevValue, nextValue, isEqual) : undefined; | ||
52 | }); | 53 | }); |
53 | } | 54 | } |
54 | }); | 55 | }); |
src/utils/propTypes.ts
1 | import { CSSProperties, VNodeChild } from 'vue'; | 1 | import { CSSProperties, VNodeChild } from 'vue'; |
2 | -import { createTypes, VueTypeValidableDef, VueTypesInterface } from 'vue-types'; | 2 | +import { createTypes, VueTypeValidableDef, VueTypesInterface, toValidableType } from 'vue-types'; |
3 | 3 | ||
4 | export type VueNode = VNodeChild | JSX.Element; | 4 | export type VueNode = VNodeChild | JSX.Element; |
5 | 5 | ||
@@ -8,8 +8,7 @@ type PropTypes = VueTypesInterface & { | @@ -8,8 +8,7 @@ type PropTypes = VueTypesInterface & { | ||
8 | readonly VNodeChild: VueTypeValidableDef<VueNode>; | 8 | readonly VNodeChild: VueTypeValidableDef<VueNode>; |
9 | // readonly trueBool: VueTypeValidableDef<boolean>; | 9 | // readonly trueBool: VueTypeValidableDef<boolean>; |
10 | }; | 10 | }; |
11 | - | ||
12 | -const propTypes = createTypes({ | 11 | +const newPropTypes = createTypes({ |
13 | func: undefined, | 12 | func: undefined, |
14 | bool: undefined, | 13 | bool: undefined, |
15 | string: undefined, | 14 | string: undefined, |
@@ -18,17 +17,19 @@ const propTypes = createTypes({ | @@ -18,17 +17,19 @@ const propTypes = createTypes({ | ||
18 | integer: undefined, | 17 | integer: undefined, |
19 | }) as PropTypes; | 18 | }) as PropTypes; |
20 | 19 | ||
21 | -propTypes.extend([ | ||
22 | - { | ||
23 | - name: 'style', | ||
24 | - getter: true, | ||
25 | - type: [String, Object], | ||
26 | - default: undefined, | ||
27 | - }, | ||
28 | - { | ||
29 | - name: 'VNodeChild', | ||
30 | - getter: true, | ||
31 | - type: undefined, | ||
32 | - }, | ||
33 | -]); | 20 | +// 从 vue-types v5.0 开始,extend()方法已经废弃,当前已改为官方推荐的ES6+方法 https://dwightjack.github.io/vue-types/advanced/extending-vue-types.html#the-extend-method |
21 | +class propTypes extends newPropTypes { | ||
22 | + // a native-like validator that supports the `.validable` method | ||
23 | + static get style() { | ||
24 | + return toValidableType('style', { | ||
25 | + type: [String, Object], | ||
26 | + }); | ||
27 | + } | ||
28 | + | ||
29 | + static get VNodeChild() { | ||
30 | + return toValidableType('VNodeChild', { | ||
31 | + type: undefined, | ||
32 | + }); | ||
33 | + } | ||
34 | +} | ||
34 | export { propTypes }; | 35 | export { propTypes }; |