Commit febb13ed by wangshufen

fixed:kinase bug修复

parent 36c9821b
{ {
"presets":["react-app"], "presets": ["react-app"],
"plugins": [ "plugins": [["import", { "libraryName": "antd", "libraryDirectory": "es", "style": "css" }], ["transform-decorators-legacy"]]
["import", { "libraryName": "antd", "libraryDirectory": "es", "style": "css" }],
["transform-decorators-legacy"]
]
} }
module.exports = {
root: true, //此项是用来告诉eslint找当前配置文件不能往父级查找
env: {
node: true,
},
// "off" -> 0 关闭规则 "warn" -> 1 开启警告规则 "error" -> 2 开启错误规则
rules: {
'generator-star-spacing': 'off',
'no-tabs': 'off',
'no-unused-vars': 'off', //声明的变量未使用
'no-console': 'off',
'no-irregular-whitespace': 'off',
'no-debugger': 'off',
eqeqeq: 'off', // 使用全等
},
parser: 'babel-eslint',
parserOptions: {
ecmaVersion: 7,
sourceType: 'module',
},
};
{
"compilerOptions": {
"baseUrl": "./",
"experimentalDecorators": true,
"paths": {
"@/*": ["src/*"]
}
}
}
import React, { Component } from 'react' import React, { Component } from 'react'
import { Pagination,message,Button,Tabs,Spin,Table,Tag,Typography} from 'antd'; import { Pagination,message,Button,Tabs,Spin,Table,Tag,Typography} from 'antd';
import { request } from '../../../utils/request' import request from '../../../utils/request'
import './index.css' import './index.css'
import qs from 'qs' import qs from 'qs'
const { Title } = Typography; const { Title } = Typography;
......
import React, { Component } from 'react' import React, { Component } from 'react'
import { Card,Tooltip,Popover,message,Radio,Button,Tabs,Spin,Table,Tag,Input, Collapse,Modal,Form,Select,InputNumber,Typography} from 'antd'; import { Card,Tooltip,Popover,message,Radio,Button,Tabs,Spin,Table,Tag,Input, Collapse,Modal,Form,Select,InputNumber,Typography} from 'antd';
import { request } from '../../../utils/request' import request from '../../../utils/request'
import Molstar from "molstar-react"; import Molstar from "molstar-react";
import { Jsme } from 'jsme-react' import { Jsme } from 'jsme-react'
import qs from 'qs' import qs from 'qs'
......
import React, { Component } from 'react' import React, { Component } from 'react'
import { Card,Tooltip,Popover,message,Radio,Button,Icon,Tabs,Spin,Table,Tag,Input, Collapse,Modal,Form,Select,InputNumber,Typography, Dropdown} from 'antd'; import { Card,Tooltip,Popover,message,Radio,Button,Icon,Tabs,Spin,Table,Tag,Input, Collapse,Modal,Form,Select,InputNumber,Typography, Dropdown} from 'antd';
import { request } from '../../../utils/request' import request from '../../../utils/request'
import Molstar from "molstar-react"; import Molstar from "molstar-react";
import { Jsme } from 'jsme-react' import { Jsme } from 'jsme-react'
import qs from 'qs' import qs from 'qs'
......
import React, { Component } from 'react' import React, { Component } from 'react'
import { Card,Tooltip,message,Button,Tabs,Spin,Table,Tag, Collapse,Divider,Modal,Form,Select,InputNumber,Popover} from 'antd'; import { Card,Tooltip,message,Button,Tabs,Spin,Table,Tag, Collapse,Divider,Modal,Form,Select,InputNumber,Popover} from 'antd';
import { request } from '../../../utils/request' import request from '../../../utils/request'
import Molstar from "molstar-react"; import Molstar from "molstar-react";
import { Jsme } from 'jsme-react' import { Jsme } from 'jsme-react'
import qs from 'qs' import qs from 'qs'
......
import React, { Component } from 'react' import React, { Component } from 'react'
import { Jsme } from 'jsme-react' import { Jsme } from 'jsme-react'
import { Card,Button,Pagination,Tabs,Spin,message ,Tag} from 'antd'; import { Card,Button,Pagination,Tabs,Spin,message ,Tag} from 'antd';
import { request } from '../../../utils/request' import request from '../../../utils/request'
import qs from 'qs' import qs from 'qs'
import './index.css' import './index.css'
const { TabPane } = Tabs; const { TabPane } = Tabs;
......
import React, { Component } from 'react' import React, { Component } from 'react'
import { Card,Tooltip,Popover,message,Radio,Button,Tabs,Spin,Table,Tag,Input, Collapse,Modal,Form,Select,InputNumber,Typography} from 'antd'; import { Card,Tooltip,Popover,message,Radio,Button,Tabs,Spin,Table,Tag,Input, Collapse,Modal,Form,Select,InputNumber,Typography} from 'antd';
import { request } from '../../../utils/request' import request from '../../../utils/request'
import Molstar from "molstar-react"; import Molstar from "molstar-react";
import { Jsme } from 'jsme-react' import { Jsme } from 'jsme-react'
import qs from 'qs' import qs from 'qs'
......
...@@ -3,7 +3,7 @@ import { Form, Input, Button,Select ,Tabs,message,Radio,Checkbox,Row ,Col} from ...@@ -3,7 +3,7 @@ import { Form, Input, Button,Select ,Tabs,message,Radio,Checkbox,Row ,Col} from
import LogoTitlte from '../../components/LogoTitlte/index' import LogoTitlte from '../../components/LogoTitlte/index'
import { Jsme } from 'jsme-react' import { Jsme } from 'jsme-react'
import qs from 'qs' import qs from 'qs'
import { request } from '../../utils/request' import request from '../../utils/request'
import './style.css' import './style.css'
const { TabPane } = Tabs; const { TabPane } = Tabs;
const { Option } = Select; const { Option } = Select;
......
import React, { Component } from 'react' import React, { Component } from 'react'
import { Pagination, message, Button, Tabs, Spin, Table, Tag, Typography } from 'antd' import { Pagination, message, Button, Tabs, Spin, Table, Tag, Typography } from 'antd'
import { request } from '../../../utils/request' import request from '../../../utils/request'
import './index.css' import './index.css'
import qs from 'qs' import qs from 'qs'
const { Title } = Typography const { Title } = Typography
...@@ -15,7 +15,7 @@ export default class IndicationDetails extends Component { ...@@ -15,7 +15,7 @@ export default class IndicationDetails extends Component {
} }
getDetails () { getDetails () {
this.setState({ loading: true }) this.setState({ loading: true })
request.post('/gpcr/indication_search', this.state.smilesData) request.post('/kinase/indication_search', this.state.smilesData)
.then(res => { .then(res => {
this.setState({ loading: false }) this.setState({ loading: false })
if (res.data.code === 200) { if (res.data.code === 200) {
......
...@@ -18,7 +18,7 @@ import { ...@@ -18,7 +18,7 @@ import {
Menu, Menu,
Dropdown, Dropdown,
} from 'antd' } from 'antd'
import { request } from '../../../utils/request' import request from '../../../utils/request'
import Molstar from 'molstar-react' import Molstar from 'molstar-react'
import { Jsme } from 'jsme-react' import { Jsme } from 'jsme-react'
import qs from 'qs' import qs from 'qs'
......
import React, { Component } from "react"; import React, { Component } from "react";
import { Jsme } from "jsme-react"; import { Jsme } from "jsme-react";
import { Card, Button, Pagination, Tabs, Spin, message, Collapse,Tag } from "antd"; import { Card, Button, Pagination, Tabs, Spin, message, Collapse,Tag } from "antd";
import { request } from "../../../utils/request"; import request from "../../../utils/request";
import qs from "qs"; import qs from "qs";
import "./index.css"; import "./index.css";
const { TabPane } = Tabs; const { TabPane } = Tabs;
......
...@@ -22,7 +22,7 @@ import { ...@@ -22,7 +22,7 @@ import {
Pagination, Pagination,
} from 'antd' } from 'antd'
import WrappedIframe from '../../../components/iframePdb' import WrappedIframe from '../../../components/iframePdb'
import { request } from '../../../utils/request' import request from '../../../utils/request'
import Molstar from 'molstar-react' import Molstar from 'molstar-react'
import { Jsme } from 'jsme-react' import { Jsme } from 'jsme-react'
import qs from 'qs' import qs from 'qs'
...@@ -1178,7 +1178,7 @@ export default class TargetDetails extends Component { ...@@ -1178,7 +1178,7 @@ export default class TargetDetails extends Component {
{targetsDetail.Structure.map((item, index) => { {targetsDetail.Structure.map((item, index) => {
return ( return (
<Option key={index.pdb} value={item.pdb.toLowerCase()}> <Option key={index.pdb} value={item.pdb.toLowerCase()}>
{item.pdb.toLowerCase()} {item.pdb&&item.pdb.toLowerCase()}
</Option> </Option>
) )
})} })}
...@@ -1537,7 +1537,7 @@ export default class TargetDetails extends Component { ...@@ -1537,7 +1537,7 @@ export default class TargetDetails extends Component {
<Option <Option
key={index} key={index}
value={item.pdb.toLowerCase()}> value={item.pdb.toLowerCase()}>
{item.pdb.toLowerCase()} {item.pdb&&item.pdb.toLowerCase()}
</Option> </Option>
) )
} }
......
...@@ -4,7 +4,7 @@ import { withRouter } from 'react-router-dom' ...@@ -4,7 +4,7 @@ import { withRouter } from 'react-router-dom'
import { inject, observer } from 'mobx-react/index' import { inject, observer } from 'mobx-react/index'
import { Form, Input,message } from 'antd' import { Form, Input,message } from 'antd'
import PromptBox from '../../components/PromptBox' import PromptBox from '../../components/PromptBox'
import { request } from '../../utils/request' import request from '../../utils/request'
import md5 from 'js-md5'; import md5 from 'js-md5';
import qs from 'qs' import qs from 'qs'
......
import React from 'react' import React from 'react';
import BGParticle from '../../utils/BGParticle' import BGParticle from '../../utils/BGParticle';
import { notification } from 'antd' import { notification } from 'antd';
import './style.css' import './style.css';
import { withRouter } from 'react-router-dom' import { withRouter } from 'react-router-dom';
import { inject, observer } from 'mobx-react/index' import { inject, observer } from 'mobx-react/index';
import Loading2 from '../../components/Loading2' import Loading2 from '../../components/Loading2';
import {preloadingImages} from '../../utils/utils' import { preloadingImages } from '../../utils/utils';
import LogoTitlte from '../../components/LogoTitlte/index' import LogoTitlte from '../../components/LogoTitlte/index';
import 'animate.css' import 'animate.css';
import LoginForm from './LoginForm' import LoginForm from './LoginForm';
import RegisterForm from './RegisterForm' import RegisterForm from './RegisterForm';
const url = '' const url = '';
const imgs = [ const imgs = [
// 'http://47.99.130.140/imgs/wallhaven-p8r1e9.jpg', // 'http://47.99.130.140/imgs/wallhaven-p8r1e9.jpg',
// 'http://47.99.130.140/imgs/wallhaven-e7zyy8.jpg', // 'http://47.99.130.140/imgs/wallhaven-e7zyy8.jpg',
// 'http://47.99.130.140/imgs/wallhaven-6k9e7q.jpg', // 'http://47.99.130.140/imgs/wallhaven-6k9e7q.jpg',
// 'http://47.99.130.140/imgs/photo.jpg', // 'http://47.99.130.140/imgs/photo.jpg',
] ];
@withRouter //更新的作用
@inject('appStore') //接收
@observer //组件变为响应式
@withRouter @inject('appStore') @observer //这三步会把对应的store挂在props上
class Login extends React.Component { class Login extends React.Component {
state = { state = {
showBox: 'login', //展示当前表单 showBox: 'login', //展示当前表单
url: '', //背景图片 url: '', //背景图片
loading:false, loading: false,
loading2:false, loading2: false,
} };
componentDidMount () { componentDidMount() {
this.props.appStore.toggleLogin(true, { username: 'username' }) this.props.appStore.toggleLogin(true, { username: 'username' });
// const { from } = this.props.location.state || { from: { pathname: '/Kinase' } } // const { from } = this.props.location.state || { from: { pathname: '/Kinase' } }
const { from } = this.props.location.state || { from: { pathname: '/login' } } const { from } = this.props.location.state || { from: { pathname: '/login' } };
this.props.history.push(from) this.props.history.push(from);
} }
componentWillUnmount () { componentWillUnmount() {
this.particle && this.particle.destory() this.particle && this.particle.destory();
notification.destroy() notification.destroy();
} }
//载入页面时的一些处理 //载入页面时的一些处理
initPage = () => { initPage = () => {
this.setState({ this.setState({
loading:true loading: true,
}) });
this.props.appStore.initUsers() this.props.appStore.initUsers();
this.loadImageAsync(url).then(url=>{ this.loadImageAsync(url)
.then((url) => {
this.setState({ this.setState({
loading:false, loading: false,
url url,
});
}) })
}).then(()=>{ .then(() => {
//为什么写在then里?id为backgroundBox的DOM元素是在loading为false时才有,而上面的setState可能是异步的,必须等到setState执行完成后才去获取dom //为什么写在then里?id为backgroundBox的DOM元素是在loading为false时才有,而上面的setState可能是异步的,必须等到setState执行完成后才去获取dom
this.particle = new BGParticle('backgroundBox') this.particle = new BGParticle('backgroundBox');
this.particle.init() this.particle.init();
// notification.open({ // notification.open({
// message:<ul><li>初始账号:admin</li><li>初始密码:admin</li></ul>, // message:<ul><li>初始账号:admin</li><li>初始密码:admin</li></ul>,
// duration:0, // duration:0,
// className:'login-notification' // className:'login-notification'
// }) // })
}) });
} };
//切换showbox //切换showbox
switchShowBox = (box) => { switchShowBox = (box) => {
this.setState({ this.setState({
showBox: box showBox: box,
}) });
} };
//登录的背景图太大,等载入完后再显示,实际上是图片预加载, //登录的背景图太大,等载入完后再显示,实际上是图片预加载,
loadImageAsync (url) { loadImageAsync(url) {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
const image = new Image(); const image = new Image();
image.onload = function() { image.onload = function() {
resolve(url); resolve(url);
}; };
image.onerror = function() { image.onerror = function() {
console.log('图片载入错误') console.log('图片载入错误');
}; };
image.src = url; image.src = url;
}); });
} }
render () { render() {
const {showBox,loading} = this.state const { showBox, loading } = this.state;
return ( return (
<div className='index-div'> <div className='index-div'>
<LogoTitlte></LogoTitlte> <LogoTitlte />
<div id='login-page'> <div id='login-page'>
<div className='home-page-div'> <div className='home-page-div'>
<div>Yashen API 是一个集成了化学、生物学、计算化学、计算生物学和机器学习的数据驱动的药物发现平台,帮助药物化学家在药物智能发现领域大展身手。</div> <div>Yashen API 是一个集成了化学、生物学、计算化学、计算生物学和机器学习的数据驱动的药物发现平台,帮助药物化学家在药物智能发现领域大展身手。</div>
<div>我们的Kinase平台专注于挖掘包括药物和配体结构、蛋白质结构在内的Kinase数据,并开发计算工具来加速Kinase药物发现。</div> <div>我们的Kinase平台专注于挖掘包括药物和配体结构、蛋白质结构在内的Kinase数据,并开发计算工具来加速Kinase药物发现。</div>
<div> Yashen API is a data-driven drug discovery platform, which integrates chemistry, biology, computational chemistry, computational biology and machine learning to empower medicinal chemists to make intelligence drug discovery decisions.</div> <div>
<div>Our Kinase platform focuses on mining available Kinase knowledge including corresponding drugs and ligands structure and protein structures data, and developing computational tools to accelerate Kinase drug discovery.</div> {' '}
Yashen API is a data-driven drug discovery platform, which integrates chemistry, biology, computational chemistry, computational biology and machine learning to empower medicinal
chemists to make intelligence drug discovery decisions.
</div>
<div>
Our Kinase platform focuses on mining available Kinase knowledge including corresponding drugs and ligands structure and protein structures data, and developing computational tools to
accelerate Kinase drug discovery.
</div>
</div> </div>
{ {
<div> <div>
<div id='backgroundBox' style={styles.backgroundBox}/> <div id='backgroundBox' style={styles.backgroundBox} />
<div className='container'> <div className='container'>
<LoginForm <LoginForm className={showBox === 'login' ? 'box showBox' : 'box hiddenBox'} switchShowBox={this.switchShowBox} />
className={showBox === 'login' ? 'box showBox' : 'box hiddenBox'} <RegisterForm className={showBox === 'register' ? 'box showBox' : 'box hiddenBox'} switchShowBox={this.switchShowBox} />
switchShowBox={this.switchShowBox}/>
<RegisterForm
className={showBox === 'register' ? 'box showBox' : 'box hiddenBox'}
switchShowBox={this.switchShowBox}/>
</div> </div>
</div> </div>
} }
</div> </div>
</div> </div>
) );
} }
} }
...@@ -129,30 +130,30 @@ const styles = { ...@@ -129,30 +130,30 @@ const styles = {
height: '100vh', height: '100vh',
// backgroundImage: `url(${url})`, // backgroundImage: `url(${url})`,
backgroundSize: 'cover', backgroundSize: 'cover',
transition:'all .5s', transition: 'all .5s',
// backgroundColor: '#4FA1D9' // backgroundColor: '#4FA1D9'
}, },
focus: { focus: {
// transform: 'scale(0.7)', // transform: 'scale(0.7)',
width: '20px', width: '20px',
opacity: 1 opacity: 1,
}, },
loadingBox:{ loadingBox: {
position:'fixed', position: 'fixed',
top:'50%', top: '50%',
left:'50%', left: '50%',
transform:'translate(-50%,-50%)' transform: 'translate(-50%,-50%)',
}, },
loadingTitle:{ loadingTitle: {
position:'fixed', position: 'fixed',
top:'50%', top: '50%',
left:'50%', left: '50%',
marginLeft: -45, marginLeft: -45,
marginTop: -18, marginTop: -18,
color:'#000', color: '#000',
fontWeight:500, fontWeight: 500,
fontSize:24 fontSize: 24,
}, },
} };
export default Login export default Login;
import React, { Component } from "react"; import React, { Component } from "react";
import { Jsme } from "jsme-react"; import { Jsme } from "jsme-react";
import qs from "qs"; import qs from "qs";
import { request } from "../../utils/request"; import request from "../../utils/request";
import { Input, Button, Modal, Table, message, Pagination } from "antd"; import { Input, Button, Modal, Table, message, Pagination } from "antd";
import Molstar from "molstar-react"; import Molstar from "molstar-react";
import "./index.css"; import "./index.css";
......
...@@ -9,7 +9,7 @@ import { ...@@ -9,7 +9,7 @@ import {
Tag, Tag,
Typography, Typography,
} from "antd"; } from "antd";
import { request } from "../../../utils/request"; import request from "../../../utils/request";
import "./index.css"; import "./index.css";
import qs from "qs"; import qs from "qs";
const { Title } = Typography; const { Title } = Typography;
......
...@@ -18,7 +18,7 @@ import { ...@@ -18,7 +18,7 @@ import {
InputNumber, InputNumber,
Typography, Typography,
} from "antd"; } from "antd";
import { request } from "../../../utils/request"; import request from "../../../utils/request";
import Molstar from "molstar-react"; import Molstar from "molstar-react";
import { Jsme } from "jsme-react"; import { Jsme } from "jsme-react";
import qs from "qs"; import qs from "qs";
......
...@@ -18,7 +18,7 @@ import { ...@@ -18,7 +18,7 @@ import {
InputNumber, InputNumber,
Typography, Typography,
} from "antd"; } from "antd";
import { request } from "../../../utils/request"; import request from "../../../utils/request";
import Molstar from "molstar-react"; import Molstar from "molstar-react";
import { Jsme } from "jsme-react"; import { Jsme } from "jsme-react";
import qs from "qs"; import qs from "qs";
......
import React, { Component } from "react"; import React, { Component } from "react";
import { Jsme } from "jsme-react"; import { Jsme } from "jsme-react";
import { Card, Button, Pagination, Tabs, Spin, message, Collapse } from "antd"; import { Card, Button, Pagination, Tabs, Spin, message, Collapse } from "antd";
import { request } from "../../../utils/request"; import request from "../../../utils/request";
import qs from "qs"; import qs from "qs";
import "./index.css"; import "./index.css";
const { TabPane } = Tabs; const { TabPane } = Tabs;
......
...@@ -19,7 +19,7 @@ import { ...@@ -19,7 +19,7 @@ import {
Typography, Typography,
Pagination, Pagination,
} from "antd"; } from "antd";
import { request } from "../../../utils/request"; import request from "../../../utils/request";
import Molstar from "molstar-react"; import Molstar from "molstar-react";
import { Jsme } from "jsme-react"; import { Jsme } from "jsme-react";
import qs from "qs"; import qs from "qs";
......
...@@ -3,7 +3,7 @@ import { Form, Input, Button,Select ,Tabs,message,Radio,Checkbox,Row ,Col} from ...@@ -3,7 +3,7 @@ import { Form, Input, Button,Select ,Tabs,message,Radio,Checkbox,Row ,Col} from
import LogoTitlte from '../../components/LogoTitlte/index' import LogoTitlte from '../../components/LogoTitlte/index'
import { Jsme } from 'jsme-react' import { Jsme } from 'jsme-react'
import qs from 'qs' import qs from 'qs'
import { request } from '../../utils/request' import request from '../../utils/request'
import './style.css' import './style.css'
const { TabPane } = Tabs; const { TabPane } = Tabs;
const { Option } = Select; const { Option } = Select;
......
import axios from 'axios';
import { getQueryString } from './utils';
import { message } from 'antd';
//禁用F12功能
function disableF12() {
document.onkeydown = function() {
var e = window.event || arguments[0];
if (e.keyCode == 123) {
return false;
} else if (e.ctrlKey && e.shiftKey && e.keyCode == 73) {
return false;
}
};
//禁用鼠标右键
document.oncontextmenu = function() {
return false;
};
}
// disableF12();
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,
headers: {
// 'Content-Type': 'application/json',
// 部分接口需要formdate格式的数据 'Content-Type': 'application/x-www-form-urlencoded' qs.stringify(data)
accessToken: token,
},
});
function checkToken(config) {
// message.error('校验token');
// 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(' 失败');
// message.error('请重新登录');
console.log('token校验没通过 返回登录页');
// window.open('http://localhost:3000/#/login');
window.open('http://localhost:3000/#/login', '_self');
}
})
.catch((err) => {
localStorage.removeItem('token');
// alert(' 服务器报错');
console.log('token校验没通过 返回登录页');
window.open('http://localhost:3000/#/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);
} else {
console.log('token为空....');
window.open('http://localhost:3000/#/login');
}
});
request.interceptors.response.use(
(res) => {
return res;
},
(err) => {
if (err && err.response) {
switch (err.response.status) {
case 400:
console.log('请求错误');
break;
case 401:
console.log('未授权访问');
break;
case 404:
console.log('页面未找到');
break;
default:
console.log('其他错误信息');
}
}
return err;
}
);
export default request;
import axios from 'axios'; import axios from 'axios';
axios.defaults.timeout = 10000; import { getQueryString } from './utils';
document.onkeydown = function() { import { message } from 'antd';
//禁用F12功能
function disableF12() {
document.onkeydown = function() {
var e = window.event || arguments[0]; var e = window.event || arguments[0];
if (e.keyCode == 123) { if (e.keyCode == 123) {
return false; return false;
} else if (e.ctrlKey && e.shiftKey && e.keyCode == 73) { } else if (e.ctrlKey && e.shiftKey && e.keyCode == 73) {
return false; return false;
} }
}; };
document.oncontextmenu = function() { //禁用鼠标右键
document.oncontextmenu = function() {
return false; return false;
}; };
}
// disableF12();
var baseURL = 'http://52.83.169.190:8002/'; // const baseURL = 'http://52.83.169.190:8002/'; //线上正式环境
const baseURL = 'http://69.235.144.91:8002/'; // 测试环境
export const request = axios.create({ //对axios二次封装
baseURL: baseURL, // 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,
// headers: {
// 'Content-Type': 'application/json',
// accessToken: token,
// },
}); });
function checkToken(config) {
// message.error('校验token');
// alert('alert 校验token')
request
.get('http://69.235.144.91:8048/yszh-login/auth/checkToken')
.then((res) => {
console.log('checkToken--res', res);
if (res.data.code === 200) {
console.log('token 检验通过');
return config;
} else {
message.error('请重新登录');
console.log('token校验没通过 返回登录页');
window.open('http://localhost:3000/#/login');
// window.open('http://localhost:3000/#/login', '_self');
}
})
.catch((err) => {
console.log('token校验没通过 返回登录页');
window.open('http://localhost:3000/#/login', '_self');
console.log('err', err);
});
}
// checkToken();
//拦截器
// request.interceptors.request.use((config) => {
// console.log('token---', '拦截器方法校验token');
// if (!!token) {
// checkToken(config);
// return config;
// } else {
// console.log('token为空....');
// window.open('http://localhost:3000/#/login', '_self');
// }
// return config;
// });
// request.interceptors.response.use(
// (res) => {
// return res;
// },
// (err) => {
// if (err && err.response) {
// switch (err.response.status) {
// case 400:
// console.log('请求错误');
// break;
// case 401:
// console.log('未授权访问');
// break;
// case 404:
// console.log('页面未找到');
// break;
// default:
// console.log('其他错误信息');
// }
// }
// return err;
// }
// );
export default request;
...@@ -64,3 +64,17 @@ export function preloadingImages(arr) { ...@@ -64,3 +64,17 @@ export function preloadingImages(arr) {
img.src = item img.src = item
}) })
} }
/**
* 获取URL中指定的参数
*/
export function getQueryString(name) {
let reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
let r = window.location.hash.split('?')[1] && window.location.hash.split('?')[1].match(reg); //获取url中"?"符后的字符串并正则匹配
let context = '';
if (r != null) context = decodeURIComponent(r[2]);
reg = null;
r = null;
return context == null || context == '' || context == 'undefined' ? '' : context;
}
\ No newline at end of file
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