File size: 739 Bytes
0163a2c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import type { App } from 'vue';
import { message, notification } from 'ant-design-vue';

declare module '@vue/runtime-core' {
  interface ComponentCustomProperties {
    $message: typeof message;
    $notify: (params: string | { title: string; desc: string; [key: string]: any }) => void;
  }
}

export default {
  install: (app: App, options?: any) => {
    app.config.globalProperties.$message = message;
    app.config.globalProperties.$notify = (params) => {
      if (typeof params === 'string') {
        notification.error({
          message: params,
        });
      } else {
        notification.error({
          message: params.title,
          description: params.desc,
          ...params,
        });
      }
    };
  },
};