feat:更新博客评论功能
This commit is contained in:
@@ -30,7 +30,7 @@ export const queryBlogByConditionApi = (query: IQueryBlog): Promise<IBlog[]> =>
|
|||||||
|
|
||||||
export const queryBlogByIdApi = (id: number): Promise<IBlog> =>
|
export const queryBlogByIdApi = (id: number): Promise<IBlog> =>
|
||||||
cloudService({
|
cloudService({
|
||||||
url: `/blog-api/blog/content/${id}`,
|
url: `/blog-api/blog/${id}/content`,
|
||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -54,13 +54,13 @@ export const queryLatestBlogApi = (): Promise<IBlog[]> =>
|
|||||||
|
|
||||||
export const queryBlogCommentApi = (blogId: number): Promise<IBlogComment[]> =>
|
export const queryBlogCommentApi = (blogId: number): Promise<IBlogComment[]> =>
|
||||||
cloudService({
|
cloudService({
|
||||||
url: `/blog-api/blog/comment/${blogId}`,
|
url: `/blog-api/blog/${blogId}/comment`,
|
||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
|
|
||||||
export const addBlogCommentApi = (blogComment: IBlogComment): Promise<boolean> =>
|
export const addBlogCommentApi = (blogId: number, blogComment: IBlogComment): Promise<boolean> =>
|
||||||
cloudService({
|
cloudService({
|
||||||
url: '/blog-api/blog/comment',
|
url: `/blog-api/blog/${blogId}/comment`,
|
||||||
method: 'put',
|
method: 'put',
|
||||||
data: blogComment
|
data: blogComment
|
||||||
})
|
})
|
||||||
|
|||||||
Binary file not shown.
BIN
src/assets/font/custom.woff2
Normal file
BIN
src/assets/font/custom.woff2
Normal file
Binary file not shown.
@@ -82,15 +82,14 @@ const onSelectEmoji = (emoji) => {
|
|||||||
|
|
||||||
const sendCommentClick = async () => {
|
const sendCommentClick = async () => {
|
||||||
blogComment.value.parentId = props.parentId
|
blogComment.value.parentId = props.parentId
|
||||||
blogComment.value.blogId = blogStore.currentBlogId
|
|
||||||
|
|
||||||
if (!blogComment.value.name) {
|
if (!blogComment.value.name) {
|
||||||
blogComment.value.name = 'Anonymous'
|
blogComment.value.name = 'Anonymous'
|
||||||
}
|
}
|
||||||
|
|
||||||
await blogStore.addBlogComment(blogComment.value)
|
await blogStore.addBlogComment(blogStore.currentBlogId, blogComment.value)
|
||||||
blogComment.value = deepCopyObject(blogStore.getEmptyBlogComment())
|
blogComment.value = deepCopyObject(blogStore.getEmptyBlogComment())
|
||||||
blogStore.isShowBlogCommentEdit = false
|
blogStore.isShowCommentEdit = false
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
<div class="sub-info">
|
<div class="sub-info">
|
||||||
<span class="content">{{ props.comment.createTime }}</span>
|
<span class="content">{{ props.comment.createTime }}</span>
|
||||||
<el-button v-if="!blogComment.isShowEdit"
|
<el-button v-if="!blogStore.isShowCommentEdit"
|
||||||
type="primary" text @click="replyClick">回复</el-button>
|
type="primary" text @click="replyClick">回复</el-button>
|
||||||
<el-button v-else type="primary"
|
<el-button v-else type="primary"
|
||||||
text @click="cancelClick">取消</el-button>
|
text @click="cancelClick">取消</el-button>
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
<p>{{ props.comment.content }}</p>
|
<p>{{ props.comment.content }}</p>
|
||||||
|
|
||||||
<blog-comment-edit v-if="blogComment.isShowEdit"
|
<blog-comment-edit v-if="blogStore.isShowCommentEdit"
|
||||||
:parent-id="props.comment.id"/>
|
:parent-id="props.comment.id"/>
|
||||||
|
|
||||||
<div class="reply-list">
|
<div class="reply-list">
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import BlogCommentEdit from '@/components/Comment/BlogCommentEdit.vue'
|
import BlogCommentEdit from '@/components/Comment/BlogCommentEdit.vue'
|
||||||
import 'vue3-emoji-picker/css'
|
import 'vue3-emoji-picker/css'
|
||||||
import { defineProps, PropType, reactive } from 'vue'
|
import { defineProps, PropType } from 'vue'
|
||||||
import { IBlogComment } from '@/types/blog'
|
import { IBlogComment } from '@/types/blog'
|
||||||
import { useBlogStore } from '@/store/blog.ts'
|
import { useBlogStore } from '@/store/blog.ts'
|
||||||
import { UAParser } from 'ua-parser-js'
|
import { UAParser } from 'ua-parser-js'
|
||||||
@@ -67,17 +67,13 @@ const props = defineProps({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const blogComment = reactive({
|
|
||||||
isShowEdit: false
|
|
||||||
})
|
|
||||||
|
|
||||||
const replyClick = () => {
|
const replyClick = () => {
|
||||||
blogStore.currentBlogComment = blogStore.getEmptyBlogComment()
|
blogStore.currentBlogComment = blogStore.getEmptyBlogComment()
|
||||||
blogComment.isShowEdit = true
|
blogStore.isShowCommentEdit = true
|
||||||
}
|
}
|
||||||
|
|
||||||
const cancelClick = () => {
|
const cancelClick = () => {
|
||||||
blogComment.isShowEdit = false
|
blogStore.isShowCommentEdit = false
|
||||||
}
|
}
|
||||||
|
|
||||||
const getOsInfo = (userAgent: string) => {
|
const getOsInfo = (userAgent: string) => {
|
||||||
|
|||||||
@@ -66,7 +66,8 @@ export const useBlogStore = defineStore('blog', {
|
|||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
totalSize: 1
|
totalSize: 1
|
||||||
},
|
},
|
||||||
progressValue: '0%'
|
progressValue: '0%',
|
||||||
|
isShowCommentEdit: false
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
async queryBlog() {
|
async queryBlog() {
|
||||||
@@ -91,9 +92,9 @@ export const useBlogStore = defineStore('blog', {
|
|||||||
this.searchBlogList = await searchBlogApi(keyword)
|
this.searchBlogList = await searchBlogApi(keyword)
|
||||||
this.isSearching = false
|
this.isSearching = false
|
||||||
},
|
},
|
||||||
async addBlogComment(blogComment: IBlogComment) {
|
async addBlogComment(blogId: number, blogComment: IBlogComment) {
|
||||||
await addBlogCommentApi(blogComment)
|
await addBlogCommentApi(blogId, blogComment)
|
||||||
await this.queryBlogById(blogComment.blogId)
|
await this.queryBlogById(blogId)
|
||||||
},
|
},
|
||||||
async queryBlogCategory() {
|
async queryBlogCategory() {
|
||||||
this.blogCategoryList = await queryBlogCategoryApi()
|
this.blogCategoryList = await queryBlogCategoryApi()
|
||||||
@@ -109,7 +110,6 @@ export const useBlogStore = defineStore('blog', {
|
|||||||
blogId: 0,
|
blogId: 0,
|
||||||
content: '',
|
content: '',
|
||||||
createTime: '',
|
createTime: '',
|
||||||
id: 0,
|
|
||||||
ipAddress: '',
|
ipAddress: '',
|
||||||
isApproved: true,
|
isApproved: true,
|
||||||
name: '',
|
name: '',
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ span, input {
|
|||||||
|
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: 'CustomFont';
|
font-family: 'CustomFont';
|
||||||
src: url('@/assets/font/custom.ttf') format('truetype');
|
src: url('@/assets/font/custom.woff2') format('truetype');
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ export interface IBlogVisit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface IBlogComment {
|
export interface IBlogComment {
|
||||||
id: number;
|
id?: number;
|
||||||
blogId: number;
|
blogId: number;
|
||||||
name: string;
|
name: string;
|
||||||
website: string;
|
website: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user