vue3 wangEditor-v5 上传视频图片


const editorConfig = { placeholder: '请输入内容...', MENU_CONF: {} }
editorConfig.MENU_CONF['uploadImage'] = {
    async customUpload(file, insertFn) {
        const {
            filePath
        } = createFileUploadPath('articleimage', file)

    client.put(filePath, file) // 上传到OSS
        .then((res) => {
            insertFn(res.url)
        }).catch((err) => {
            console.log(err)
        })
    },
}
这里是 可根据实际需要修改,

// 根据选择的文件,拼凑上传最终路径
const createFileUploadPath = (dir, file) => {
    // 文件扩展名
    const fileExt = file.name.split('.')[1]
    const date = new Date()
    return {
        filePath: `${dir}/${date.getFullYear()}/${date.getMonth() + 1}/${random(12)}.${fileExt}`,
        fileExt
    }
}

至于上传视频也是非常简单,只需要将MENU_CONF['uploadImage']改成MENU_CONF['uploadvideo']即可。

参考 https://www.shuanghei.com/article/2022/05/62773fe45a586c4b3fcbafef.html