Skip to content

Commit 9dd377d

Browse files
committed
fix spell bug
1 parent d615303 commit 9dd377d

23 files changed

+522
-30
lines changed

.eslintrc.json

+399-1
Large diffs are not rendered by default.

build/copy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ mkdir('-p', './dist/');
55
cp('-R', 'favicon.ico', './dist/');
66
cp('-R', 'robots.txt', './dist/');
77
cp('-R', 'static/', './dist/');
8-
dp('-R', 'src/template/admin-add.html', './dist/');
8+
cp('-R', 'src/template/admin-add.html', './dist/');

build/setup-dev-server.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ module.exports = function setupDevServer(app, callback){
2525
const fs = devMiddleware.fileSystem;
2626
// 前台
2727
const frontendPath = path.join(clientConfig.output.path, 'server.html');
28-
if(fs.existSync(frontendPath)){
28+
if(fs.existsSync(frontendPath)){
2929
frontend = fs.readFileSync(frontendPath, 'utf-8');
3030
}
3131
// 后台
3232
const backendPath = path.join(clientConfig.output.path, 'admin.html');
33-
if(fs.existSync(backendPath)){
33+
if(fs.existsSync(backendPath)){
3434
backend = fs.readFileSync(backendPath, 'utf-8');
3535
}
3636
if(bundle){
@@ -49,7 +49,7 @@ module.exports = function setupDevServer(app, callback){
4949
if(err) throw err;
5050
stats = stats.toJson();
5151
stats.errors.forEach(err => console.error(err));
52-
stats.warning.forEach(err => console.warn(err));
52+
stats.warnings.forEach(err => console.warn(err));
5353
const bundlePath = path.join(serverConfig.output.path, 'vue-ssr-bundle.json');
5454
bundle = JSON.parse(mfs.readFileSync(bundlePath, 'utf-8'));
5555
if(frontend && backend){

build/vue-loader.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const ExtractTextPlugin = require('extract-text-webpack-plugin');
22

3-
const loaders = {};
3+
let loaders = {};
44
if(process.env.NODE_ENV !== 'production'){
55
loaders = {
66
css: 'vue-style-loader!css-loader',

build/webpack.base.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const config = {
4343
path.join(__dirname, '../node_modules')
4444
]
4545
},
46-
modules: {
46+
module: {
4747
rules: [{
4848
test: /\.js$/,
4949
loader: 'babel-loader',

build/webpack.client.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const prodConfig = require('./webpack.client.prod.config');
99
const vueConfig = require('./vue-loader.config');
1010
const projectRoot = path.resolve(__dirname, '../');
1111

12-
const config = merge(baseConfig, {
12+
let config = merge(baseConfig, {
1313
externals: {
1414
'jquery': 'jQeury'
1515
},

server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const compression = require('compression');
99
// const HTMLStream = require('vue-ssr-html-stream');
1010
const logger = require('morgan');
1111
const cookieParser = require('cookie-parser');
12-
const bodyParser = reuqire('body-parser');
12+
const bodyParser = require('body-parser');
1313
const { createBundleRenderer } = require('vue-server-renderer');
1414
const config = require('./src/api/config-server');
1515
const resolve = file => path.resolve(__dirname, file);

server/api/backend-article.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ exports.recover = (req, res) => {
126126
});
127127
});
128128
}).catch(err => {
129-
res.json(err => {
129+
res.json({
130130
code: -200,
131-
message: err.toString()
131+
message: err.toString()
132132
});
133133
});
134134
};

server/api/backend-user.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const moment = require('moment');
44
const jwt = require('jsonwebtoken');
55

66
const mongoose = require('../mongoose');
7-
const Admin = mongoose.model('Adming');
7+
const Admin = mongoose.model('Admin');
88
const fsExistsSync = require('../utils').fsExistsSync;
99
const config = require('../config');
1010
const md5Pre = config.md5Pre;

server/api/frontend-comment.js

+52-1
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,55 @@ exports.getList = (req, res) => {
111111
});
112112
});
113113
}
114-
};
114+
};
115+
116+
/**
117+
* 评论删除
118+
* @method deleteAdmin
119+
* @param {[type]} req [description]
120+
* @param {[type]} res [description]
121+
* @return {[type]} [description]
122+
*/
123+
exports.deletes = (req, res) => {
124+
let id = req.query.id;
125+
Comment.update({_id: id}, { is_delete: 1}).then(() => {
126+
return Article.update({_id: id}, {'$inc': {'comment_count': -1}}).then(() => {
127+
res.json({
128+
code: 200,
129+
message: '删除成功',
130+
data: 'success'
131+
});
132+
});
133+
}).catch(err => {
134+
res.json({
135+
code: -200,
136+
message: err.toString()
137+
});
138+
});
139+
};
140+
141+
/**
142+
* 评论恢复
143+
* @method deleteAdmin
144+
* @param {[type]} req [description]
145+
* @param {[type]} res [description]
146+
* @return {[type]} [description]
147+
*/
148+
149+
exports.recover = (req, res) => {
150+
let id = req.query.id;
151+
Comment.update({_id: id}, {is_delete: 0}).then(() => {
152+
return Article.update({_id: id}, {'$inc': {'comment_count': 1}}).then(() => {
153+
res.json({
154+
code: 200,
155+
message: '恢复成功',
156+
data: 'success'
157+
});
158+
});
159+
}).catch(err => {
160+
res.json({
161+
code: -200,
162+
message: err.toString()
163+
});
164+
});
165+
};

server/models/admin.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const mongoose = require('../mongoose');
2-
const Schema = mongosse.Schema;
2+
const Schema = mongoose.Schema;
33
const Promise = require('bluebird');
44

55
const AdminSchema = new Schema({

server/models/articles.js renamed to server/models/article.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const mongoose = require('../mongoose');
2-
const Schema = mongosse.Schema;
2+
const Schema = mongoose.Schema;
33
const Promise = require('bluebird');
44

55
const ArticleSchema = new Schema({

server/models/category.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const mongoose = require('../mongoose');
2-
const Schema = mongosse.Schema;
2+
const Schema = mongoose.Schema;
33
const Promise = require('bluebird');
44

5-
const CategorySchema = new Schema = ({
5+
const CategorySchema = new Schema ({
66
cate_name: String,
77
cate_order: String,
88
cate_num: Number,

server/models/comment.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const mongoose = require('../mongoose');
2-
const Schema = mongosse.Schema;
2+
const Schema = mongoose.Schema;
33
const Promise = require('bluebird');
44

55
const CommentSchema = new Schema({

server/models/like.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const mongoose = require('../mongoose');
2-
const Schema = mongosse.Schema;
2+
const Schema = mongoose.Schema;
33
const Promise = require('bluebird');
44

55
const LikeSchema = new Schema({

server/mongoose.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var mongoose = require('mongoose');
2-
mongoose.connect('mongodb://localhost/fakerliblog');
1+
const mongoose = require('mongoose');
2+
mongoose.connect('mongodb://localhost:9000/fakerliblog');
33
mongoose.Promise = global.Promise;
44
module.exports = mongoose;

server/routes/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ router.get('/backend/user/list', isAdmin, frontendUser.getList);
7070
// 获取单个用户
7171
router.get('/backend/user/item', isAdmin, frontendUser.getItem);
7272
// 编辑用户
73-
router.post('/backend/user/modify', isAdmin, ,multipartMiddleware, frontendUser.modify);
73+
router.post('/backend/user/modify', isAdmin, multipartMiddleware, frontendUser.modify);
7474
// 删除用户
7575
router.get('/backend/user/delete', isAdmin,frontendUser.deletes);
7676
// 恢复用户
@@ -82,7 +82,7 @@ router.post('/frontend/comment/insert', isUser, multipartMiddleware, frontendCom
8282
// 读取评论列表
8383
router.get('/frontend/comment/list', frontendComment.getList);
8484
// 删除评论
85-
router.get('/frontend/comment.delete', isAdmin, frontendComment.deletes);
85+
router.get('/frontend/comment/delete', isAdmin, frontendComment.deletes);
8686
// 恢复评论
8787
router.get('/frontend/comment/recover', isAdmin, frontendComment.recover);
8888

@@ -120,7 +120,7 @@ router.get('*', (req, res) => {
120120
res.json({
121121
code: -200,
122122
message: '没有找到该页面'
123-
})
123+
});
124124
});
125125

126126
module.exports = router;

src/admin.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ Object.keys(filters).forEach(key => {
1717
Vue.filter(key, filters[key]);
1818
});
1919

20-
const app =new Vue({
20+
const app = new Vue({
2121
router,
2222
store,
2323
render: h => h(App)
24-
});
24+
});
25+
26+
app.$mount('#app');

src/components/signin.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
this.$store.dispatch('global/showMsg', '请将表单填写完整!');
5050
return;
5151
}
52-
cosnt { data: {message, code}} = await api.post('frontend/user/login', this.form);
52+
const { data: {message, code}} = await api.post('frontend/user/login', this.form);
5353
if(code === 200) {
5454
this.$store.dispatch('global/showMsg', {
5555
type: 'success',

src/entry-client.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ router.onReady(() => {
2121

2222
// only https
2323
if(process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator && window.location.hostname !== 'localhost') {
24-
navigator.serviceWorker.register('/service-worker.js');
24+
navigator.serviceWorker.register('/service-worker.js');
2525
}

src/store/index.js

+36-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
11
import Vue from 'vue';
22
import Vuex from 'vuex';
3-
import backendAdmin from './modules/backend-admin';
3+
import backendAdmin from './modules/backend-admin';
4+
import backendArticle from './modules/backend-article';
5+
import backendUser from './modules/backend-user';
6+
import frontendArticle from './modules/frontend-article';
7+
import global from './modules/global';
8+
import globalCategory from './modules/global-category';
9+
import globalComment from './modules/global-comment';
10+
11+
Vue.use(Vuex);
12+
13+
export default new Vuex.Store({
14+
modules: {
15+
backend: {
16+
namespaced: true,
17+
modules: {
18+
admin: backendAdmin,
19+
article: backendArticle,
20+
user: backendUser
21+
}
22+
},
23+
frontend: {
24+
namespaced: true,
25+
modules: {
26+
article: frontendArticle
27+
}
28+
},
29+
global: {
30+
namespaced: true,
31+
...global,
32+
modules: {
33+
category: globalCategory,
34+
comment: globalComment
35+
}
36+
}
37+
}
38+
});

src/store/modules/frontend-article.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const actions = {
3333
});
3434
}
3535
},
36-
async ['getArticleItem']({commit, statem rootState: {route: { path, params: { id }}}}) {
36+
async ['getArticleItem']({commit, state, rootState: {route: { path, params: { id }}}}) {
3737
if(path === state.item.path) {
3838
global.progress = 100;
3939
return;

src/store/modules/global-comment.js

+6
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ const mutations = {
4848
};
4949

5050
const getters = {
51+
['getCommentList'](state) {
52+
return state.lists;
53+
}
54+
};
55+
56+
export default {
5157
namespaced: true,
5258
state,
5359
actions,

0 commit comments

Comments
 (0)