From 0a9f2102d11648a26a40368484b492fcf6ce60a0 Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 15 Apr 2021 09:39:20 +0800 Subject: [PATCH] chore: prefer using extend (#8531) --- src/address-edit/AddressEdit.tsx | 2 +- src/composables/use-expose.ts | 3 ++- src/contact-edit/ContactEdit.tsx | 4 +--- src/dialog/function-call.tsx | 2 +- src/notify/function-call.tsx | 2 +- src/toast/function-call.tsx | 2 +- src/utils/mount-component.ts | 3 ++- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/address-edit/AddressEdit.tsx b/src/address-edit/AddressEdit.tsx index 5c9ca5777..ba3e647d0 100644 --- a/src/address-edit/AddressEdit.tsx +++ b/src/address-edit/AddressEdit.tsx @@ -166,7 +166,7 @@ export default defineComponent({ const detail = areaRef.value.getArea(); detail.areaCode = detail.code; delete detail.code; - Object.assign(state.data, detail); + extend(state.data, detail); } }; diff --git a/src/composables/use-expose.ts b/src/composables/use-expose.ts index 3a06d4ac4..e42909145 100644 --- a/src/composables/use-expose.ts +++ b/src/composables/use-expose.ts @@ -1,9 +1,10 @@ import { getCurrentInstance } from 'vue'; +import { extend } from '../utils'; // expose public api export function useExpose(apis: Record) { const instance = getCurrentInstance(); if (instance) { - Object.assign(instance.proxy, apis); + extend(instance.proxy, apis); } } diff --git a/src/contact-edit/ContactEdit.tsx b/src/contact-edit/ContactEdit.tsx index 85b146374..7bf973e9b 100644 --- a/src/contact-edit/ContactEdit.tsx +++ b/src/contact-edit/ContactEdit.tsx @@ -105,9 +105,7 @@ export default defineComponent({ watch( () => props.contactInfo, - (value) => { - Object.assign(contact, DEFAULT_CONTACT, value); - } + (value) => extend(contact, DEFAULT_CONTACT, value) ); return () => ( diff --git a/src/dialog/function-call.tsx b/src/dialog/function-call.tsx index 13342175e..d46d612a5 100644 --- a/src/dialog/function-call.tsx +++ b/src/dialog/function-call.tsx @@ -108,7 +108,7 @@ Dialog.close = () => { }; Dialog.setDefaultOptions = (options: DialogOptions) => { - Object.assign(Dialog.currentOptions, options); + extend(Dialog.currentOptions, options); }; Dialog.resetDefaultOptions = () => { diff --git a/src/notify/function-call.tsx b/src/notify/function-call.tsx index 60a277c9c..6d3af1a31 100644 --- a/src/notify/function-call.tsx +++ b/src/notify/function-call.tsx @@ -85,7 +85,7 @@ Notify.clear = () => { Notify.currentOptions = defaultOptions(); Notify.setDefaultOptions = (options: NotifyOptions) => { - Object.assign(Notify.currentOptions, options); + extend(Notify.currentOptions, options); }; Notify.resetDefaultOptions = () => { diff --git a/src/toast/function-call.tsx b/src/toast/function-call.tsx index 89da07e79..48194a131 100644 --- a/src/toast/function-call.tsx +++ b/src/toast/function-call.tsx @@ -166,7 +166,7 @@ function setDefaultOptions(type: ToastType | ToastOptions, options?: any) { if (typeof type === 'string') { defaultOptionsMap[type] = options; } else { - Object.assign(currentOptions, type); + extend(currentOptions, type); } } diff --git a/src/utils/mount-component.ts b/src/utils/mount-component.ts index f90dd0d43..e3a6dae86 100644 --- a/src/utils/mount-component.ts +++ b/src/utils/mount-component.ts @@ -1,4 +1,5 @@ import { createApp, reactive, Component, nextTick } from 'vue'; +import { extend } from '../utils'; import { useExpose } from '../composables/use-expose'; export function usePopupState() { @@ -11,7 +12,7 @@ export function usePopupState() { }; const open = (props: Record) => { - Object.assign(state, props); + extend(state, props); nextTick(() => toggle(true)); };