Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
9d29b71a7b
@ -4,9 +4,13 @@ import pageRoutes from './router.config';
|
|||||||
import webpackPlugin from './plugin.config';
|
import webpackPlugin from './plugin.config';
|
||||||
import defaultSettings from '../src/defaultSettings';
|
import defaultSettings from '../src/defaultSettings';
|
||||||
import slash from 'slash2';
|
import slash from 'slash2';
|
||||||
|
import proxy from './proxy';
|
||||||
|
|
||||||
const { pwa, primaryColor } = defaultSettings;
|
const { pwa, primaryColor } = defaultSettings;
|
||||||
const { NODE_ENV, APP_TYPE, TEST } = process.env;
|
const { NODE_ENV, APP_TYPE, TEST, BASE_PATH } = process.env;
|
||||||
|
|
||||||
|
// 用于控制,部署非跟目录下
|
||||||
|
const basePath = BASE_PATH ? BASE_PATH : '';
|
||||||
|
|
||||||
const plugins = [
|
const plugins = [
|
||||||
[
|
[
|
||||||
@ -60,6 +64,8 @@ if (APP_TYPE === 'site') {
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
// add for transfer to umi
|
// add for transfer to umi
|
||||||
|
base: basePath,
|
||||||
|
publicPath: basePath,
|
||||||
plugins,
|
plugins,
|
||||||
define: {
|
define: {
|
||||||
APP_TYPE: APP_TYPE || '',
|
APP_TYPE: APP_TYPE || '',
|
||||||
@ -79,18 +85,7 @@ export default {
|
|||||||
'@antv/data-set': 'DataSet',
|
'@antv/data-set': 'DataSet',
|
||||||
bizcharts: 'BizCharts',
|
bizcharts: 'BizCharts',
|
||||||
},
|
},
|
||||||
proxy: {
|
proxy: proxy(NODE_ENV, basePath),
|
||||||
'/admin-api/': {
|
|
||||||
target: 'http://180.167.213.26:18083/',
|
|
||||||
changeOrigin: true,
|
|
||||||
pathRewrite: {},
|
|
||||||
},
|
|
||||||
'/server/api/': {
|
|
||||||
target: 'https://preview.pro.ant.design/',
|
|
||||||
changeOrigin: true,
|
|
||||||
pathRewrite: { '^/server': '' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
ignoreMomentLocale: true,
|
ignoreMomentLocale: true,
|
||||||
lessLoaderOptions: {
|
lessLoaderOptions: {
|
||||||
javascriptEnabled: true,
|
javascriptEnabled: true,
|
||||||
|
27
admin-web/config/proxy/index.js
Normal file
27
admin-web/config/proxy/index.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// development 和 production
|
||||||
|
|
||||||
|
import path from 'path';
|
||||||
|
import proxyDev from './proxy.dev';
|
||||||
|
import proxyProd from './proxy.prod';
|
||||||
|
|
||||||
|
function basePathBuilder(proxys, basePath) {
|
||||||
|
for (const key in proxys) {
|
||||||
|
const proxy = proxys[key];
|
||||||
|
const pathRewrite = proxy.pathRewrite;
|
||||||
|
const newPathRewrite = {};
|
||||||
|
for (const key2 in pathRewrite) {
|
||||||
|
const item = pathRewrite[key2];
|
||||||
|
newPathRewrite[key2] = path.join(basePath, item);
|
||||||
|
}
|
||||||
|
proxy.pathRewrite = newPathRewrite;
|
||||||
|
}
|
||||||
|
return proxys;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function(NODE_ENV, basePath) {
|
||||||
|
let proxys = NODE_ENV === 'development' || NODE_ENV === 'undefined' ? proxyDev : proxyProd;
|
||||||
|
if (basePath) {
|
||||||
|
proxys = basePathBuilder(proxys, basePath);
|
||||||
|
}
|
||||||
|
return proxys;
|
||||||
|
}
|
14
admin-web/config/proxy/proxy.dev.js
Normal file
14
admin-web/config/proxy/proxy.dev.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// 开发环境,的代理配置
|
||||||
|
|
||||||
|
export default {
|
||||||
|
'/admin-api/': {
|
||||||
|
target: 'http://180.167.213.26:18083/',
|
||||||
|
changeOrigin: true,
|
||||||
|
pathRewrite: {},
|
||||||
|
},
|
||||||
|
'/server/api/': {
|
||||||
|
target: 'https://preview.pro.ant.design/',
|
||||||
|
changeOrigin: true,
|
||||||
|
pathRewrite: { '^/server': '' },
|
||||||
|
},
|
||||||
|
};
|
16
admin-web/config/proxy/proxy.prod.js
Normal file
16
admin-web/config/proxy/proxy.prod.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// production 配置文件
|
||||||
|
|
||||||
|
export default {
|
||||||
|
'/admin-api/': {
|
||||||
|
target: 'http://180.167.213.26:18083/',
|
||||||
|
changeOrigin: true,
|
||||||
|
pathRewrite: {
|
||||||
|
'^/admin-api': `/admin-web/admin-api`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'/server/api/': {
|
||||||
|
target: 'https://preview.pro.ant.design/',
|
||||||
|
changeOrigin: true,
|
||||||
|
pathRewrite: { '^/server': '' },
|
||||||
|
},
|
||||||
|
};
|
25
admin-web/config/server/README.md
Normal file
25
admin-web/config/server/README.md
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
# 使用说明
|
||||||
|
|
||||||
|
|
||||||
|
### 第一步
|
||||||
|
|
||||||
|
```
|
||||||
|
npm install
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### 第二步
|
||||||
|
复制文件到 server 目录
|
||||||
|
|
||||||
|
```
|
||||||
|
cp -rf dist server
|
||||||
|
```
|
||||||
|
|
||||||
|
### 第三步
|
||||||
|
|
||||||
|
```
|
||||||
|
node server.prod
|
||||||
|
```
|
||||||
|
|
12
admin-web/config/server/config/chalk.config.js
Normal file
12
admin-web/config/server/config/chalk.config.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
//
|
||||||
|
// 粉笔:
|
||||||
|
// 输出不同颜色的提示信息
|
||||||
|
|
||||||
|
const chalk = require('chalk');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
chalkError: chalk.red,
|
||||||
|
chalkSuccess: chalk.green,
|
||||||
|
chalkWarning: chalk.yellow,
|
||||||
|
chalkProcessing: chalk.blue,
|
||||||
|
};
|
10
admin-web/config/server/config/proxy.prod.config.js
Normal file
10
admin-web/config/server/config/proxy.prod.config.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
module.exports = {
|
||||||
|
'/admin-api -> http://180.167.213.26:18083/': {
|
||||||
|
changeOrigin: true,
|
||||||
|
pathRewrite: {},
|
||||||
|
},
|
||||||
|
'/server/api -> https://preview.pro.ant.design/': {
|
||||||
|
changeOrigin: true,
|
||||||
|
pathRewrite: { '^/server': '' },
|
||||||
|
},
|
||||||
|
};
|
10
admin-web/config/server/package.json
Normal file
10
admin-web/config/server/package.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"name": "browser-work-server",
|
||||||
|
"description": "node server",
|
||||||
|
"dependencies": {
|
||||||
|
"express": "^4.16.3",
|
||||||
|
"object-assign": "4.1.1",
|
||||||
|
"chalk": "2.4.1",
|
||||||
|
"http-proxy-middleware": "^0.18.0"
|
||||||
|
}
|
||||||
|
}
|
11
admin-web/config/server/pm2.json
Normal file
11
admin-web/config/server/pm2.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "admin-web",
|
||||||
|
"script": "./server.prod.js",
|
||||||
|
"instances": "2",
|
||||||
|
"env": {
|
||||||
|
"NODE_ENV": "development"
|
||||||
|
},
|
||||||
|
"env_production": {
|
||||||
|
"NODE_ENV": "production"
|
||||||
|
}
|
||||||
|
}
|
35
admin-web/config/server/server.prod.js
Normal file
35
admin-web/config/server/server.prod.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
const path = require('path');
|
||||||
|
const express = require('express');
|
||||||
|
|
||||||
|
const { chalkSuccess } = require('./config/chalk.config');
|
||||||
|
const proxyConfig = require('./config/proxy.prod.config');
|
||||||
|
const proxyBuild = require('./utils/proxy.build');
|
||||||
|
|
||||||
|
// create app server
|
||||||
|
const app = express();
|
||||||
|
const port = 3000;
|
||||||
|
|
||||||
|
// host proxy
|
||||||
|
app.use(proxyBuild(proxyConfig));
|
||||||
|
|
||||||
|
// use index.html
|
||||||
|
app.use(express.static(path.join(__dirname, 'dist/static')));
|
||||||
|
app.use(express.static(path.join(__dirname, 'dist')));
|
||||||
|
|
||||||
|
app.use((req, res) => {
|
||||||
|
res.sendFile(path.join(__dirname, 'dist', 'index.html'));
|
||||||
|
});
|
||||||
|
|
||||||
|
app.listen(port, error => {
|
||||||
|
if (error) {
|
||||||
|
console.error(error);
|
||||||
|
} else {
|
||||||
|
console.info(
|
||||||
|
chalkSuccess(
|
||||||
|
'==> 🌎 Listening on port %s. ' + 'Open up http://localhost:%s/ in your browser.'
|
||||||
|
),
|
||||||
|
port,
|
||||||
|
port
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
24
admin-web/config/server/shell.sh
Normal file
24
admin-web/config/server/shell.sh
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
|
||||||
|
# 安装依赖包
|
||||||
|
|
||||||
|
cd mall
|
||||||
|
|
||||||
|
cd admin-web
|
||||||
|
|
||||||
|
npm install
|
||||||
|
|
||||||
|
# 开始构建
|
||||||
|
|
||||||
|
npm run build
|
||||||
|
|
||||||
|
# 创建 app 运行目录
|
||||||
|
|
||||||
|
mkdir app
|
||||||
|
|
||||||
|
# 复制配置文件
|
||||||
|
|
||||||
|
cp -rf config/server app/
|
||||||
|
|
||||||
|
# 复制文件到 server 努力
|
||||||
|
|
||||||
|
cp -rf dist app/
|
46
admin-web/config/server/utils/proxy.build.js
Normal file
46
admin-web/config/server/utils/proxy.build.js
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
const proxy = require('http-proxy-middleware');
|
||||||
|
const ObjectAssign = require('object-assign');
|
||||||
|
const { chalkError, chalkSuccess } = require('../config/chalk.config');
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* key :
|
||||||
|
* [0]: /api
|
||||||
|
* [1]: target url
|
||||||
|
*
|
||||||
|
* 预计写法:
|
||||||
|
* 1、 /api -> baidu.com : { }
|
||||||
|
* 2、 /user : function() { return {} }
|
||||||
|
*
|
||||||
|
* @param config
|
||||||
|
*/
|
||||||
|
module.exports = function(config) {
|
||||||
|
console.info(chalkSuccess('build proxy.%s.config 配置!'), process.env.NODE_ENV);
|
||||||
|
|
||||||
|
const proxys = [];
|
||||||
|
|
||||||
|
if (!config) {
|
||||||
|
console.log(chalkError('proxy.%s.config 没有配置!'), process.env.NODE_ENV);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const key in config) {
|
||||||
|
if (/->/.test(key)) {
|
||||||
|
const keys = key.toString().split('->');
|
||||||
|
const source = keys[0].trim();
|
||||||
|
const target = keys[1].trim();
|
||||||
|
|
||||||
|
if (typeof config !== 'object') {
|
||||||
|
console.log(
|
||||||
|
chalkError('%s: proxy.%s.config 初始化失败 config 类型为 object!'),
|
||||||
|
key,
|
||||||
|
process.env.NODE_ENV
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
proxys.push(proxy(source, ObjectAssign({ target }, config[key])));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return proxys;
|
||||||
|
};
|
@ -44,8 +44,8 @@ function getDictionaryText(req, res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
'GET /admin-api/admins/resource/admin_menu_tree': getAdminMenuAll,
|
'GET /admin-api/admins/admin/menu_resource_tree': getAdminMenuAll,
|
||||||
'GET /admin-api/admins/resource/admin_url_list': getAdminUrls,
|
'GET /admin-api/admins/admin/url_resource_list': getAdminUrls,
|
||||||
'GET /admin-api/admins/resource/tree': getResourceTree,
|
'GET /admin-api/admins/resource/tree': getResourceTree,
|
||||||
'GET /admin-api/admins/role/page': getQueryRole,
|
'GET /admin-api/admins/role/page': getQueryRole,
|
||||||
'GET /admin-api/admins/admin/page': getQueryRole,
|
'GET /admin-api/admins/admin/page': getQueryRole,
|
||||||
|
@ -74,9 +74,9 @@ export default {
|
|||||||
address: 'Sidney No. 1 Lake Park',
|
address: 'Sidney No. 1 Lake Park',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
'POST /admin-api/admin/passport/login': (req, res) => {
|
'POST /admin-api/admins/passport/login': (req, res) => {
|
||||||
const { password, username } = req.body;
|
const { username } = req.body;
|
||||||
if (password === 'admin' && username === 'admin') {
|
if (username === 'admin') {
|
||||||
res.send({
|
res.send({
|
||||||
code: 0,
|
code: 0,
|
||||||
data: {
|
data: {
|
||||||
@ -91,7 +91,7 @@ export default {
|
|||||||
res.send({
|
res.send({
|
||||||
code: 1000,
|
code: 1000,
|
||||||
data: {},
|
data: {},
|
||||||
message: '账号或密码错误!',
|
message: '账号或密码错误-mock!',
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
'POST /api/register': (req, res) => {
|
'POST /api/register': (req, res) => {
|
||||||
|
@ -7,7 +7,10 @@
|
|||||||
"presite": "cd functions && npm install",
|
"presite": "cd functions && npm install",
|
||||||
"start": "cross-env APP_TYPE=site umi dev",
|
"start": "cross-env APP_TYPE=site umi dev",
|
||||||
"start:no-mock": "cross-env MOCK=none umi dev",
|
"start:no-mock": "cross-env MOCK=none umi dev",
|
||||||
|
"start:admin-web": "cross-env BASE_PATH='/admin-web/' NODE_ENV=development APP_TYPE=site umi dev",
|
||||||
|
"start:admin-web:no-mock": "cross-env BASE_PATH='/admin-web/' NODE_ENV=development MOCK=none APP_TYPE=site umi dev",
|
||||||
"build": "umi build",
|
"build": "umi build",
|
||||||
|
"build:admin-web": "cross-env BASE_PATH='/admin-web/' NODE_ENV=production umi build",
|
||||||
"site": "npm run presite && cross-env APP_TYPE=site npm run build && firebase deploy && npm run docker:push",
|
"site": "npm run presite && cross-env APP_TYPE=site npm run build && firebase deploy && npm run docker:push",
|
||||||
"analyze": "cross-env ANALYZE=1 umi build",
|
"analyze": "cross-env ANALYZE=1 umi build",
|
||||||
"lint:style": "stylelint 'src/**/*.less' --syntax less",
|
"lint:style": "stylelint 'src/**/*.less' --syntax less",
|
||||||
|
@ -36,14 +36,14 @@ const copyright = (
|
|||||||
|
|
||||||
class UserLayout extends Component {
|
class UserLayout extends Component {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const {
|
// const {
|
||||||
dispatch,
|
// dispatch,
|
||||||
route: { routes, authority },
|
// route: { routes, authority },
|
||||||
} = this.props;
|
// } = this.props;
|
||||||
dispatch({
|
// dispatch({
|
||||||
type: 'menu/getMenuData',
|
// type: 'menu/getMenuData',
|
||||||
payload: { routes, authority },
|
// payload: { routes, authority },
|
||||||
});
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -4,11 +4,11 @@ import request from '@/utils/request';
|
|||||||
// auth
|
// auth
|
||||||
|
|
||||||
export async function getAdminMenus() {
|
export async function getAdminMenus() {
|
||||||
return request('/admin-api/admins/resource/admin_menu_tree');
|
return request('/admin-api/admins/admin/menu_resource_tree');
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getAdminUrls(params) {
|
export async function getAdminUrls(params) {
|
||||||
return request(`/admin-api/admins/resource/admin_url_list?${stringify(params)}`);
|
return request(`/admin-api/admins/admin/url_resource_list?${stringify(params)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// admin
|
// admin
|
||||||
|
@ -104,14 +104,14 @@ export async function updateFakeList(params) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function fakeAccountLogin(params) {
|
export async function fakeAccountLogin(params) {
|
||||||
return request(`/admin-api/admin/passport/login?${stringify(params)}`, {
|
return request(`/admin-api/admins/passport/login?${stringify(params)}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: params,
|
body: params,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function fakeRegister(params) {
|
export async function fakeRegister(params) {
|
||||||
return request(`/admin-api/admin/passport/login?${stringify(params)}`, {
|
return request(`/admin-api/admins/passport/login?${stringify(params)}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: params,
|
body: params,
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user