Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
ant-design-pro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanledexianxianxian
ant-design-pro
Commits
d2de675e
Commit
d2de675e
authored
Aug 06, 2018
by
ιεΈ
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modify a few logical errors
parent
36eeb6c1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
11 deletions
+14
-11
src/utils/request.js
src/utils/request.js
+14
-11
No files found.
src/utils/request.js
View file @
d2de675e
...
@@ -61,7 +61,6 @@ const cachedSave = (response, hashcode) => {
...
@@ -61,7 +61,6 @@ const cachedSave = (response, hashcode) => {
* @return {object} An object containing either "data" or "err"
* @return {object} An object containing either "data" or "err"
*/
*/
export
default
function
request
(
url
,
options
=
{})
{
export
default
function
request
(
url
,
options
=
{})
{
console
.
log
(
url
);
/**
/**
* Produce fingerprints based on url and parameters
* Produce fingerprints based on url and parameters
* Maybe url has the same parameters
* Maybe url has the same parameters
...
@@ -96,17 +95,21 @@ export default function request(url, options = {}) {
...
@@ -96,17 +95,21 @@ export default function request(url, options = {}) {
};
};
}
}
}
}
let
cached
=
sessionStorage
.
getItem
(
hashcode
);
let
whenCached
=
sessionStorage
.
getItem
(
hashcode
+
'
:timestamp
'
);
const
expirys
=
options
.
expirys
||
60
;
const
expirys
=
options
.
expirys
||
60
;
if
(
cached
!==
null
&&
whenCached
!==
null
&&
expirys
!==
false
)
{
// options.expirys !== false, return the cache,
let
age
=
(
Date
.
now
()
-
whenCached
)
/
1000
;
if
(
options
.
expirys
!==
false
)
{
if
(
age
<
expirys
)
{
let
cached
=
sessionStorage
.
getItem
(
hashcode
);
let
response
=
new
Response
(
new
Blob
([
cached
]));
let
whenCached
=
sessionStorage
.
getItem
(
hashcode
+
'
:timestamp
'
);
return
response
.
json
();
if
(
cached
!==
null
&&
whenCached
!==
null
)
{
}
else
{
let
age
=
(
Date
.
now
()
-
whenCached
)
/
1000
;
sessionStorage
.
removeItem
(
hashcode
);
if
(
age
<
expirys
)
{
sessionStorage
.
removeItem
(
hashcode
+
'
:timestamp
'
);
let
response
=
new
Response
(
new
Blob
([
cached
]));
return
response
.
json
();
}
else
{
sessionStorage
.
removeItem
(
hashcode
);
sessionStorage
.
removeItem
(
hashcode
+
'
:timestamp
'
);
}
}
}
}
}
return
fetch
(
url
,
newOptions
)
return
fetch
(
url
,
newOptions
)
...
...
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