mirror of
https://gitee.com/dromara/go-view.git
synced 2025-04-06 03:58:04 +08:00
fix: 修改全局 dialog 提示
This commit is contained in:
parent
621a302451
commit
8ca08a5600
@ -27,7 +27,7 @@ export const loadingError = () => {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* * render 对话框
|
* * render 对话框
|
||||||
* @param { Object} params 配置参数
|
* @param { Object} params 配置参数, 详见 https://www.naiveui.com/zh-CN/light/components/dialog
|
||||||
* @param { Function } dialogFn 函数
|
* @param { Function } dialogFn 函数
|
||||||
* ```
|
* ```
|
||||||
* 最简易的 demo
|
* 最简易的 demo
|
||||||
@ -40,6 +40,8 @@ export const goDialog = (
|
|||||||
params: {
|
params: {
|
||||||
// 基本
|
// 基本
|
||||||
type?: DialogEnum
|
type?: DialogEnum
|
||||||
|
// 标题
|
||||||
|
title?: string | (() => any)
|
||||||
// 提示
|
// 提示
|
||||||
message?: string
|
message?: string
|
||||||
// 取消提示词
|
// 取消提示词
|
||||||
@ -64,6 +66,7 @@ export const goDialog = (
|
|||||||
) => {
|
) => {
|
||||||
const {
|
const {
|
||||||
type,
|
type,
|
||||||
|
title,
|
||||||
message,
|
message,
|
||||||
negativeText,
|
negativeText,
|
||||||
negativeButtonProps,
|
negativeButtonProps,
|
||||||
@ -98,33 +101,33 @@ export const goDialog = (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const d: DialogReactive = typeObj[type || DialogEnum.warning]['fn']({
|
const dialog: DialogReactive = typeObj[type || DialogEnum.warning]['fn']({
|
||||||
title: '提示',
|
// 导入其余 NaiveUI 支持参数
|
||||||
|
...params,
|
||||||
|
title: title || '提示',
|
||||||
icon: renderIcon(InformationCircleIcon, { size: dialogIconSize }),
|
icon: renderIcon(InformationCircleIcon, { size: dialogIconSize }),
|
||||||
content: typeObj[type || DialogEnum.warning]['message'],
|
content: typeObj[type || DialogEnum.warning]['message'],
|
||||||
positiveText: positiveText || '确定',
|
positiveText: positiveText || '确定',
|
||||||
positiveButtonProps: positiveButtonProps,
|
|
||||||
negativeText: negativeText || '取消',
|
negativeText: negativeText || '取消',
|
||||||
negativeButtonProps: negativeButtonProps,
|
|
||||||
// 是否通过遮罩关闭
|
// 是否通过遮罩关闭
|
||||||
maskClosable: isMaskClosable || maskClosable,
|
maskClosable: isMaskClosable || maskClosable,
|
||||||
onPositiveClick: async () => {
|
onPositiveClick: async () => {
|
||||||
// 执行异步
|
// 执行异步
|
||||||
if (promise && onPositiveCallback) {
|
if (promise && onPositiveCallback) {
|
||||||
d.loading = true
|
dialog.loading = true
|
||||||
try {
|
try {
|
||||||
const res = await onPositiveCallback()
|
const res = await onPositiveCallback()
|
||||||
promiseResCallback && promiseResCallback(res)
|
promiseResCallback && promiseResCallback(res)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
promiseRejCallback && promiseRejCallback(err)
|
promiseRejCallback && promiseRejCallback(err)
|
||||||
}
|
}
|
||||||
d.loading = false
|
dialog.loading = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
onPositiveCallback && onPositiveCallback(d)
|
onPositiveCallback && onPositiveCallback(dialog)
|
||||||
},
|
},
|
||||||
onNegativeClick: async () => {
|
onNegativeClick: async () => {
|
||||||
onNegativeCallback && onNegativeCallback(d)
|
onNegativeCallback && onNegativeCallback(dialog)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user