|
|
|
@ -2,6 +2,7 @@ import * as DataEvent from '../../../src/com/events/DataEvent';
|
|
|
|
|
import Auth from '../../data/Auth';
|
|
|
|
|
import Render from '../../data/Render';
|
|
|
|
|
import SettingsData from '../../data/Settings';
|
|
|
|
|
import Navigation from '../../data/Navigation';
|
|
|
|
|
import Book from '../../data/Book';
|
|
|
|
|
const express = require('express');
|
|
|
|
|
const router = express.Router();
|
|
|
|
@ -15,6 +16,7 @@ const auth = new Auth();
|
|
|
|
|
const render = new Render();
|
|
|
|
|
const book = new Book();
|
|
|
|
|
const settingsData = new SettingsData();
|
|
|
|
|
const nav = new Navigation();
|
|
|
|
|
const uploadPath =
|
|
|
|
|
'./public/assets/images/user/' + moment().format('YYYY') + '/' + moment().format('MM');
|
|
|
|
|
fs.ensureDir(uploadPath, () => {
|
|
|
|
@ -63,23 +65,28 @@ router.post('/sync', (req, res) => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
router.post('/nav-sync', (req, res) => {
|
|
|
|
|
let payload = req.body;
|
|
|
|
|
if (req.session.user) {
|
|
|
|
|
settings.menu = payload;
|
|
|
|
|
fs.writeJson('site/settings.json', settings)
|
|
|
|
|
.then(() => {
|
|
|
|
|
res.json({
|
|
|
|
|
type: DataEvent.SETTINGS_UPDATED,
|
|
|
|
|
message: 'Menu order saved, champ'
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
.catch(err => {
|
|
|
|
|
res.json({
|
|
|
|
|
type: DataEvent.REQUEST_LAME,
|
|
|
|
|
message: err
|
|
|
|
|
auth.authCheck(req)
|
|
|
|
|
.then(() => {
|
|
|
|
|
nav.sync(req)
|
|
|
|
|
.then(response => {
|
|
|
|
|
res.json({
|
|
|
|
|
type: response.type,
|
|
|
|
|
message: response.message
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
.catch(err => {
|
|
|
|
|
res.json({
|
|
|
|
|
type: DataEvent.REQUEST_LAME,
|
|
|
|
|
message: err
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
.catch(err => {
|
|
|
|
|
res.json({
|
|
|
|
|
type: err.type,
|
|
|
|
|
message: err.message
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
router.post('/publish-pages', (req, res) => {
|
|
|
|
|