vr-uniapp/src/utils/common.ts

35 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// 定义一个MessageType类型可以根据实际情况进行修改
type MessageType = 'info' | 'success' | 'warning' | 'error';
type Message = 'delete' | 'save' | 'edit' | 'add';
export default {
// massageBox封装
message_box: (msg: string, type: MessageType = 'warning') => {
return new Promise((resolve, reject) => {
ElMessageBox.confirm(msg, '温馨提示', {
type: type,
autofocus: false,
confirmButtonText: '确定',
cancelButtonText: '取消',
})
.then(() => {
resolve(true);
})
.catch(() => {
reject(false);
});
});
},
// alert封装
alert: (msg: string, type: MessageType = 'warning') => {
return new Promise((resolve, reject) => {
ElMessageBox.alert(msg, '温馨提示', {
type: type,
autofocus: false,
confirmButtonText: '确定',
}).then(() => {
resolve(true);
});
});
},
};