mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-12 04:16:47 +08:00
feat:增加删除的获取cookie
This commit is contained in:
@@ -231,6 +231,37 @@ function changeOwnership(classify, selectProjectId, selectPeopleArr) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//name 字段名 value 字段值 perpetual 有效期
|
||||||
|
const setCookie = (name, value, perpetual) => {
|
||||||
|
console.log('存储token到cookie')
|
||||||
|
let exdate = new Date()
|
||||||
|
exdate.setDate(perpetual * 24 * 60 * 60 * 1000) //exdate.setDate(exdate.getDate() + 365)
|
||||||
|
document.cookie = name + '=' + value + ';expires=' + exdate.toGMTString()
|
||||||
|
//永久有效
|
||||||
|
//document.cookie = name + '=' + value + ';expires=' + 'Fri, 31 Dec 9999 23:59:59 GMT'
|
||||||
|
}
|
||||||
|
//获取cookie数据
|
||||||
|
//先写一个方法
|
||||||
|
function getCookie(name) {
|
||||||
|
//1.获取cookie字符串
|
||||||
|
var cookies = document.cookie;
|
||||||
|
//通过;来分割字符串
|
||||||
|
var cookie = cookies.split("; ");
|
||||||
|
// console.log('cookie', cookie)
|
||||||
|
//遍历,使键值对匹配上
|
||||||
|
for (var i = 0; i < cookie.length; i++) {
|
||||||
|
var arr = cookie[i].split("token=");
|
||||||
|
// console.log('arr', arr)
|
||||||
|
console.log('name', name)
|
||||||
|
// if (arr[0] == name) {
|
||||||
|
// console.log('arr[1]', arr[1])
|
||||||
|
// return arr[1];
|
||||||
|
// }
|
||||||
|
// console.log('arr[1]', arr[1])
|
||||||
|
return arr[1]
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
//新建延迟
|
//新建延迟
|
||||||
const commonData = {
|
const commonData = {
|
||||||
@@ -254,7 +285,8 @@ export {
|
|||||||
getWeek,
|
getWeek,
|
||||||
autoComma,
|
autoComma,
|
||||||
formatNumber,
|
formatNumber,
|
||||||
|
setCookie,
|
||||||
|
getCookie,
|
||||||
scrollLoad,
|
scrollLoad,
|
||||||
changeOwnership,
|
changeOwnership,
|
||||||
commonData,
|
commonData,
|
||||||
|
|||||||
Reference in New Issue
Block a user