Browse Source

auth 参数配置

release_0.0.1
yuan_yi 3 years ago
parent
commit
90b6c11a3f
  1. 2
      code/VideoAccess-VCMP/web/client/src/layout/components/header/index.jsx
  2. 18
      code/VideoAccess-VCMP/web/client/src/sections/auth/actions/auth.js
  3. 4
      code/VideoAccess-VCMP/web/config.js
  4. 2
      code/VideoAccess-VCMP/web/package.json

2
code/VideoAccess-VCMP/web/client/src/layout/components/header/index.jsx

@ -23,7 +23,7 @@ const Header = props => {
history.push(`/signin`); history.push(`/signin`);
} }
}}> }}>
<Nav.Sub itemKey={'user'} text={<div style={{ display: 'inline-block' }}>{user.namePresent}</div>}> <Nav.Sub itemKey={'user'} text={<div style={{ display: 'inline-block' }}>{user && user.namePresent}</div>}>
<Nav.Item itemKey={'logout'} text={'退出'} /> <Nav.Item itemKey={'logout'} text={'退出'} />
</Nav.Sub> </Nav.Sub>
</Nav> </Nav>

18
code/VideoAccess-VCMP/web/client/src/sections/auth/actions/auth.js

@ -28,15 +28,15 @@ export function login (username, password) {
return Promise.resolve(); return Promise.resolve();
} }
return dispatch({ // return dispatch({
type: LOGIN_SUCCESS, // type: LOGIN_SUCCESS,
payload: { // payload: {
user: { // user: {
authorized: true, // authorized: true,
namePresent: 'TEST' // namePresent: 'TEST'
} // }
}, // },
}); // });
return AuthRequest.post(ApiTable.login, { username, password }) return AuthRequest.post(ApiTable.login, { username, password })
.then(user => { .then(user => {

4
code/VideoAccess-VCMP/web/config.js

@ -12,10 +12,12 @@ dev && console.log('\x1B[33m%s\x1b[0m', '请遵循并及时更新 readme.md,
// // 启动参数 // // 启动参数
args.option(['p', 'port'], '启动端口'); args.option(['p', 'port'], '启动端口');
args.option(['u', 'api-url'], 'webapi的URL'); args.option(['u', 'api-url'], 'webapi的URL');
args.option('apiAuthUrl', 'apiAuthUrl');
const flags = args.parse(process.argv); const flags = args.parse(process.argv);
const API_URL = process.env.API_URL || flags.apiUrl; const API_URL = process.env.API_URL || flags.apiUrl;
const API_AUTH_URL = process.env.API_AUTH_URL || flags.apiAuthUrl;
if (!API_URL) { if (!API_URL) {
console.log('缺少启动参数,异常退出'); console.log('缺少启动参数,异常退出');
@ -35,7 +37,7 @@ const product = {
}, { }, {
entry: require('./middlewares/proxy').entry, entry: require('./middlewares/proxy').entry,
opts: { opts: {
host: 'http://localhost:4200', host: API_AUTH_URL,
match: /^\/_auth\//, match: /^\/_auth\//,
} }
}, { }, {

2
code/VideoAccess-VCMP/web/package.json

@ -7,7 +7,7 @@
"test": "mocha", "test": "mocha",
"start-vite": "cross-env NODE_ENV=developmentVite npm run start-params", "start-vite": "cross-env NODE_ENV=developmentVite npm run start-params",
"start": "cross-env NODE_ENV=development npm run start-params", "start": "cross-env NODE_ENV=development npm run start-params",
"start-params": "node server -p 5000 -u http://127.0.0.1:4000", "start-params": "node server -p 5000 -u http://127.0.0.1:4000 --apiAuthUrl http://10.8.30.82:4200",
"deploy": "export NODE_ENV=production&& npm run build && node server", "deploy": "export NODE_ENV=production&& npm run build && node server",
"build-dev": "export NODE_ENV=development&&webpack --config webpack.config.js", "build-dev": "export NODE_ENV=development&&webpack --config webpack.config.js",
"build": "export NODE_ENV=production&&webpack --config webpack.config.prod.js" "build": "export NODE_ENV=production&&webpack --config webpack.config.prod.js"

Loading…
Cancel
Save