Skip to content

Commit

Permalink
Merge pull request #280 from XPoet/dev
Browse files Browse the repository at this point in the history
fix: optimize deepAssignObject function
  • Loading branch information
XPoet committed Jan 22, 2024
2 parents bcc0ed3 + 19a093e commit 9edc808
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/auto-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ declare global {
const IEpPicture: typeof import('~icons/ep/picture')['default']
const IEpPostcard: typeof import('~icons/ep/postcard')['default']
const IEpSetting: typeof import('~icons/ep/setting')['default']
const IEpSwitch: typeof import('~icons/ep/switch')['default']
const IEpUpload: typeof import('~icons/ep/upload')['default']
}
11 changes: 11 additions & 0 deletions src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ declare module '@vue/runtime-core' {
CompressTool: typeof import('./components/tools/compress-tool/compress-tool.vue')['default']
CopyImageLink: typeof import('./components/copy-image-link/copy-image-link.vue')['default']
DeployBar: typeof import('./components/deploy-bar/deploy-bar.vue')['default']
ElAlert: typeof import('element-plus/es')['ElAlert']
ElBreadcrumb: typeof import('element-plus/es')['ElBreadcrumb']
ElBreadcrumbItem: typeof import('element-plus/es')['ElBreadcrumbItem']
ElButton: typeof import('element-plus/es')['ElButton']
Expand All @@ -27,6 +28,9 @@ declare module '@vue/runtime-core' {
ElCollapse: typeof import('element-plus/es')['ElCollapse']
ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem']
ElColorPicker: typeof import('element-plus/es')['ElColorPicker']
ElDescriptions: typeof import('element-plus/es')['ElDescriptions']
ElDescriptionsItem: typeof import('element-plus/es')['ElDescriptionsItem']
ElDialog: typeof import('element-plus/es')['ElDialog']
ElDivider: typeof import('element-plus/es')['ElDivider']
ElDropdown: typeof import('element-plus/es')['ElDropdown']
ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
Expand All @@ -40,6 +44,7 @@ declare module '@vue/runtime-core' {
ElLink: typeof import('element-plus/es')['ElLink']
ElOption: typeof import('element-plus/es')['ElOption']
ElPopover: typeof import('element-plus/es')['ElPopover']
ElProgress: typeof import('element-plus/es')['ElProgress']
ElRadio: typeof import('element-plus/es')['ElRadio']
ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
ElRow: typeof import('element-plus/es')['ElRow']
Expand All @@ -59,9 +64,14 @@ declare module '@vue/runtime-core' {
IEpCheck: typeof import('~icons/ep/check')['default']
IEpCircleCheckFilled: typeof import('~icons/ep/circle-check-filled')['default']
IEpClose: typeof import('~icons/ep/close')['default']
IEpConnection: typeof import('~icons/ep/connection')['default']
IEpCopyDocument: typeof import('~icons/ep/copy-document')['default']
IEpDArrowLeft: typeof import('~icons/ep/d-arrow-left')['default']
IEpDArrowRight: typeof import('~icons/ep/d-arrow-right')['default']
IEpDelete: typeof import('~icons/ep/delete')['default']
IEpDocument: typeof import('~icons/ep/document')['default']
IEpDocumentCopy: typeof import('~icons/ep/document-copy')['default']
IEpFolder: typeof import('~icons/ep/folder')['default']
IEpLink: typeof import('~icons/ep/link')['default']
IEpMoreFilled: typeof import('~icons/ep/more-filled')['default']
IEpOperation: typeof import('~icons/ep/operation')['default']
Expand All @@ -70,6 +80,7 @@ declare module '@vue/runtime-core' {
IEpSwitch: typeof import('~icons/ep/switch')['default']
IEpUpload: typeof import('~icons/ep/upload')['default']
IEpUploadFilled: typeof import('~icons/ep/upload-filled')['default']
IEpUser: typeof import('~icons/ep/user')['default']
IEpUserFilled: typeof import('~icons/ep/user-filled')['default']
ImageCard: typeof import('./components/image-card/image-card.vue')['default']
ImageHostingDeploy: typeof import('./components/deploy-bar/image-hosting-deploy.vue')['default']
Expand Down
14 changes: 6 additions & 8 deletions src/utils/common-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,15 @@ export const deepAssignObject = (obj1: object, obj2: object) => {
for (const key in obj2) {
// @ts-ignore
if (getType(obj2[key]) !== 'object') {
if (obj1) {
// @ts-ignore
obj1[key] = obj2[key]
}
} else {
// @ts-ignore
// eslint-disable-next-line no-lonely-if
if (obj1[key]) {
obj1[key] = obj2[key]
} else {
if (!Object.hasOwn(obj1, key)) {
// @ts-ignore
deepAssignObject(obj1[key], obj2[key])
obj1[key] = {}
}
// @ts-ignore
deepAssignObject(obj1[key], obj2[key])
}
}
}
Expand Down

0 comments on commit 9edc808

Please sign in to comment.