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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
| import {Message, MessageBox} from 'element-ui'
| import i18n from '../i18n'
|
| /**
| * 提示与加载工具类
| */
| export default class Tips {
| static toast(text) {
| Message(text)
| }
|
| /**
| * 警告框
| */
| static alert(text) {
| Message({
| message: text,
| type: 'warning',
| duration: 1500
| })
| }
|
| static alertTo(text, title = i18n.t('prompt.title'), confirmText = i18n.t('confirm')) {
| return new Promise((resolve, reject) => {
| MessageBox.alert(text, title, {
| confirmButtonText: confirmText,
| callback: action => {
| resolve()
| }
| })
| })
| }
|
| /**
| * 弹出确认窗口
| */
| static confirm(text, title = i18n.t('prompt.title'), confirmText = i18n.t('confirm'), cancelText = i18n.t('cancel')) {
| return new Promise((resolve) => {
| MessageBox.confirm(text, title, {
| confirmButtonText: confirmText,
| cancelButtonText: cancelText,
| type: 'warning'
| }).then(() => {
| resolve(true)
| }).catch(() => {
| resolve(false)
| })
| })
| }
|
| static success(text = i18n.t('prompt.success'), duration = 500) {
| Message({
| message: text,
| type: 'success',
| duration: 1000,
| onClose: () => {
| return new Promise((resolve) => {
| setTimeout(() => {
| resolve()
| }, duration)
| })
| }
| })
| }
|
| /**
| * 错误框
| */
| static error(text) {
| Message({
| message: text,
| type: 'error',
| duration: 1500
| })
| }
| }
|
|