🎨 optimized code
This commit is contained in:
@@ -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();
|
||||
|
@@ -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, '<br/>').replace(/\n/g, '<br/>').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();
|
||||
|
@@ -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, '<br/>').replace(/\n/g, '<br/>').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();
|
||||
|
Reference in New Issue
Block a user