Skip to content

Commit 88cd179

Browse files
author
xiaoshen
committed
DoraCMS 2.1.8 版本升级
1 parent b1b17b9 commit 88cd179

File tree

383 files changed

+21932
-21930
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

383 files changed

+21932
-21930
lines changed

.eslintignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
backstage
2+
databak
3+
*/**/node_modules
4+
*/**/dist
5+
app/assets
6+
app/public
7+
dist

.eslintrc

+37-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,39 @@
11
{
2-
"extends": "eslint-config-egg"
2+
"extends": "eslint-config-egg",
3+
"parser": "babel-eslint",
4+
"plugins": ["prettier"],
5+
"rules": {
6+
"no-control-regex": 0,
7+
"no-unused-vars": "off",
8+
"one-var-declaration-per-line": ["error", "initializations"],
9+
"quotes": [2, "single"],
10+
"arrow-parens": ["error", "always"],
11+
"array-bracket-spacing": [2, "never"],
12+
"space-before-function-paren": 0,
13+
"indent": [0, 2],
14+
"prettier/prettier": ["error", {}],
15+
"linebreak-style": ["error", "unix"]
16+
},
17+
"globals": {
18+
"exec": true,
19+
"concatPopulate": true,
20+
"getDateStr": true,
21+
"getContentListFields": true,
22+
"getAuthUserFields": true,
23+
"checkCurrentId": true,
24+
"remote": true,
25+
"hot": true,
26+
"news": true,
27+
"random": true,
28+
"near_post": true,
29+
"hottags": true,
30+
"ads": true,
31+
"recommend": true,
32+
"tags": true,
33+
"navtree": true,
34+
"childnav": true,
35+
"PluginsExtension": true,
36+
"HeaderExtension": true,
37+
"AssetsExtension": true
38+
}
339
}

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ run/
99
*.swp
1010
*.vscode
1111
package-lock.json
12-
# app/public/upload
13-
12+
app/public/upload
1413
app/ext
1514
app/controller/ext
15+
databak/
1616
dist/*
1717

1818

.prettierrc

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"semi": true,
3+
"singleQuote": true,
4+
"proseWrap": "preserve",
5+
"tabWidth": 2,
6+
"trailingComma:": "none",
7+
"bracketSpacing": true,
8+
"brace-style": [1, "1tbs"],
9+
"spaced-comment": 0,
10+
"eslintIntegration": true
11+
}

README.md

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
# Notice: DoraCMS SQL (基于sequelize) 已发布,开源无限制可商用,觉得好请记得 star 哟!
2-
[DoraCMS mysql 源码](https://github.com/doramart/Pandora)
3-
[DoraCMS mysql 版本预览](https://sql.html-js.cn/)
4-
> 数据库通过花生壳连接,可能有所延时
5-
6-
71
# DoraCMS 2.1.7
82

93
![DoraCMS](https://ae01.alicdn.com/kf/H114ba4fd0eab4f36a4b16d970e11222dz.png "DoraCMS")

app.js

+60-57
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,68 @@
1+
'use strict';
12
const path = require('path');
2-
var Cache = require('js-cache');
3+
const Cache = require('js-cache');
34
class AppBootHook {
5+
constructor(app) {
6+
this.app = app;
7+
}
48

9+
beforeStart() {
10+
this.app.runSchedule('backup_data');
11+
}
512

6-
constructor(app) {
7-
this.app = app;
8-
}
13+
configWillLoad() {
14+
this.app.loader.loadFile(
15+
path.join(this.app.config.baseDir, 'app/bootstrap/index.js')
16+
);
17+
const ctx = this.app.createAnonymousContext();
18+
this.app.nunjucks.addExtension('remote', new remote(ctx));
19+
this.app.nunjucks.addExtension('HeaderExtension', new HeaderExtension(ctx));
20+
this.app.nunjucks.addExtension('AssetsExtension', new AssetsExtension(ctx));
21+
this.app.nunjucks.addExtension(
22+
'PluginsExtension',
23+
new PluginsExtension(ctx)
24+
);
25+
this.app.nunjucks.addExtension('recommend', new recommend(ctx));
26+
this.app.nunjucks.addExtension('hot', new hot(ctx));
27+
this.app.nunjucks.addExtension('news', new news(ctx));
28+
this.app.nunjucks.addExtension('random', new random(ctx));
29+
this.app.nunjucks.addExtension('near_post', new near_post(ctx));
30+
this.app.nunjucks.addExtension('tags', new tags(ctx));
31+
this.app.nunjucks.addExtension('hottags', new hottags(ctx));
32+
this.app.nunjucks.addExtension('ads', new ads(ctx));
33+
this.app.nunjucks.addExtension('navtree', new navtree(ctx));
34+
this.app.nunjucks.addExtension('childnav', new childnav(ctx));
35+
}
936

10-
beforeStart() {
11-
this.app.runSchedule('backup_data');
12-
}
37+
async willReady() {
38+
// 请将你的应用项目中 app.beforeStart 中的代码置于此处。
39+
}
1340

14-
configWillLoad() {
15-
16-
this.app.loader.loadFile(path.join(this.app.config.baseDir, 'app/bootstrap/index.js'));
17-
const ctx = this.app.createAnonymousContext();
18-
this.app.nunjucks.addExtension('remote', new remote(ctx));
19-
this.app.nunjucks.addExtension('HeaderExtension', new HeaderExtension(ctx));
20-
this.app.nunjucks.addExtension('AssetsExtension', new AssetsExtension(ctx));
21-
this.app.nunjucks.addExtension('PluginsExtension', new PluginsExtension(ctx));
22-
this.app.nunjucks.addExtension('recommend', new recommend(ctx));
23-
this.app.nunjucks.addExtension('hot', new hot(ctx));
24-
this.app.nunjucks.addExtension('news', new news(ctx));
25-
this.app.nunjucks.addExtension('random', new random(ctx));
26-
this.app.nunjucks.addExtension('near_post', new near_post(ctx));
27-
this.app.nunjucks.addExtension('tags', new tags(ctx));
28-
this.app.nunjucks.addExtension('hottags', new hottags(ctx));
29-
this.app.nunjucks.addExtension('ads', new ads(ctx));
30-
this.app.nunjucks.addExtension('navtree', new navtree(ctx));
31-
this.app.nunjucks.addExtension('childnav', new childnav(ctx));
32-
}
33-
34-
async didLoad() {
35-
36-
}
37-
38-
async willReady() {
39-
40-
// 请将你的应用项目中 app.beforeStart 中的代码置于此处。
41-
}
42-
43-
async didReady() {
44-
let _theApp = this.app;
45-
_theApp.cache = new Cache();
46-
47-
_theApp.messenger.on('refreshCache', by => {
48-
_theApp.logger.info('start update by %s', by);
49-
const ctx = _theApp.createAnonymousContext();
50-
ctx.runInBackground(async () => {
51-
let {
52-
key,
53-
value,
54-
time
55-
} = by;
56-
_theApp.cache.set(key, value, time);
57-
});
58-
});
59-
// 应用初始化
60-
let thisCtx = this.app.createAnonymousContext();
61-
this.app.init(thisCtx);
62-
}
41+
async didReady() {
42+
const _theApp = this.app;
43+
_theApp.cache = new Cache();
44+
// 缓存设置
45+
_theApp.messenger.on('refreshCache', (by) => {
46+
_theApp.logger.info('start update by %s', by);
47+
const ctx = _theApp.createAnonymousContext();
48+
ctx.runInBackground(async () => {
49+
const { key, value, time } = by;
50+
_theApp.cache.set(key, value, time);
51+
});
52+
});
53+
// 缓存清除
54+
_theApp.messenger.on('clearCache', (by) => {
55+
_theApp.logger.info('start clear by %s', by);
56+
const ctx = _theApp.createAnonymousContext();
57+
ctx.runInBackground(async () => {
58+
const { key } = by;
59+
key && _theApp.cache.del(key);
60+
});
61+
});
62+
// 应用初始化
63+
const thisCtx = this.app.createAnonymousContext();
64+
this.app.init(thisCtx);
65+
}
6366
}
6467

65-
module.exports = AppBootHook;
68+
module.exports = AppBootHook;

app/bootstrap/global.js

+47-44
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
/*
2-
* @Author: doramart
3-
* @Date: 2019-06-18 17:04:40
2+
* @Author: doramart
3+
* @Date: 2019-06-18 17:04:40
44
* @Last Modified by: doramart
5-
* @Last Modified time: 2020-04-28 00:04:55
5+
* @Last Modified time: 2021-07-17 21:00:39
66
*/
7+
'use strict';
78

8-
const _ = require('lodash');
99
const shortid = require('shortid');
1010
const moment = require('moment');
1111

1212
// 校验合法ID
1313
global.checkCurrentId = (ids) => {
1414
if (!ids) return false;
1515
let idState = true;
16-
let idsArr = ids.split(',');
17-
if (typeof idsArr === "object" && idsArr.length > 0) {
16+
const idsArr = ids.split(',');
17+
if (typeof idsArr === 'object' && idsArr.length > 0) {
1818
for (let i = 0; i < idsArr.length; i++) {
1919
if (!shortid.isValid(idsArr[i])) {
2020
idState = false;
@@ -25,8 +25,7 @@ global.checkCurrentId = (ids) => {
2525
idState = false;
2626
}
2727
return idState;
28-
}
29-
28+
};
3029

3130
global.getStrLength = (str) => {
3231
let charCode = -1;
@@ -35,62 +34,66 @@ global.getStrLength = (str) => {
3534
let zhChar = 0,
3635
enChar = 0;
3736
for (let i = 0; i < len; i++) {
38-
charCode = str.charCodeAt(i)
37+
charCode = str.charCodeAt(i);
3938
if (charCode >= 0 && charCode <= 128) {
4039
realLength += 1;
41-
enChar++
40+
enChar++;
4241
} else {
4342
realLength += 2;
44-
zhChar++
43+
zhChar++;
4544
}
4645
}
4746
return {
4847
length: realLength,
4948
enChar,
50-
zhChar
51-
}
52-
}
53-
49+
zhChar,
50+
};
51+
};
5452

5553
global.getDateStr = (addDayCount) => {
56-
var dd = new Date();
57-
dd.setDate(dd.getDate() + addDayCount); //获取AddDayCount天后的日期
58-
var y = dd.getFullYear();
59-
var m = (dd.getMonth() + 1) < 10 ? "0" + (dd.getMonth() + 1) : (dd.getMonth() + 1); //获取当前月份的日期,不足10补0
60-
var d = dd.getDate() < 10 ? "0" + dd.getDate() : dd.getDate(); //获取当前几号,不足10补0
61-
let endDate = moment().format("YYYY-MM-DD");
54+
const dd = new Date();
55+
dd.setDate(dd.getDate() + addDayCount); // 获取AddDayCount天后的日期
56+
const y = dd.getFullYear();
57+
const m =
58+
dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1; // 获取当前月份的日期,不足10补0
59+
const d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate(); // 获取当前几号,不足10补0
60+
const endDate = moment().format('YYYY-MM-DD');
6261
return {
63-
startTime: y + "-" + m + "-" + d + ' 23:59:59',
64-
endTime: endDate + ' 23:59:59'
65-
}
66-
}
67-
62+
startTime: y + '-' + m + '-' + d + ' 23:59:59',
63+
endTime: endDate + ' 23:59:59',
64+
};
65+
};
6866

6967
global.getAuthUserFields = (type = '') => {
70-
let fieldStr = "id userName category group logo date enable state";
71-
if (type == 'login') {
72-
fieldStr = "id userName category group logo date enable state phoneNum countryCode email comments position loginActive birth password";
73-
} else if (type == 'base') {
74-
fieldStr = "id userName category group logo date enable state phoneNum countryCode email watchers followers comments favorites favoriteCommunityContent despises comments profession experience industry introduction birth creativeRight gender";
75-
} else if (type == 'session') {
76-
fieldStr = "id userName name category group logo date enable state phoneNum countryCode email watchers followers praiseContents praiseMessages praiseCommunityContent watchSpecials watchCommunity watchTags favorites favoriteCommunityContent despises despiseMessage despiseCommunityContent comments position gender vip";
68+
let fieldStr = 'id userName category group logo date enable state';
69+
if (type === 'login') {
70+
fieldStr =
71+
'id userName category group logo date enable state phoneNum countryCode email comments position loginActive birth password';
72+
} else if (type === 'base') {
73+
fieldStr =
74+
'id userName category group logo date enable state phoneNum countryCode email watchers followers comments favorites favoriteCommunityContent despises comments profession experience industry introduction birth creativeRight gender';
75+
} else if (type === 'session') {
76+
fieldStr =
77+
'id userName name category group logo date enable state phoneNum countryCode email watchers followers praiseContents praiseMessages praiseCommunityContent watchSpecials watchCommunity watchTags favorites favoriteCommunityContent despises despiseMessage despiseCommunityContent comments position gender vip';
7778
}
7879
return fieldStr;
79-
}
80-
80+
};
8181

8282
global.getContentListFields = (type = '') => {
83-
8483
let files = null;
85-
if (type == 'normal') {
86-
files = '_id url title stitle sImg uAuthor date updateDate discription clickNum roofPlacement type videoImg state dismissReason categories isTop'
87-
} else if (type == 'simple') {
88-
files = '_id url title stitle sImg stitle date updateDate clickNum roofPlacement type videoImg state dismissReason';
89-
} else if (type == 'stage1') {
90-
files = '_id url title stitle sImg uAuthor date updateDate discription comments clickNum roofPlacement type videoImg state dismissReason categories isTop'
84+
if (type === 'normal') {
85+
files =
86+
'_id url keywords source title stitle sImg uAuthor date updateDate discription clickNum roofPlacement type videoImg state dismissReason categories isTop';
87+
} else if (type === 'simple') {
88+
files =
89+
'_id url keywords source title stitle sImg stitle date updateDate clickNum roofPlacement type videoImg state dismissReason';
90+
} else if (type === 'stage1') {
91+
files =
92+
'_id url keywords source title stitle sImg uAuthor date updateDate discription comments clickNum roofPlacement type videoImg state dismissReason categories isTop';
9193
} else {
92-
files = '_id url title stitle sImg uAuthor date discription clickNum roofPlacement type appShowType imageArr videoArr duration simpleComments comments videoImg state dismissReason categories isTop'
94+
files =
95+
'_id url keywords source title stitle sImg uAuthor date discription clickNum roofPlacement type appShowType imageArr videoArr duration simpleComments comments videoImg state dismissReason categories isTop';
9396
}
9497
// console.log('--files----', files)
9598
return files;
96-
}
99+
};

app/bootstrap/index.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
/*
2-
* @Author: doramart
3-
* @Date: 2019-06-18 17:04:27
2+
* @Author: doramart
3+
* @Date: 2019-06-18 17:04:27
44
* @Last Modified by: doramart
5-
* @Last Modified time: 2019-07-30 11:14:07
5+
* @Last Modified time: 2021-04-17 14:13:41
66
*/
7-
require('module-alias/register')
7+
'use strict';
8+
require('module-alias/register');
89
require('./global');
9-
require('./tags');
10+
require('./tags');

0 commit comments

Comments
 (0)