mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-23 07:41:53 +08:00
vue2: 移除 js-cookie ,使用 localStorage
This commit is contained in:
parent
1179ca1a8a
commit
3d1afe5271
@ -50,7 +50,6 @@
|
|||||||
"fuse.js": "6.4.3",
|
"fuse.js": "6.4.3",
|
||||||
"highlight.js": "9.18.5",
|
"highlight.js": "9.18.5",
|
||||||
"js-beautify": "1.13.0",
|
"js-beautify": "1.13.0",
|
||||||
"js-cookie": "3.0.1",
|
|
||||||
"jsencrypt": "3.0.0-rc.1",
|
"jsencrypt": "3.0.0-rc.1",
|
||||||
"nprogress": "0.2.0",
|
"nprogress": "0.2.0",
|
||||||
"quill": "1.3.7",
|
"quill": "1.3.7",
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
|
||||||
import Cookies from 'js-cookie'
|
|
||||||
|
|
||||||
import Element from 'element-ui'
|
import Element from 'element-ui'
|
||||||
import './assets/styles/element-variables.scss'
|
import './assets/styles/element-variables.scss'
|
||||||
|
|
||||||
@ -84,8 +82,8 @@ import '@/styles/index.scss'
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Vue.use(Element, {
|
Vue.use(Element, {
|
||||||
size: Cookies.get('size') || 'medium' // set element-ui default size
|
size: localStorage.getItem("size") || "medium", // set element-ui default size
|
||||||
})
|
});
|
||||||
|
|
||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false
|
||||||
|
|
||||||
|
@ -1,66 +1,66 @@
|
|||||||
import Cookies from 'js-cookie'
|
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
sidebar: {
|
sidebar: {
|
||||||
opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true,
|
opened: localStorage.getItem("sidebarStatus")
|
||||||
|
? !!+localStorage.getItem("sidebarStatus")
|
||||||
|
: true,
|
||||||
withoutAnimation: false,
|
withoutAnimation: false,
|
||||||
hide: false
|
hide: false,
|
||||||
},
|
},
|
||||||
device: 'desktop',
|
device: "desktop",
|
||||||
size: Cookies.get('size') || 'medium'
|
size: localStorage.getItem("size") || "medium",
|
||||||
}
|
};
|
||||||
|
|
||||||
const mutations = {
|
const mutations = {
|
||||||
TOGGLE_SIDEBAR: state => {
|
TOGGLE_SIDEBAR: (state) => {
|
||||||
if (state.sidebar.hide) {
|
if (state.sidebar.hide) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
state.sidebar.opened = !state.sidebar.opened
|
state.sidebar.opened = !state.sidebar.opened;
|
||||||
state.sidebar.withoutAnimation = false
|
state.sidebar.withoutAnimation = false;
|
||||||
if (state.sidebar.opened) {
|
if (state.sidebar.opened) {
|
||||||
Cookies.set('sidebarStatus', 1)
|
localStorage.setItem("sidebarStatus", 1);
|
||||||
} else {
|
} else {
|
||||||
Cookies.set('sidebarStatus', 0)
|
localStorage.setItem("sidebarStatus", 0);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
CLOSE_SIDEBAR: (state, withoutAnimation) => {
|
CLOSE_SIDEBAR: (state, withoutAnimation) => {
|
||||||
Cookies.set('sidebarStatus', 0)
|
localStorage.setItem("sidebarStatus", 0);
|
||||||
state.sidebar.opened = false
|
state.sidebar.opened = false;
|
||||||
state.sidebar.withoutAnimation = withoutAnimation
|
state.sidebar.withoutAnimation = withoutAnimation;
|
||||||
},
|
},
|
||||||
TOGGLE_DEVICE: (state, device) => {
|
TOGGLE_DEVICE: (state, device) => {
|
||||||
state.device = device
|
state.device = device;
|
||||||
},
|
},
|
||||||
SET_SIZE: (state, size) => {
|
SET_SIZE: (state, size) => {
|
||||||
state.size = size
|
state.size = size;
|
||||||
Cookies.set('size', size)
|
localStorage.setItem("size", size);
|
||||||
},
|
},
|
||||||
SET_SIDEBAR_HIDE: (state, status) => {
|
SET_SIDEBAR_HIDE: (state, status) => {
|
||||||
state.sidebar.hide = status
|
state.sidebar.hide = status;
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
|
|
||||||
const actions = {
|
const actions = {
|
||||||
toggleSideBar({ commit }) {
|
toggleSideBar({ commit }) {
|
||||||
commit('TOGGLE_SIDEBAR')
|
commit("TOGGLE_SIDEBAR");
|
||||||
},
|
},
|
||||||
closeSideBar({ commit }, { withoutAnimation }) {
|
closeSideBar({ commit }, { withoutAnimation }) {
|
||||||
commit('CLOSE_SIDEBAR', withoutAnimation)
|
commit("CLOSE_SIDEBAR", withoutAnimation);
|
||||||
},
|
},
|
||||||
toggleDevice({ commit }, device) {
|
toggleDevice({ commit }, device) {
|
||||||
commit('TOGGLE_DEVICE', device)
|
commit("TOGGLE_DEVICE", device);
|
||||||
},
|
},
|
||||||
setSize({ commit }, size) {
|
setSize({ commit }, size) {
|
||||||
commit('SET_SIZE', size)
|
commit("SET_SIZE", size);
|
||||||
},
|
},
|
||||||
toggleSideBarHide({ commit }, status) {
|
toggleSideBarHide({ commit }, status) {
|
||||||
commit('SET_SIDEBAR_HIDE', status)
|
commit("SET_SIDEBAR_HIDE", status);
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
state,
|
state,
|
||||||
mutations,
|
mutations,
|
||||||
actions
|
actions,
|
||||||
}
|
};
|
||||||
|
@ -106,7 +106,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import {getCodeImg, sendSmsCode, socialAuthRedirect} from "@/api/login";
|
import {getCodeImg, sendSmsCode, socialAuthRedirect} from "@/api/login";
|
||||||
import {getTenantIdByName} from "@/api/system/tenant";
|
import {getTenantIdByName} from "@/api/system/tenant";
|
||||||
import Cookies from "js-cookie";
|
|
||||||
import {SystemUserSocialTypeEnum} from "@/utils/constants";
|
import {SystemUserSocialTypeEnum} from "@/utils/constants";
|
||||||
import {getTenantEnable} from "@/utils/ruoyi";
|
import {getTenantEnable} from "@/utils/ruoyi";
|
||||||
import {
|
import {
|
||||||
@ -152,7 +151,7 @@ export default {
|
|||||||
{required: true, trigger: "blur", message: "手机号不能为空"},
|
{required: true, trigger: "blur", message: "手机号不能为空"},
|
||||||
{
|
{
|
||||||
validator: function (rule, value, callback) {
|
validator: function (rule, value, callback) {
|
||||||
if (/^1[0-9]\d{9}$/.test(value) == false) {
|
if (/^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[189]))\d{8}$/.test(value) == false) {
|
||||||
callback(new Error("手机号格式错误"));
|
callback(new Error("手机号格式错误"));
|
||||||
} else {
|
} else {
|
||||||
callback();
|
callback();
|
||||||
|
@ -63,8 +63,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Cookies from "js-cookie";
|
|
||||||
import { encrypt, decrypt } from '@/utils/jsencrypt'
|
|
||||||
import {
|
import {
|
||||||
getPassword, getRememberMe,
|
getPassword, getRememberMe,
|
||||||
getUsername,
|
getUsername,
|
||||||
|
Loading…
Reference in New Issue
Block a user