util.cookies.js 727 字节
Newer Older
yma16's avatar
yma16 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
import JsCookie from 'js-cookie'

/**
 * 
 * @param {String} name 名称
 * @param {*} value 值
 * @param {Object} cookieSetting 配置
 */
export function setCookie(name = 'default', value, cookieSetting) {
    const currentCookieSetting = {
        expires: 1
    }
    Object.assign(currentCookieSetting, cookieSetting)
    JsCookie.set(`VBI-${name}`, value, currentCookieSetting)
}
/**
 * 
 * @param {String} name 
 */


export function getCookie(name = 'default') {
    return JsCookie.get(`VBI-${name}`)
}
/**
 * 获取全部cookie
 */
export function getCookieAll() {
    return JsCookie.get()
}
/**
 * 
 * @param {String} name 名称
 */
export function removeCookie(name) {
    return JsCookie.remove(`VBI-${name}`)
}