♻️ refactor some code

This commit is contained in:
2025-02-05 18:57:58 +08:00
parent a2e80b9a91
commit b4ef5a4b51
21 changed files with 501 additions and 217 deletions

View File

@@ -40,35 +40,32 @@
<AUpload
:accept="'image/jpg, image/png, image/jpeg'"
name="images"
:max-count="3"
:max-count="1"
:multiple="true"
method="post"
:directory="false"
:show-upload-list="false"
:custom-request="comment.customUploadRequest"
:before-upload="comment.beforeUpload"
:disabled="comment.imageList.length >= 3 || comment.uploadLoading"
:disabled="comment.uploadLoading"
>
<ABadge :count="comment.imageList.length">
<AButton type="text" size="small" :icon="h(PictureOutlined)"
class="comment-action-icon" :loading="comment.uploadLoading">
{{ t('comment.picture') }}
</AButton>
</ABadge>
<AButton type="text" size="small" :icon="h(PictureOutlined)"
class="comment-action-icon" :loading="comment.uploadLoading">
{{ t('comment.picture') }}
</AButton>
</AUpload>
<template v-if="comment.imageList.length > 0">
<AImagePreviewGroup>
<ABadge style="margin-left: 10px;" v-for="(item, index) in comment.imageList" :key="index">
<template #count>
<CloseCircleOutlined @click="comment.removeBase64Image(index)" style="color: #f5222d"/>
<template v-if="comment.imageList">
<ABadge style="margin-left: 10px;">
<template #count>
<CloseCircleOutlined @click="comment.removeBase64Image()" style="color: #f5222d"/>
</template>
<AAvatar shape="square" size="small">
<template #icon>
<AImage :width="24" :height="24" :src="comment.imageList"/>
</template>
<AAvatar shape="square" size="small">
<template #icon>
<AImage v-if="item" :width="24" :height="24" :src="item"/>
</template>
</AAvatar>
</ABadge>
</AImagePreviewGroup>
</AAvatar>
</ABadge>
</template>
</AFlex>
</AFlex>
@@ -153,10 +150,6 @@ async function commentSubmit(point: any) {
message.error(t('comment.commentContentNotEmpty'));
return;
}
if (comment.imageList.length > 3) {
message.error(t('comment.maxImageCount'));
return;
}
const content = commentContent.value.replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' ');
const regex = /\[((1[0-6][0-6]|[1-9]?[0-9])\.gif)]/g; // 匹配 [1.gif] 的字符串
const contentWithEmoji = content.replace(regex, (_match, p1) => {
@@ -216,10 +209,6 @@ async function showSlideCaptcha() {
if (commentContent.value.trim() === "") {
return;
}
if (comment.imageList.length > 3) {
message.warning(t('comment.maxImageCount'));
return;
}
const res = await comment.getSlideCaptchaData();
if (res) {
showSubmitCaptcha.value = true;

View File

@@ -68,8 +68,7 @@
<AFlex :vertical="false" align="center" class="reply-images" v-if="item.images">
<AImagePreviewGroup>
<ASpace direction="horizontal">
<AImage :width="80" :height="80" v-for="(image, index) in item.images" :key="index"
:src="image">
<AImage :width="80" :height="80" :src="item.images">
<template #previewMask>
<EyeOutlined style="font-size: 20px;"/>
</template>

View File

@@ -56,24 +56,24 @@
:show-upload-list="false"
:custom-request="comment.customUploadRequest"
:before-upload="comment.beforeUpload"
:disabled="comment.imageList.length >= 3 || comment.uploadLoading"
:disabled="comment.uploadLoading"
>
<ABadge :count="comment.imageList.length">
<ABadge>
<AButton type="text" size="small" :icon="h(PictureOutlined)"
class="comment-action-icon-reply" :loading="comment.uploadLoading">
{{ t('comment.picture') }}
</AButton>
</ABadge>
</AUpload>
<template v-if="comment.imageList.length > 0">
<template v-if="comment.imageList">
<AImagePreviewGroup>
<ABadge style="margin-left: 10px;" v-for="(item, index) in comment.imageList" :key="index">
<ABadge style="margin-left: 10px;">
<template #count>
<CloseCircleOutlined @click="comment.removeBase64Image(index)" style="color: #f5222d"/>
<CloseCircleOutlined @click="comment.removeBase64Image()" style="color: #f5222d"/>
</template>
<AAvatar shape="square" size="small">
<template #icon>
<AImage v-if="item" :width="24" :height="24" :src="item"/>
<AImage :width="24" :height="24" :src="comment.imageList"/>
</template>
</AAvatar>
</ABadge>
@@ -157,10 +157,6 @@ async function replySubmit(point: any) {
if (replyContent.value.trim() === "") {
return;
}
if (comment.imageList.length > 3) {
message.warning(t('comment.maxImageCount'));
return;
}
const content = replyContent.value.replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' ');
const regex = /\[((1[0-6][0-6]|[1-9]?[0-9])\.gif)\]/g; // 匹配 [1.gif] 的字符串
const contentWithEmoji = content.replace(regex, (_match, p1) => {
@@ -234,10 +230,6 @@ async function showSlideCaptcha() {
message.warning(t('comment.commentContentNotEmpty'));
return;
}
if (comment.imageList.length > 3) {
message.warning(t('comment.maxImageCount'));
return;
}
const res = await comment.getSlideCaptchaData();
if (res) {
showSubmitCaptcha.value = true;

View File

@@ -51,8 +51,7 @@
<AImagePreviewGroup>
<AImagePreviewGroup>
<ASpace direction="horizontal">
<AImage :width="80" :height="80" v-for="(image, index) in child.images" :key="index"
:src="image">
<AImage :width="80" :height="80" :src="child.images">
<template #previewMask>
<EyeOutlined style="font-size: 20px;"/>
</template>

View File

@@ -59,26 +59,25 @@
:show-upload-list="false"
:custom-request="comment.customUploadRequest"
:before-upload="comment.beforeUpload"
:disabled="comment.imageList.length >= 3 || comment.uploadLoading"
:disabled="comment.uploadLoading"
>
<ABadge :count="comment.imageList.length">
<ABadge>
<AButton type="text" size="small" :icon="h(PictureOutlined)"
class="comment-action-icon-reply-child" :loading="comment.uploadLoading">
{{ t('comment.picture') }}
</AButton>
</ABadge>
</AUpload>
<template v-if="comment.imageList.length > 0">
<template v-if="comment.imageList">
<AImagePreviewGroup>
<ABadge style="margin-left: 10px;" v-for="(item, index) in comment.imageList"
:key="index">
<ABadge style="margin-left: 10px;">
<template #count>
<CloseCircleOutlined @click="comment.removeBase64Image(index)"
<CloseCircleOutlined @click="comment.removeBase64Image()"
style="color: #f5222d"/>
</template>
<AAvatar shape="square" size="small">
<template #icon>
<AImage v-if="item" :width="24" :height="24" :src="item"/>
<AImage :width="24" :height="24" :src="comment.imageList"/>
</template>
</AAvatar>
</ABadge>
@@ -168,10 +167,6 @@ async function replyReplySubmit(point: any) {
if (replyReplyContent.value.trim() === "") {
return;
}
if (comment.imageList.length > 3) {
message.warning(t('comment.maxImageCount'));
return;
}
const content = replyReplyContent.value.replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' ');
const regex = /\[((1[0-6][0-6]|[1-9]?[0-9])\.gif)]/g; // 匹配 [1.gif] 的字符串
const contentWithEmoji = content.replace(regex, (_match, p1) => {
@@ -240,10 +235,6 @@ async function showSlideCaptcha() {
message.warning(t('comment.commentContentNotEmpty'));
return;
}
if (comment.imageList.length > 3) {
message.warning(t('comment.maxImageCount'));
return;
}
const res = await comment.getSlideCaptchaData();
if (res) {
showSubmitCaptcha.value = true;

View File

@@ -5,7 +5,7 @@
@click="handleClick"
:style="cardStyle">
<div class="hover-circle" @click.stop="toggleSelection"
v-if="showHoverCircle"
v-if="showHoverCircle && !isSelected"
:style="{ width: iconSize + 'px', height: iconSize + 'px' }">
<img :src="greyComplete" alt="Hover" class="hover-icon"
:style="{ width: iconSize + 'px', height: iconSize + 'px' }"/>