Commit 8ad873b9 authored by Sixiang_Zzb's avatar Sixiang_Zzb

修复记住密码存储时间bug

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