mirror of
https://gitee.com/log4j/pig-ui.git
synced 2024-12-22 12:58:55 +08:00
feat: 富文本支持文件上传功能
This commit is contained in:
parent
c39a034fb2
commit
4ecc06b17d
@ -14,8 +14,8 @@
|
||||
"@chenfengyuan/vue-qrcode": "^2.0.0",
|
||||
"@element-plus/icons-vue": "^2.0.10",
|
||||
"@highlightjs/vue-plugin": "^2.1.0",
|
||||
"@wangeditor/editor": "^5.1.23",
|
||||
"@wangeditor/editor-for-vue": "^5.1.12",
|
||||
"@wangeditor/editor": "5.1.23",
|
||||
"@wangeditor/editor-for-vue": "5.1.12",
|
||||
"axios": "^1.3.3",
|
||||
"crypto-js": "^3.1.9-1",
|
||||
"echarts": "^5.4.1",
|
||||
|
@ -19,6 +19,7 @@ import { reactive, shallowRef, watch, onBeforeUnmount } from 'vue';
|
||||
// @ts-ignore
|
||||
import { IDomEditor } from '@wangeditor/editor';
|
||||
import { Toolbar, Editor } from '@wangeditor/editor-for-vue';
|
||||
import { Session } from '/@/utils/storage';
|
||||
|
||||
// 定义父组件传过来的值
|
||||
const props = defineProps({
|
||||
@ -47,16 +48,41 @@ const props = defineProps({
|
||||
getHtml: String,
|
||||
// 双向绑定,用于获取 editor.getText()
|
||||
getText: String,
|
||||
uploadFileUrl: {
|
||||
type: String,
|
||||
default: '/admin/sys-file/upload',
|
||||
},
|
||||
});
|
||||
|
||||
// 定义子组件向父组件传值/事件
|
||||
const emit = defineEmits(['update:getHtml', 'update:getText']);
|
||||
|
||||
// 定义变量内容
|
||||
// 定义上传需要的请求头信息
|
||||
const headers = computed(() => {
|
||||
return {
|
||||
Authorization: 'Bearer ' + Session.get('token'),
|
||||
'TENANT-ID': Session.getTenant(),
|
||||
};
|
||||
});
|
||||
|
||||
// 定义上传需要的字段信息
|
||||
const uploadAttr = reactive({
|
||||
fieldName: 'file',
|
||||
server: props.uploadFileUrl,
|
||||
headers: headers,
|
||||
customInsert(res, insertFn) {
|
||||
insertFn(res.data.url);
|
||||
},
|
||||
});
|
||||
|
||||
const editorRef = shallowRef();
|
||||
const state = reactive({
|
||||
editorConfig: {
|
||||
placeholder: props.placeholder,
|
||||
MENU_CONF: {
|
||||
uploadImage: uploadAttr,
|
||||
uploadVideo: uploadAttr,
|
||||
},
|
||||
},
|
||||
editorVal: props.getHtml,
|
||||
});
|
||||
|
@ -51,9 +51,6 @@
|
||||
import { useMessage } from '/@/hooks/message';
|
||||
import other from '/@/utils/other';
|
||||
import { Session } from '/@/utils/storage';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const emit = defineEmits(['sizeChange', 'refreshDataList']);
|
||||
const prop = defineProps({
|
||||
|
@ -60,10 +60,6 @@
|
||||
<script setup lang="ts" name="upload-file">
|
||||
import { useMessage } from '/@/hooks/message';
|
||||
import { Local, Session } from '/@/utils/storage';
|
||||
import {useI18n} from 'vue-i18n';
|
||||
|
||||
|
||||
const {t} = useI18n()
|
||||
const props = defineProps({
|
||||
modelValue: [String, Array],
|
||||
// 数量限制
|
||||
|
Loading…
Reference in New Issue
Block a user