Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
elegantDeepGPCR
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangshufen
elegantDeepGPCR
Commits
cfebc75e
Commit
cfebc75e
authored
Feb 28, 2023
by
wangshufen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加readme.md文件
parent
6ff31608
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
37 deletions
+41
-37
README.md
+12
-0
src/utils/request.js
+29
-37
No files found.
README.md
View file @
cfebc75e
项目启动:
1.
yarn
2.
yarn start
项目打包上线
yarn build
项目待优化:
1.
webpack打包后 文件太大 可做适当的压缩,分包处理(所有前端项目都有的问题)
2.
2.F:
\w
ork
\需
求文档
\小
分子平台前端需求2023.02.10.docx 文档里优化调整的地方,GPCR项目还没改,参照kinase修改
\ No newline at end of file
src/utils/request.js
View file @
cfebc75e
...
...
@@ -4,52 +4,44 @@ import { getQueryString } from './utils';
const
token
=
getQueryString
(
'token'
)
||
localStorage
.
getItem
(
'token'
);
const
request
=
axios
.
create
({
baseURL
:
'http://52.83.169.190:8005/'
,
baseURL
:
'http://69.235.144.91:8005/'
,
//测试服务器
// baseURL: 'http://52.83.169.190:8005/',//正式服务器
timeout
:
15000
,
headers
:
{
accessToken
:
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://ysplatform.atelligence-ai.com/#/login'
,
'_self'
);
}
})
.
catch
(
function
(
err
)
{
console
.
log
(
'err'
,
err
);
window
.
open
(
'http://ysplatform.atelligence-ai.com/#/login'
,
'_self'
);
});
// 封装同步Ajax请求
function
checkAjaxToken
()
{
const
token
=
getQueryString
(
'token'
)
||
localStorage
.
getItem
(
'token'
);
let
xhr
=
new
XMLHttpRequest
();
xhr
.
open
(
'GET'
,
'http://69.235.144.91:8048/yszh-login/auth/checkToken'
,
false
);
xhr
.
setRequestHeader
(
'accessToken'
,
token
);
xhr
.
send
(
null
);
console
.
log
(
xhr
);
//准备状态
if
(
xhr
.
status
==
200
&&
JSON
.
parse
(
xhr
.
responseText
).
code
==
200
)
{
// 获取响应结果
// console.log(xhr.responseText);
token
&&
localStorage
.
setItem
(
'token'
,
token
);
return
true
;
}
else
{
console
.
log
(
'状态码:'
+
xhr
.
status
+
',原因:'
+
xhr
.
responseText
);
return
false
;
}
}
checkFetch
Token
();
// checkAjax
Token();
//拦截器
request
.
interceptors
.
request
.
use
((
config
)
=>
{
// alert('拦截器..');
console
.
log
(
'token---'
,
'拦截器方法校验token'
);
console
.
log
(
config
);
if
(
localStorage
.
getItem
(
'token'
))
{
config
.
headers
[
'accessToken'
]
=
localStorage
.
getItem
(
'token'
);
return
config
;
}
else
{
console
.
log
(
'token为空....'
);
window
.
open
(
'http://ysplatform.atelligence-ai.com/#/login'
,
'_self'
);
}
});
// request.interceptors.request.use((config) => {
// console.log('config',config);
// if (checkAjaxToken()) {
// return config;
// } else {
// console.log('token校验失败...');
// window.open('http://ysplatform.atelligence-ai.com/#/login', '_self');
// }
// });
request
.
interceptors
.
response
.
use
(
(
res
)
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment