Skip to content

Commit 9e688c6

Browse files
author
piexlMax(奇淼
committed
fix(richtext): 为富文本编辑器上传图片添加token认证头
添加用户token到图片上传请求头中,确保有权限的用户才能上传文件
1 parent 8b0a00b commit 9e688c6

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

web/src/components/richtext/rich-edit.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
2828
import { ElMessage } from 'element-plus'
2929
import { getUrl } from '@/utils/image'
30+
import { useUserStore } from '@/pinia/modules/user'
3031
3132
const emits = defineEmits(['change', 'update:modelValue'])
3233
@@ -35,6 +36,7 @@
3536
emits('update:modelValue', valueHtml.value)
3637
}
3738
39+
const userStore = useUserStore()
3840
const props = defineProps({
3941
modelValue: {
4042
type: String,
@@ -53,6 +55,9 @@
5355
editorConfig.MENU_CONF['uploadImage'] = {
5456
fieldName: 'file',
5557
server: basePath + '/fileUploadAndDownload/upload?noSave=1',
58+
headers: {
59+
'x-token': userStore.token,
60+
},
5661
customInsert(res, insertFn) {
5762
if (res.code === 0) {
5863
const urlPath = getUrl(res.data.file.url)

0 commit comments

Comments
 (0)