Skip to content

Commit e856e65

Browse files
committed
delete some libs; modify gulp dev step
1 parent 3c4eeaa commit e856e65

32 files changed

+93
-482
lines changed

app.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ var path = require('path');
22
var express = require('express');
33
var app = express();
44

5+
// 静态资源目录; TODO: 静态资源推荐走 CDN
56
app.use('/static', express.static(path.join(__dirname, 'static')));
67

7-
app.get('/', function (req, res) {
8-
res.send('Hello World!');
9-
});
8+
// 首页
9+
app.get('/', require('server/js/controller/pageController').homepage);
1010

1111
var server = app.listen(8888, function () {
1212
var port = server.address().port;

gulpfile.js

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var Path = require('path');
22
var gulp = require('gulp');
33
var clean = require('gulp-clean');
4+
var config = require('./resource/config.json');
45

56
/**************************
67
* webpack *
@@ -25,38 +26,18 @@ gulp.task('webpack-dev-server', function() {
2526
var webpack = require('webpack');
2627

2728
new WebpackDevServer(webpack(webpackConfig), {
29+
contentBase: config.devServerUrl,
2830
publicPath: webpackConfig.output.publicPath,
2931
hot: true,
3032
noInfo: false,
3133
historyApiFallback: true,
32-
proxy: [{
33-
path: /^\/f\//,
34-
ignorePath: true,
35-
target: 'http://127.0.0.1:3000/html/index.html'
36-
}]
37-
}).listen(3000, 'localhost', function(err, result) {
34+
proxy: { '*': config.devServerUrl }
35+
}).listen(3000, 'localhost', function(err) {
3836
if (err) console.log(err);
3937
console.log('Listening at localhost:3000');
38+
open('http://127.0.0.1:3000/webpack-dev-server/');
4039
});
4140
});
42-
/**************************
43-
* webpack build libs *
44-
**************************/
45-
gulp.task('clean-libs', function() {
46-
var dir = Path.join('static', 'libs', '*.min.*');
47-
return gulp.src(dir)
48-
.pipe(clean());
49-
});
50-
gulp.task('webpack-build-libs', ['clean-libs'], function() {
51-
var webpackConfig = require('./webpack.libs.js');
52-
var gulpWebpack = require('gulp-webpack');
53-
var dir = Path.join('static', 'libs');
54-
55-
return gulp
56-
.src(dir)
57-
.pipe(gulpWebpack(webpackConfig))
58-
.pipe(gulp.dest(dir));
59-
});
6041
/**************************
6142
* copy profiles *
6243
**************************/
@@ -66,16 +47,12 @@ gulp.task('copyProfile', function() {
6647
if (allowEnv.indexOf(env) === -1) {
6748
env = allowEnv[0];
6849
}
69-
return gulp.src(Path.join(__dirname, 'src', 'profiles', env, '*'))
50+
return gulp.src(Path.join(__dirname, 'profiles', env, '*'))
7051
.pipe(gulp.dest(Path.join(__dirname, 'resource')));
7152
});
7253
/**************************
7354
* Main *
7455
**************************/
75-
gulp.task('default', function() {
76-
console.info('demo');
77-
});
7856
gulp.task('dev', ['copyProfile', 'webpack-dev-server']);
79-
gulp.task('libs', ['webpack-build-libs']);
8057
gulp.task('beta', ['webpack']);
8158
gulp.task('prod', ['webpack']);

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"author": "",
1717
"license": "MIT",
1818
"dependencies": {
19-
"antd": "^1.6.4",
2019
"body-parser": "^1.13.3",
2120
"codemirror": "^5.16.0",
2221
"cookie-parser": "^1.3.5",

server/profiles/beta/config.json renamed to profiles/beta/config.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"env": "local",
2+
"env": "beta",
33

44
"mysql": {
55
"host" : "localhost",
@@ -10,5 +10,9 @@
1010
"writeLog" : false
1111
},
1212

13-
"feUrl": ""
13+
"feUrl": "",
14+
15+
"devServerUrl": "http://127.0.0.1:8888",
16+
17+
"appRun": 8888
1418
}

server/profiles/prod/config.json renamed to profiles/dev/config.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"env": "local",
2+
"env": "dev",
33

44
"mysql": {
55
"host" : "localhost",
@@ -10,5 +10,8 @@
1010
"writeLog" : false
1111
},
1212

13-
"feUrl": ""
13+
"feUrl": "http://127.0.0.1:3000",
14+
"devServerUrl": "http://127.0.0.1:8888",
15+
16+
"appRun": 8888
1417
}

server/profiles/dev/config.json renamed to profiles/prod/config.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"env": "local",
2+
"env": "prod",
33

44
"mysql": {
55
"host" : "localhost",
@@ -10,5 +10,9 @@
1010
"writeLog" : false
1111
},
1212

13-
"feUrl": "http://127.0.0.1:3000"
13+
"feUrl": "",
14+
15+
"devServerUrl": "http://127.0.0.1:8888",
16+
17+
"appRun": 8888
1418
}
Lines changed: 4 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,13 @@
11
/**
22
* 页面入口的
3-
* @Author yuanqin.wang
4-
* @Date 2016-03-31
53
*/
64
var config = require('../../../resource/config.json');
75
var qzzUrl = config.qzzUrl;
8-
/*@Controller*/
9-
module.exports = {
10-
/*@Autowired("../service/loginService")*/
11-
loginService: null,
126

137

14-
/*@RequestMapping("/")*/
15-
index: function(req, res) {
16-
renderView (res, 'index');
17-
res.end("");
18-
},
19-
/*@RequestMapping("/404")*/
20-
error: function(req, res) {
21-
res.render('error');
22-
res.end("");
23-
},
24-
/*@RequestMapping([{url: "/data"},{url: "/data/{menu}/{channel}/{page}"},{url: "/data/{menu}/{channel}"},{url: "/data/{menu}"}])*/
25-
data: function(req, res) {
26-
renderView (res, 'index');
27-
res.end("");
28-
},
29-
/*@RequestMapping("/healthcheck.html")*/
30-
healthcheck: function(req, res) {
31-
res.write("200");
8+
module.exports = {
9+
homepage: function(req, res) {
10+
res.render('index', { qzzUrl: qzzUrl });
3211
res.end("");
33-
},
34-
/*@RequestMapping([{url: "/admin"}, {url: "/admin/{menu}"}, {url: "/admin/{menu}/{submenu}"}])*/
35-
admin: function(req, res) {
36-
var path = req.path;
37-
// 检查是否已经登录
38-
if (this.loginService.isLogin(req)) {
39-
renderView (res, 'admin');
40-
res.end();
41-
} else {
42-
// 没有登录
43-
// 如果当前是登录页, 则渲染登录页
44-
if (path === '/admin/login') {
45-
res.render('login');
46-
res.end();
47-
}
48-
// 如果是登录验证接口
49-
else if (path === '/admin') {
50-
// 调用登录验证接口
51-
this.loginService.doLogin(req, res);
52-
}
53-
else {
54-
// 跳转到奥登录页
55-
res.redirect(301, '/admin/login');
56-
}
57-
}
5812
}
59-
60-
};
61-
62-
63-
64-
function renderView (res, view) {
65-
res.render(view, { qzzUrl: qzzUrl });
66-
}
13+
};

server/js/dao/db.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ var connect = {
5050
}
5151
};
5252

53-
exports.query = function(sql, data) {
53+
exports.execSQL = function(sql, data) {
5454
return new Promise(function(resolve, reject){
5555
connect.mysql(CONNECT_CONFIG, sql, data, function(result){
5656
if (result.error) {

0 commit comments

Comments
 (0)