Commit 3d1afe5271cd70b48ba56b8dde5b215d70f30870

Authored by xingyu
1 parent 1179ca1a

vue2: 移除 js-cookie ,使用 localStorage

yudao-ui-admin/package.json
@@ -50,7 +50,6 @@ @@ -50,7 +50,6 @@
50 "fuse.js": "6.4.3", 50 "fuse.js": "6.4.3",
51 "highlight.js": "9.18.5", 51 "highlight.js": "9.18.5",
52 "js-beautify": "1.13.0", 52 "js-beautify": "1.13.0",
53 - "js-cookie": "3.0.1",  
54 "jsencrypt": "3.0.0-rc.1", 53 "jsencrypt": "3.0.0-rc.1",
55 "nprogress": "0.2.0", 54 "nprogress": "0.2.0",
56 "quill": "1.3.7", 55 "quill": "1.3.7",
yudao-ui-admin/src/main.js
1 import Vue from 'vue' 1 import Vue from 'vue'
2 2
3 -import Cookies from 'js-cookie'  
4 -  
5 import Element from 'element-ui' 3 import Element from 'element-ui'
6 import './assets/styles/element-variables.scss' 4 import './assets/styles/element-variables.scss'
7 5
@@ -84,8 +82,8 @@ import '@/styles/index.scss' @@ -84,8 +82,8 @@ import '@/styles/index.scss'
84 */ 82 */
85 83
86 Vue.use(Element, { 84 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 +});
89 87
90 Vue.config.productionTip = false 88 Vue.config.productionTip = false
91 89
yudao-ui-admin/src/store/modules/app.js
1 -import Cookies from 'js-cookie'  
2 -  
3 const state = { 1 const state = {
4 sidebar: { 2 sidebar: {
5 - opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true, 3 + opened: localStorage.getItem("sidebarStatus")
  4 + ? !!+localStorage.getItem("sidebarStatus")
  5 + : true,
6 withoutAnimation: false, 6 withoutAnimation: false,
7 - hide: false 7 + hide: false,
8 }, 8 },
9 - device: 'desktop',  
10 - size: Cookies.get('size') || 'medium'  
11 -} 9 + device: "desktop",
  10 + size: localStorage.getItem("size") || "medium",
  11 +};
12 12
13 const mutations = { 13 const mutations = {
14 - TOGGLE_SIDEBAR: state => { 14 + TOGGLE_SIDEBAR: (state) => {
15 if (state.sidebar.hide) { 15 if (state.sidebar.hide) {
16 return false; 16 return false;
17 } 17 }
18 - state.sidebar.opened = !state.sidebar.opened  
19 - state.sidebar.withoutAnimation = false 18 + state.sidebar.opened = !state.sidebar.opened;
  19 + state.sidebar.withoutAnimation = false;
20 if (state.sidebar.opened) { 20 if (state.sidebar.opened) {
21 - Cookies.set('sidebarStatus', 1) 21 + localStorage.setItem("sidebarStatus", 1);
22 } else { 22 } else {
23 - Cookies.set('sidebarStatus', 0) 23 + localStorage.setItem("sidebarStatus", 0);
24 } 24 }
25 }, 25 },
26 CLOSE_SIDEBAR: (state, withoutAnimation) => { 26 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;
30 }, 30 },
31 TOGGLE_DEVICE: (state, device) => { 31 TOGGLE_DEVICE: (state, device) => {
32 - state.device = device 32 + state.device = device;
33 }, 33 },
34 SET_SIZE: (state, size) => { 34 SET_SIZE: (state, size) => {
35 - state.size = size  
36 - Cookies.set('size', size) 35 + state.size = size;
  36 + localStorage.setItem("size", size);
37 }, 37 },
38 SET_SIDEBAR_HIDE: (state, status) => { 38 SET_SIDEBAR_HIDE: (state, status) => {
39 - state.sidebar.hide = status  
40 - }  
41 -} 39 + state.sidebar.hide = status;
  40 + },
  41 +};
42 42
43 const actions = { 43 const actions = {
44 toggleSideBar({ commit }) { 44 toggleSideBar({ commit }) {
45 - commit('TOGGLE_SIDEBAR') 45 + commit("TOGGLE_SIDEBAR");
46 }, 46 },
47 closeSideBar({ commit }, { withoutAnimation }) { 47 closeSideBar({ commit }, { withoutAnimation }) {
48 - commit('CLOSE_SIDEBAR', withoutAnimation) 48 + commit("CLOSE_SIDEBAR", withoutAnimation);
49 }, 49 },
50 toggleDevice({ commit }, device) { 50 toggleDevice({ commit }, device) {
51 - commit('TOGGLE_DEVICE', device) 51 + commit("TOGGLE_DEVICE", device);
52 }, 52 },
53 setSize({ commit }, size) { 53 setSize({ commit }, size) {
54 - commit('SET_SIZE', size) 54 + commit("SET_SIZE", size);
55 }, 55 },
56 toggleSideBarHide({ commit }, status) { 56 toggleSideBarHide({ commit }, status) {
57 - commit('SET_SIDEBAR_HIDE', status)  
58 - }  
59 -} 57 + commit("SET_SIDEBAR_HIDE", status);
  58 + },
  59 +};
60 60
61 export default { 61 export default {
62 namespaced: true, 62 namespaced: true,
63 state, 63 state,
64 mutations, 64 mutations,
65 - actions  
66 -} 65 + actions,
  66 +};
yudao-ui-admin/src/views/login.vue
@@ -106,7 +106,6 @@ @@ -106,7 +106,6 @@
106 <script> 106 <script>
107 import {getCodeImg, sendSmsCode, socialAuthRedirect} from "@/api/login"; 107 import {getCodeImg, sendSmsCode, socialAuthRedirect} from "@/api/login";
108 import {getTenantIdByName} from "@/api/system/tenant"; 108 import {getTenantIdByName} from "@/api/system/tenant";
109 -import Cookies from "js-cookie";  
110 import {SystemUserSocialTypeEnum} from "@/utils/constants"; 109 import {SystemUserSocialTypeEnum} from "@/utils/constants";
111 import {getTenantEnable} from "@/utils/ruoyi"; 110 import {getTenantEnable} from "@/utils/ruoyi";
112 import { 111 import {
@@ -152,7 +151,7 @@ export default { @@ -152,7 +151,7 @@ export default {
152 {required: true, trigger: "blur", message: "手机号不能为空"}, 151 {required: true, trigger: "blur", message: "手机号不能为空"},
153 { 152 {
154 validator: function (rule, value, callback) { 153 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) {
156 callback(new Error("手机号格式错误")); 155 callback(new Error("手机号格式错误"));
157 } else { 156 } else {
158 callback(); 157 callback();
yudao-ui-admin/src/views/socialLogin.vue
@@ -63,8 +63,6 @@ @@ -63,8 +63,6 @@
63 </template> 63 </template>
64 64
65 <script> 65 <script>
66 -import Cookies from "js-cookie";  
67 -import { encrypt, decrypt } from '@/utils/jsencrypt'  
68 import { 66 import {
69 getPassword, getRememberMe, 67 getPassword, getRememberMe,
70 getUsername, 68 getUsername,