From 46e6b49c02647ea9a100190862f867ae295d422e Mon Sep 17 00:00:00 2001 From: landaiqing Date: Wed, 27 Nov 2024 18:59:11 +0800 Subject: [PATCH] :art: optimized code --- package.json | 4 +-- .../src/CommentInput/CommentInput.vue | 12 +++++---- .../src/ReplyInput/ReplyInput.vue | 14 +++++------ .../src/ReplyReplyInput/ReplyReply.vue | 14 +++++------ src/layout/Landing/Footer/Footer.vue | 2 +- src/layout/default/Header/Header.vue | 7 +++--- src/layout/default/Header/index.scss | 7 ++++++ src/store/modules/commentStore.ts | 12 +++++---- src/views/Forget/ForgetPage.vue | 17 +++++++------ src/views/Login/LoginFooter.vue | 4 +-- src/views/Login/LoginPage.vue | 25 +++++++++++++------ src/views/QRLogin/QRLogin.vue | 2 +- src/views/QRLogin/index.scss | 2 +- vite.config.ts | 2 +- 14 files changed, 74 insertions(+), 50 deletions(-) diff --git a/package.json b/package.json index eb54cc6..bffb5d0 100644 --- a/package.json +++ b/package.json @@ -54,14 +54,14 @@ }, "devDependencies": { "@eslint/js": "^9.15.0", - "@vitejs/plugin-vue": "^5.2.0", + "@vitejs/plugin-vue": "^5.2.1", "eslint-plugin-vue": "^9.31.0", "globals": "^15.12.0", "sass": "^1.81.0", "typescript": "^5.7.2", "typescript-eslint": "^8.15.0", "unplugin-vue-components": "^0.27.4", - "vite": "^6.0.0", + "vite": "^6.0.1", "vite-plugin-bundle-obfuscator": "1.3.1", "vite-plugin-chunk-split": "^0.5.0", "vue-tsc": "^2.1.10" diff --git a/src/components/CommentReply/src/CommentInput/CommentInput.vue b/src/components/CommentReply/src/CommentInput/CommentInput.vue index e785d85..ce44559 100644 --- a/src/components/CommentReply/src/CommentInput/CommentInput.vue +++ b/src/components/CommentReply/src/CommentInput/CommentInput.vue @@ -168,7 +168,7 @@ async function commentSubmit(point: any) { images: comment.imageList, author: user.user.uid, point: [point.x, point.y], - key: comment.slideCaptchaData.key, + key: comment.slideCaptchaData.captKey, }; const result: any = await commentSubmitApi(commentParams); if (result.code === 200) { @@ -182,8 +182,8 @@ async function commentSubmit(point: any) { created_time: result.data.created_time, browser: result.data.browser, operating_system: result.data.operating_system, - reply_count: result.data.reply_count, - likes: result.data.likes, + reply_count: 0, + likes: 0, author: result.data.author, location: result.data.location, is_liked: false, @@ -193,13 +193,15 @@ async function commentSubmit(point: any) { comment.commentList.comments = []; // 初始化 comments 数组 } comment.commentList.comments.unshift(tmpData); + comment.commentMap[result.data.id] = tmpData; + commentContent.value = ""; await comment.clearFileList(); showSubmitCaptcha.value = false; message.success(t('comment.commentSuccess')); } else { await comment.getSlideCaptchaData(); - message.error(result.message || t('comment.commentError')); + message.warning(result.message || t('comment.commentError')); } } @@ -215,7 +217,7 @@ async function showSlideCaptcha() { return; } if (comment.imageList.length > 3) { - message.error(t('comment.maxImageCount')); + message.warning(t('comment.maxImageCount')); return; } const res = await comment.getSlideCaptchaData(); diff --git a/src/components/CommentReply/src/ReplyInput/ReplyInput.vue b/src/components/CommentReply/src/ReplyInput/ReplyInput.vue index 4e6b599..6385876 100644 --- a/src/components/CommentReply/src/ReplyInput/ReplyInput.vue +++ b/src/components/CommentReply/src/ReplyInput/ReplyInput.vue @@ -158,7 +158,7 @@ async function replySubmit(point: any) { return; } if (comment.imageList.length > 3) { - message.error(t('comment.maxImageCount')); + message.warning(t('comment.maxImageCount')); return; } const content = replyContent.value.replace(/\r\n/g, '
').replace(/\n/g, '
').replace(/\s/g, ' '); @@ -183,7 +183,7 @@ async function replySubmit(point: any) { reply_id: props.item.id, reply_user: props.item.user_id, point: [point.x, point.y], - key: comment.slideCaptchaData.key, + key: comment.slideCaptchaData.captKey, }; const result: any = await replySubmitApi(replyParams); if (result.code === 200) { @@ -198,8 +198,8 @@ async function replySubmit(point: any) { browser: result.data.browser, operating_system: result.data.operating_system, location: result.data.location, - likes: result.data.likes, - reply_count: result.data.reply_count, + reply_count: 0, + likes: 0, reply_user: result.data.reply_user, nickname: user.user.nickname, avatar: user.user.avatar, @@ -218,7 +218,7 @@ async function replySubmit(point: any) { message.success(t('comment.replySuccess')); } else { await comment.getSlideCaptchaData(); - message.error(t('comment.replyError')); + message.warning(t('comment.replyError')); } } @@ -229,11 +229,11 @@ const getSlideCaptchaDataThrottled = useThrottleFn(comment.getSlideCaptchaData, */ async function showSlideCaptcha() { if (replyContent.value.trim() === "") { - message.error(t('comment.commentContentNotEmpty')); + message.warning(t('comment.commentContentNotEmpty')); return; } if (comment.imageList.length > 3) { - message.error(t('comment.maxImageCount')); + message.warning(t('comment.maxImageCount')); return; } const res = await comment.getSlideCaptchaData(); diff --git a/src/components/CommentReply/src/ReplyReplyInput/ReplyReply.vue b/src/components/CommentReply/src/ReplyReplyInput/ReplyReply.vue index 6b5ed88..d918ad3 100644 --- a/src/components/CommentReply/src/ReplyReplyInput/ReplyReply.vue +++ b/src/components/CommentReply/src/ReplyReplyInput/ReplyReply.vue @@ -169,7 +169,7 @@ async function replyReplySubmit(point: any) { return; } if (comment.imageList.length > 3) { - message.error(t('comment.maxImageCount')); + message.warning(t('comment.maxImageCount')); return; } const content = replyReplyContent.value.replace(/\r\n/g, '
').replace(/\n/g, '
').replace(/\s/g, ' '); @@ -186,7 +186,7 @@ async function replyReplySubmit(point: any) { reply_id: props.item.id, reply_user: props.child.user_id, point: [point.x, point.y], - key: comment.slideCaptchaData.key, + key: comment.slideCaptchaData.captKey, }; const result: any = await replyReplySubmitApi(replyParams); if (result.code === 200) { @@ -201,8 +201,8 @@ async function replyReplySubmit(point: any) { browser: result.data.browser, operating_system: result.data.operating_system, location: result.data.location, - likes: result.data.likes, - reply_count: result.data.reply_count, + reply_count: 0, + likes: 0, reply_user: result.data.reply_user, nickname: user.user.nickname, avatar: user.user.avatar, @@ -224,7 +224,7 @@ async function replyReplySubmit(point: any) { message.success(t('comment.replySuccess')); } else { await comment.getSlideCaptchaData(); - message.error(t('comment.replyError')); + message.warning(t('comment.replyError')); } } @@ -235,11 +235,11 @@ const getSlideCaptchaDataThrottled = useThrottleFn(comment.getSlideCaptchaData, */ async function showSlideCaptcha() { if (replyReplyContent.value.trim() === "") { - message.error(t('comment.commentContentNotEmpty')); + message.warning(t('comment.commentContentNotEmpty')); return; } if (comment.imageList.length > 3) { - message.error(t('comment.maxImageCount')); + message.warning(t('comment.maxImageCount')); return; } const res = await comment.getSlideCaptchaData(); diff --git a/src/layout/Landing/Footer/Footer.vue b/src/layout/Landing/Footer/Footer.vue index 7573dfd..1e160fe 100644 --- a/src/layout/Landing/Footer/Footer.vue +++ b/src/layout/Landing/Footer/Footer.vue @@ -13,7 +13,7 @@