Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
xCss committed Jun 21, 2019
1 parent fd1b2ec commit 56b3cab
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 16 deletions.
6 changes: 3 additions & 3 deletions dist/Valine.Pure.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/Valine.min.js

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.3.6",
"version": "1.3.7",
"description": "A simple comment system based on Leancloud.",
"main": "/dist/Valine.min.js",
"author": "xCss <[email protected]> (https://github.com/xCss)",
Expand Down
32 changes: 24 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const Utils = require('./utils/htmlUtils');
const Emoji = require('./plugins/emojis');
const hanabi = require('hanabi');
const LINKREG = /^https?\:\/\//;

window.AV = undefined;
const defaultComment = {
comment: '',
nick: 'Anonymous',
Expand Down Expand Up @@ -113,6 +113,16 @@ function ValineFactory(option) {
return root;
}


/**
* 动态加载SDK
*/
(function(){
let avSDK = Utils.create('script', 'src', '//cdn.jsdelivr.net/npm/leancloud-storage/dist/av-min.js');
let s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(avSDK, s);
})();

/**
* Valine Init
* @param {Object} option
Expand All @@ -123,6 +133,7 @@ ValineFactory.prototype.init = function (option) {
return;
}
let root = this;
root['config'] = {};
try {
let {
lang,
Expand All @@ -134,8 +145,11 @@ ValineFactory.prototype.init = function (option) {
verify,
visitor,
pageSize,
recordIP
recordIP,
serverURLs = 'https://avoscloud.com',
clazzName = 'Comment'
} = option;
root['config']['clazzName'] = clazzName;
let ds = _avatarSetting['ds'];
let force = avatarForce ? '&q=' + Math.random().toString(32).substring(2) : '';

Expand Down Expand Up @@ -174,21 +188,22 @@ ValineFactory.prototype.init = function (option) {
smartLists: true,
smartypants: true
});

if (!AV) {
setTimeout(() => {
root.init(option)
}, 20)
return;
}
console.log(1)
let id = option.app_id || option.appId;
let key = option.app_key || option.appKey;
if (!id || !key) throw 99;
AV.applicationId && delete AV._config.applicationId || (AV.applicationId = null);
AV.applicationKey && delete AV._config.applicationKey || (AV.applicationKey = null);
AV.init({
appId: id,
appKey: key
appKey: key,
serverURLs: serverURLs,
});

// get comment count
Expand Down Expand Up @@ -399,11 +414,12 @@ let CounterFactory = {
* @param {String} id
*/
ValineFactory.prototype.Q = function (k) {
let len = arguments.length
let root = this;
let len = arguments.length;
if (len == 1) {
let notExist = new AV.Query('Comment');
let notExist = new AV.Query(root['config']['clazzName']);
notExist.doesNotExist('rid');
let isEmpty = new AV.Query('Comment');
let isEmpty = new AV.Query(root['config']['clazzName']);
isEmpty.equalTo('rid', '');
let q = AV.Query.or(notExist, isEmpty);
q.equalTo('url', decodeURI(k));
Expand All @@ -412,7 +428,7 @@ ValineFactory.prototype.Q = function (k) {
return q;
} else {
let ids = JSON.stringify(arguments[1]).replace(/(\[|\])/g, '');
let cql = `select * from Comment where rid in (${ids}) order by -createdAt,-createdAt`;
let cql = `select * from ${root['config']['clazzName']} where rid in (${ids}) order by -createdAt,-createdAt`;
return AV.Query.doCloudQuery(cql)
}
}
Expand Down
1 change: 1 addition & 0 deletions src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

.v {
font-size:16px;
* {
box-sizing: border-box; //font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", 微软雅黑, "helvetica neue", helvetica, ubuntu, roboto, noto, "segoe ui", Arial, sans-serif;
//font-size: 16px;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/htmlUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const utils = {
*/
clearAttr(el) {
let attrs = el.attributes
let ignoreAttrs = ['align', 'alt', 'disabled', 'href', 'id', 'target', 'title', 'type', 'src', 'class', 'style']
let ignoreAttrs = ['align', 'alt', 'checked', 'class', 'disabled', 'href', 'id', 'target', 'title', 'type', 'src', 'style']
utils.each(attrs, (idx, attr) => {
let name = attr.name
switch (attr.name.toLowerCase()) {
Expand Down

0 comments on commit 56b3cab

Please sign in to comment.