chore: remove object spead (#8514)

This commit is contained in:
neverland
2021-04-12 20:57:24 +08:00
committed by GitHub
parent 0b764b6347
commit 9deca34d1d
41 changed files with 204 additions and 241 deletions
+5 -7
View File
@@ -4,6 +4,7 @@ import { PropType, reactive, defineComponent } from 'vue';
import { callInterceptor, Interceptor } from '../utils/interceptor';
import {
pick,
extend,
addUnit,
isFunction,
UnknownProp,
@@ -34,8 +35,7 @@ const popupKeys = [
export default defineComponent({
name,
props: {
...popupSharedProps,
props: extend({}, popupSharedProps, {
title: String,
theme: String as PropType<DialogTheme>,
width: [Number, String],
@@ -63,7 +63,7 @@ export default defineComponent({
type: Boolean,
default: true,
},
},
}),
emits: ['confirm', 'cancel', 'update:show'],
@@ -231,10 +231,8 @@ export default defineComponent({
class={[bem([theme]), className]}
style={{ width: addUnit(width) }}
aria-labelledby={title || message}
{...{
...pick(props, popupKeys),
'onUpdate:show': updateShow,
}}
{...pick(props, popupKeys)}
{...{ 'onUpdate:show': updateShow }}
>
{renderTitle()}
{renderContent()}
+12 -17
View File
@@ -1,5 +1,5 @@
import { App, CSSProperties, TeleportProps } from 'vue';
import { inBrowser, ComponentInstance, withInstall } from '../utils';
import { inBrowser, ComponentInstance, withInstall, extend } from '../utils';
import { Interceptor } from '../utils/interceptor';
import { mountComponent, usePopupState } from '../utils/mount-component';
import VanDialog, {
@@ -40,7 +40,7 @@ function initInstance() {
const Wrapper = {
setup() {
const { state, toggle } = usePopupState();
return () => <VanDialog {...{ ...state, 'onUpdate:show': toggle }} />;
return () => <VanDialog {...state} {...{ 'onUpdate:show': toggle }} />;
},
};
@@ -58,13 +58,13 @@ function Dialog(options: DialogOptions) {
initInstance();
}
instance.open({
...Dialog.currentOptions,
...options,
callback: (action: DialogAction) => {
(action === 'confirm' ? resolve : reject)(action);
},
});
instance.open(
extend({}, Dialog.currentOptions, options, {
callback: (action: DialogAction) => {
(action === 'confirm' ? resolve : reject)(action);
},
})
);
});
}
@@ -94,17 +94,12 @@ Dialog.defaultOptions = {
closeOnClickOverlay: false,
};
Dialog.currentOptions = {
...Dialog.defaultOptions,
};
Dialog.currentOptions = extend({}, Dialog.defaultOptions);
Dialog.alert = Dialog;
Dialog.confirm = (options: DialogOptions) =>
Dialog({
showCancelButton: true,
...options,
});
Dialog(extend({ showCancelButton: true }, options));
Dialog.close = () => {
if (instance) {
@@ -117,7 +112,7 @@ Dialog.setDefaultOptions = (options: DialogOptions) => {
};
Dialog.resetDefaultOptions = () => {
Dialog.currentOptions = { ...Dialog.defaultOptions };
Dialog.currentOptions = extend({}, Dialog.defaultOptions);
};
Dialog.install = (app: App) => {