feat(files): 新增前端上传与订单证据图片

This commit is contained in:
yml2213
2026-10-30 14:08:11 +08:00
parent 8499dac163
commit 4fc4e9236b
5 changed files with 324 additions and 14 deletions
+33
View File
@@ -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),
})
})
}