代码拉取完成,页面将自动刷新
同步操作将从 liuzy88/TheFamily 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
const Sequelize = require('sequelize');
const Op = Sequelize.Op;
const co = require('co');
const express = require('express');
const path = require('path');
const cookieParser = require('cookie-parser');
const logger = require('morgan');
const DB = require('./db');
const DT = require('./lib/dt');
const EJS = require('./lib/ejs');
const index = require('./routes/index');
const wall = require('./routes/wall');
const tree = require('./routes/tree');
const person = require('./routes/person');
const calendar = require('./routes/calendar');
const app = express();
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({extended: false}));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.locals.DT = DT;
app.locals.EJS = EJS;
app.use('*', function (req, res, next) {
co(function* () {
req.int = function(key, def) {
try {
return parseInt(req.params[key] || req.query[key] || req.body[key] || 0);
} catch (e) {
return def || 0;
}
};
let today = DT.today;
const date = new Date();
const gong = `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
if (!today || today.gong !== gong) {
today = yield DB.Calendar.findOne({
raw: true,
where: {
gong: gong,
}
});
const arrG = today.gong.split('-');
today.gongY = parseInt(arrG[0]);
today.gongM = parseInt(arrG[1]);
today.gongD = parseInt(arrG[2]);
today.gongW = DT.getWeek(today.gong, date.getDay());
const arrN = today.nong.split('-');
today.nongY = parseInt(arrN[0]);
today.nongM = parseInt(arrN[1]);
today.nongD = parseInt(arrN[2]);
DT.today = today;
console.log('今天是:', JSON.stringify(today));
}
next();
}).catch((err) => {
next(err);
})
});
app.use('/', index);
app.use('/wall', wall);
app.use('/tree', tree);
app.use('/person', person);
app.use('/calendar', calendar);
app.use(function (req, res, next) {
res.status(404).send('404 Not Found')
});
app.use(function (err, req, res, next) {
console.log(err);
res.status(500).send('500 Server Error')
});
module.exports = app;
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。