Skip to content

Commit

Permalink
✨ 增加前台登录行为验证及优化UA展示
Browse files Browse the repository at this point in the history
  • Loading branch information
Licoy committed Dec 7, 2022
1 parent e93eeee commit 9c8ba3e
Show file tree
Hide file tree
Showing 18 changed files with 229 additions and 157 deletions.
13 changes: 7 additions & 6 deletions assets/dist/js/libs.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/dist/js/puock.min.js

Large diffs are not rendered by default.

92 changes: 46 additions & 46 deletions assets/dist/setting/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions assets/dist/style/animal.min.css

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

1 change: 1 addition & 0 deletions assets/dist/style/animation.min.css

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

2 changes: 1 addition & 1 deletion assets/dist/style/common.min.css

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions assets/dist/style/libs.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/dist/style/style.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/dist/style/var.min.css

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

87 changes: 51 additions & 36 deletions assets/js/puock.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,40 +140,51 @@ class Puock {
return false;
}
}
const url = form.attr("action");
const method = form.attr("method");
const data = form.serialize();
const dataType = "json";
const successTip = form.attr("data-success");
const errorTip = form.attr("data-error");
$.ajax({
url, method, data, dataType,
success: (res) => {
if (res.code === 0) {
this.toast(res.msg || successTip, TYPE_SUCCESS)
form.trigger("reset")
if (res.data) {
const resData = res.data
if (resData.action) {
setTimeout(() => {
switch (resData.action) {
case 'reload':
this.goUrl(window.location.href)
break
}
}, 500)
const validateType = form.data("validate");
const startSubmit = (args = {}) => {
const url = form.attr("action");
const method = form.attr("method");
const data = this.parseFormData(form, args);
const dataType = "json";
const successTip = form.attr("data-success");
const errorTip = form.attr("data-error");
$.ajax({
url, method, data, dataType,
success: (res) => {
if (res.code === 0) {
this.toast(res.msg || successTip, TYPE_SUCCESS)
form.trigger("reset")
if (res.data) {
const resData = res.data
if (resData.action) {
setTimeout(() => {
switch (resData.action) {
case 'reload':
this.goUrl(window.location.href)
break
}
}, 500)
}
}
} else {
this.toast(res.msg || errorTip, TYPE_DANGER)
this.loadCommentCaptchaImage(form, true)
}
} else {
this.toast(res.msg || errorTip, TYPE_DANGER)
},
error: (e) => {
this.toast(`请求错误:${e.statusText}`, TYPE_DANGER)
this.loadCommentCaptchaImage(form, true)
}
},
error: (e) => {
this.toast(`请求错误:${e.statusText}`, TYPE_DANGER)
this.loadCommentCaptchaImage(form, true)
}
})
})
}
if (validateType === 'gt') {
this.gt.validate((code) => {
startSubmit(code)
});
} else {
startSubmit()
}
return false;
})
}

Expand Down Expand Up @@ -714,6 +725,15 @@ class Puock {

}

parseFormData(formEl, args = {}) {
const dataArr = formEl.serializeArray();
const data = {...args};
for (let i = 0; i < dataArr.length; i++) {
data[dataArr[i].name] = dataArr[i].value;
}
return jQuery.param(data);
}

eventCommentPreSubmit() {
$(document).on('submit', '#comment-form', (e) => {
e.preventDefault();
Expand Down Expand Up @@ -746,14 +766,9 @@ class Puock {
let submitUrl = $("#comment-form").attr("action");
this.commentFormLoadStateChange();
const el = $(target);
const dataArr = el.serializeArray();
const data = {...args};
for (let i = 0; i < dataArr.length; i++) {
data[dataArr[i].name] = dataArr[i].value;
}
$.ajax({
url: submitUrl,
data: jQuery.param(data),
data: this.parseFormData(el, args),
type: el.attr('method'),
success: (data) => {
this.toast('评论已提交成功', TYPE_SUCCESS);
Expand Down
17 changes: 17 additions & 0 deletions assets/style/animation.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@-webkit-keyframes breathe {
0% {
opacity: .5;
}

100% {
opacity: 1;
}
}

.pk-breathe{
-webkit-animation-timing-function: ease-in-out;
-webkit-animation-name: breathe;
-webkit-animation-duration: 1200ms;
-webkit-animation-iteration-count: infinite;
-webkit-animation-direction: alternate;
}
6 changes: 3 additions & 3 deletions assets/style/common.less
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ a {
}

.c-sub() {
color: #808695 !important;
color: var(--pk-c-sub) !important;
}

.bg-255 {
Expand All @@ -318,7 +318,7 @@ a {
}

.c-sub-a {
color: #808695 !important;
color: var(--pk-c-sub) !important;
.ta3-fun();

&:hover {
Expand Down Expand Up @@ -461,7 +461,7 @@ a {
cursor: pointer;
border-radius: 2px;
background-color: var(--pk-bg-box-content);
color: #808695 !important;
color: var(--pk-c-sub) !important;
&:hover{
background-color: var(--pk-c-primary);
color: var(--pk-c-light) !important;
Expand Down
1 change: 1 addition & 0 deletions assets/style/style.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@import "var";
@import "init";
@import "common";
@import "animation";

body {
background-color: var(--pk-bg-body);
Expand Down
1 change: 1 addition & 0 deletions assets/style/var.less
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ body {
--pk-c-secondary: #6c757d;
--pk-c-yellow: #f5c800;
--pk-c-font: #343a40;
--pk-c-sub: #808695;
--pk-bg-body: #f3f5f7;
--pk-bg-card: #fff;
--pk-bg-box: #fff;
Expand Down
Loading

0 comments on commit 9c8ba3e

Please sign in to comment.