import cache from '@/utils/cache'

/**
 * @description 是否是新一天
 * @param {Number} value 是否开启
 * @param {String} key 存储的key
 * @return {Boolean}
 */
export const isNewDay = (value: number | boolean, key: string) => {
    const lastVisitTime = cache.get(key)
    const currentTime = new Date().toDateString()
    const isNewDay = !lastVisitTime || lastVisitTime !== currentTime
    if (isNewDay && value) {
        cache.set(key, currentTime)
    }
    return isNewDay
}