This commit is contained in:
xuyucheng 2022-02-08 09:56:12 +08:00
parent 13a064bbfb
commit 2d6bcf9034
8 changed files with 24 additions and 41 deletions

View File

@ -6,15 +6,6 @@ const operationAction = (panes,activeKey) => {
}
}
const operationMenus = (menus) =>{
return {
type: "operation_menus",
menus,
}
}
module.exports = {
operationAction,
operationMenus
}

View File

@ -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) {

View File

@ -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 {
<Option value="guest">guest</Option>
</Select>
</Form.Item>
<Form.Item name="duty" label="duty" rules={[{ required: true, message: 'Please input duty!' }]}>
<Select>
<Option value="developers">developer</Option>
<Option value="analysts">analysts</Option>
<Option value="manager">manager</Option>
</Select>
</Form.Item>
</Form>
</Modal>
</React.Fragment>

View File

@ -10,7 +10,6 @@ class Head extends Component {
}
confirm = () => {
console.log(this)
localStorage.removeItem("token")
this.props.history.push('/login')
}

View File

@ -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({

View File

@ -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: <ApartmentOutlined />, category: 'Model' },
{ title: '企业管理', path: '/test/company', icon: <FundProjectionScreenOutlined />, category: 'Test' },
{ title: '服务管理', path: '/service', icon: <GlobalOutlined />, category: 'Test' },
{ title: '用户', path: '/setting/user', icon: <UserOutlined />, category: 'Setting'},
{ title: '用户', path: '/setting/user', icon: <UserOutlined />, category: 'Setting' },
{ title: '设置', path: '/service', icon: <SettingOutlined />, 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 <Menu.ItemGroup title={item} key={i}>
{this.state.data.map((ele, index) => {
return ele.category === item?<Menu.Item key={index} icon={ele.icon} onClick={this.handleClick}>{ele.title}</Menu.Item>:null
return ele.category === item ? <Menu.Item key={index} icon={ele.icon} onClick={this.handleClick}>{ele.title}</Menu.Item> : null
})}
</Menu.ItemGroup>
})
@ -47,7 +47,7 @@ class Side extends Component {
theme="dark"
className='menu'
>
<PageHeader title="TFSE" style={{ marginBottom: '40px',color:'#fff' }}></PageHeader>
<PageHeader title="TFSE" style={{ marginBottom: '40px', color: '#fff' }}></PageHeader>
{menuItem}
</Menu>
)

View File

@ -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)

View File

@ -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