Commit 72f1dc61 by wangshufen

fixed:修改request.js token校验

parent a05cccab
......@@ -12,16 +12,16 @@ const menus = [
icon: 'search',
key: '/Kinase',
},
{
title: 'PDB小分子搜索',
icon: 'search',
key: '/MolecularSearch',
},
{
title: '分子对接',
icon: '',
key: '/dockingUploadDetails',
},
// {
// title: 'PDB小分子搜索',
// icon: 'search',
// key: '/MolecularSearch',
// },
// {
// title: '分子对接',
// icon: '',
// key: '/dockingUploadDetails',
// },
{
title: 'Drugbank',
icon: 'medicine-box',
......
......@@ -684,7 +684,7 @@ export default class TargetDetails extends Component {
columns={columnsMutation}
/>
</Panel>
<Panel header="Drug & Clinical imformation" key="4">
<Panel header="Drug & Clinical information" key="4">
<Table
bordered
rowKey='item'
......
import React, { Component } from 'react'
import { Pagination, message, Button, Tabs, Spin, Table, Tag, Typography } from 'antd'
import request from '../../../utils/request'
import './index.css'
import qs from 'qs'
const { Title } = Typography
import React, { Component } from 'react';
import { Pagination, message, Button, Tabs, Spin, Table, Tag, Typography } from 'antd';
import request from '../../../utils/request';
import './index.css';
import qs from 'qs';
const { Title } = Typography;
export default class IndicationDetails extends Component {
state = {
IndicationList: [],
smilesData: qs.parse(this.props.location.search.slice(1)),
total_num: 0
total_num: 0,
};
componentDidMount() {
this.getDetails();
}
componentDidMount () {
this.getDetails()
}
getDetails () {
this.setState({ loading: true })
request.post('/kinase/indication_search', this.state.smilesData)
.then(res => {
this.setState({ loading: false })
getDetails() {
this.setState({ loading: true });
request
.post('/kinase/indication_search', this.state.smilesData)
.then((res) => {
this.setState({ loading: false });
if (res.data.code === 200) {
this.setState({ IndicationList: res.data.data })
this.setState({ total_num: res.data.total_num })
this.setState({ IndicationList: res.data.data });
this.setState({ total_num: res.data.total_num });
} else {
message.error(res.data.msg)
message.error(res.data.msg);
}
})
.catch(err => {
console.error(err)
})
.catch((err) => {
console.error(err);
});
}
onShowSizeChange = (current, pageSize) => {
let smilesData = this.state.smilesData
smilesData.page = current
smilesData.page_size = pageSize
let smilesData = this.state.smilesData;
smilesData.page = current;
smilesData.page_size = pageSize;
this.setState({
smilesData
})
smilesData,
});
this.getDetails()
}
this.getDetails();
};
onChange = (current, pageSize) => {
let smilesData = this.state.smilesData
smilesData.page = current
smilesData.page_size = pageSize
let smilesData = this.state.smilesData;
smilesData.page = current;
smilesData.page_size = pageSize;
this.setState({
smilesData
})
this.getDetails()
}
getOne (e) {
console.log(e)
const { dataid, datatype } = e
smilesData,
});
this.getDetails();
};
getOne(e) {
console.log(e);
const { dataid, datatype } = e;
let data = {
dataid,
datatype
}
this.props.history.push({ pathname: '/home/SearchDetails', search: qs.stringify(data) })
datatype,
};
this.props.history.push({ pathname: '/kinase/SearchDetails', search: qs.stringify(data) });
}
getOne2 (e) {
console.log(e)
const { dataid, datatype } = e
getOne2(e) {
console.log(e);
const { dataid, datatype } = e;
let data = {
dataid,
datatype
}
this.props.history.push({ pathname: '/home/TargetDetails', search: qs.stringify(data) })
datatype,
};
this.props.history.push({ pathname: '/kinase/TargetDetails', search: qs.stringify(data) });
}
getReferences = (e) => {
window.open(e)
}
window.open(e);
};
render () {
render() {
const columns = [
{
title: 'indicationName',
......@@ -111,13 +97,17 @@ export default class IndicationDetails extends Component {
title: 'Drug',
dataIndex: 'Drug',
key: 'Drug',
render: Drug => (
render: (Drug) => (
<span>
{
<Tag color="blue" onClick={() => { this.getOne(Drug) }} >
{(Drug.name)}
<Tag
color='blue'
onClick={() => {
this.getOne(Drug);
}}
>
{Drug.name}
</Tag>
}
</span>
),
......@@ -150,42 +140,34 @@ export default class IndicationDetails extends Component {
{
title: 'References',
dataIndex: 'References',
render: References => (
render: (References) => (
<span>
{References.map(item => {
{References.map((item) => {
return (
<Tag color="blue" key={item} onClick={() => { this.getReferences(item) }} >
<Tag
color='blue'
key={item}
onClick={() => {
this.getReferences(item);
}}
>
{item.toUpperCase()}
</Tag>
)
);
})}
</span>
),
},
]
const { IndicationList, total_num } = this.state
];
const { IndicationList, total_num } = this.state;
return (
<div className='IndicationDetails-div'>
<Title>{IndicationList.name}</Title>
<Table
bordered
rowKey='item'
dataSource={IndicationList}
pagination={false}
columns={columns}
/>
<Table bordered rowKey='item' dataSource={IndicationList} pagination={false} columns={columns} />
<div className='bottom-div'>
<Pagination
showSizeChanger
onShowSizeChange={this.onShowSizeChange}
onChange={this.onChange}
total={total_num}
/>
<Pagination showSizeChanger onShowSizeChange={this.onShowSizeChange} onChange={this.onChange} total={total_num} />
</div>
</div>
)
);
}
}
......@@ -1144,7 +1144,7 @@ export default class TargetDetails extends Component {
<Link href='#Sequence' title='Sequence' />
<Link href='#Structure' title='Structure' />
<Link href='#Mutation' title='Mutation' />
<Link href='#Drug' title='Drug & Clinical imformation' />
<Link href='#Drug' title='Drug & Clinical information' />
<Link href='#Bioassay' title='Bioassay' />
</Anchor>
</div>
......@@ -1261,9 +1261,13 @@ export default class TargetDetails extends Component {
{/* {PanelList} */}
<Collapse defaultActiveKey={['1', '2', '3', '4', '5', '6']} onChange={this.callback}>
<Panel header='Sequence' key='1' id='Sequence'>
<Button type='primary' onClick={this.alignmentEve}>
alignment
</Button>
<div>
<Button type='primary' onClick={this.alignmentEve}>
alignment
</Button>
<div style={{ width: '90%', overflow: 'scroll' }}>{targetsDetail.SequenceStr}</div>
</div>
<div className='Sequence-div'>
{targetsDetail.Sequence &&
targetsDetail.Sequence.map((item, index) => {
......@@ -1451,7 +1455,7 @@ export default class TargetDetails extends Component {
<Table bordered rowKey='item' dataSource={targetsDetail.MutationList} pagination={false} columns={columnsMutation} onChange={this.onChangeTable} />
<Pagination showSizeChanger onShowSizeChange={this.onShowSizeChange} onChange={this.onChange} total={total_num} />
</Panel>
<Panel header='Drug & Clinical imformation' key='4' id='Drug'>
<Panel header='Drug & Clinical information' key='4' id='Drug'>
<Table bordered rowKey='item' dataSource={targetsDetail.DrugsInformation} pagination={false} expandedRowRender={expandedRowRender} columns={columnsDrug} />
<Pagination showSizeChanger onShowSizeChange={this.onShowSizeChange3} onChange={this.onChange3} total={total_num3} />
</Panel>
......
......@@ -777,7 +777,7 @@ export default class TargetDetails extends Component {
})}
</Tabs>
</Panel>
<Panel header="Drug&Clinical imformation" key="6">
<Panel header="Drug&Clinical information" key="6">
<Table
bordered
rowKey="item"
......
......@@ -17,13 +17,54 @@ function disableF12() {
}
// disableF12();
//对axios二次封装
const token = getQueryString('token');
function checkFetchToken() {
fetch('http://69.235.144.91:8048/yszh-login/auth/checkToken', {
method: 'GET',
headers: {
accessToken: token,
},
})
.then((res) => res.json())
.then((res) => {
console.log('fetch--res', res);
if (res.code === 200) {
//校验通过,存储token
token && localStorage.setItem('token', token);
} else {
alert('token校验失败,返回登录页');
// window.open('http://localhost:3000/#/login', '_self');
window.open('http://69.235.144.91:3048/#/login', '_self');
}
})
.catch(function(err) {
console.log('err', err);
window.open('http://69.235.144.91:3048/#/login', '_self');
});
// request
// .get('http://69.235.144.91:8048/yszh-login/auth/checkToken')
// .then((res) => {
// console.log('--res', res);
// if (res.data.code === 200) {
// console.log('token 检验通过');
// return config;
// } else {
// console.log('token校验没通过 返回登录页');
// window.open('http://69.235.144.91:3048/#/login', '_self');
// }
// })
// .catch((err) => {
// console.log('token校验没通过 返回登录页');
// window.open('http://69.235.144.91:3048/#/login', '_self');
// console.log('err', err);
// });
}
checkFetchToken();
const baseURL = 'http://52.83.169.190:8002/'; //线上正式环境
// const baseURL = 'http://69.235.144.91:8002/'; 测试环境
//对axios二次封装
// console.log('getQueryString', getQueryString('token'));
// console.log('localStorage', localStorage.getItem('token'));
const token = getQueryString('token') || localStorage.getItem('token');
const request = axios.create({
baseURL,
timeout: 15000,
......@@ -34,44 +75,16 @@ const request = axios.create({
},
});
function checkToken(config) {
// alert(' 校验token111');
request
.get('http://69.235.144.91:8048/yszh-login/auth/checkToken')
.then((res) => {
console.log('--res', res);
if (res.data.code === 200) {
console.log('token 检验通过');
return config;
} else {
localStorage.removeItem('token');
// alert(' 失败');
console.log('token校验没通过 返回登录页');
// window.open('http://localhost:3000/#/login', '_self');
window.open('http://69.235.144.91:3048/#/login', '_self');
}
})
.catch((err) => {
localStorage.removeItem('token');
// alert(' 服务器报错');
console.log('token校验没通过 返回登录页');
window.open('http://69.235.144.91:3048/#/login', '_self');
console.log('err', err);
return false;
});
}
checkToken();
//拦截器
request.interceptors.request.use((config) => {
// alert('拦截器..');
console.log('token---', '拦截器方法校验token');
console.log(config);
if (getQueryString('token') || localStorage.getItem('token')) {
checkToken(config);
if (localStorage.getItem('token')) {
config.headers['accessToken'] = localStorage.getItem('token');
return config;
} else {
console.log('token为空....');
localStorage.removeItem('token');
window.open('http://69.235.144.91:3048/#/login', '_self');
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment