zs
2025-04-29 e5ff622848b3af0d00fb1b4ec165513cca11878d
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import sdk from 'sdk'
import { Message } from 'element-plus'
 
const MessageType = ['success', 'warning', 'info', 'error'] as const
const MessageBoxType = ['alert', 'confirm', 'prompt'] as const
 
const ElMessage: any = (...args: any) => {
  sdk.importAsync('element-plus').then((elementPlus: any) => {
    elementPlus.ElMessage(...args)
  })
}
 
MessageType.forEach((type) => {
  ElMessage[type] = (...args: any) => {
    sdk.importAsync('element-plus').then((elementPlus: any) => {
      elementPlus.ElMessage[type](...args)
    })
  }
})
 
const ElMessageBox: any = (...args: any[]) => {
  sdk.importAsync('element-plus').then((elementPlus: any) => {
    elementPlus.ElMessageBox(...args)
  })
}
 
MessageBoxType.forEach((type) => {
  ElMessageBox[type] = (...args: any) => {
    return new Promise((resolve, reject) => {
      sdk.importAsync('element-plus').then((elementPlus: any) => {
        elementPlus.ElMessageBox[type](...args)
          .then((action: any) => {
            resolve(action)
          })
          .catch((action: any) => {
            reject(action)
          })
      })
    })
  }
})
 
export { ElMessageBox, ElMessage }