fix(richtext): 为富文本编辑器上传图片添加token认证头

添加用户token到图片上传请求头中,确保有权限的用户才能上传文件
This commit is contained in:
piexlMax(奇淼
2025-09-01 15:17:58 +08:00
parent 8b0a00b98a
commit 9e688c65d3

View File

@@ -27,6 +27,7 @@
import { ElMessage } from 'element-plus'
import { getUrl } from '@/utils/image'
import { useUserStore } from '@/pinia/modules/user'
const emits = defineEmits(['change', 'update:modelValue'])
@@ -35,6 +36,7 @@
emits('update:modelValue', valueHtml.value)
}
const userStore = useUserStore()
const props = defineProps({
modelValue: {
type: String,
@@ -53,6 +55,9 @@
editorConfig.MENU_CONF['uploadImage'] = {
fieldName: 'file',
server: basePath + '/fileUploadAndDownload/upload?noSave=1',
headers: {
'x-token': userStore.token,
},
customInsert(res, insertFn) {
if (res.code === 0) {
const urlPath = getUrl(res.data.file.url)