ソースを参照

fix:调整依赖引入顺序,调整cookie名称定义

hanyang 1 年間 前
コミット
91593ba353

+ 2 - 2
src/base/ajax.js

@@ -1,6 +1,6 @@
 import axios from 'axios';
 
-import { cookieST_Authorization } from './storage';
+import { kuky_Authorization } from './storage';
 
 const ajax = axios.create({
   withCredentials: true, // 跨域发送 cookie
@@ -12,7 +12,7 @@ const ajax = axios.create({
 
 ajax.interceptors.request.use(
   (config) => {
-    const token = cookieST_Authorization.get();
+    const token = kuky_Authorization.get();
     if (token) {
       config.headers['Authorization'] = `Bearer ${token}`;
     }

+ 1 - 1
src/base/storage.js

@@ -22,4 +22,4 @@ export const sessionST_Expire = new MySessionStorage('expire');
  * 任意 cookie 的定义,必须添加 kuky_ 前缀
  */
 export const kuky_UserName = new MyCookie('user_name');
-export const cookieST_Authorization = new MyCookie('token'); // 用户身份token
+export const kuky_Authorization = new MyCookie('token'); // 用户身份token

+ 3 - 3
src/base/store/use-current-user.js

@@ -1,6 +1,6 @@
 import { defineStore } from 'pinia';
 import { login, getInfo } from '../../base/api/login';
-import { cookieST_Authorization } from '../storage';
+import { kuky_Authorization } from '../storage';
 
 /**
  * 当前登录的用户信息
@@ -10,7 +10,7 @@ export const useCurrentUserStore = defineStore('current_user', {
     return {
       name: 'Jack',
       token_type: '',
-      token: cookieST_Authorization.get(),
+      token: kuky_Authorization.get(),
       username: '',
       nickname: '',
       dept: [],
@@ -33,7 +33,7 @@ export const useCurrentUserStore = defineStore('current_user', {
               this.token_type = res.data.token_type;
               this.username = res.data.username;
               this.nickname = res.data.nickname;
-              cookieST_Authorization.set(res.data.access_token);
+              kuky_Authorization.set(res.data.access_token);
               resolve(res.msg);
               /**
                * 获取用户信息

+ 3 - 3
src/views/login-register/FormItem.vue

@@ -47,11 +47,11 @@
 </template>
 
 <script setup>
-import { register } from '../../base/api/login';
-import { loginFormRules } from '../../utils/auth';
 import { ref, reactive, getCurrentInstance, nextTick } from 'vue';
-import { useCurrentUserStore } from '../../base/store/use-current-user';
 import { useRouter } from 'vue-router';
+import { useCurrentUserStore } from '../../base/store/use-current-user';
+import { loginFormRules } from '../../utils/auth';
+import { register } from '../../base/api/login';
 
 const router = useRouter();