Commit 22abed05 authored by 前端-许佳敏's avatar 前端-许佳敏

feat: cookie方法

parent 5b575715
......@@ -153,7 +153,7 @@ const config: any = {
theme,
devServer: {
https: true,
https: false,
}
};
......
......@@ -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)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment