diff --git a/src/action/index.js b/src/action/index.js index a772bfa..29803b1 100644 --- a/src/action/index.js +++ b/src/action/index.js @@ -6,15 +6,6 @@ const operationAction = (panes,activeKey) => { } } -const operationMenus = (menus) =>{ - return { - type: "operation_menus", - menus, - } -} - - module.exports = { operationAction, - operationMenus } \ No newline at end of file diff --git a/src/api/request.js b/src/api/request.js index 47f16bb..c4c41ef 100644 --- a/src/api/request.js +++ b/src/api/request.js @@ -1,5 +1,5 @@ import axios from 'axios' -// import { message } from 'antd' +import { message } from 'antd' axios.defaults.timeout = 50000; axios.defaults.baseURL = 'http://139.9.249.34:51013' @@ -23,11 +23,12 @@ axios.interceptors.response.use(function (response) { return Promise.reject(response); } }, function (error) { - // const { status } = error.response; - // if (status === 401) { - // message.warning("认证失效,请重新登录"); - // window.location.href = '/#/login' - // } + const { status } = error.response; + if (status === 401) { + message.warning("认证失效,请重新登录"); + localStorage.removeItem("token") + window.location.href = '/#/login' + } return Promise.reject(error); }); @@ -80,7 +81,7 @@ const api = { axios.get( path, { responseType: 'blob' }) .then(function (response) { - const blob = new Blob([response.data],{ type: 'application/pdf' }); + const blob = new Blob([response.data], { type: 'application/pdf' }); resolve(window.URL.createObjectURL(blob)); }) .catch(function (error) { @@ -93,7 +94,7 @@ const api = { axios.post( path, data, { responseType: 'blob' }) .then(function (response) { - const blob = new Blob([response.data],{type:"application/pdf"}); + const blob = new Blob([response.data], { type: "application/pdf" }); resolve(window.URL.createObjectURL(blob)); }) .catch(function (error) { diff --git a/src/pages/home/branch/setting/user.js b/src/pages/home/branch/setting/user.js index 8ffbbcd..25c6d67 100644 --- a/src/pages/home/branch/setting/user.js +++ b/src/pages/home/branch/setting/user.js @@ -40,7 +40,6 @@ class UserSet extends Component { name: form.getFieldsValue().name, pwd: rsaKey(form.getFieldsValue().pwd), role: form.getFieldsValue().role, - duty: form.getFieldsValue().duty, } api.post("/admin/user/create_user", data).then(res => { message.success(res.info) @@ -93,13 +92,6 @@ class UserSet extends Component { - - - diff --git a/src/pages/home/head.js b/src/pages/home/head.js index e571227..65221fa 100644 --- a/src/pages/home/head.js +++ b/src/pages/home/head.js @@ -10,7 +10,6 @@ class Head extends Component { } confirm = () => { - console.log(this) localStorage.removeItem("token") this.props.history.push('/login') } diff --git a/src/pages/home/index.js b/src/pages/home/index.js index c30ef92..eec15ed 100644 --- a/src/pages/home/index.js +++ b/src/pages/home/index.js @@ -3,6 +3,7 @@ import Head from './head' import Side from './side' import Main from './content' import React, { Component } from 'react' +import api from "@/api/request" const { Header, Sider, Content } = Layout; class Home extends Component { @@ -13,6 +14,11 @@ class Home extends Component { } } + componentDidMount(){ + api.get("/admin/user/online_check").then(res=>{ + console.log(res) + }) + } getMenuItem = (value) => { this.setState({ diff --git a/src/pages/home/side.js b/src/pages/home/side.js index 0125718..64728c8 100644 --- a/src/pages/home/side.js +++ b/src/pages/home/side.js @@ -1,7 +1,7 @@ import { Menu, PageHeader } from 'antd'; import React, { Component } from 'react'; import { connect } from 'react-redux'; -import { AreaChartOutlined,UserOutlined, BookOutlined, FundProjectionScreenOutlined,GlobalOutlined,BranchesOutlined,ApartmentOutlined,SettingOutlined } from '@ant-design/icons'; +import { AreaChartOutlined, UserOutlined, BookOutlined, FundProjectionScreenOutlined, GlobalOutlined, BranchesOutlined, ApartmentOutlined, SettingOutlined } from '@ant-design/icons'; class Side extends Component { constructor(props) { @@ -16,7 +16,7 @@ class Side extends Component { { title: '行业分类', path: '/service', icon: , category: 'Model' }, { title: '企业管理', path: '/test/company', icon: , category: 'Test' }, { title: '服务管理', path: '/service', icon: , category: 'Test' }, - { title: '用户', path: '/setting/user', icon: , category: 'Setting'}, + { title: '用户', path: '/setting/user', icon: , category: 'Setting' }, { title: '设置', path: '/service', icon: , category: 'Setting' }, ] } @@ -24,17 +24,17 @@ class Side extends Component { handleClick = e => { this.props.parent.getMenuItem({ - title:this.state.data[e.key].title, - path:this.state.data[e.key].path + title: this.state.data[e.key].title, + path: this.state.data[e.key].path }) } render() { - // ['Board', 'Manage','Model','Test','Setting'] - const menuItem = this.props.menus.map((item,i) => { + const menus = localStorage.getItem("menus").split(',') || ['Board', 'Manage','Model','Test','Setting'] + const menuItem = menus.map((item, i) => { return {this.state.data.map((ele, index) => { - return ele.category === item?{ele.title}:null + return ele.category === item ? {ele.title} : null })} }) @@ -47,7 +47,7 @@ class Side extends Component { theme="dark" className='menu' > - + {menuItem} ) diff --git a/src/pages/user/index.js b/src/pages/user/index.js index 16d5bed..d475471 100644 --- a/src/pages/user/index.js +++ b/src/pages/user/index.js @@ -4,8 +4,6 @@ import { Layout, Form, Input, Button, message, Row, Col } from 'antd' import { UserOutlined, LockOutlined, MailOutlined } from '@ant-design/icons'; import api from "@/api/request" import { rsaKey } from "@/utils/rsaKey.js"; -import { operationMenus } from "@/action/index" -import store from "@/store/index" const { Content } = Layout; @@ -45,7 +43,7 @@ class User extends Component { if ("result" in res) { message.success("登录成功") localStorage.setItem("token", res.result.token) - store.dispatch(operationMenus(res.result.menus)) + localStorage.setItem("menus",res.result.menus) this.props.history.push('/home') } else { message.warning(res.info) diff --git a/src/reducer/index.js b/src/reducer/index.js index 6422235..c9399eb 100644 --- a/src/reducer/index.js +++ b/src/reducer/index.js @@ -3,7 +3,6 @@ const intState = { panes: [{ title: '面板', content: "/dashboard", key: "0" }], activeKey: "0", - menus: ["Board","Manage","Model","Setting"] } const reducer = (state = intState, action) => { @@ -11,12 +10,9 @@ const reducer = (state = intState, action) => { case "operation_panes": delete state.activeKey return Object.assign({}, state, action) - case "operation_menus": - return Object.assign({}, state, action) default: return state; } - } export default reducer \ No newline at end of file