소스 검색

修改登录接口

yuanmingze 3 달 전
부모
커밋
3fd011cbae
5개의 변경된 파일41개의 추가작업 그리고 18개의 파일을 삭제
  1. 23 14
      eslint.config.ts
  2. 3 0
      package.json
  3. 9 0
      pnpm-lock.yaml
  4. 5 3
      src/services/request/index.ts
  5. 1 1
      src/stores/modules/user.ts

+ 23 - 14
eslint.config.ts

@@ -1,32 +1,41 @@
-import { globalIgnores } from 'eslint/config'
+// eslint.config.js
 import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
 import pluginVue from 'eslint-plugin-vue'
+import eslintPluginJs from '@eslint/js'
 import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'
-
-// To allow more languages other than `ts` in `.vue` files, uncomment the following lines:
-// import { configureVueProject } from '@vue/eslint-config-typescript'
-// configureVueProject({ scriptLangs: ['ts', 'tsx'] })
-// More info at https://github.com/vuejs/eslint-config-typescript/#advanced-setup
+import { globalIgnores } from 'eslint/config'
 
 export default defineConfigWithVueTs(
-  {
-    name: 'app/files-to-lint',
-    files: ['**/*.{ts,mts,tsx,vue}'],
-  },
-
-  globalIgnores(['**/dist/**', '**/dist-ssr/**', '**/coverage/**']),
+  // ✅ 基础推荐规则(提供语法检测能力)
+  eslintPluginJs.configs.recommended,
 
+  // ✅ Vue 规则
   pluginVue.configs['flat/essential'],
+
+  // ✅ TypeScript 推荐规则
   vueTsConfigs.recommended,
+
+  // ✅ 跳过格式化冲突(Prettier)
   skipFormatting,
+
+  // ✅ 忽略目录
+  globalIgnores(['**/dist/**', '**/dist-ssr/**', '**/coverage/**']),
+
+  // ✅ 项目自定义规则
   {
     name: 'app/files-to-lint',
     files: ['**/*.{ts,mts,tsx,vue}'],
     rules: {
-      // 禁用 vue/multi-word-component-names 规则(已存在)
+      // 🚫 关闭常用约束
       'vue/multi-word-component-names': 'off',
-      // 禁用 @typescript-eslint/no-explicit-any 规则
       '@typescript-eslint/no-explicit-any': 'off',
+
+      // ✅ 强化语法检测
+      'no-unexpected-multiline': 'error',
+      'no-unreachable': 'error',
+      'no-empty': 'error',
+      'no-extra-parens': 'error',
+      'no-fallthrough': 'error',
     },
   },
 )

+ 3 - 0
package.json

@@ -31,9 +31,12 @@
     "vue-router": "^4.6.3"
   },
   "devDependencies": {
+    "@eslint/js": "^9.38.0",
     "@tsconfig/node22": "^22.0.2",
     "@types/node": "^22.18.11",
     "@types/qs": "^6.14.0",
+    "@typescript-eslint/eslint-plugin": "^8.46.2",
+    "@typescript-eslint/parser": "^8.46.2",
     "@vant/auto-import-resolver": "^1.3.0",
     "@vitejs/plugin-vue": "^6.0.1",
     "@vue/eslint-config-prettier": "^10.2.0",

+ 9 - 0
pnpm-lock.yaml

@@ -48,6 +48,9 @@ importers:
         specifier: ^4.6.3
         version: 4.6.3(vue@3.5.22(typescript@5.9.3))
     devDependencies:
+      '@eslint/js':
+        specifier: ^9.38.0
+        version: 9.38.0
       '@tsconfig/node22':
         specifier: ^22.0.2
         version: 22.0.2
@@ -57,6 +60,12 @@ importers:
       '@types/qs':
         specifier: ^6.14.0
         version: 6.14.0
+      '@typescript-eslint/eslint-plugin':
+        specifier: ^8.46.2
+        version: 8.46.2(@typescript-eslint/parser@8.46.2(eslint@9.38.0(jiti@2.6.1))(typescript@5.9.3))(eslint@9.38.0(jiti@2.6.1))(typescript@5.9.3)
+      '@typescript-eslint/parser':
+        specifier: ^8.46.2
+        version: 8.46.2(eslint@9.38.0(jiti@2.6.1))(typescript@5.9.3)
       '@vant/auto-import-resolver':
         specifier: ^1.3.0
         version: 1.3.0

+ 5 - 3
src/services/request/index.ts

@@ -152,12 +152,14 @@ const onRequest = (config: CustomAxiosRequestConfig): CustomAxiosRequestConfig =
   requestMap.set(requestKey, controller)
 
   const headers = config.headers as Record<string, any>
+  if (tenant_id) {
+    headers['TENANT-ID'] = tenant_id
+  }
 
   if (access_token && headers.isToken !== false) {
     headers.Authorization = `Bearer ${access_token}`
-  }
-  if (tenant_id) {
-    headers['X-Tenant-Id'] = tenant_id
+  } else if (config.url?.includes('/auth/login/etssms')) {
+    headers.Authorization = `Basic ZXRzOmV0cw==`
   }
 
   if (config.method === 'post' && headers.serialize) {

+ 1 - 1
src/stores/modules/user.ts

@@ -22,7 +22,7 @@ interface UserState {
 export const useUserStore = defineStore('user', {
   state: (): UserState => ({
     access_token: '',
-    tenant_id: '',
+    tenant_id: '1',
     menu: [],
   }),
   actions: {