chore: prefer using extend (#8531)

This commit is contained in:
neverland 2021-04-15 09:39:20 +08:00 committed by GitHub
parent dde06c43fe
commit 0a9f2102d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 9 additions and 9 deletions

View File

@ -166,7 +166,7 @@ export default defineComponent({
const detail = areaRef.value.getArea(); const detail = areaRef.value.getArea();
detail.areaCode = detail.code; detail.areaCode = detail.code;
delete detail.code; delete detail.code;
Object.assign(state.data, detail); extend(state.data, detail);
} }
}; };

View File

@ -1,9 +1,10 @@
import { getCurrentInstance } from 'vue'; import { getCurrentInstance } from 'vue';
import { extend } from '../utils';
// expose public api // expose public api
export function useExpose(apis: Record<string, any>) { export function useExpose(apis: Record<string, any>) {
const instance = getCurrentInstance(); const instance = getCurrentInstance();
if (instance) { if (instance) {
Object.assign(instance.proxy, apis); extend(instance.proxy, apis);
} }
} }

View File

@ -105,9 +105,7 @@ export default defineComponent({
watch( watch(
() => props.contactInfo, () => props.contactInfo,
(value) => { (value) => extend(contact, DEFAULT_CONTACT, value)
Object.assign(contact, DEFAULT_CONTACT, value);
}
); );
return () => ( return () => (

View File

@ -108,7 +108,7 @@ Dialog.close = () => {
}; };
Dialog.setDefaultOptions = (options: DialogOptions) => { Dialog.setDefaultOptions = (options: DialogOptions) => {
Object.assign(Dialog.currentOptions, options); extend(Dialog.currentOptions, options);
}; };
Dialog.resetDefaultOptions = () => { Dialog.resetDefaultOptions = () => {

View File

@ -85,7 +85,7 @@ Notify.clear = () => {
Notify.currentOptions = defaultOptions(); Notify.currentOptions = defaultOptions();
Notify.setDefaultOptions = (options: NotifyOptions) => { Notify.setDefaultOptions = (options: NotifyOptions) => {
Object.assign(Notify.currentOptions, options); extend(Notify.currentOptions, options);
}; };
Notify.resetDefaultOptions = () => { Notify.resetDefaultOptions = () => {

View File

@ -166,7 +166,7 @@ function setDefaultOptions(type: ToastType | ToastOptions, options?: any) {
if (typeof type === 'string') { if (typeof type === 'string') {
defaultOptionsMap[type] = options; defaultOptionsMap[type] = options;
} else { } else {
Object.assign(currentOptions, type); extend(currentOptions, type);
} }
} }

View File

@ -1,4 +1,5 @@
import { createApp, reactive, Component, nextTick } from 'vue'; import { createApp, reactive, Component, nextTick } from 'vue';
import { extend } from '../utils';
import { useExpose } from '../composables/use-expose'; import { useExpose } from '../composables/use-expose';
export function usePopupState() { export function usePopupState() {
@ -11,7 +12,7 @@ export function usePopupState() {
}; };
const open = (props: Record<string, any>) => { const open = (props: Record<string, any>) => {
Object.assign(state, props); extend(state, props);
nextTick(() => toggle(true)); nextTick(() => toggle(true));
}; };