Skip to content

Commit a91335d

Browse files
committed
refactor(projects): replace cloneDeep of lodash-es with klona
1 parent 3e2a993 commit a91335d

File tree

7 files changed

+18
-12
lines changed

7 files changed

+18
-12
lines changed

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
"clipboard": "2.0.11",
5858
"dayjs": "1.11.12",
5959
"echarts": "5.5.1",
60-
"lodash-es": "4.17.21",
6160
"naive-ui": "2.39.0",
6261
"nprogress": "0.2.0",
6362
"pinia": "2.1.7",
@@ -73,7 +72,6 @@
7372
"@sa/scripts": "workspace:*",
7473
"@sa/uno-preset": "workspace:*",
7574
"@soybeanjs/eslint-config": "1.3.7",
76-
"@types/lodash-es": "4.17.12",
7775
"@types/node": "20.14.11",
7876
"@types/nprogress": "0.2.3",
7977
"@unocss/eslint-config": "0.61.5",

packages/utils/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"dependencies": {
1313
"colord": "2.9.3",
1414
"crypto-js": "4.2.0",
15+
"klona": "2.0.6",
1516
"localforage": "1.10.0",
1617
"nanoid": "5.0.7"
1718
},

packages/utils/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export * from './crypto';
22
export * from './storage';
33
export * from './nanoid';
4+
export * from './klona';

packages/utils/src/klona.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { klona as jsonClone } from 'klona/json';
2+
3+
export { jsonClone };

pnpm-lock.yaml

Lines changed: 9 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/hooks/common/table.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { computed, effectScope, onScopeDispose, reactive, ref, watch } from 'vue';
22
import type { Ref } from 'vue';
33
import type { PaginationProps } from 'naive-ui';
4-
import { cloneDeep } from 'lodash-es';
4+
import { jsonClone } from '@sa/utils';
55
import { useBoolean, useHookTable } from '@sa/hooks';
66
import { useAppStore } from '@/store/modules/app';
77
import { $t } from '@/locales';
@@ -225,7 +225,7 @@ export function useTableOperate<T extends TableData = TableData>(data: Ref<T[]>,
225225
function handleEdit(id: T['id']) {
226226
operateType.value = 'edit';
227227
const findItem = data.value.find(item => item.id === id) || null;
228-
editingData.value = cloneDeep(findItem);
228+
editingData.value = jsonClone(findItem);
229229

230230
openDrawer();
231231
}

src/store/plugins/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { PiniaPluginContext } from 'pinia';
2-
import { cloneDeep } from 'lodash-es';
2+
import { jsonClone } from '@sa/utils';
33
import { SetupStoreId } from '@/enum';
44

55
/**
@@ -13,7 +13,7 @@ export function resetSetupStore(context: PiniaPluginContext) {
1313
if (setupSyntaxIds.includes(context.store.$id)) {
1414
const { $state } = context.store;
1515

16-
const defaultStore = cloneDeep($state);
16+
const defaultStore = jsonClone($state);
1717

1818
context.store.$reset = () => {
1919
context.store.$patch(defaultStore);

0 commit comments

Comments
 (0)