You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
966 B

3 years ago
import Cookies from "js-cookie";
import Setting from "@/setting";
3 years ago
const cookies = {};
/**
* @description 存储 cookie
* @param {String} name cookie name
* @param {String} value cookie value
* @param {Object} cookieSetting cookie setting
*/
3 years ago
cookies.set = function(name = "default", value = "", cookieSetting = {}) {
3 years ago
let currentCookieSetting = {
expires: Setting.cookiesExpires
};
Object.assign(currentCookieSetting, cookieSetting);
Cookies.set(name, value, currentCookieSetting);
3 years ago
};
/**
* @description 拿到 cookie
* @param {String} name cookie name
*/
3 years ago
cookies.get = function(name = "default") {
return Cookies.get(name);
3 years ago
};
/**
* @description 拿到 cookie 全部的值
*/
3 years ago
cookies.getAll = function() {
3 years ago
return Cookies.get();
};
/**
* @description 删除 cookie
* @param {String} name cookie name
*/
3 years ago
cookies.remove = function(name = "default") {
return Cookies.remove(name);
3 years ago
};
export default cookies;