Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
DesertsPan committed Sep 14, 2018
1 parent 7508239 commit 6963e29
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 37 deletions.
2 changes: 1 addition & 1 deletion dist/Valine.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/Valine.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": "valine",
"version": "1.1.5",
"version": "1.1.6",
"description": "A simple comment system based on Leancloud.",
"main": "/src/Valine.js",
"author": {
Expand Down
36 changes: 17 additions & 19 deletions src/Valine.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const defaultComment = {
comment: '',
rid: '',
at: '',
nick: '小可爱',
nick: '访客',
mail: '',
link: '',
ua: navigator.userAgent,
Expand Down Expand Up @@ -51,7 +51,7 @@ class Valine {
}
_root.el = el;
_root.el.classList.add('valine');
let placeholder = option.placeholder || 'ヾノ≧∀≦)o来啊,快活啊!';
let placeholder = option.placeholder || '';
let eleHTML = `<div class="vwrap">
<div class="textarea-wrapper">
<textarea class="veditor" placeholder="${placeholder}"></textarea>
Expand Down Expand Up @@ -81,18 +81,17 @@ class Valine {
</p>
</div>
<section class="auth-section">
<div class="input-wrapper"><input type="text" name="author" class="vnick" placeholder="名字" value=""></div>
<div class="input-wrapper"><input type="email" name="email" class="vmail" placeholder="E-mail" value=""></div>
<div class="input-wrapper"><input type="text" name="author" class="vnick" placeholder="昵称" value=""></div>
<div class="input-wrapper"><input type="email" name="email" class="vmail" placeholder="邮箱" value=""></div>
<div class="input-wrapper"><input type="text" name="website" class="vlink" placeholder="网站 (可选)" value=""></div>
<div class="post-action"><button type="button" class="vsubmit">提交</button></div>
</section>
<div style="display:none;" class="vmark"></div>
</div>
<div class="info">
<div class="col"> <span class="count">0</span> 条评论</div>
<div class="col">已有 <span class="count">0</span> 条评论</div>
<div class="col power float-right">
<svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M14.85 3H1.15C.52 3 0 3.52 0 4.15v7.69C0 12.48.52 13 1.15 13h13.69c.64 0 1.15-.52 1.15-1.15v-7.7C16 3.52 15.48 3 14.85 3zM9 11H7V8L5.5 9.92 4 8v3H2V5h2l1.5 2L7 5h2v6zm2.99.5L9.5 8H11V5h2v3h1.5l-2.51 3.5z"></path></svg>
<span>Markdown supported</span>
<a href="https://segmentfault.com/markdown" target="_blank"><svg aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M14.85 3H1.15C.52 3 0 3.52 0 4.15v7.69C0 12.48.52 13 1.15 13h13.69c.64 0 1.15-.52 1.15-1.15v-7.7C16 3.52 15.48 3 14.85 3zM9 11H7V8L5.5 9.92 4 8v3H2V5h2l1.5 2L7 5h2v6zm2.99.5L9.5 8H11V5h2v3h1.5l-2.51 3.5z"></path></svg></a>
</div>
</div>
<div class="vsubmitting" style="display:none;"></div>
Expand Down Expand Up @@ -233,6 +232,7 @@ class Valine {
textField.value += tag;
textField.focus()
}
defaultComment["comment"] = textField.value;
let submitBtn = _root.el.querySelector('.vsubmit');
if (submitBtn.getAttribute('disabled')) submitBtn.removeAttribute('disabled');
})
Expand All @@ -252,10 +252,10 @@ class Valine {
let query = new _root.v.Query('Comment');
query.select(['nick', 'comment', 'link', 'rid', 'isSpam', 'emailHash', 'like', 'pin']);
query.equalTo('url', defaultComment['url']);
query.addDescending('like')
query.addDescending('createdAt');
query.addDescending('like');
return query;
}
};

var num = 1;
let query = (n = 1) => {
Expand Down Expand Up @@ -309,7 +309,7 @@ class Valine {
<div class="like-count" id="like-count-${ret.id}">
${ret.get("like") > 0 ? ret.get("like") : ""}
</div>
<div class="heart" id="heart-${ret.id}"></div>
<div class="heart" id="heart-${ret.id}" style="background:url(//cloud.panjunwen.com/heart.png);background-position:left;background-repeat:no-repeat;background-size:2900%;"></div>
</div>
<a rid='${ret.id}' at='@${ret.get('nick')}' class="vat">回复</a>
</div>
Expand Down Expand Up @@ -469,15 +469,15 @@ class Valine {
if (!mailRet.k && !linkRet.k) {
_root.alert.show({
type: 1,
text: '您的网址和邮箱格式不正确, 是否继续提交?',
text: '您的网址和邮箱格式不正确, 将导致无法正确显示头像和接收回复通知邮件。是否继续提交?',
cb() {
commitEvt()
}
})
} else if (!mailRet.k) {
_root.alert.show({
type: 1,
text: '您的邮箱格式不正确, 是否继续提交?',
text: '您的邮箱格式不正确, 将导致无法正确显示头像和接收回复通知邮件。是否继续提交?',
cb() {
commitEvt();
}
Expand Down Expand Up @@ -578,7 +578,7 @@ const check = {
link(l) {
l = (l.length > 0 && (/^(http|https)/.test(l)) ? l : `http://${l}`);
return {
k: /(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])?/.test(l),
k: l.length > 0 ? true : /(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])?/.test(l),
v: l
};
}
Expand Down Expand Up @@ -651,12 +651,10 @@ const timeAgo = (date) => {
return hours + ' 小时前';
}
if (days < 0) return '刚刚';

if (days < 8) {
return days + ' 天前';
} else {
return dateFormat(date)
}
else if (days < 30) return days + ' 天前';
else if (days < 365) return Math.floor(days / 30) + ' 月前';
else return Math.floor(days / 365) + ' 年前';
return dateFormat(date);
} catch (error) {
console.log(error)
}
Expand Down
30 changes: 15 additions & 15 deletions src/Valine.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
color: #4b5b62;
width: 100%;
background: #fafdff;
border: .06em solid #edf4f8;
border-radius: .2em;
border: 1px solid #e9eff3;
border-radius: 0;
padding: .4em .5em;
textarea {
color: #4b5b62;
Expand Down Expand Up @@ -49,8 +49,8 @@
input {
color: #4b5b62;
background: #fafdff;
border: .06em solid #edf4f8;
border-radius: .2em;
border: 1px solid #e9eff3;
border-radius: 0;
padding: .4em .5em;
line-height: 2;
font-size: 1em !important;
Expand All @@ -76,9 +76,9 @@
width: 100%;
line-height: 2;
font-weight: bolder;
background: #33b1ff;
border: .06em solid #edf4f8;
border-radius: .2em;
border-radius: .1em;
border: 1px solid #e9eff3;
background-color: #207CDF;
padding: .4em .5em;
-webkit-appearance: none;
-moz-appearance: none;
Expand All @@ -89,6 +89,9 @@
user-select: none;
font-size: 1em !important;
}
button:hover {
background-color: #106CCA;
}
}
@media screen and(max-width: 720px) {
display: block;
Expand Down Expand Up @@ -147,7 +150,7 @@
fill: currentColor;
}
.count {
font-size: 1.5em;
//font-size: 1.5em;
}
}
.power {
Expand Down Expand Up @@ -183,9 +186,9 @@
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
background: #33b1ff;
border: .06em solid #33b1ff;
border-radius: .2em;
border: 1px solid #e9eff3;
background-color: #207CDF;
border-radius: .1em;
color: #fff;
padding: .5em 1.5em;
cursor: pointer;
Expand All @@ -202,6 +205,7 @@
.vbtn:active,
.vbtn:hover {
border-color: #33b1ff;

}
.vpage {
margin: 1.5rem;
Expand Down Expand Up @@ -409,10 +413,6 @@
background-position:right !important;
}
.heart{
background:url(https://cloud.panjunwen.com/2018/05/5429406-1516e14e9fc2b898.png);
background-position:left;
background-repeat:no-repeat;
background-size:2900%;
width: 3em;
height: 3em;
display:inline-block;
Expand Down

0 comments on commit 6963e29

Please sign in to comment.