Skip to content

Commit

Permalink
* messager: add type param to Messager.show.
Browse files Browse the repository at this point in the history
  • Loading branch information
catouse committed May 29, 2024
1 parent d16a1bb commit 45668e6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/messager/src/vanilla/messager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,18 @@ export class Messager extends Component<MessagerOptions> {
return $holder[0];
}

static show(options: (MessagerOptions & {container?: string | HTMLElement}) | string) {
static TypeOptions: Record<string, Partial<MessagerOptions>> = {};

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<MessagerOptions>);
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<MessagerOptions>);
messager.hide();
messager.show();
return messager;
Expand Down

0 comments on commit 45668e6

Please sign in to comment.