Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄庭坚
jinfa-platform
Commits
2344b126
Commit
2344b126
authored
May 20, 2021
by
前端-许佳敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 文件丢失补充
parent
7304bac5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
0 deletions
+84
-0
keepAlive.ts
src/components/NiceForm/utils/keepAlive.ts
+46
-0
session.ts
src/components/NiceForm/utils/session.ts
+38
-0
No files found.
src/components/NiceForm/utils/keepAlive.ts
0 → 100644
View file @
2344b126
import
{
get
,
set
,
remove
}
from
'./session'
;
const
STATE_KEY
=
'currentState'
;
export
interface
currentStateType
{
pathname
:
string
;
current
:
number
;
pageSize
:
number
;
queryParams
:
any
;
}
/**
* 保存表格状态
* @param current
* @param pageSize
*/
export
const
saveCurrentState
=
(
current
:
number
,
pageSize
:
number
,
queryParams
?:
any
,
)
=>
{
let
currentPage
=
get
(
STATE_KEY
);
set
(
STATE_KEY
,
Object
.
assign
(
currentPage
?
currentPage
:
{},
{
pathname
:
window
.
location
.
pathname
,
current
,
pageSize
,
queryParams
,
}),
);
};
/**
* 获取表格状态数据
*/
export
const
getCurrentState
=
()
=>
{
return
get
(
STATE_KEY
);
};
/**
* 清除表格状态数据
*/
export
const
clearCurrentState
=
()
=>
{
return
remove
(
STATE_KEY
);
};
src/components/NiceForm/utils/session.ts
0 → 100644
View file @
2344b126
export
const
get
=
key
=>
{
let
result
;
result
=
sessionStorage
.
getItem
(
key
);
if
(
result
)
{
if
(
isJSON
(
result
))
{
result
=
JSON
.
parse
(
result
);
}
return
result
;
}
return
undefined
;
};
export
const
set
=
(
key
,
value
)
=>
{
if
(
typeof
value
===
'object'
)
{
value
=
JSON
.
stringify
(
value
);
}
sessionStorage
.
setItem
(
key
,
value
);
};
export
const
remove
=
key
=>
{
sessionStorage
.
removeItem
(
key
);
};
const
isJSON
=
str
=>
{
if
(
typeof
str
===
'string'
)
{
try
{
var
obj
=
JSON
.
parse
(
str
);
if
(
typeof
obj
===
'object'
&&
obj
)
{
return
true
;
}
else
{
return
false
;
}
}
catch
(
e
)
{
return
false
;
}
}
};
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