Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
KnowledgeMap
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
KnowledgeMap
Commits
5ccd0da8
Commit
5ccd0da8
authored
Feb 27, 2023
by
wangshufen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加readme 文件
parent
c2d68ca1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
33 deletions
+31
-33
README.md
+7
-0
src/utils/request.js
+24
-33
No files found.
README.md
View file @
5ccd0da8
知识图谱
只修改了request.js文件 其他的未做修改
待优化:
1.
参照elegantDeepKinase项目,在根目录添加 .eslintrc.js jsconfig.json, 项目启动时消除eslint警告
\ No newline at end of file
src/utils/request.js
View file @
5ccd0da8
...
...
@@ -28,45 +28,36 @@ 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
// 封装同步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
{
alert
(
'token校验失败,返回登录页'
);
// window.open('http://localhost:3000/#/login', '_self');
window
.
open
(
'http://ysplatform.atelligence-ai.com/#/login'
,
'_self'
);
console
.
log
(
'状态码:'
+
xhr
.
status
+
',原因:'
+
xhr
.
responseText
);
return
false
;
}
})
.
catch
(
function
(
err
)
{
console
.
log
(
'err'
,
err
);
window
.
open
(
'http://ysplatform.atelligence-ai.com/#/login'
,
'_self'
);
});
}
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