Browse Source

登录登出

release_0.0.1
yuan_yi 3 years ago
parent
commit
d18dfa9c30
  1. 25
      code/VideoAccess-VCMP/web/client/index.html
  2. 2
      code/VideoAccess-VCMP/web/client/src/app.jsx
  3. 30
      code/VideoAccess-VCMP/web/client/src/sections/auth/actions/auth.js
  4. 2
      code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/style.less
  5. 3
      code/VideoAccess-VCMP/web/client/src/utils/index.js
  6. 3
      code/VideoAccess-VCMP/web/client/src/utils/webapi.js
  7. 6
      code/VideoAccess-VCMP/web/config.js
  8. 2
      code/VideoAccess-VCMP/web/package.json

25
code/VideoAccess-VCMP/web/client/index.html

@ -26,18 +26,19 @@
<script> <script>
//过滤掉一些无用的警告、没有价值的报错 //过滤掉一些无用的警告、没有价值的报错
//代理console.warn方法 //代理console.warn方法
const _consoleWarn = (...rest) => {
console.error(...rest) // const _consoleWarn = (...rest) => {
}; // console.error(...rest)
console.error = (...rest) => { // };
if ( // console.error = (...rest) => {
![ // if (
'Each child in a list should have a unique "key" prop', // ![
].some((item) => rest[0].indexOf(item) !== -1) // 'Each child in a list should have a unique "key" prop',
) { // ].some((item) => rest[0].indexOf(item) !== -1)
_consoleWarn(...rest); // ) {
} // _consoleWarn(...rest);
}; // }
// };
</script> </script>
</body> </body>

2
code/VideoAccess-VCMP/web/client/src/app.jsx

@ -16,7 +16,7 @@ const App = props => {
return ( return (
<Layout <Layout
title={projectName} title={projectName}
sections={[Auth,EquipmentWarehouse]} sections={[Auth, EquipmentWarehouse]}
/> />
) )
} }

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

@ -1,7 +1,6 @@
'use strict'; 'use strict';
import { ApiTable } from '$utils' import { ApiTable, AuthRequest } from '$utils'
import { Request } from '@peace/utils'
export const INIT_AUTH = 'INIT_AUTH'; export const INIT_AUTH = 'INIT_AUTH';
export function initAuth () { export function initAuth () {
@ -29,18 +28,17 @@ 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,
displayName: 'TEST' // displayName: 'TEST'
} // }
}, // },
}); // });
const url = ApiTable.login; return AuthRequest.post(ApiTable.login, { username, password })
return Request.post(url, { username, password, p: '456' })
.then(user => { .then(user => {
sessionStorage.setItem('user', JSON.stringify(user)); sessionStorage.setItem('user', JSON.stringify(user));
dispatch({ dispatch({
@ -61,11 +59,9 @@ export function login (username, password) {
export const LOGOUT = 'LOGOUT'; export const LOGOUT = 'LOGOUT';
export function logout (user) { export function logout (user) {
const token = user.token;
const url = ApiTable.logout;
sessionStorage.removeItem('user'); sessionStorage.removeItem('user');
Request.put(url, { AuthRequest.put(ApiTable.logout, {
token: token token: user.token
}); });
return { return {
type: LOGOUT type: LOGOUT

2
code/VideoAccess-VCMP/web/client/src/sections/equipmentWarehouse/style.less

@ -1,5 +1,5 @@
.NvrHeader{ .NvrHeader{
background-image: url(../../../assets/images/background/nvr_banner.png); background-image: url(/assets/images/background/nvr_banner.png);
height: 171px; height: 171px;
background-size:100% 100%; background-size:100% 100%;
} }

3
code/VideoAccess-VCMP/web/client/src/utils/index.js

@ -1,7 +1,7 @@
'use strict'; 'use strict';
import { isAuthorized } from './func'; import { isAuthorized } from './func';
import { AuthorizationCode } from './authCode'; import { AuthorizationCode } from './authCode';
import { ApiTable, RouteTable } from './webapi' import { ApiTable, RouteTable, AuthRequest } from './webapi'
export { export {
isAuthorized, isAuthorized,
@ -10,4 +10,5 @@ export {
ApiTable, ApiTable,
RouteTable, RouteTable,
AuthRequest,
} }

3
code/VideoAccess-VCMP/web/client/src/utils/webapi.js

@ -1,4 +1,7 @@
'use strict'; 'use strict';
import { ProxyRequest } from '@peace/utils'
export const AuthRequest = new ProxyRequest('_auth')
export const ApiTable = { export const ApiTable = {
login: 'login', login: 'login',

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

@ -32,6 +32,12 @@ const product = {
host: API_URL, host: API_URL,
match: /^\/_api\//, match: /^\/_api\//,
} }
}, {
entry: require('./middlewares/proxy').entry,
opts: {
host: 'http://localhost:4200',
match: /^\/_auth\//,
}
}, { }, {
entry: require('./routes').entry, entry: require('./routes').entry,
opts: { opts: {

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

@ -54,7 +54,7 @@
"@douyinfe/semi-ui": "^2.8.0", "@douyinfe/semi-ui": "^2.8.0",
"@fs/attachment": "^1.0.0", "@fs/attachment": "^1.0.0",
"@peace/components": "0.0.35", "@peace/components": "0.0.35",
"@peace/utils": "^0.0.44", "@peace/utils": "^0.0.48",
"@vitejs/plugin-react": "^1.3.1", "@vitejs/plugin-react": "^1.3.1",
"@vitejs/plugin-react-refresh": "^1.3.6", "@vitejs/plugin-react-refresh": "^1.3.6",
"args": "^5.0.1", "args": "^5.0.1",

Loading…
Cancel
Save