refactor(projects): replace cloneDeep of lodash-es with klona

This commit is contained in:
Soybean 2024-07-20 02:14:20 +08:00
parent 3e2a993db8
commit a91335d74b
7 changed files with 18 additions and 12 deletions

View File

@ -57,7 +57,6 @@
"clipboard": "2.0.11",
"dayjs": "1.11.12",
"echarts": "5.5.1",
"lodash-es": "4.17.21",
"naive-ui": "2.39.0",
"nprogress": "0.2.0",
"pinia": "2.1.7",
@ -73,7 +72,6 @@
"@sa/scripts": "workspace:*",
"@sa/uno-preset": "workspace:*",
"@soybeanjs/eslint-config": "1.3.7",
"@types/lodash-es": "4.17.12",
"@types/node": "20.14.11",
"@types/nprogress": "0.2.3",
"@unocss/eslint-config": "0.61.5",

View File

@ -12,6 +12,7 @@
"dependencies": {
"colord": "2.9.3",
"crypto-js": "4.2.0",
"klona": "2.0.6",
"localforage": "1.10.0",
"nanoid": "5.0.7"
},

View File

@ -1,3 +1,4 @@
export * from './crypto';
export * from './storage';
export * from './nanoid';
export * from './klona';

View File

@ -0,0 +1,3 @@
import { klona as jsonClone } from 'klona/json';
export { jsonClone };

View File

@ -41,9 +41,6 @@ importers:
echarts:
specifier: 5.5.1
version: 5.5.1
lodash-es:
specifier: 4.17.21
version: 4.17.21
naive-ui:
specifier: 2.39.0
version: 2.39.0(vue@3.4.33(typescript@5.5.3))
@ -84,9 +81,6 @@ importers:
'@soybeanjs/eslint-config':
specifier: 1.3.7
version: 1.3.7(@unocss/eslint-config@0.61.5(eslint@9.7.0)(typescript@5.5.3))(eslint-plugin-vue@9.27.0(eslint@9.7.0))(eslint@9.7.0)(typescript@5.5.3)(vue-eslint-parser@9.4.3(eslint@9.7.0))
'@types/lodash-es':
specifier: 4.17.12
version: 4.17.12
'@types/node':
specifier: 20.14.11
version: 20.14.11
@ -259,6 +253,9 @@ importers:
crypto-js:
specifier: 4.2.0
version: 4.2.0
klona:
specifier: 2.0.6
version: 2.0.6
localforage:
specifier: 1.10.0
version: 1.10.0
@ -2978,6 +2975,10 @@ packages:
resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==}
engines: {node: '>=6'}
klona@2.0.6:
resolution: {integrity: sha512-dhG34DXATL5hSxJbIexCft8FChFXtmskoZYnoPWjXQuebWYCNkVeV3KkGegCK9CP1oswI/vQibS2GY7Em/sJJA==}
engines: {node: '>= 8'}
kolorist@1.8.0:
resolution: {integrity: sha512-Y+60/zizpJ3HRH8DCss+q95yr6145JXZo46OTpFvDZWLfRCE4qChOyk1b26nMaNpfHHgxagk9dXT5OP0Tfe+dQ==}
@ -7738,6 +7739,8 @@ snapshots:
kleur@4.1.5: {}
klona@2.0.6: {}
kolorist@1.8.0: {}
latest-version@7.0.0:

View File

@ -1,7 +1,7 @@
import { computed, effectScope, onScopeDispose, reactive, ref, watch } from 'vue';
import type { Ref } from 'vue';
import type { PaginationProps } from 'naive-ui';
import { cloneDeep } from 'lodash-es';
import { jsonClone } from '@sa/utils';
import { useBoolean, useHookTable } from '@sa/hooks';
import { useAppStore } from '@/store/modules/app';
import { $t } from '@/locales';
@ -225,7 +225,7 @@ export function useTableOperate<T extends TableData = TableData>(data: Ref<T[]>,
function handleEdit(id: T['id']) {
operateType.value = 'edit';
const findItem = data.value.find(item => item.id === id) || null;
editingData.value = cloneDeep(findItem);
editingData.value = jsonClone(findItem);
openDrawer();
}

View File

@ -1,5 +1,5 @@
import type { PiniaPluginContext } from 'pinia';
import { cloneDeep } from 'lodash-es';
import { jsonClone } from '@sa/utils';
import { SetupStoreId } from '@/enum';
/**
@ -13,7 +13,7 @@ export function resetSetupStore(context: PiniaPluginContext) {
if (setupSyntaxIds.includes(context.store.$id)) {
const { $state } = context.store;
const defaultStore = cloneDeep($state);
const defaultStore = jsonClone($state);
context.store.$reset = () => {
context.store.$patch(defaultStore);