fix: enable tips

This commit is contained in:
tim
2025-08-01 00:55:10 +08:00
parent a182b0b8da
commit cc371fad85

View File

@@ -81,7 +81,7 @@ export function createVditor(editorId, options = {}) {
multiple: false, multiple: false,
handler: async (files) => { handler: async (files) => {
const file = files[0] const file = files[0]
vditor.tip.show('图片上传中', 0) vditor.tip('图片上传中', 0)
vditor.disabled() vditor.disabled()
const res = await fetch( const res = await fetch(
`${API_BASE_URL}/api/upload/presign?filename=${encodeURIComponent(file.name)}`, `${API_BASE_URL}/api/upload/presign?filename=${encodeURIComponent(file.name)}`,
@@ -89,14 +89,14 @@ export function createVditor(editorId, options = {}) {
) )
if (!res.ok) { if (!res.ok) {
vditor.enable() vditor.enable()
vditor.tip.hide() vditor.tip('获取上传地址失败')
return '获取上传地址失败' return '获取上传地址失败'
} }
const info = await res.json() const info = await res.json()
const put = await fetch(info.uploadUrl, { method: 'PUT', body: file }) const put = await fetch(info.uploadUrl, { method: 'PUT', body: file })
if (!put.ok) { if (!put.ok) {
vditor.enable() vditor.enable()
vditor.tip.hide() vditor.tip('上传失败')
return '上传失败' return '上传失败'
} }
@@ -127,7 +127,7 @@ export function createVditor(editorId, options = {}) {
} }
vditor.insertValue(md + '\n') vditor.insertValue(md + '\n')
vditor.enable() vditor.enable()
vditor.tip.hide() vditor.tip('上传成功')
return null return null
} }
}, },