Commit 8ad873b9 authored by Sixiang_Zzb's avatar Sixiang_Zzb

修复记住密码存储时间bug

parent a329cf87
...@@ -48,17 +48,17 @@ export const getCookie = (key: string) => { ...@@ -48,17 +48,17 @@ export const getCookie = (key: string) => {
return ''; return '';
}; };
/**
* @param key 名字
* @param value 值
* @param time 存储时间
*/
export const setCookie = (key: string, value: string, time?: number) => { export const setCookie = (key: string, value: string, time?: number) => {
let expires: string; const d = new Date();
// 是否传入缓存时间 // cookie 设置时间,防止刷新就丢失
if (time) { d.setTime(d.getTime() + (time || 1) * 24 * 60 * 60 * 1000);
expires = "expores=" + time; let expires = 'expires=' + d.toUTCString();
} else {
// cookie 设置时间,防止刷新就丢失
var d = new Date();
d.setTime(d.getTime() + 1 * 24 * 60 * 60 * 1000);
expires = 'expires=' + d.toUTCString();
}
document.cookie = key + '=' + value + '; ' + expires + ';path=/'; document.cookie = key + '=' + value + '; ' + expires + ';path=/';
}; };
......
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