/* * @Author: 李佐宁 * @Description: * @Date: 2023-01-11 15:26:19 * @LastEditTime: 2023-01-13 11:17:04 * @LastEditors: 李佐宁 */ // @ts-nocheck import Cookies from 'js-cookie' type timeUnit = 'seconds' | 'hours' | 'days' export const setCookie = (name: string, value: string, time: number, timeUnit: timeUnit = 'hours' ) => { let _time = '' if (timeUnit === 'seconds') { _time = new Date(new Date() * 1 + time * 1000) } if (timeUnit === 'hours') { _time = new Date(new Date().getTime() + time * 60 * 60 * 1000); } if (timeUnit === 'days') { _time = time } const obj = { expires: _time, } console.log(self != top, 'self != topself != top'); if (self != top) { obj.SameSite = 'None' obj.Secure = true } Cookies.set(name, value, obj) } export const getCookie = (name: string) => { return Cookies.get(name) } export const removeCookie = (name: string) => { Cookies.remove(name) }