util.cookies.js 727 字节
Newer Older
yma16's avatar
yma16 已提交
1 2 3
import JsCookie from 'js-cookie'

/**
4
 *
yma16's avatar
yma16 已提交
5 6 7 8
 * @param {String} name 名称
 * @param {*} value 值
 * @param {Object} cookieSetting 配置
 */
9
export function setCookie (name = 'default', value, cookieSetting) {
yma16's avatar
yma16 已提交
10 11 12 13 14 15 16
    const currentCookieSetting = {
        expires: 1
    }
    Object.assign(currentCookieSetting, cookieSetting)
    JsCookie.set(`VBI-${name}`, value, currentCookieSetting)
}
/**
17 18
 *
 * @param {String} name
yma16's avatar
yma16 已提交
19 20
 */

21
export function getCookie (name = 'default') {
yma16's avatar
yma16 已提交
22 23 24 25 26
    return JsCookie.get(`VBI-${name}`)
}
/**
 * 获取全部cookie
 */
27
export function getCookieAll () {
yma16's avatar
yma16 已提交
28 29 30
    return JsCookie.get()
}
/**
31
 *
yma16's avatar
yma16 已提交
32 33
 * @param {String} name 名称
 */
34
export function removeCookie (name) {
yma16's avatar
yma16 已提交
35
    return JsCookie.remove(`VBI-${name}`)
36
}