Kaynağa Gözat

fix: 登陆修复

赖奇 1 yıl önce
ebeveyn
işleme
be7b2a4994

+ 2 - 0
apps/web-ele/package.json

@@ -45,11 +45,13 @@
     "dayjs": "catalog:",
     "element-plus": "catalog:",
     "pinia": "catalog:",
+    "qs": "^6.14.0",
     "uuid": "^11.0.5",
     "vue": "catalog:",
     "vue-router": "catalog:"
   },
   "devDependencies": {
+    "@types/qs": "^6.9.18",
     "unplugin-auto-import": "^19.0.0",
     "unplugin-element-plus": "catalog:",
     "unplugin-vue-components": "^28.0.0"

BIN
apps/web-ele/public/favicon.ico


+ 11 - 1
apps/web-ele/src/api/core/auth.ts

@@ -11,7 +11,17 @@ export namespace AuthApi {
 
   /** 登录接口返回值 */
   export interface LoginResult {
-    accessToken: string;
+    bmid: number;
+    bm: null | string;
+    token: string;
+    gw: string;
+    workerid: string;
+    accountid: string;
+    timeout: number;
+    nickname: string;
+    account: string;
+    popedom: string;
+    grouplist: string;
   }
 
   export interface RefreshTokenResult {

+ 8 - 2
apps/web-ele/src/api/request.ts

@@ -14,6 +14,7 @@ import {
 import { useAccessStore } from '@vben/stores';
 
 import { ElMessage } from 'element-plus';
+import qs from 'qs';
 
 import { useAuthStore } from '#/store';
 
@@ -67,6 +68,11 @@ function createRequestClient(baseURL: string, options?: RequestClientOptions) {
 
       config.headers.Authorization = formatToken(accessStore.accessToken);
       config.headers['Accept-Language'] = preferences.app.locale;
+
+      // .net 序列化请求数据
+      if (config.headers['Content-Type'] !== 'multipart/form-data') {
+        config.data = qs.stringify(config.data);
+      }
       return config;
     },
   });
@@ -74,8 +80,8 @@ function createRequestClient(baseURL: string, options?: RequestClientOptions) {
   // 处理返回的响应数据格式
   client.addResponseInterceptor(
     defaultResponseInterceptor({
-      codeField: 'code',
-      dataField: 'data',
+      codeField: 'Status',
+      dataField: 'Data',
       successCode: 0,
     }),
   );

+ 16 - 3
apps/web-ele/src/store/auth.ts

@@ -5,6 +5,7 @@ import { useRouter } from 'vue-router';
 
 import { DEFAULT_HOME_PATH, LOGIN_PATH } from '@vben/constants';
 import { resetAllStores, useAccessStore, useUserStore } from '@vben/stores';
+import { useStorage } from '@vben/utils';
 
 import { ElNotification } from 'element-plus';
 import { defineStore } from 'pinia';
@@ -17,7 +18,6 @@ import {
   logoutApi,
 } from '#/api';
 import { $t } from '#/locales';
-import { useStorage } from '@vben/utils';
 
 export const useAuthStore = defineStore('auth', () => {
   const accessStore = useAccessStore();
@@ -41,19 +41,32 @@ export const useAuthStore = defineStore('auth', () => {
     params: Recordable<any>,
     onSuccess?: () => Promise<void> | void,
   ) {
-    console.log(params);
     // 异步处理用户登录操作并获取 accessToken
     let userInfo: null | UserInfo = null;
     try {
       loginLoading.value = true;
       const storage = useStorage('captcha-uuid');
-      const { accessToken } = await loginApi({
+      const res = await loginApi({
         account: params.username,
         pwd: params.password,
         code: params.captcha,
         uuid: storage.getItem() as string,
       });
 
+      // "bmid": 76,
+      // "bm": null,
+      // "token": "a2fd3e10a990c2f7a34de2c7160139a4",
+      // "gw": "销售装维",
+      // "workerid": "1",
+      // "accountid": "1",
+      // "timeout": 7200,
+      // "nickname": "超级管理员",
+      // "account": "admin",
+      // "popedom": "1401,1413,1412,1411,1410,1409,1406,1404,1402,1392,1399,1398,1397,1396,1395,1394,1393,1390,1389,1383,1376,1405,1403,1391,1387,1386,1385,1384,1381,1380,1379,1378,1377,333,346,331,280,289,330,287,286,285,284,1426,1414,367,366,329,328,311,299,298,282,278,345,335,334,332,313,312,310,309,307,305,304,303,302,301,279,277,276,275,274,273,269,288,283,272,271,270,306,255,234,232,354,353,352,351,350,349,348,297,293,268,267,266,265,264,263,261,260,259,258,257,256,362,361,64,63,62,19,308,300,181,178,167,125,123,101,92,91,87,86,85,84,83,82,81,80,54,23,22,21,20,2,290,296,295,294,292,291,147,146,145,144,143,142,141,60,59,58,57,55,229,228,93,18,7,1400,171,170,169,168,5,14,4,156,132,131,16,15,3,130,129,128,127,17,281,233,230,61,1,6",
+      // "grouplist": "1"
+
+      const { token: accessToken } = res;
+
       // 如果成功获取到 accessToken
       if (accessToken) {
         // 将 accessToken 存储到 accessStore 中

+ 1 - 1
apps/web-ele/vite.config.mts

@@ -36,7 +36,7 @@ export default defineConfig(async () => {
             changeOrigin: true,
             rewrite: (path) => path.replace(/^\/api/, ''),
             // mock代理目标地址
-            target: 'http://211.149.199.65:5010/',
+            target: 'http://211.149.199.65:5012/',
             ws: true,
           },
         },

+ 1 - 1
packages/effects/layouts/src/authentication/authentication.vue

@@ -65,7 +65,7 @@ const { authPanelCenter, authPanelLeft, authPanelRight, isDark } =
       <div
         class="text-foreground lg:text-foreground ml-4 mt-4 flex flex-1 items-center sm:left-6 sm:top-6"
       >
-        <img v-if="logo" :alt="appName" :src="logo" class="mr-2" width="42" />
+        <img v-if="logo" :alt="appName" :src="logo" class="mr-2" width="30" />
         <p v-if="appName" class="text-xl font-medium">
           {{ appName }}
         </p>

+ 7 - 2
packages/effects/request/src/request-client/preset-interceptors.ts

@@ -20,14 +20,19 @@ export const defaultResponseInterceptor = ({
 }): ResponseInterceptorConfig => {
   return {
     fulfilled: (response) => {
-      const { config, data: responseData, status } = response;
+      const { config, data: responseData, status, headers } = response;
+
+      // responseContentType
+      if (['image/jpeg'].includes(headers['content-type'])) {
+        return responseData;
+      }
 
       if (config.responseReturn === 'raw') {
         return response;
       }
 
       if (status >= 200 && status < 400) {
-        if (['body', 'data'].includes(config.responseReturn ?? '')) {
+        if (config.responseReturn === 'body') {
           return responseData;
         } else if (
           isFunction(successCode)

+ 2 - 1
packages/effects/request/src/request-client/request-client.ts

@@ -31,7 +31,8 @@ class RequestClient {
     // 合并默认配置和传入的配置
     const defaultConfig: RequestClientOptions = {
       headers: {
-        'Content-Type': 'application/json;charset=utf-8',
+        // 'Content-Type': 'application/json;charset=utf-8',
+        'Content-Type': 'application/x-www-form-urlencoded',
       },
       responseReturn: 'raw',
       // 默认超时时间

+ 19 - 0
pnpm-lock.yaml

@@ -643,6 +643,9 @@ importers:
       pinia:
         specifier: ^2.3.1
         version: 2.3.1(typescript@5.7.3)(vue@3.5.13(typescript@5.7.3))
+      qs:
+        specifier: ^6.14.0
+        version: 6.14.0
       uuid:
         specifier: ^11.0.5
         version: 11.0.5
@@ -653,6 +656,9 @@ importers:
         specifier: 'catalog:'
         version: 4.5.0(vue@3.5.13(typescript@5.7.3))
     devDependencies:
+      '@types/qs':
+        specifier: ^6.9.18
+        version: 6.9.18
       unplugin-auto-import:
         specifier: ^19.0.0
         version: 19.0.0(@nuxt/kit@3.15.4(magicast@0.3.5)(rollup@4.34.2))(@vueuse/core@12.5.0(typescript@5.7.3))(rollup@4.34.2)
@@ -3787,6 +3793,9 @@ packages:
   '@types/qrcode@1.5.5':
     resolution: {integrity: sha512-CdfBi/e3Qk+3Z/fXYShipBT13OJ2fDO2Q2w5CIP5anLTLIndQG9z6P1cnm+8zCWSpm5dnxMFd/uREtb0EXuQzg==}
 
+  '@types/qs@6.9.18':
+    resolution: {integrity: sha512-kK7dgTYDyGqS+e2Q4aK9X3D7q234CIZ1Bv0q/7Z5IwRDoADNU81xXJK/YVyLbLTZCoIwUoDoffFeF+p/eIklAA==}
+
   '@types/readdir-glob@1.1.5':
     resolution: {integrity: sha512-raiuEPUYqXu+nvtY2Pe8s8FEmZ3x5yAH4VkLdihcPdalvsHltomrRC9BzuStrJ9yk06470hS0Crw0f1pXqD+Hg==}
 
@@ -7855,6 +7864,10 @@ packages:
     engines: {node: '>=10.13.0'}
     hasBin: true
 
+  qs@6.14.0:
+    resolution: {integrity: sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==}
+    engines: {node: '>=0.6'}
+
   queue-microtask@1.2.3:
     resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==}
 
@@ -11936,6 +11949,8 @@ snapshots:
     dependencies:
       '@types/node': 22.13.1
 
+  '@types/qs@6.9.18': {}
+
   '@types/readdir-glob@1.1.5':
     dependencies:
       '@types/node': 22.13.1
@@ -16408,6 +16423,10 @@ snapshots:
       pngjs: 5.0.0
       yargs: 15.4.1
 
+  qs@6.14.0:
+    dependencies:
+      side-channel: 1.1.0
+
   queue-microtask@1.2.3: {}
 
   radix-vue@1.9.13(vue@3.5.13(typescript@5.7.3)):