优化:文章编辑页面的加载

This commit is contained in:
jmal 2020-12-27 22:43:54 +08:00
parent 9b4e972b16
commit d27061de74

View File

@ -110,7 +110,6 @@
<script> <script>
import markdownApi from '@/api/markdown-api' import markdownApi from '@/api/markdown-api'
import uploadApi from '@/api/file-api'
import DirTree from"@/components/FileTree/DirTree" import DirTree from"@/components/FileTree/DirTree"
import fileConfig from '@/utils/file-config' import fileConfig from '@/utils/file-config'
@ -119,7 +118,6 @@
import categoryApi from "@/api/category"; import categoryApi from "@/api/category";
import tagApi from "@/api/tag"; import tagApi from "@/api/tag";
import EditElement from "@/views/markdown/EditElement"; import EditElement from "@/views/markdown/EditElement";
import api from "@/api/file-api";
let toolbar = [ let toolbar = [
'emoji', 'emoji',
@ -200,7 +198,7 @@
inputValueExist: false, inputValueExist: false,
inputNewTagClass: 'input-new-tag', inputNewTagClass: 'input-new-tag',
inputErrorClass: 'input-error', inputErrorClass: 'input-error',
vditorLoading: true, vditorLoading: false,
treeProps: { treeProps: {
label: 'name', label: 'name',
}, },
@ -242,13 +240,14 @@
}) })
cb(results) cb(results)
}, },
handleSelect(item){ handleSelect(){
this.handleInputConfirm() this.handleInputConfirm()
}, },
valueHasChanged(){ valueHasChanged(){
this.$emit('update:hasChange', true) this.$emit('update:hasChange', true)
}, },
getMarkdown(isReload){ getMarkdown(isReload){
this.vditorLoading = true
this.draft = false this.draft = false
if(this.$route.query.id){ if(this.$route.query.id){
this.editStatus = true this.editStatus = true
@ -267,6 +266,7 @@
// 初始化编辑器 // 初始化编辑器
if(isReload){ if(isReload){
this.contentEditor.setValue(this.file.contentText) this.contentEditor.setValue(this.file.contentText)
this.vditorLoading = false
} else { } else {
this.vditorInit(this.file.contentText) this.vditorInit(this.file.contentText)
} }
@ -359,7 +359,7 @@
this.contentEditor.setValue(content) this.contentEditor.setValue(content)
this.vditorLoading = false this.vditorLoading = false
}, },
input: (val) => { input: () => {
this.valueHasChanged() this.valueHasChanged()
}, },
upload: this.markdownImageUplaod() upload: this.markdownImageUplaod()