Skip to content

Commit

Permalink
Merge branch 'kingwrcy:dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Jinvic authored Feb 14, 2025
2 parents 37c18ad + 4bda6c8 commit d001c0e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
8 changes: 5 additions & 3 deletions backend/handler/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,6 @@ func (c CommentHandler) AddComment(ctx echo.Context) error {
frontendHost := ctx.Request().Host
if err = c.commentEmailNotification(comment, frontendHost); err != nil {
c.base.log.Error().Msgf("邮件通知失败,原因:%s", err)
} else {
c.base.log.Info().Msgf("成功发送邮件")
}
}()
return SuccessResp(ctx, h{})
Expand All @@ -232,13 +230,16 @@ func (c CommentHandler) commentEmailNotification(comment db.Comment, host string
return nil
}

// 验证邮箱是否可用
// 验证邮箱是否为空
var targetEmail string
if comment.ReplyTo != "" { // 回复评论
targetEmail = comment.ReplyEmail
} else { // 直接评论
targetEmail = user.Email
}
if targetEmail == "" {
return nil
}

// 获取smtp客户端
client, err := mail.GetSMTPClient(sysConfigVO.SmtpHost, sysConfigVO.SmtpPort, sysConfigVO.SmtpUsername, sysConfigVO.SmtpPassword)
Expand Down Expand Up @@ -297,5 +298,6 @@ func (c CommentHandler) commentEmailNotification(comment db.Comment, host string
return err
}

c.base.log.Info().Msgf("成功发送邮件")
return nil
}
15 changes: 10 additions & 5 deletions front/components/CommentBox.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
<template>
<div class="px-4 py-2 flex flex-col gap-2 mt-2" v-if="currentCommentBox === pid">
<div class="relative">
<UTextarea :rows="3" autofocus :placeholder="replyTo ? `回复给${replyTo}` : ''" v-model="state.content"/>
<div class="animate-bounce absolute right-2 bottom-1 cursor-pointer text-xl select-none" @click="toggleEmoji">😊
<UTextarea :rows="4" autofocus :placeholder="replyTo ? `回复给${replyTo}` : ''" v-model="state.content"/>
<div class="flex gap-2 absolute right-3 bottom-2">
<UIcon v-if="!global.userinfo.token" class="text-[#9fc84a] w-6 h-6 cursor-pointer" name="i-carbon-user-avatar" @click="toggleUser"/>
<UIcon class="text-[#9fc84a] w-6 h-6 cursor-pointer select-none" name="i-carbon-face-satisfied" @click="toggleEmoji"/>
<UButton class="cursor-pointer text-xs" color="white" @click="comment">发送</UButton>
</div>
</div>
<Emoji v-if="emojiShow" @selected="emojiSelected"/>
<div class="flex gap-1">
<div v-if="userShow" class="flex gap-1">
<template v-if="!global.userinfo.token">
<UInput placeholder="姓名" v-model="state.username"/>
<UInput placeholder="网站" v-model="state.website"/>
<UInput placeholder="邮箱" v-model="state.email"/>
</template>
<UButton color="white" @click="comment">发布评论</UButton>
</div>
</div>
</template>
Expand Down Expand Up @@ -40,6 +42,7 @@ const localCommentUserinfo = useStorage('localCommentUserinfo', {
website: "",
email: "",
})
const userShow = ref(false)
const emojiShow = ref(false)
const currentCommentBox = useState('currentCommentBox')
const sysConfig = useState<SysConfigVO>('sysConfig')
Expand Down Expand Up @@ -88,7 +91,9 @@ const doComment = async (token?: string) => {
memoChangedEvent.emit(props.memoId)
}
const toggleUser = () => {
userShow.value = !userShow.value
}
const toggleEmoji = () => {
emojiShow.value = !emojiShow.value
}
Expand Down
4 changes: 1 addition & 3 deletions front/components/MemoEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
<div class="w-full" @contextmenu.prevent="onContextMenu">
<div class="relative">
<UTextarea ref="contentRef" v-model="state.content" :rows="8" autoresize padded autofocus/>
<div class="animate-bounce absolute right-2 bottom-1 cursor-pointer text-xl select-none" @click="toggleEmoji">
😊
</div>
<UIcon class="text-[#9fc84a] w-6 h-6 animate-bounce absolute right-2 bottom-1 cursor-pointer select-none" name="i-carbon-face-satisfied" @click="toggleEmoji"/>
</div>

<Emoji v-if="emojiShow" @selected="emojiSelected" @close="emojiShow=false"/>
Expand Down
2 changes: 1 addition & 1 deletion front/pages/user/settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const reload = async () => {
const save = async () => {
await useMyFetch('/user/saveProfile', state)
toast.success("保存成功")
await reload()
location.reload()
}
const uploadAvatarUrl = async (files: FileList) => {
Expand Down

0 comments on commit d001c0e

Please sign in to comment.