fix: 文章列表文章分组显示不正确

This commit is contained in:
lbw 2023-06-22 15:15:23 +08:00
parent c927c2da34
commit f85a1933f6
3 changed files with 23 additions and 9 deletions

View File

@ -1,10 +1,10 @@
<template> <template>
<div class="editor-container"> <div class="flex flex-col border border-br" :style="styles">
<Toolbar :editor="editorRef" :mode="mode" /> <Toolbar class="border-b border-br" :editor="editorRef" :mode="mode" />
<Editor <Editor
class="flex-1 overflow-y-auto"
:mode="mode" :mode="mode"
:defaultConfig="state.editorConfig" :defaultConfig="state.editorConfig"
:style="{ height }"
v-model="state.editorVal" v-model="state.editorVal"
@onCreated="handleCreated" @onCreated="handleCreated"
@onChange="handleChange" @onChange="handleChange"
@ -14,11 +14,12 @@
<script setup lang="ts" name="wngEditor"> <script setup lang="ts" name="wngEditor">
import '@wangeditor/editor/dist/css/style.css'; import '@wangeditor/editor/dist/css/style.css';
import { reactive, shallowRef, watch, onBeforeUnmount } from 'vue'; import { reactive, shallowRef, watch, onBeforeUnmount, CSSProperties } from 'vue';
// @ts-ignore // @ts-ignore
import { IDomEditor } from '@wangeditor/editor'; import { IDomEditor } from '@wangeditor/editor';
import { Toolbar, Editor } from '@wangeditor/editor-for-vue'; import { Toolbar, Editor } from '@wangeditor/editor-for-vue';
import { Session } from '/@/utils/storage'; import { Session } from '/@/utils/storage';
import other from '/@/utils/other';
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance();
// //
@ -42,7 +43,12 @@ const props = defineProps({
// //
height: { height: {
type: String, type: String,
default: () => '310px', default: () => '310',
},
//
width: {
type: String,
default: () => 'auto',
}, },
// editor.getHtml() // editor.getHtml()
getHtml: String, getHtml: String,
@ -87,21 +93,29 @@ const state = reactive({
editorVal: props.getHtml, editorVal: props.getHtml,
}); });
const styles = computed<CSSProperties>(() => ({
height: other.addUnit(props.height),
width: other.addUnit(props.width),
}));
// //
const handleCreated = (editor: IDomEditor) => { const handleCreated = (editor: IDomEditor) => {
editorRef.value = editor; editorRef.value = editor;
}; };
// //
const handleChange = (editor: IDomEditor) => { const handleChange = (editor: IDomEditor) => {
emit('update:getHtml', editor.getHtml()); emit('update:getHtml', editor.getHtml());
emit('update:getText', editor.getText()); emit('update:getText', editor.getText());
}; };
// //
onBeforeUnmount(() => { onBeforeUnmount(() => {
const editor = editorRef.value; const editor = editorRef.value;
if (editor == null) return; if (editor == null) return;
editor.destroy(); editor.destroy();
}); });
// //
watch( watch(
() => props.disable, () => props.disable,

View File

@ -1,8 +1,8 @@
<template> <template>
<div class="layout-padding-auto layout-padding-view"> <div class="layout-padding-auto layout-padding-view">
<el-card shadow="never"> <el-card shadow="never">
<el-form ref="dataFormRef" class="ls-form" :model="form" label-width="85px" :rules="dataRules"> <el-form ref="dataFormRef" class="form" :model="form" label-width="85px" :rules="dataRules">
<div class="xl:flex"> <div class="flex">
<div> <div>
<el-form-item label="文章标题" prop="title"> <el-form-item label="文章标题" prop="title">
<div class="w-80"> <div class="w-80">
@ -77,7 +77,7 @@
</el-col> </el-col>
</el-row> </el-row>
<el-form-item label="文章内容" required prop="content"> <el-form-item label="文章内容" required prop="content">
<editor v-model:get-html="form.content" /> <editor v-model:get-html="form.content" :height="500" :width="600" />
</el-form-item> </el-form-item>
<div style="text-align: center"> <div style="text-align: center">
<el-button type="primary" @click="onSubmit">保存</el-button> <el-button type="primary" @click="onSubmit">保存</el-button>

View File

@ -43,7 +43,7 @@
> >
<el-table-column type="selection" width="40" align="center" /> <el-table-column type="selection" width="40" align="center" />
<el-table-column type="index" label="#" width="40" /> <el-table-column type="index" label="#" width="40" />
<el-table-column prop="cid" label="分类" show-overflow-tooltip /> <el-table-column prop="cname" label="分类" show-overflow-tooltip />
<el-table-column prop="title" label="标题" show-overflow-tooltip /> <el-table-column prop="title" label="标题" show-overflow-tooltip />
<el-table-column prop="author" label="作者" show-overflow-tooltip /> <el-table-column prop="author" label="作者" show-overflow-tooltip />
<el-table-column prop="visit" label="浏览" show-overflow-tooltip /> <el-table-column prop="visit" label="浏览" show-overflow-tooltip />