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
| import { ref, watch } from 'vue';
| import { useMessageBoxTip, useMessageBox } from './messageBox';
|
| // 各类弹出框开关逻辑
| export function useDialog() {
| const show = ref(false);
| function confirmClick() {
| if (options.tip) {
| useMessageBoxTip({
| confirmMsg: options.confrim.msg,
| confirmTitle: options.confrim.title,
| onConfirm: async () => {
| const res = options.confrim.do();
| show.value = false;
| return res;
| }
| });
| } else {
| useMessageBox({
| confirmMsg: options.cancel.msg,
| confirmTitle: options.cancel.title,
| onConfirm: () => {
| const res = options.cancel.do();
| show.value = false;
| return res;
| }
| });
| }
| }
| function cancelClick() {
| show.value = false;
| }
| const options = {
| tip: false,
| cancel: {
| title: '取消',
| msg: '是否放弃已编辑的内容?',
| do: () => {}
| },
| confirm: {
| title: '提交',
| msg: '确认是否提交?',
| do: () => {}
| }
| };
| return { show, confirmClick, cancelClick, options };
| }
|
|