Skip to content

Commit

Permalink
去除邮箱必填的要求
Browse files Browse the repository at this point in the history
  • Loading branch information
cetr committed May 26, 2022
1 parent b9423f9 commit 0167519
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 121 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@

1. 进入Halo博客后台 -> 系统 -> 博客设置 -> 评论设置

2.`评论模块 JS` 修改为:`https://npm.elemecdn.com/halo-comment-yu@1.5.2/dist/halo-comment.min.js`
2.`评论模块 JS` 修改为:`https://npm.elemecdn.com/halo-comment-yu@1.5.3/dist/halo-comment.min.js`

3. 保存
78 changes: 22 additions & 56 deletions dist/halo-comment.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/halo-comment.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions dist/halo-comment.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/halo-comment.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "halo-comment-yu",
"version": "v1.5.2",
"version": "v1.5.3",
"main": "dist/halo-comment.min.js",
"private": false,
"files": [
Expand Down
74 changes: 19 additions & 55 deletions src/components/CommentEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@
名称 <span>*</span>
</label>
<span class="input-avatar">
<img :src="avatar" class="avatar-img">
</span>
<img :src="avatar" class="avatar-img"/>
</span>
<input
type="text"
id="author"
Expand All @@ -107,24 +107,18 @@
tabindex="1"
required="required"
aria-required="true"
placeholder="填写QQ号自动获取昵称和邮箱"
@blur="pullInfo"
placeholder="姓名或昵称(必填)"
>
</div>
<div class="commentator commentator-email">
<label for="email">
邮箱 <span>*</span>
</label>
<label for="email">邮箱</label>
<input
type="text"
id="email"
class="comment-input email"
v-model="comment.email"
tabindex="2"
required="required"
aria-required="true"
placeholder="用于获取头像和接收回复通知"
@blur="pullInfo"
placeholder="接收回复和获取头像(选填,将保密)"
>
</div>
<div class="commentator commentator-authorUrl">
Expand All @@ -135,7 +129,7 @@
class="comment-input link"
v-model="comment.authorUrl"
tabindex="3"
placeholder="网站或博客地址"
placeholder="网站或博客(选填)"
>
</div>
</div>
Expand Down Expand Up @@ -201,10 +195,9 @@ import {
renderedEmojiHtml,
decodeHtmlLabel,
validEmail,
returnBr
returnBr, isUrl
} from "../utils/util";
import commentApi from "../api/comment";
import axios from "axios";
import autosize from "autosize";
export default {
Expand Down Expand Up @@ -273,13 +266,6 @@ export default {
const gravatarMd5 = md5(this.comment.email);
return `${gravatarSource}${gravatarMd5}?s=256&d=${gravatarDefault}`;
},
commentValid() {
return (
!isEmpty(this.comment.author) &&
!isEmpty(this.comment.email) &&
!isEmpty(this.comment.content)
);
},
infoAlertVisiable() {
return this.infoes !== null && this.infoes.length > 0;
},
Expand All @@ -306,15 +292,23 @@ export default {
methods: {
handleSubmitClick() {
if (isEmpty(this.comment.author)) {
this.warnings.push("评论者昵称不能为空");
this.clearAlertClose();
this.warnings.push("评论者昵称不能为空!");
return;
}
if (isEmpty(this.comment.email)) {
this.warnings.push("邮箱不能为空");
if (!isEmpty(this.comment.email) && !validEmail(this.comment.email)) {
this.clearAlertClose();
this.warnings.push("邮箱格式不正确!");
return;
}
if (!isEmpty(this.comment.authorUrl) && !isUrl(this.comment.authorUrl)) {
this.clearAlertClose();
this.warnings.push("网址格式不正确!");
return;
}
if (isEmpty(this.comment.content)) {
this.warnings.push("评论内容不能为空");
this.clearAlertClose();
this.warnings.push("评论内容不能为空!");
return;
}
Expand Down Expand Up @@ -383,36 +377,6 @@ export default {
this.comment.content += emoji.emoji;
}
},
pullInfo() {
let author = this.comment.author;
if (author.length != 0 && /^[1-9][0-9]{4,9}$/gim.test(author)) {
this.pullQQInfo(() => {
this.warnings.push("拉取QQ信息失败!");
});
return;
}
},
pullQQInfo(errorQQCallback) {
let _self = this;
axios
.get("https://api.coor.top/qqinfo", {
params: {
qq: _self.comment.author
}
})
.then(function (res) {
let data = res.data;
if (!!data.code && data.code == 500) {
errorQQCallback();
}
_self.comment.author = data.nickname;
_self.comment.email = data.email;
// _self.avatar = data.avatar;
})
.catch(() => {
errorQQCallback();
});
},
clearAlertClose() {
this.infoes = [];
this.warnings = [];
Expand Down
2 changes: 1 addition & 1 deletion src/components/EmojiPicker/data/_emojis.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 18 additions & 1 deletion src/styles/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,24 @@ $md-link-color: #1890ff;
}
}

@media (max-width: 520px) {
@media (max-width: 991px) {
.halo-comment {
.author-info {
.commentator-author,
.commentator-email {
width: 50%;
margin-bottom: 15px;
}

.commentator-authorUrl {
width: 100%;
margin-bottom: 15px;
}
}
}
}

@media (max-width: 580px) {
.halo-comment {
.author-info {
.commentator {
Expand Down

0 comments on commit 0167519

Please sign in to comment.