新增文章内容详情页,修复框架wangedit封装组件bug

This commit is contained in:
Double-_-Z 2025-07-17 00:31:53 +08:00
parent 728b94b5ee
commit 688a7a10b3
3 changed files with 23 additions and 12 deletions

View File

@ -84,7 +84,7 @@ export default {
}},
editMode: 'default',
editor: null,
editValue: null,
editValue: this.value,
isFull: false,
}
},
@ -96,6 +96,9 @@ export default {
])
},
watch: {
value(newVal, oldVal){
this.editValue = newVal;
},
editValue(newVal, oldVal) {
this.$emit('input', newVal)
},
@ -105,6 +108,7 @@ export default {
methods: {
onCreated(editor) {
this.editor = Object.seal(editor)
if(!this.disableShowFullscreen) editor.fullScreen();
this.editValue = this.value
},
//

View File

@ -1,6 +1,6 @@
<template>
<div class="article-content">
<wang-editor v-loading="loading" v-model="text" disable style="width: 100%;overflow-y: hidden;"
<wang-editor v-loading="loading" v-model="textDetail" disable style="width: 100%;overflow-y: hidden;"
:disableShowFullscreen="false" ref="editor" />
</div>
</template>
@ -12,25 +12,32 @@ export default {
components: {WangEditor},
data() {
return {
text: '暂无文章内容',
textDetail: ' ',
loading: false
}
},
mounted(){
created(){
const { id } = this.$route.query;
if(id) this.getArticleContentById(id);
},
methods:{
async getArticleContentById(id){
var texts = '暂无文章内容';
await text(id).then(res => {
getArticleContentById(id){
try {
this.loading = true;
text(id).then(res => {
if(res){
texts = res.text;
this.textDetail = res.text;
}else{
this.textDetail = '暂无文章内容!';
this.$message.error('文章内容获取失败!');
}
})
this.text = texts;
} catch (error) {
this.textDetail = '暂无文章内容!';
this.$message.error('文章内容获取失败!');
} finally {
this.loading = false;
}
}
}
}

View File

@ -94,7 +94,7 @@ export default {
copyLink(row){
if(row.id == null||row.id == ''){ this.$message.warning('链接为空');return;}
var aux = document.createElement("input");
aux.setAttribute("value", `${process.env.VUE_APP_BASE_PATH}/#/article/content?id=${row.id}`);
aux.setAttribute("value", `${process.env.VUE_APP_BASE_PATH}/#/article/content?id=${row.textid}`);
document.body.appendChild(aux);
aux.select();
document.execCommand("copy");
@ -125,7 +125,7 @@ export default {
},
//
toPreview(row) {
window.open(`${process.env.VUE_APP_BASE_PATH}/#/article/content?id=${row.id}`);
window.open(`${process.env.VUE_APP_BASE_PATH}/#/article/content?id=${row.textid}`);
},
//
toAddArticle() {