Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bf29003

Browse files
feat: title & meta & stuff & fix bug
1 parent 7b897ec commit bf29003

File tree

35 files changed

+1038
-2025
lines changed

35 files changed

+1038
-2025
lines changed

‎front/build/checkPort.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ module.exports = function checkPort(port = 6180) {
1111
}
1212
if (port == _port) {
1313
resolve(port)
14-
console.log(`port: ${port} was not occupied`)
1514
} else {
1615
resolve(_port)
1716
console.log(`port: ${port} was occupied, try port: ${_port}`)

‎front/build/webpack.base.config.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ module.exports = {
7575
compress: {
7676
warnings: false,
7777
drop_debugger: true,
78-
drop_console: false
78+
drop_console: true
7979
},
8080
sourceMap: false // true
8181
}),

‎front/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"author": "",
66
"private": true,
77
"scripts": {
8+
"preinstall": "node ./preinstall.js",
89
"dev": "cross-env NODE_ENV=development node server",
910
"start": "cross-env NODE_ENV=production node server",
1011
"build": "rimraf dist && npm run build:client && npm run build:server && npm run copy",

‎front/preinstall.js‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @desc 创建数据库/第三方登录等配置文件
3+
* @author justJokee
4+
*/
5+
6+
const fs = require('fs-extra')
7+
const path = './server/db/secret.js'
8+
if (!fs.pathExistsSync(path)) {
9+
const str = fs.readFileSync('./template/secret.js')
10+
fs.ensureFileSync(path)
11+
fs.writeFileSync(path, str, 'utf8')
12+
13+
console.log()
14+
console.log('配置文件创建成功 >>>>')
15+
console.log()
16+
}

‎front/server.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ readyPromise.then(() => {
109109

110110
const port = process.env.__SAFE_PORT__
111111
const uri = 'http://localhost:' + port
112-
// uri = 'http://127.0.0.1:' + data;
113112
console.log()
114113
console.log('启动服务路径' + uri)
114+
console.log()
115115
server.listen(port, '0.0.0.0')
116116
})

‎front/server/api/login.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ router.post('/api/admin/login', async (req, res) => {
5454
})
5555
}
5656
} catch (e) {
57-
console.log('致命错误--->>>', e)
5857
res.status(500).end()
5958
}
6059
})

‎front/server/api/viewer.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ router.get('/api/front/viewer/getDevice', async (req, res) => {
111111
info: '访客设备信息统计成功'
112112
})
113113
} catch (e) {
114-
console.log('对方水电费', e)
115114
res.status(500).end()
116115
}
117116
})

‎front/server/db/schema.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const visitorsSchema = new mongoose.Schema({
2626
// 0: 自定义用户 1: qq 2: github
2727
type: 'number',
2828
githubId: 'number',
29-
qqOpenId: 'number',
29+
qqOpenId: 'string',
3030
date: 'date'
3131
})
3232
// 文章分类

‎front/server/http/server-api.js‎

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
const axios = require('axios')
22
const qs = require('qs')
3-
const LRU = require('lru-cache')
4-
require('es6-promise').polyfill()
53
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'
64
function ajax(type, url, options) {
75
let _params = {}
@@ -11,42 +9,29 @@ function ajax(type, url, options) {
119
axios({
1210
method: type,
1311
url: url,
14-
// baseURL: "http://localhost: 6180",
1512
..._params
1613
})
17-
.then(_res => {
14+
.then((_res) => {
1815
if (_res.status === 200) {
1916
resolve(_res.data)
2017
} else {
2118
reject('request error in ' + url)
2219
}
2320
})
24-
.catch(err => {
21+
.catch((err) => {
2522
console.log(err, url)
2623
})
2724
})
2825
}
2926
const config = {
3027
get(url, options) {
31-
return new Promise((resolve, reject) => {
32-
ajax('get', url, options).then(data => {
33-
resolve(data)
34-
})
35-
})
28+
return ajax('get', url, options)
3629
},
3730
post(url, options) {
38-
return new Promise((resolve, reject) => {
39-
ajax('post', url, options).then(data => {
40-
resolve(data)
41-
})
42-
})
31+
return ajax('post', url, options)
4332
},
4433
patch(url, options) {
45-
return new Promise((resolve, reject) => {
46-
ajax('patch', url, options).then(data => {
47-
resolve(data)
48-
})
49-
})
34+
return ajax('patch', url, options)
5035
}
5136
}
5237

‎front/server/utils/schedule.js‎

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/**
2-
* @desc 定时任务 - 爬取豆瓣电影
2+
* @desc 定时任务 - 爬取豆瓣电影等
3+
* @author justJokee
34
*/
45

56
const schedule = require('node-schedule')
@@ -18,15 +19,13 @@ let cache = {
1819
getMovieDo: []
1920
}
2021
const douban = new DoubanSpider({
21-
// uid: 'tan-mu'
2222
uid: '173712770'
2323
})
2424

2525
function startSchedule() {
2626
// 每天凌晨1点进行爬取
27-
// schedule.scheduleJob('0 0 1 * * *', async () => {
28-
schedule.scheduleJob('0 14 18 * * *', async () => {
29-
console.log('定时任务触发------>>>>>>>')
27+
schedule.scheduleJob('0 0 1 * * *', async () => {
28+
console.log('定时任务触发 -->>>>>')
3029
getMovies()
3130
})
3231
}
@@ -42,18 +41,17 @@ async function handleMovies(method) {
4241
try {
4342
const res = await douban[method]()
4443
cache[method].push(res.data)
45-
console.log('第1页爬取成功====>>>>>')
44+
console.log(`[${method}]: 第1页爬取成功 -->>>>`)
4645
fs.writeFileSync(`${moviesPath[method]}/pageTotal.txt`, res.page.totalPage + '', 'utf8')
4746
if (res.page.totalPage > 1) {
4847
// 保存总页码数
4948

5049
for (let i = 2; i <= res.page.totalPage; i++) {
51-
// for (let i = 2; i <= 3; i++) {
52-
// 爬取速度1分钟1页,避免触发反爬
50+
// 爬取速度 30s/1页,避免触发反爬机制
5351
await sleep()
5452
const res = await douban[method](i)
5553
cache[method].push(res.data)
56-
console.log(`第${i}页爬取成功====>>>>>`)
54+
console.log(`[${method}]: ${i}页爬取成功 -->>>>`)
5755
}
5856
}
5957
// 写入json文件
@@ -64,7 +62,7 @@ async function handleMovies(method) {
6462
// 释放空间
6563
cache[method] = []
6664
} catch (e) {
67-
console.log('爬虫解析错误---->>>>', e)
65+
console.log('爬虫解析错误-->>>>', e)
6866
cache = {
6967
getMovieCollect: [],
7068
getMovieWish: [],

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /