Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pdbSmallMolecules
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
pdbSmallMolecules
Commits
3db5f72c
Commit
3db5f72c
authored
Feb 27, 2023
by
wangshufen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改readme文件
parent
e5b7554b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
30 deletions
+30
-30
README.md
+9
-0
src/utils/request.js
+21
-30
No files found.
README.md
View file @
3db5f72c
启动 yarn start
打包 yarn build
测试服务器路径: /data/enable/CommonService/
北京服务器路径: /home/WebSite/CommonService/
其他的没做修改
\ No newline at end of file
src/utils/request.js
View file @
3db5f72c
...
...
@@ -28,42 +28,33 @@ const request = axios.create({
},
});
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
;
}
}
check
Fetch
Token
();
check
Ajax
Token
();
//拦截器
request
.
interceptors
.
request
.
use
((
config
)
=>
{
// alert('拦截器..');
console
.
log
(
'token---'
,
'拦截器方法校验token'
);
console
.
log
(
config
);
if
(
localStorage
.
getItem
(
'token'
))
{
config
.
headers
[
'accessToken'
]
=
localStorage
.
getItem
(
'token'
);
console
.
log
(
'config'
,
config
);
if
(
checkAjaxToken
())
{
return
config
;
}
else
{
console
.
log
(
'token
为空.
...'
);
console
.
log
(
'token
校验失败
...'
);
window
.
open
(
'http://ysplatform.atelligence-ai.com/#/login'
,
'_self'
);
}
});
...
...
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