Skip to content

Commit 74eb493

Browse files
committed
vue2: 移除 js-cookie ,使用 localStorage
1 parent fb6374e commit 74eb493

File tree

5 files changed

+33
-39
lines changed

5 files changed

+33
-39
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
"fuse.js": "6.4.3",
5151
"highlight.js": "9.18.5",
5252
"js-beautify": "1.13.0",
53-
"js-cookie": "3.0.1",
5453
"jsencrypt": "3.0.0-rc.1",
5554
"nprogress": "0.2.0",
5655
"quill": "1.3.7",

src/main.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import Vue from 'vue'
22

3-
import Cookies from 'js-cookie'
4-
53
import Element from 'element-ui'
64
import './assets/styles/element-variables.scss'
75

@@ -84,8 +82,8 @@ import '@/styles/index.scss'
8482
*/
8583

8684
Vue.use(Element, {
87-
size: Cookies.get('size') || 'medium' // set element-ui default size
88-
})
85+
size: localStorage.getItem("size") || "medium", // set element-ui default size
86+
});
8987

9088
Vue.config.productionTip = false
9189

src/store/modules/app.js

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,66 @@
1-
import Cookies from 'js-cookie'
2-
31
const state = {
42
sidebar: {
5-
opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true,
3+
opened: localStorage.getItem("sidebarStatus")
4+
? !!+localStorage.getItem("sidebarStatus")
5+
: true,
66
withoutAnimation: false,
7-
hide: false
7+
hide: false,
88
},
9-
device: 'desktop',
10-
size: Cookies.get('size') || 'medium'
11-
}
9+
device: "desktop",
10+
size: localStorage.getItem("size") || "medium",
11+
};
1212

1313
const mutations = {
14-
TOGGLE_SIDEBAR: state => {
14+
TOGGLE_SIDEBAR: (state) => {
1515
if (state.sidebar.hide) {
1616
return false;
1717
}
18-
state.sidebar.opened = !state.sidebar.opened
19-
state.sidebar.withoutAnimation = false
18+
state.sidebar.opened = !state.sidebar.opened;
19+
state.sidebar.withoutAnimation = false;
2020
if (state.sidebar.opened) {
21-
Cookies.set('sidebarStatus', 1)
21+
localStorage.setItem("sidebarStatus", 1);
2222
} else {
23-
Cookies.set('sidebarStatus', 0)
23+
localStorage.setItem("sidebarStatus", 0);
2424
}
2525
},
2626
CLOSE_SIDEBAR: (state, withoutAnimation) => {
27-
Cookies.set('sidebarStatus', 0)
28-
state.sidebar.opened = false
29-
state.sidebar.withoutAnimation = withoutAnimation
27+
localStorage.setItem("sidebarStatus", 0);
28+
state.sidebar.opened = false;
29+
state.sidebar.withoutAnimation = withoutAnimation;
3030
},
3131
TOGGLE_DEVICE: (state, device) => {
32-
state.device = device
32+
state.device = device;
3333
},
3434
SET_SIZE: (state, size) => {
35-
state.size = size
36-
Cookies.set('size', size)
35+
state.size = size;
36+
localStorage.setItem("size", size);
3737
},
3838
SET_SIDEBAR_HIDE: (state, status) => {
39-
state.sidebar.hide = status
40-
}
41-
}
39+
state.sidebar.hide = status;
40+
},
41+
};
4242

4343
const actions = {
4444
toggleSideBar({ commit }) {
45-
commit('TOGGLE_SIDEBAR')
45+
commit("TOGGLE_SIDEBAR");
4646
},
4747
closeSideBar({ commit }, { withoutAnimation }) {
48-
commit('CLOSE_SIDEBAR', withoutAnimation)
48+
commit("CLOSE_SIDEBAR", withoutAnimation);
4949
},
5050
toggleDevice({ commit }, device) {
51-
commit('TOGGLE_DEVICE', device)
51+
commit("TOGGLE_DEVICE", device);
5252
},
5353
setSize({ commit }, size) {
54-
commit('SET_SIZE', size)
54+
commit("SET_SIZE", size);
5555
},
5656
toggleSideBarHide({ commit }, status) {
57-
commit('SET_SIDEBAR_HIDE', status)
58-
}
59-
}
57+
commit("SET_SIDEBAR_HIDE", status);
58+
},
59+
};
6060

6161
export default {
6262
namespaced: true,
6363
state,
6464
mutations,
65-
actions
66-
}
65+
actions,
66+
};

src/views/login.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@
106106
<script>
107107
import {getCodeImg, sendSmsCode, socialAuthRedirect} from "@/api/login";
108108
import {getTenantIdByName} from "@/api/system/tenant";
109-
import Cookies from "js-cookie";
110109
import {SystemUserSocialTypeEnum} from "@/utils/constants";
111110
import {getTenantEnable} from "@/utils/ruoyi";
112111
import {
@@ -152,7 +151,7 @@ export default {
152151
{required: true, trigger: "blur", message: "手机号不能为空"},
153152
{
154153
validator: function (rule, value, callback) {
155-
if (/^1[0-9]\d{9}$/.test(value) == false) {
154+
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) {
156155
callback(new Error("手机号格式错误"));
157156
} else {
158157
callback();

src/views/socialLogin.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@
6363
</template>
6464

6565
<script>
66-
import Cookies from "js-cookie";
67-
import { encrypt, decrypt } from '@/utils/jsencrypt'
6866
import {
6967
getPassword, getRememberMe,
7068
getUsername,

0 commit comments

Comments
 (0)