1234567891011121314151617181920212223242526272829 |
- /*
- * @Description:
- * @Author: 欧阳承珺
- * @LastEditors: 欧阳承珺
- * @Date: 2022-10-26 09:30:22
- * @LastEditTime: 2022-11-16 13:54:28
- */
- import createPersistedState from 'vuex-persistedstate'
- import * as Cookies from 'js-cookie'
- import cookie from 'cookie';
- export default ({store, req}) => {
- createPersistedState({
- storage: {
- getItem: (key) => {
- if (process.server) {
- const parsedCookies = cookie.parse(req.headers.cookie);
- return parsedCookies[key];
- } else {
- return Cookies.get(key);
- }
- },
- setItem: (key, value) => Cookies.set(key, value, { expires: 15, secure: false }),
- removeItem: key => Cookies.remove(key)
- }
- })(store);
- }
|