1- import { mdiAlert , mdiAlertOctagon , mdiCheck , mdiCheckCircleOutline , mdiInformation } from "@mdi/js" ;
2- import { ref } from "vue" ;
1+ import {
2+ mdiAlert ,
3+ mdiAlertOctagon ,
4+ mdiCheckCircleOutline ,
5+ mdiInformation
6+ } from '@mdi/js' ;
7+ import { ref } from 'vue' ;
38
49export declare type NotificationOption = {
510 type : NotificationType ;
@@ -10,24 +15,24 @@ export declare type NotificationOption = {
1015} ;
1116
1217export declare type NotificationType =
13- | " white"
14- | " light"
15- | " info"
16- | " success"
17- | " contrast"
18- | " warning"
19- | " danger" ;
18+ | ' white'
19+ | ' light'
20+ | ' info'
21+ | ' success'
22+ | ' contrast'
23+ | ' warning'
24+ | ' danger' ;
2025
2126export const notificationMap = ref ( new Map < string , NotificationOption > ( ) ) ;
2227
2328const acceptables = [
24- " white" ,
25- " light" ,
26- " info" ,
27- " success" ,
28- " contrast" ,
29- " warning" ,
30- " danger" ,
29+ ' white' ,
30+ ' light' ,
31+ ' info' ,
32+ ' success' ,
33+ ' contrast' ,
34+ ' warning' ,
35+ ' danger' ,
3136] ;
3237
3338export const defaultIcons = {
@@ -44,22 +49,22 @@ let id = 0;
4449 * @param option 选项
4550 */
4651export function createNotify ( option : NotificationOption | string ) {
47- if ( typeof option === " string" ) {
48- createNotify ( { message : option , type : " info" , title : "提示" } ) ;
52+ if ( typeof option === ' string' ) {
53+ createNotify ( { message : option , type : ' info' , title : '提示' } ) ;
4954 return ;
5055 }
5156
5257 const {
5358 type,
54- title = "" ,
55- message = "" ,
59+ title = '' ,
60+ message = '' ,
5661 duration = 5000 ,
5762 icon = defaultIcons [ type ] ,
5863 } = option ;
5964
60- if ( ! acceptables . includes ( type ) ) throw new TypeError ( " `type`类型错误" ) ;
65+ if ( ! acceptables . includes ( type ) ) throw new TypeError ( ' `type`类型错误' ) ;
6166
62- if ( typeof message != " string" ) throw new TypeError ( " `message`类型错误" ) ;
67+ if ( typeof message != ' string' ) throw new TypeError ( ' `message`类型错误' ) ;
6368
6469 const currentId = id . toString ( ) ;
6570
0 commit comments