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

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

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

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

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save