完成大作业部分及其打磨

This commit is contained in:
li-chx
2025-05-11 17:22:21 +08:00
parent 3ab2c26776
commit 0622b15509
23 changed files with 651 additions and 160 deletions
@@ -0,0 +1,24 @@
<script setup lang="ts">
import { MdPreview } from 'md-editor-v3';
import 'md-editor-v3/lib/style.css';
import BackButton from '~/components/BackButton.vue';
const store = useArticleStore();
const content = store.currentArticle.content;
const title = store.currentArticle.title;
</script>
<template>
<div class="p-6">
<back-button class="ml-3" />
<div
class="m-2 bg-white rounded-xl p-6 border-gray-200 border-2 min-h-[300px] dark:bg-black dark:border-zinc-600"
>
<span class="text-4xl">{{ title }}</span>
<MdPreview
v-model="content"
:theme="useColorMode().preference"
class="mt-6"
></MdPreview>
</div>
</div>
</template>
@@ -0,0 +1,23 @@
<script setup lang="ts">
const store = useArticleStore();
const content = ref(store.currentArticle.content);
const title = ref(store.currentArticle.title);
async function saveArticle(data: { title: string; content: string }) {
store.currentArticle.title = data.title;
store.currentArticle.content = data.content;
await store.modifyArticle();
useRouter().back();
}
</script>
<template>
<ArticleEditor
:base-content="content"
:base-title="title"
:save-button="'更改文章'"
@article-edit-finish="saveArticle"
/>
</template>
<style scoped lang="less"></style>