feat(files): 新增前端上传与订单证据图片
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import type { ModalFuncProps } from 'antd'
|
||||
|
||||
type ConfirmApi = {
|
||||
confirm: (props: ModalFuncProps) => unknown
|
||||
}
|
||||
|
||||
/**
|
||||
* AntD v5 的 modal.confirm 返回控制对象而不是 Promise,直接 await 会立刻得到真值。
|
||||
* 这里包一层 Promise,确保「取消」时不会继续执行危险操作。
|
||||
*/
|
||||
export function confirmModal(modal: ConfirmApi, props: ModalFuncProps): Promise<boolean> {
|
||||
return new Promise(resolve => {
|
||||
let settled = false
|
||||
const finish = (value: boolean) => {
|
||||
if (settled) return
|
||||
settled = true
|
||||
resolve(value)
|
||||
}
|
||||
|
||||
modal.confirm({
|
||||
...props,
|
||||
onOk: async () => {
|
||||
finish(true)
|
||||
await props.onOk?.()
|
||||
},
|
||||
onCancel: (...args) => {
|
||||
finish(false)
|
||||
props.onCancel?.(...args)
|
||||
},
|
||||
afterClose: () => finish(false),
|
||||
})
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user