Skip to content

Commit 0c12b80

Browse files
author
zhe-he
committed
end
1 parent 684c0f3 commit 0c12b80

23 files changed

+5470
-172
lines changed

README.md

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,20 @@
1414
### clean
1515
`npm run clean`
1616

17-
### how to use
17+
### 本地开发
1818
You just need to run `npm run dev`.
1919

20-
### how to publish
20+
### 打包上线
2121
`npm run build`
2222

23+
### 本地测试
24+
`npm run test`
2325

26+
### 特别说明
27+
dist文件夹里面的文件为上线文件,其他文件均为开发文件。
2428

2529
### 项目介绍
30+
1. dist/ 输出/上线目录,所有被编译的文件都会输出到此目录
2631
1. src/data/ 某些数据
2732
1. src/libs/ 插件目录
2833
1. src/modules/ 自定义模块目录
@@ -33,8 +38,56 @@ You just need to run `npm run dev`.
3338
1. images/ 图片目录
3439
1. images/static/ 此文件夹下 图片/目录 不会被压缩、base64处理
3540
1. build/ 配置信息
36-
1. dist/ 输出/上线 目录,所有被编译的文件都会输出到此目录
3741

3842
*截止到2017-09-21 15:54,package.json模块最新版*
3943
*如果问题,请[联系我](mailto:[email protected])*
4044

45+
46+
### history 后台配置
47+
##### Apache
48+
```
49+
<IfModule mod_rewrite.c>
50+
RewriteEngine On
51+
RewriteBase /
52+
RewriteRule ^index\.html$ - [L]
53+
RewriteCond %{REQUEST_FILENAME} !-f
54+
RewriteCond %{REQUEST_FILENAME} !-d
55+
RewriteRule . /index.html [L]
56+
</IfModule>
57+
```
58+
59+
##### nginx
60+
```
61+
location / {
62+
try_files $uri $uri/ /index.html;
63+
}
64+
```
65+
##### nodejs
66+
```
67+
const http = require('http')
68+
const fs = require('fs')
69+
const httpPort = 80
70+
71+
http.createServer((req, res) => {
72+
fs.readFile('index.htm', 'utf-8', (err, content) => {
73+
if (err) {
74+
console.log('We cannot open \'index.htm\' file.')
75+
}
76+
77+
res.writeHead(200, {
78+
'Content-Type': 'text/html; charset=utf-8'
79+
})
80+
81+
res.end(content)
82+
})
83+
}).listen(httpPort, () => {
84+
console.log('Server listening on: http://localhost:%s', httpPort)
85+
})
86+
```
87+
##### Caddy
88+
```
89+
rewrite {
90+
regexp .*
91+
to {path} /
92+
}
93+
```

build/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ if (process.env.NODE_ENV === 'production') {
1515
srcVuex = srcVuex.replace('vuex.js','vuex.min.js');
1616
srcVueRouter = srcVueRouter.replace('vue-router.js','vue-router.min.js');
1717
// common.min
18-
srcEcharts = echarts.replace('echarts.js','echarts.min.js');
18+
srcEcharts = srcEcharts.replace('echarts.js','echarts.min.js');
1919
}
2020

2121
const cssLoader = [
@@ -45,7 +45,8 @@ module.exports = {
4545
{from: srcVue, to: 'js/vue.js'},
4646
{from: srcVuex, to: 'js/vuex.js'},
4747
{from: srcVueRouter, to: 'js/vue-router.js'},
48-
{from: srcEcharts, to: 'js/echarts.js'}
48+
{from: srcEcharts, to: 'js/echarts.js'},
49+
{from: 'build/publicServer.js', to: 'server.js'}
4950
]),
5051
new HtmlWebpackPlugin({
5152
filename: 'index.html',

build/publicServer.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* 此文件为模拟线上服务器,可删除
3+
*/
4+
5+
const express=require('express');
6+
const fs = require('fs');
7+
var opn = require('opn');
8+
var port = 1111;
9+
var app=express();
10+
app.listen(port);
11+
app.use('/js',express.static(__dirname+'/js'));
12+
app.use('/images',express.static(__dirname+'/images'));
13+
app.use('/css',express.static(__dirname+'/css'));
14+
app.use('/favicon.ico',express.static(__dirname+'/favicon.ico'));
15+
16+
app.use((req,res)=>{
17+
console.log(req.url);
18+
fs.readFile(__dirname+'/index.html', 'utf-8',(err,content) => {
19+
if (err) {
20+
content = 'We cannot open \'index.html\' file.'
21+
console.log(content);
22+
}
23+
res.send(content);
24+
});
25+
});
26+
opn('http://localhost:'+port);

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"build": "cross-env NODE_ENV=production webpack -p --config build/ --progress --colors",
1010
"dev": "cross-env NODE_ENV=development node build/server --4010",
1111
"pack": "node build/pack",
12-
"clean": "node build/clean"
12+
"clean": "node build/clean",
13+
"test": "node dist/server"
1314
},
1415
"author": {
1516
"name": "zhe-he",

src/app.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<template>
22
<div>
3-
<mz-head></mz-head>
3+
<router-view name="head"></router-view>
44
<keep-alive v-if="$route.meta.keepAlive">
55
<router-view v-if="$route.meta.keepAlive"></router-view>
66
</keep-alive>
77
<router-view v-if="!$route.meta.keepAlive"></router-view>
8-
<mz-foot></mz-foot>
98
</div>
109
</template>
1110

0 commit comments

Comments
 (0)