util拆分
Former-commit-id: 822c86f85a1268c28513cf97b7107dd697eb6d43 [formerly 822c86f85a1268c28513cf97b7107dd697eb6d43 [formerly 822c86f85a1268c28513cf97b7107dd697eb6d43 [formerly 822c86f85a1268c28513cf97b7107dd697eb6d43 [formerly 68c12439e9dd03521d919105efcbc06cb6da2126 [formerly 1d5c6a4b53da991761dd4a9399eefb27e70e96ca]]]]] Former-commit-id: fbe49d601541d01db7f4c36658c71a6e3b014733 Former-commit-id: e2e4e2958c7f63990339e1d06b4b3aaf463dab31 Former-commit-id: 20c693d8bcc308b276d15d7cbc7288c74c709dbf [formerly fc2f99d56d410c349d5bff5e42176a6fc97325da] Former-commit-id: 004230c8e00651d1793fd4ee68bb34299d4049f5 Former-commit-id: 94a29c7f87d6d3b6f200d9bdc9033fb25641cf3f Former-commit-id: b5d93d8b5c1b5e85b62c01ca815c87dc943a694f Former-commit-id: d787061bbfae4ea01a3aabf6f92cd1620377b572 Former-commit-id: 2fc8371e6d340382cca7539a5dc1aa09881fecb2
This commit is contained in:
43
src/libs/util.cookies.js
Normal file
43
src/libs/util.cookies.js
Normal file
@@ -0,0 +1,43 @@
|
||||
import Cookies from 'js-cookie'
|
||||
import { version } from '../../package.json'
|
||||
|
||||
const cookies = {}
|
||||
|
||||
/**
|
||||
* @description 存储 cookie 值
|
||||
* @param {String} name cookie name
|
||||
* @param {String} value cookie value
|
||||
* @param {Object} setting cookie setting
|
||||
*/
|
||||
cookies.set = function (name = 'default', value = '', setting = {}) {
|
||||
let cookieSetting = {
|
||||
expires: 1
|
||||
}
|
||||
Object.assign(cookieSetting, setting)
|
||||
Cookies.set(`d2admin-${version}-${name}`, value, cookieSetting)
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 拿到 cookie 值
|
||||
* @param {String} name cookie name
|
||||
*/
|
||||
cookies.get = function (name = 'default') {
|
||||
return Cookies.get(`d2admin-${version}-${name}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 拿到 cookie 全部的值
|
||||
*/
|
||||
cookies.getAll = function () {
|
||||
return Cookies.get()
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 删除 cookie
|
||||
* @param {String} name cookie name
|
||||
*/
|
||||
cookies.remove = function (name = 'default') {
|
||||
return Cookies.remove(`d2admin-${version}-${name}`)
|
||||
}
|
||||
|
||||
export default cookies
|
||||
Reference in New Issue
Block a user