qingcheng-Web/greenOrange/src/view/Index.vue

38 lines
796 B
Vue
Raw Normal View History

2025-05-15 11:51:13 +00:00
<template>
2025-05-28 10:03:31 +00:00
<div class="edit-page">
<h1>文章编辑</h1>
2025-05-15 11:51:13 +00:00
2025-05-28 10:03:31 +00:00
<RichTextEditor
:context="initialContent"
:disable="isDisabled"
@content-change="handleContentChange"
/>
2025-05-15 11:51:13 +00:00
2025-05-28 10:03:31 +00:00
<button @click="saveContent">保存内容</button>
2025-05-15 11:51:13 +00:00
</div>
</template>
2025-05-28 10:03:31 +00:00
<script setup>
import { ref } from 'vue'
import RichTextEditor from './components/RichTextEditor.vue'
2025-05-15 11:51:13 +00:00
2025-05-28 10:03:31 +00:00
const initialContent = ref('<p>初始内容</p>') // 从接口获取
const isDisabled = ref(false)
2025-05-15 11:51:13 +00:00
2025-05-28 10:03:31 +00:00
const handleContentChange = (html) => {
console.log('最新内容:', html)
// 可在此处实时保存草稿
2025-05-15 11:51:13 +00:00
}
2025-05-28 10:03:31 +00:00
const saveContent = () => {
// 提交到后端接口
axios.post('/api/save', { content: initialContent.value })
2025-05-15 11:51:13 +00:00
}
2025-05-28 10:03:31 +00:00
</script>
2025-05-15 11:51:13 +00:00
2025-05-28 10:03:31 +00:00
<style scoped>
.edit-page {
width: 100%;
2025-05-15 11:51:13 +00:00
height: 100%;
}
</style>