-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jacobs
committed
Dec 4, 2019
0 parents
commit ceb15c6
Showing
87 changed files
with
17,641 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"presets": [ | ||
"@babel/preset-env", | ||
"@babel/preset-react" | ||
], | ||
"plugins": [ | ||
"@babel/plugin-proposal-function-bind", | ||
"@babel/plugin-proposal-class-properties" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
>1% | ||
not dead | ||
not ie <= 11 | ||
not op_mini all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[*.{js,jsx,ts,tsx}] | ||
indent_style = space | ||
indent_size = 2 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules/* | ||
package-lock.json | ||
.idea/ | ||
dist/static/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# NgRouter Gateway management Portal (NgRouter网关管理控制台) | ||
|
||
## 项目安装依赖 | ||
``` | ||
npm install | ||
``` | ||
|
||
### 本地环境运行 | ||
``` | ||
npm run start | ||
``` | ||
|
||
### 编译打包生产, | ||
``` | ||
npm run build | ||
``` | ||
|
||
### 在config/index.js中,根据不同环境,提供不同的NgrAdmin RESTFUL API域名和端口 | ||
|
||
``` | ||
var path = require('path') | ||
const NODE_ENV = process.env.NODE_ENV | ||
module.exports = { | ||
build: { | ||
restfulApi:'http://product.gateway-api.com', | ||
mode: NODE_ENV, | ||
sourceMap: false, | ||
assetsRoot: path.resolve(__dirname, '../dist'), | ||
assetsSubDirectory: 'static', | ||
assetsPublicPath: '/', | ||
bundleAnalyzerReport: process.env.analyz | ||
}, | ||
dev: { | ||
restfulApi:'http://dev.gateway-api.com', | ||
mode: NODE_ENV, | ||
sourceMap: 'source-map', | ||
assetsRoot: path.resolve(__dirname, '../dist'), | ||
assetsSubDirectory: 'static', | ||
assetsPublicPath: '/', | ||
port: 3000, | ||
autoOpenBrowser: true, | ||
overlay: true, | ||
historyApiFallback: true, | ||
noInfo: true | ||
}, | ||
} | ||
``` | ||
|
||
### 提供在服务器上pm2启动项目的功能 | ||
|
||
``` | ||
1. 修改config/index, 配置Ngr Admin RESTFUL API server地址。配置一次即可。 | ||
var path = require('path') | ||
const NODE_ENV = process.env.NODE_ENV | ||
module.exports = { | ||
build: { | ||
restfulApi:'http://product.gateway-api.com', | ||
mode: NODE_ENV, | ||
sourceMap: false, | ||
assetsRoot: path.resolve(__dirname, '../dist'), | ||
assetsSubDirectory: 'static', | ||
assetsPublicPath: '/', | ||
bundleAnalyzerReport: process.env.analyz | ||
}, | ||
dev: { | ||
restfulApi:'http://dev.gateway-api.com', | ||
mode: NODE_ENV, | ||
sourceMap: 'source-map', | ||
assetsRoot: path.resolve(__dirname, '../dist'), | ||
assetsSubDirectory: 'static', | ||
assetsPublicPath: '/', | ||
port: 3000, | ||
autoOpenBrowser: true, | ||
overlay: true, | ||
historyApiFallback: true, | ||
noInfo: true | ||
}, | ||
} | ||
2. 本地打包编译。 | ||
npm run build | ||
3. 推送代码到远程仓库 | ||
git push origin xxx | ||
4. 服务器用pm2起node服务 | ||
npm run pm2_start | ||
5. 服务器ip+端口访问,如有需要自行配置ngnix做域名解析 | ||
``` | ||
|
||
### 部署建议 | ||
|
||
- NgrAdmin服务与NgrAdminPortal部署在同一应用实例上,NgrAdminPortal访问本地NgrAdmin服务。 | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
var express = require('express'); | ||
var path = require('path'); | ||
|
||
var app = express(); | ||
|
||
// 设置模板引擎 | ||
app.set('views', path.join(__dirname, 'dist')); | ||
app.engine('.html', require('ejs').__express); | ||
app.set('view engine', 'html'); | ||
|
||
app.use(express.json()); | ||
app.use(express.urlencoded({ extended: false })); | ||
app.use(express.static(path.join(__dirname, 'dist'))); | ||
|
||
// 接收请求,返回根页面,前端处理页面路由(单页应用) | ||
app.use('/', function(req, res, next) { | ||
res.render('index'); | ||
}); | ||
|
||
|
||
module.exports = app; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#!/usr/bin/env node | ||
|
||
/** | ||
* Module dependencies. | ||
*/ | ||
|
||
var app = require('../app'); | ||
var debug = require('debug')('ngr_webadmin:server'); | ||
var http = require('http'); | ||
|
||
/** | ||
* Get port from environment and store in Express. | ||
*/ | ||
|
||
var port = normalizePort('3000'); | ||
app.set('port', port); | ||
|
||
/** | ||
* Create HTTP server. | ||
*/ | ||
|
||
var server = http.createServer(app); | ||
|
||
/** | ||
* Listen on provided port, on all network interfaces. | ||
*/ | ||
|
||
server.listen(port); | ||
server.on('error', onError); | ||
server.on('listening', onListening); | ||
|
||
/** | ||
* Normalize a port into a number, string, or false. | ||
*/ | ||
|
||
function normalizePort(val) { | ||
var port = parseInt(val, 10); | ||
|
||
if (isNaN(port)) { | ||
// named pipe | ||
return val; | ||
} | ||
|
||
if (port >= 0) { | ||
// port number | ||
return port; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Event listener for HTTP server "error" event. | ||
*/ | ||
|
||
function onError(error) { | ||
if (error.syscall !== 'listen') { | ||
throw error; | ||
} | ||
|
||
var bind = typeof port === 'string' | ||
? 'Pipe ' + port | ||
: 'Port ' + port; | ||
|
||
// handle specific listen errors with friendly messages | ||
switch (error.code) { | ||
case 'EACCES': | ||
console.error(bind + ' requires elevated privileges'); | ||
process.exit(1); | ||
break; | ||
case 'EADDRINUSE': | ||
console.error(bind + ' is already in use'); | ||
process.exit(1); | ||
break; | ||
default: | ||
throw error; | ||
} | ||
} | ||
|
||
/** | ||
* Event listener for HTTP server "listening" event. | ||
*/ | ||
|
||
function onListening() { | ||
var addr = server.address(); | ||
var bind = typeof addr === 'string' | ||
? 'pipe ' + addr | ||
: 'port ' + addr.port; | ||
debug('Listening on ' + bind); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
|
||
const path = require('path') | ||
const MiniCssExtractPlugin = require('mini-css-extract-plugin') | ||
const config = require('../config') | ||
const NODE_ENV = process.env.NODE_ENV | ||
// style files regexes | ||
const preRegex = /\.(less)$/ | ||
|
||
function resolve(dir) { | ||
return path.join(__dirname, '..', dir) | ||
} | ||
|
||
// common function to get style loaders | ||
const getStyleLoaders = () => { | ||
const preProcessor = 'less-loader' | ||
const loaders = [ | ||
NODE_ENV === 'development' ? 'style-loader' : MiniCssExtractPlugin.loader, | ||
{ | ||
loader: 'css-loader', | ||
options: { | ||
modules: true, | ||
localIdentName: '[name]_[local]-[hash:base64:8]', | ||
} | ||
}, | ||
{ | ||
loader: 'postcss-loader' | ||
}, | ||
preProcessor | ||
] | ||
|
||
return loaders | ||
} | ||
|
||
module.exports = { | ||
entry: resolve('src/index.js'), | ||
resolve: { | ||
extensions: ['.js', '.jsx', '.json'] | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.(js|jsx)$/, | ||
loader: 'babel-loader', | ||
exclude: /node_modules/ | ||
}, | ||
{ | ||
test: /\.css$/, | ||
use: [NODE_ENV === 'development' ? 'style-loader' : MiniCssExtractPlugin.loader, 'css-loader'], | ||
},{ | ||
test: /\.less$/, | ||
use: ['style-loader', 'css-loader', 'less-loader'] | ||
}, | ||
// { | ||
// test: preRegex, | ||
// use: getStyleLoaders(), | ||
// exclude: /node_modules/ | ||
// }, | ||
{ | ||
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, | ||
loader: 'url-loader', | ||
options: { | ||
limit: 10000, | ||
name: `${config.build.assetsSubDirectory}/img/[name].[hash:8].[ext]` | ||
} | ||
}, | ||
{ | ||
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/, | ||
loader: 'url-loader', | ||
options: { | ||
limit: 10000, | ||
name: `${config.build.assetsSubDirectory}/media/[name].[hash:8].[ext]` | ||
} | ||
}, | ||
{ | ||
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, | ||
loader: 'url-loader', | ||
options: { | ||
limit: 10000, | ||
name: `${config.build.assetsSubDirectory}/fonts/[name].[hash:8].[ext]` | ||
} | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
|
||
const path = require('path') | ||
const webpack = require('webpack') | ||
const merge = require('webpack-merge') | ||
const HtmlWebpackPlugin = require('html-webpack-plugin') | ||
const WebpackServerQRcode = require('@ice-point/webpack-server-qrcode') | ||
const baseWebpackConfig = require('./webpack.base.conf.js') | ||
const config = require('../config') | ||
|
||
module.exports = merge(baseWebpackConfig, { | ||
mode: config.dev.mode, | ||
devtool: config.dev.sourceMap, | ||
output: { | ||
path: config.dev.assetsRoot, | ||
filename: path.join(config.dev.assetsSubDirectory, 'js/[name].js'), | ||
chunkFilename: path.join(config.dev.assetsSubDirectory, 'js/[name].chunk.js'), | ||
publicPath: config.dev.assetsPublicPath | ||
}, | ||
devServer: { | ||
contentBase: config.dev.assetsRoot, | ||
disableHostCheck:true, | ||
host: config.dev.host, | ||
port: config.dev.port, | ||
open: config.dev.autoOpenBrowser, | ||
inline: true, | ||
hot: true, | ||
overlay: config.dev.overlay, | ||
historyApiFallback: config.dev.historyApiFallback, | ||
noInfo: config.dev.noInfo | ||
}, | ||
plugins: [ | ||
new WebpackServerQRcode(), | ||
new webpack.HotModuleReplacementPlugin(), | ||
new HtmlWebpackPlugin({ | ||
template: './src/index.tpl.html' | ||
}), | ||
] | ||
}) |
Oops, something went wrong.