mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2025-12-18 17:05:54 +08:00
commit message
This commit is contained in:
30
buyer/src/plugins/storage.js
Normal file
30
buyer/src/plugins/storage.js
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Created by Andste on 2018/5/3.
|
||||
*/
|
||||
|
||||
import Cookies from 'js-cookie';
|
||||
const psl = require('psl');
|
||||
|
||||
export default {
|
||||
setItem: (key, value, options = {}) => {
|
||||
if (process.client) {
|
||||
const p_psl = psl.parse(document.domain);
|
||||
let domain = p_psl.domain;
|
||||
if (/\d+\.\d+\.\d+\.\d+/.test(p_psl.input)) domain = p_psl.input;
|
||||
options = { domain, ...options };
|
||||
}
|
||||
Cookies.set(key, value, options);
|
||||
},
|
||||
getItem: (key) => {
|
||||
return Cookies.get(key);
|
||||
},
|
||||
removeItem: (key, options = {}) => {
|
||||
if (process.client) {
|
||||
const p_psl = psl.parse(document.domain);
|
||||
let domain = p_psl.domain;
|
||||
if (/\d+\.\d+\.\d+\.\d+/.test(p_psl.input)) domain = p_psl.input;
|
||||
options = { domain, ...options };
|
||||
}
|
||||
Cookies.remove(key, options);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user