diff --git a/lib/messager/src/vanilla/messager.ts b/lib/messager/src/vanilla/messager.ts index 9974df9292..1d441e2350 100644 --- a/lib/messager/src/vanilla/messager.ts +++ b/lib/messager/src/vanilla/messager.ts @@ -66,12 +66,18 @@ export class Messager extends Component { return $holder[0]; } - static show(options: (MessagerOptions & {container?: string | HTMLElement}) | string) { + static TypeOptions: Record> = {}; + + static show(options: (MessagerOptions & {container?: string | HTMLElement}) | string, type?: string) { if (typeof options === 'string') { options = {content: options}; } const {container, ...others} = options; - const messager = Messager.ensure(container || 'body', {key: `messager_${nextGid()}`, ...others} as Partial); + const finalOptions = {type, key: `messager_${nextGid()}`, ...others}; + if (finalOptions.type) { + $.extend(finalOptions, this.TypeOptions[finalOptions.type]); + } + const messager = Messager.ensure(container || 'body', finalOptions as Partial); messager.hide(); messager.show(); return messager;