Commit 3d1afe5271cd70b48ba56b8dde5b215d70f30870

Authored by xingyu
1 parent 1179ca1a

vue2: 移除 js-cookie ,使用 localStorage

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