import Cookies from 'js-cookie'

// 设置 cookie
const setCookie = (key: string, value: any, options?: Cookies.CookieAttributes): void => {
  Cookies.set(key, value, options)
}

// 获取 cookie
const getCookie = (key: string): string | undefined => {
  return Cookies.get(key)
}

// 删除 cookie
const removeCookie = (key: string): void => {
  Cookies.remove(key)
}

// 删除所有 cookie
const removeAllCookies = (): void => {
  Object.keys(Cookies.get()).forEach(cookieName => {
    Cookies.remove(cookieName)
  })
}

export {
  setCookie,
  getCookie, 
  removeCookie,
  removeAllCookies
}

// 使用示例:
/*
// 设置 cookie
setCookie('token', 'abc123', { expires: 7 }) // 7天过期

// 获取 cookie
const token = getCookie('token')

// 删除单个 cookie 
removeCookie('token')

// 删除所有 cookie
removeAllCookies()
*/

