|
|
@@ -3,16 +3,22 @@ import '@wangeditor/editor/dist/css/style.css'
|
|
|
import { Editor, Toolbar } from '@wangeditor/editor-for-vue'
|
|
|
import { useUserStore } from '@/stores/user'
|
|
|
import { ACCESS_TOKEN } from '@/utils/constants'
|
|
|
+import { isAbsolutePath } from '@/utils/utils'
|
|
|
+import config from '@/config/defaultSetting'
|
|
|
|
|
|
interface Props {
|
|
|
modelValue: string
|
|
|
mode?: string
|
|
|
height?: string
|
|
|
+ uploadApi?: string
|
|
|
+ fieldName?: string
|
|
|
}
|
|
|
|
|
|
const props = withDefaults(defineProps<Props>(), {
|
|
|
mode: 'simple',
|
|
|
- height: '300px'
|
|
|
+ height: '300px',
|
|
|
+ uploadApi: config.uploadApi,
|
|
|
+ fieldName: 'file'
|
|
|
})
|
|
|
const emits = defineEmits(['update:modelValue', 'change'])
|
|
|
|
|
|
@@ -31,9 +37,9 @@ const editorConfig = {
|
|
|
placeholder: '请输入内容...',
|
|
|
MENU_CONF: {
|
|
|
uploadImage: {
|
|
|
- server: `${import.meta.env.VITE_BASE_API}/file/upload`,
|
|
|
+ server: isAbsolutePath(props.uploadApi) ? props.uploadApi : import.meta.env.VITE_BASE_API + props.uploadApi,
|
|
|
headers: { [ACCESS_TOKEN]: userStore.token },
|
|
|
- fieldName: 'file',
|
|
|
+ fieldName: props.fieldName,
|
|
|
// 自定义插入图片
|
|
|
customInsert(res: any, insertFn: Function) {
|
|
|
const file = res?.data
|