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
linweijiong
jinfa-platform
Commits
22abed05
Commit
22abed05
authored
Jun 22, 2021
by
前端-许佳敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: cookie方法
parent
5b575715
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
5 deletions
+3
-5
config.ts
config/config.ts
+1
-1
cookie.ts
src/utils/cookie.ts
+2
-4
No files found.
config/config.ts
View file @
22abed05
...
...
@@ -153,7 +153,7 @@ const config: any = {
theme
,
devServer
:
{
https
:
tru
e
,
https
:
fals
e
,
}
};
...
...
src/utils/cookie.ts
View file @
22abed05
...
...
@@ -3,8 +3,7 @@ import { Base64 } from './cryptoAes'
export
const
setCookie
=
(
key
:
string
,
value
:
string
,
options
:
CookieAttributes
=
{})
=>
{
if
(
typeof
value
===
'string'
)
{
// set(key, Base64.encode(value), options)
set
(
key
,
value
,
options
)
set
(
key
,
Base64
.
encode
(
value
),
options
)
}
else
{
throw
new
Error
(
'value只能是字符串类型'
)
}
...
...
@@ -14,8 +13,7 @@ export const getCookie = (key: string, type: 'json' | 'string' = 'json'): Object
if
(
get
(
key
))
{
switch
(
type
)
{
case
'json'
:
// return JSON.parse(Base64.decode(get(key)))
return
JSON
.
parse
(
get
(
key
)
||
''
)
return
JSON
.
parse
(
Base64
.
decode
(
get
(
key
)))
default
:
return
get
(
key
)
}
...
...
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