Skip to content

Commit

Permalink
refactor(projects): replace cloneDeep of lodash-es with klona
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed Jul 19, 2024
1 parent 3e2a993 commit a91335d
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 12 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
1 change: 1 addition & 0 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
1 change: 1 addition & 0 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './crypto';
export * from './storage';
export * from './nanoid';
export * from './klona';
3 changes: 3 additions & 0 deletions packages/utils/src/klona.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { klona as jsonClone } from 'klona/json';

export { jsonClone };
15 changes: 9 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/hooks/common/table.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions src/store/plugins/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { PiniaPluginContext } from 'pinia';
import { cloneDeep } from 'lodash-es';
import { jsonClone } from '@sa/utils';
import { SetupStoreId } from '@/enum';

/**
Expand All @@ -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);
Expand Down

0 comments on commit a91335d

Please sign in to comment.