You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.2 KiB
51 lines
1.2 KiB
export function checkToken(vm) {
|
|
let expiresTime = vm.$store.state.user.vuex_loginInfo.expiresTime
|
|
let nowTime = new Date() * 1
|
|
// console.log('超时了')
|
|
// console.log(expiresTime)
|
|
if (nowTime > expiresTime * 1) {
|
|
vm.$store.commit('goLogin')
|
|
// 如果小于20分钟就刷新一下token &&
|
|
} else if ((expiresTime * 1 - nowTime) / 60000 <5) {
|
|
vm.$store.dispatch('refreshToken')
|
|
}
|
|
}
|
|
|
|
function dateRangeFn(dateRange) {
|
|
let tmp = []
|
|
let dateArr = []
|
|
dateRange.forEach((date) => {
|
|
let dateStr = date.toISOString().split('T')[0]
|
|
let dd = dateStr.split('-')[2]
|
|
const daysOfWeek = ['日', '一', '二', '三', '四', '五', '六'];
|
|
const dayOfWeek = date.getDay();
|
|
const weekName = daysOfWeek[dayOfWeek];
|
|
// console.log(dateStr)
|
|
// console.log(weekName)
|
|
if (tmp.length == 0) {
|
|
dateArr.push(tmp)
|
|
}
|
|
let obj = {
|
|
week: weekName,
|
|
num: dd,
|
|
date: dateStr
|
|
}
|
|
tmp.push(obj)
|
|
if (tmp.length == 5) {
|
|
tmp = []
|
|
}
|
|
});
|
|
// console.log(dateArr)
|
|
return dateArr
|
|
}
|
|
|
|
export function getDates(startDate, endDate) {
|
|
const dates = [];
|
|
let currentDate = new Date(startDate);
|
|
|
|
while (currentDate <= endDate) {
|
|
dates.push(new Date(currentDate));
|
|
currentDate.setDate(currentDate.getDate() + 1);
|
|
}
|
|
return dateRangeFn(dates)
|
|
}
|