feat: 继续完成文章编辑器中
This commit is contained in:
1 parent
caadd5a484
commit
31e253eaef
5 files changed
+90
-9
No files matched your search
+2
-2
@@ -2,8 +2,8 @@
|
||||
<div :class="['user-main', showSidebar ? '' : 'hide-sidebar']">
|
||||
<div class="user-sidebar">
|
||||
<!-- <el-button @click="handleHideSidebar">hide</el-button> -->
|
||||
<div class="sidebar-item" @click="handleHideSidebar">
|
||||
<div class="sidebar-item-icon">
|
||||
<div class="sidebar-item" @click="handleHideSidebar" style="justify-content: center;">
|
||||
<div class="sidebar-item-icon" style="transform: translateX(3px);">
|
||||
<component class="sidebar-item-icon-noFill" :is="chevronDown"
|
||||
:style="{ transform: showSidebar ? '' : 'rotate(-90deg)' }"></component>
|
||||
</div>
|
||||
|
||||
@@ -1,15 +1,61 @@
|
||||
<template>
|
||||
<div>
|
||||
edit: id-{{ route.params.id }}
|
||||
<editor v-model:id="id" v-model:title="title" v-model:summary="summary" v-model:tags="tags"
|
||||
v-model:content="content"></editor>
|
||||
<el-button @click = handleUpdate>
|
||||
upload
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import editor from '~/components/user/postEditor.vue';
|
||||
import useDefaultStore from '~/hooks/pinia/useDefaultStore';
|
||||
import useFetch from '~/hooks/useMiaoFetch';
|
||||
import type { postItem } from '~/types/post';
|
||||
|
||||
type resType = {
|
||||
data: string
|
||||
} & postItem
|
||||
|
||||
|
||||
const { post: { getPost, updatePost } } = useFetch()
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
const id = ref<number>(-1)
|
||||
const title = ref<string>('title')
|
||||
const summary = ref<string>('summary')
|
||||
const tags = ref<string[]>([])
|
||||
const content = ref<string>('content')
|
||||
|
||||
const handleUpdate = () => {
|
||||
updatePost({
|
||||
id: id.value,
|
||||
title: title.value,
|
||||
summary: summary.value,
|
||||
tags: tags.value,
|
||||
url: '',
|
||||
content: content.value,
|
||||
type: 'markdown',
|
||||
date: Date.now()
|
||||
})
|
||||
const store = useDefaultStore()
|
||||
store.deleteCache('posts')
|
||||
}
|
||||
|
||||
onBeforeMount(async () => {
|
||||
|
||||
id.value = parseInt(route.params.id as string)
|
||||
const res = await getPost(id.value) as any as resType
|
||||
console.log(res)
|
||||
id.value = res.id
|
||||
title.value = res.title
|
||||
summary.value = res.summary
|
||||
tags.value = []
|
||||
content.value = res.data
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
<style scoped></style>
|
||||
Reference in new issue
Block a user