|
|
|
@ -11,7 +11,12 @@
@@ -11,7 +11,12 @@
|
|
|
|
|
<div class="header"> |
|
|
|
|
<span>{{ data.fileName }}</span> |
|
|
|
|
<div> |
|
|
|
|
<EDFSButton innerText="保存为草稿" type="info" v-if="!isRootMd" @click="onSave(1)" /> |
|
|
|
|
<EDFSButton |
|
|
|
|
innerText="保存为草稿" |
|
|
|
|
type="info" |
|
|
|
|
v-if="!isRootMd" |
|
|
|
|
@click="onSave(1)" |
|
|
|
|
/> |
|
|
|
|
<EDFSButton innerText="发布文章" type="primary" @click="onSave(0)" /> |
|
|
|
|
</div> |
|
|
|
|
</div> |
|
|
|
@ -27,7 +32,7 @@ import { isResError, useMessage } from '@/hooks/useMessage'
@@ -27,7 +32,7 @@ import { isResError, useMessage } from '@/hooks/useMessage'
|
|
|
|
|
import { cloneDeep } from 'lodash' |
|
|
|
|
import EDFSButton from '@/components/dashboard/Edfs-button/index.vue' |
|
|
|
|
import Vditor from 'vditor' |
|
|
|
|
import { type ContentType } from '@/api/module/eam/device/document' |
|
|
|
|
import { createImage, type ContentType } from '@/api/module/eam/device/document' |
|
|
|
|
import 'vditor/dist/index.css' |
|
|
|
|
import { vditorToolbar } from '../utils' |
|
|
|
|
interface Props { |
|
|
|
@ -81,6 +86,34 @@ function initEditor() {
@@ -81,6 +86,34 @@ function initEditor() {
|
|
|
|
|
after: () => { |
|
|
|
|
contentEditor.value?.setValue(props?.data?.content ?? '') |
|
|
|
|
}, |
|
|
|
|
upload: { |
|
|
|
|
url: ' ', |
|
|
|
|
accept: 'image/*', |
|
|
|
|
multiple: false, |
|
|
|
|
handler: async files => { |
|
|
|
|
const data = new FormData() |
|
|
|
|
data.append('file', files[0]) |
|
|
|
|
data.append('name', files[0].name) |
|
|
|
|
// 校验文件类型 智能上传图片 |
|
|
|
|
if (!files[0].type.includes('image')) { |
|
|
|
|
message.error('请上传图片') |
|
|
|
|
return null |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const res = await createImage(data) |
|
|
|
|
if (isResError(res)) { |
|
|
|
|
message.error('上传失败') |
|
|
|
|
return null |
|
|
|
|
} |
|
|
|
|
const { url } = res.data |
|
|
|
|
if (!url) { |
|
|
|
|
message.success('上传失败,图片路径未找到!') |
|
|
|
|
return null |
|
|
|
|
} |
|
|
|
|
contentEditor.value?.insertValue(``) |
|
|
|
|
return null |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|