@peng_kai/kit 0.2.39 → 0.2.40

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.
@@ -44,7 +44,7 @@ export function useFilterParams<T extends Record<string, any>>(shcemes: ShcemeCo
44
44
  const prevParams = Object.freeze({ ...modifiableParams });
45
45
  const beforeParams = {};
46
46
  const modifiedParamKeys = Object.keys(readonlyParams).filter(pk => !eq(modifiableParams[pk], readonlyParams[pk]));
47
- const beforeFuns = Object.entries(shcemes).filter(([k, s]) => modifiedParamKeys.includes(k) && !!s.effect).map(([_, s]) => s.effect!);
47
+ const beforeFuns = Object.entries(shcemes).filter(([k, s]) => modifiedParamKeys.includes(k) && !!s.before).map(([_, s]) => s.before!);
48
48
  const needResetPage = modifiedParamKeys.some(k => !!shcemes[k]?.resetPage);
49
49
  const pageParams = needResetPage || !!force ? { page: 1 } : {};
50
50
 
@@ -67,7 +67,7 @@ const amountColor = computed(() => {
67
67
  <!-- 约等于 -->
68
68
  <span v-if="props.approx">≈</span>
69
69
  <!-- 符号 -->
70
- <CurrencyIcon class="symbol-logo" :symbol="symbol" :useCdn="useCdn" />
70
+ <CurrencyIcon v-if="symbol" class="symbol-logo" :symbol="symbol" :useCdn="useCdn" />
71
71
  <!-- 金额 -->
72
72
  <span class="color-$amount-color amount">{{ amountText }}</span>
73
73
  <!-- 单位 -->
@@ -5,8 +5,9 @@
5
5
 
6
6
  import type { FormInstance, FormItemProps, RuleObject } from 'ant-design-vue/es/form';
7
7
  import type { FormProps } from 'ant-design-vue';
8
- import { type MaybeRefOrGetter, computed, reactive, ref, toRef, watch, watchEffect } from 'vue';
8
+ import { type MaybeRefOrGetter, computed, reactive, ref, shallowRef, toRef, watch, watchEffect } from 'vue';
9
9
  import { mapValues } from 'lodash-es';
10
+ import { reactiveComputed } from '@vueuse/core';
10
11
  import { GROUP_SEP, buildGroupField, getGroupIndex } from './useAntdForm.helpers';
11
12
 
12
13
  export { useAntdForm };
@@ -28,12 +29,12 @@ interface Options<S, TS> {
28
29
  function useAntdForm<S extends Record<string, unknown>, TS = S>(schemas: MaybeRefOrGetter<SchemaConfig<S>>, options?: Options<S, TS>) {
29
30
  const schemasR = toRef(schemas);
30
31
 
31
- const state = ref({} as S);
32
+ const state = shallowRef({} as S);
32
33
  const stateTF = computed<TS>(() => options?.transform?.(<any>state.value) ?? <any>state.value);
33
34
  const show = computed(() => mapValues(state.value, (_, k): boolean => schemasR.value[k].show?.(state.value) ?? true));
34
35
  const props = computed<FormProps>(() => ({ model: state.value, ref: (c: any) => (formRef.value = c) }));
35
36
  const itemProps = computed(() => mapValues(state.value, (_, k): FormItemProps => {
36
- const r = schemasR.value[k].rules;
37
+ const r = schemasR.value[k]?.rules;
37
38
  const rules = typeof r === 'function' ? r(state.value)?.filter((i: any) => !!i) : r;
38
39
 
39
40
  return { name: k, rules };
@@ -83,27 +84,18 @@ function useAntdForm<S extends Record<string, unknown>, TS = S>(schemas: MaybeRe
83
84
  watch(itemProps, () => $form.clearValidate?.(), { flush: 'post', deep: true });
84
85
 
85
86
  watchEffect(() => {
86
- const _state: any = {};
87
-
88
- for (const k in schemasR.value) {
89
- const item = schemasR.value[k];
90
- _state[k] = (k in state.value) ? toRef(state.value, k) : ref(item.value);
87
+ const schemas = schemasR.value;
88
+ const oldState = state.value;
89
+ const newState: any = {};
90
+
91
+ for (const k of Object.keys(schemas)) {
92
+ const value = schemas[k].value;
93
+ const isExist = Object.prototype.hasOwnProperty.call(oldState, k);
94
+ newState[k] = isExist ? oldState[k] : toRef(value);
91
95
  }
92
96
 
93
- state.value = _state;
94
- });
95
-
96
- // 为什么之前用 watchEffect?
97
- // watch(schemasR, () => {
98
- // const _state: any = {};
99
-
100
- // for (const k in schemasR.value) {
101
- // const item = schemasR.value[k];
102
- // _state[k] = (k in state.value) ? toRef(state.value, k) : toRef(item, 'value');
103
- // }
104
-
105
- // state.value = _state;
106
- // }, { immediate: true });
97
+ state.value = newState;
98
+ }, { flush: 'pre' });
107
99
 
108
- return reactive({ state, stateTF, show, props, itemProps, $form });
100
+ return reactive({ state: reactiveComputed(() => state.value as S), stateTF, show, props, itemProps, $form });
109
101
  }
package/package.json CHANGED
@@ -1,95 +1,95 @@
1
- {
2
- "name": "@peng_kai/kit",
3
- "type": "module",
4
- "version": "0.2.39",
5
- "description": "",
6
- "author": "",
7
- "license": "ISC",
8
- "keywords": [],
9
- "main": "index.js",
10
- "scripts": {
11
- "dev:js": "tsx ./admin/scripts/deploy.ts",
12
- "lint": "eslint .",
13
- "lint:fix": "eslint . --fix"
14
- },
15
- "peerDependencies": {
16
- "ant-design-vue": "4.2.3",
17
- "vue": "3.4.31",
18
- "vue-router": "4.4.0"
19
- },
20
- "dependencies": {
21
- "@aws-sdk/client-s3": "^3.609.0",
22
- "@aws-sdk/lib-storage": "^3.609.0",
23
- "@babel/generator": "^7.24.7",
24
- "@babel/parser": "^7.24.7",
25
- "@babel/traverse": "^7.24.7",
26
- "@babel/types": "^7.24.7",
27
- "@ckeditor/ckeditor5-vue": "^5.1.0",
28
- "@fingerprintjs/fingerprintjs": "^4.4.1",
29
- "@tanstack/vue-query": "^5.49.1",
30
- "@vueuse/components": "^10.11.0",
31
- "@vueuse/core": "^10.11.0",
32
- "@vueuse/router": "^10.11.0",
33
- "a-calc": "^1.3.12",
34
- "archiver": "^7.0.1",
35
- "axios": "^1.7.2",
36
- "bignumber.js": "^9.1.2",
37
- "chokidar": "^3.6.0",
38
- "crypto-es": "^2.1.0",
39
- "dayjs": "^1.11.11",
40
- "echarts": "^5.4.3",
41
- "execa": "^9.3.0",
42
- "fast-glob": "^3.3.2",
43
- "localstorage-slim": "^2.7.1",
44
- "lodash-es": "^4.17.21",
45
- "nprogress": "^0.2.0",
46
- "pinia": "^2.1.7",
47
- "tsx": "^4.16.00",
48
- "vue": "^3.4.31",
49
- "vue-i18n": "^9.13.1",
50
- "vue-router": "^4.4.0"
51
- },
52
- "devDependencies": {
53
- "@ckeditor/ckeditor5-adapter-ckfinder": "^41.1.0",
54
- "@ckeditor/ckeditor5-alignment": "^41.1.0",
55
- "@ckeditor/ckeditor5-autoformat": "^41.1.0",
56
- "@ckeditor/ckeditor5-basic-styles": "^41.1.0",
57
- "@ckeditor/ckeditor5-block-quote": "^41.1.0",
58
- "@ckeditor/ckeditor5-build-classic": "^41.1.0",
59
- "@ckeditor/ckeditor5-code-block": "^41.1.0",
60
- "@ckeditor/ckeditor5-document-outline": "^41.1.0",
61
- "@ckeditor/ckeditor5-editor-classic": "^41.1.0",
62
- "@ckeditor/ckeditor5-essentials": "^41.1.0",
63
- "@ckeditor/ckeditor5-font": "^41.1.0",
64
- "@ckeditor/ckeditor5-heading": "^41.1.0",
65
- "@ckeditor/ckeditor5-highlight": "^41.1.0",
66
- "@ckeditor/ckeditor5-horizontal-line": "^41.1.0",
67
- "@ckeditor/ckeditor5-html-embed": "^41.1.0",
68
- "@ckeditor/ckeditor5-html-support": "^41.1.0",
69
- "@ckeditor/ckeditor5-image": "^41.1.0",
70
- "@ckeditor/ckeditor5-import-word": "^41.1.0",
71
- "@ckeditor/ckeditor5-indent": "^41.1.0",
72
- "@ckeditor/ckeditor5-link": "^41.1.0",
73
- "@ckeditor/ckeditor5-list": "^41.1.0",
74
- "@ckeditor/ckeditor5-media-embed": "^41.1.0",
75
- "@ckeditor/ckeditor5-paragraph": "^41.1.0",
76
- "@ckeditor/ckeditor5-remove-format": "^41.1.0",
77
- "@ckeditor/ckeditor5-show-blocks": "^41.1.0",
78
- "@ckeditor/ckeditor5-source-editing": "^41.1.0",
79
- "@ckeditor/ckeditor5-table": "^41.1.0",
80
- "@ckeditor/ckeditor5-theme-lark": "^41.1.0",
81
- "@ckeditor/ckeditor5-typing": "^41.1.0",
82
- "@ckeditor/ckeditor5-upload": "^41.1.0",
83
- "@ckeditor/ckeditor5-word-count": "^41.1.0",
84
- "@peng_kai/lint": "^0.1.0",
85
- "@types/archiver": "^6.0.2",
86
- "@types/crypto-js": "^4.2.2",
87
- "@types/lodash-es": "^4.17.12",
88
- "@types/node": "^18.19.39",
89
- "@types/nprogress": "^0.2.3",
90
- "ant-design-vue": "^4.2.3",
91
- "type-fest": "^4.21.0",
92
- "typescript": "^5.5.3",
93
- "vue-component-type-helpers": "^2.0.24"
94
- }
95
- }
1
+ {
2
+ "name": "@peng_kai/kit",
3
+ "type": "module",
4
+ "version": "0.2.40",
5
+ "description": "",
6
+ "author": "",
7
+ "license": "ISC",
8
+ "keywords": [],
9
+ "main": "index.js",
10
+ "scripts": {
11
+ "dev:js": "tsx ./admin/scripts/deploy.ts",
12
+ "lint": "eslint .",
13
+ "lint:fix": "eslint . --fix"
14
+ },
15
+ "peerDependencies": {
16
+ "ant-design-vue": "4.2.3",
17
+ "vue": "3.4.31",
18
+ "vue-router": "4.4.0"
19
+ },
20
+ "dependencies": {
21
+ "@aws-sdk/client-s3": "^3.609.0",
22
+ "@aws-sdk/lib-storage": "^3.609.0",
23
+ "@babel/generator": "^7.24.7",
24
+ "@babel/parser": "^7.24.7",
25
+ "@babel/traverse": "^7.24.7",
26
+ "@babel/types": "^7.24.7",
27
+ "@ckeditor/ckeditor5-vue": "^5.1.0",
28
+ "@fingerprintjs/fingerprintjs": "^4.4.1",
29
+ "@tanstack/vue-query": "^5.49.1",
30
+ "@vueuse/components": "^10.11.0",
31
+ "@vueuse/core": "^10.11.0",
32
+ "@vueuse/router": "^10.11.0",
33
+ "a-calc": "^1.3.12",
34
+ "archiver": "^7.0.1",
35
+ "axios": "^1.7.2",
36
+ "bignumber.js": "^9.1.2",
37
+ "chokidar": "^3.6.0",
38
+ "crypto-es": "^2.1.0",
39
+ "dayjs": "^1.11.11",
40
+ "echarts": "^5.4.3",
41
+ "execa": "^9.3.0",
42
+ "fast-glob": "^3.3.2",
43
+ "localstorage-slim": "^2.7.1",
44
+ "lodash-es": "^4.17.21",
45
+ "nprogress": "^0.2.0",
46
+ "pinia": "^2.1.7",
47
+ "tsx": "^4.16.00",
48
+ "vue": "^3.4.31",
49
+ "vue-i18n": "^9.13.1",
50
+ "vue-router": "^4.4.0"
51
+ },
52
+ "devDependencies": {
53
+ "@ckeditor/ckeditor5-adapter-ckfinder": "^41.1.0",
54
+ "@ckeditor/ckeditor5-alignment": "^41.1.0",
55
+ "@ckeditor/ckeditor5-autoformat": "^41.1.0",
56
+ "@ckeditor/ckeditor5-basic-styles": "^41.1.0",
57
+ "@ckeditor/ckeditor5-block-quote": "^41.1.0",
58
+ "@ckeditor/ckeditor5-build-classic": "^41.1.0",
59
+ "@ckeditor/ckeditor5-code-block": "^41.1.0",
60
+ "@ckeditor/ckeditor5-document-outline": "^41.1.0",
61
+ "@ckeditor/ckeditor5-editor-classic": "^41.1.0",
62
+ "@ckeditor/ckeditor5-essentials": "^41.1.0",
63
+ "@ckeditor/ckeditor5-font": "^41.1.0",
64
+ "@ckeditor/ckeditor5-heading": "^41.1.0",
65
+ "@ckeditor/ckeditor5-highlight": "^41.1.0",
66
+ "@ckeditor/ckeditor5-horizontal-line": "^41.1.0",
67
+ "@ckeditor/ckeditor5-html-embed": "^41.1.0",
68
+ "@ckeditor/ckeditor5-html-support": "^41.1.0",
69
+ "@ckeditor/ckeditor5-image": "^41.1.0",
70
+ "@ckeditor/ckeditor5-import-word": "^41.1.0",
71
+ "@ckeditor/ckeditor5-indent": "^41.1.0",
72
+ "@ckeditor/ckeditor5-link": "^41.1.0",
73
+ "@ckeditor/ckeditor5-list": "^41.1.0",
74
+ "@ckeditor/ckeditor5-media-embed": "^41.1.0",
75
+ "@ckeditor/ckeditor5-paragraph": "^41.1.0",
76
+ "@ckeditor/ckeditor5-remove-format": "^41.1.0",
77
+ "@ckeditor/ckeditor5-show-blocks": "^41.1.0",
78
+ "@ckeditor/ckeditor5-source-editing": "^41.1.0",
79
+ "@ckeditor/ckeditor5-table": "^41.1.0",
80
+ "@ckeditor/ckeditor5-theme-lark": "^41.1.0",
81
+ "@ckeditor/ckeditor5-typing": "^41.1.0",
82
+ "@ckeditor/ckeditor5-upload": "^41.1.0",
83
+ "@ckeditor/ckeditor5-word-count": "^41.1.0",
84
+ "@peng_kai/lint": "^0.1.0",
85
+ "@types/archiver": "^6.0.2",
86
+ "@types/crypto-js": "^4.2.2",
87
+ "@types/lodash-es": "^4.17.12",
88
+ "@types/node": "^18.19.39",
89
+ "@types/nprogress": "^0.2.3",
90
+ "ant-design-vue": "^4.2.3",
91
+ "type-fest": "^4.21.0",
92
+ "typescript": "^5.5.3",
93
+ "vue-component-type-helpers": "^2.0.24"
94
+ }
95
+ }