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