Эх сурвалжийг харах

1. 接入登录接口。
待办:1)验证码的接入;2)多租户的接入

YunaiV 2 жил өмнө
parent
commit
7ad120e2a3

+ 3 - 2
.env

@@ -2,7 +2,8 @@
 VITE_DEV_PORT = '8080'
 
 # development path
-VITE_DEV_PATH = 'https://demo.mtruning.club'
+# VITE_DEV_PATH = 'https://demo.mtruning.club'
+VITE_DEV_PATH = 'http://127.0.0.1:48080'
 
 # production path
-VITE_PRO_PATH = 'https://demo.mtruning.club'
+VITE_PRO_PATH = 'https://demo.mtruning.club'

+ 25 - 68
pnpm-lock.yaml

@@ -1,4 +1,4 @@
-lockfileVersion: 5.4
+lockfileVersion: 5.3
 
 specifiers:
   '@amap/amap-jsapi-loader': ^1.0.1
@@ -88,14 +88,14 @@ dependencies:
   keymaster: 1.6.2
   monaco-editor: 0.33.0
   naive-ui: 2.34.3_vue@3.2.37
-  pinia: 2.0.14_ub5l46u3nefphax5x2tezui4oq
+  pinia: 2.0.14_typescript@4.6.3+vue@3.2.37
   screenfull: 6.0.1
   three: 0.145.0
   vue: 3.2.37
   vue-demi: 0.13.1_vue@3.2.37
   vue-i18n: 9.2.2_vue@3.2.37
   vue-router: 4.0.12_vue@3.2.37
-  vue3-lazyload: 0.2.5-beta_2yymnzrok6eda47acnj2yjm3ae
+  vue3-lazyload: 0.2.5-beta_d630c6e62e57883073e01353ac259b01
   vue3-sketch-ruler: 1.3.4_vue@3.2.37
   vuedraggable: 4.1.0_vue@3.2.37
 
@@ -104,8 +104,8 @@ devDependencies:
   '@commitlint/config-conventional': 17.0.2
   '@types/node': 16.11.40
   '@types/three': 0.144.0
-  '@typescript-eslint/eslint-plugin': 5.28.0_evi7yu7wunhzwb24olrfvzynny
-  '@typescript-eslint/parser': 5.28.0_sfmgizikprcxt7r54j7cnzjamu
+  '@typescript-eslint/eslint-plugin': 5.28.0_2551fc53f6a34f9b075c72e25ae70d6e
+  '@typescript-eslint/parser': 5.28.0_eslint@8.17.0+typescript@4.6.3
   '@vicons/carbon': 0.12.0
   '@vicons/ionicons5': 0.11.0
   '@vitejs/plugin-vue': 1.10.2_vite@2.9.9
@@ -117,8 +117,8 @@ devDependencies:
   echarts: 5.3.3
   eslint: 8.17.0
   eslint-config-prettier: 8.5.0_eslint@8.17.0
-  eslint-plugin-import: 2.26.0_wyrfqmvemfacbroyi3ypviy7f4
-  eslint-plugin-prettier: 4.0.0_nguwan5pqsajixjz57ffz7bkde
+  eslint-plugin-import: 2.26.0_eslint@8.17.0
+  eslint-plugin-prettier: 4.0.0_69a96037af8480945d39efca5cfc2a19
   eslint-plugin-vue: 8.7.1_eslint@8.17.0
   husky: 8.0.1
   lodash: 4.17.21
@@ -530,7 +530,7 @@ packages:
       '@types/node': 17.0.43
       chalk: 4.1.2
       cosmiconfig: 7.0.1
-      cosmiconfig-typescript-loader: 2.0.1_sg2ukyc6p547g74ru6fclbyzsu
+      cosmiconfig-typescript-loader: 2.0.1_91b545605e7f79f37f91a78a25871995
       lodash: 4.17.21
       resolve-from: 5.0.0
       typescript: 4.7.3
@@ -950,7 +950,7 @@ packages:
     resolution: {integrity: sha512-IUMDPSXnYIbEO2IereEFcgcqfDREOgmbGqtrMpVPpACTU6pltYLwHgVkrnYv0XhWEcjio9sYEfIEzgn3c7nDqA==}
     dev: true
 
-  /@typescript-eslint/eslint-plugin/5.28.0_evi7yu7wunhzwb24olrfvzynny:
+  /@typescript-eslint/eslint-plugin/5.28.0_2551fc53f6a34f9b075c72e25ae70d6e:
     resolution: {integrity: sha512-DXVU6Cg29H2M6EybqSg2A+x8DgO9TCUBRp4QEXQHJceLS7ogVDP0g3Lkg/SZCqcvkAP/RruuQqK0gdlkgmhSUA==}
     engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
     peerDependencies:
@@ -961,10 +961,10 @@ packages:
       typescript:
         optional: true
     dependencies:
-      '@typescript-eslint/parser': 5.28.0_sfmgizikprcxt7r54j7cnzjamu
+      '@typescript-eslint/parser': 5.28.0_eslint@8.17.0+typescript@4.6.3
       '@typescript-eslint/scope-manager': 5.28.0
-      '@typescript-eslint/type-utils': 5.28.0_sfmgizikprcxt7r54j7cnzjamu
-      '@typescript-eslint/utils': 5.28.0_sfmgizikprcxt7r54j7cnzjamu
+      '@typescript-eslint/type-utils': 5.28.0_eslint@8.17.0+typescript@4.6.3
+      '@typescript-eslint/utils': 5.28.0_eslint@8.17.0+typescript@4.6.3
       debug: 4.3.4
       eslint: 8.17.0
       functional-red-black-tree: 1.0.1
@@ -977,7 +977,7 @@ packages:
       - supports-color
     dev: true
 
-  /@typescript-eslint/parser/5.28.0_sfmgizikprcxt7r54j7cnzjamu:
+  /@typescript-eslint/parser/5.28.0_eslint@8.17.0+typescript@4.6.3:
     resolution: {integrity: sha512-ekqoNRNK1lAcKhZESN/PdpVsWbP9jtiNqzFWkp/yAUdZvJalw2heCYuqRmM5eUJSIYEkgq5sGOjq+ZqsLMjtRA==}
     engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
     peerDependencies:
@@ -1005,7 +1005,7 @@ packages:
       '@typescript-eslint/visitor-keys': 5.28.0
     dev: true
 
-  /@typescript-eslint/type-utils/5.28.0_sfmgizikprcxt7r54j7cnzjamu:
+  /@typescript-eslint/type-utils/5.28.0_eslint@8.17.0+typescript@4.6.3:
     resolution: {integrity: sha512-SyKjKh4CXPglueyC6ceAFytjYWMoPHMswPQae236zqe1YbhvCVQyIawesYywGiu98L9DwrxsBN69vGIVxJ4mQQ==}
     engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
     peerDependencies:
@@ -1015,7 +1015,7 @@ packages:
       typescript:
         optional: true
     dependencies:
-      '@typescript-eslint/utils': 5.28.0_sfmgizikprcxt7r54j7cnzjamu
+      '@typescript-eslint/utils': 5.28.0_eslint@8.17.0+typescript@4.6.3
       debug: 4.3.4
       eslint: 8.17.0
       tsutils: 3.21.0_typescript@4.6.3
@@ -1050,7 +1050,7 @@ packages:
       - supports-color
     dev: true
 
-  /@typescript-eslint/utils/5.28.0_sfmgizikprcxt7r54j7cnzjamu:
+  /@typescript-eslint/utils/5.28.0_eslint@8.17.0+typescript@4.6.3:
     resolution: {integrity: sha512-E60N5L0fjv7iPJV3UGc4EC+A3Lcj4jle9zzR0gW7vXhflO7/J29kwiTGITA2RlrmPokKiZbBy2DgaclCaEUs6g==}
     engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
     peerDependencies:
@@ -1791,8 +1791,6 @@ packages:
       finalhandler: 1.1.2
       parseurl: 1.3.3
       utils-merge: 1.0.1
-    transitivePeerDependencies:
-      - supports-color
     dev: true
 
   /constant-case/3.0.4:
@@ -1846,7 +1844,7 @@ packages:
       safe-buffer: 5.1.2
     dev: true
 
-  /cosmiconfig-typescript-loader/2.0.1_sg2ukyc6p547g74ru6fclbyzsu:
+  /cosmiconfig-typescript-loader/2.0.1_91b545605e7f79f37f91a78a25871995:
     resolution: {integrity: sha512-B9s6sX/omXq7I6gC6+YgLmrBFMJhPWew7ty/X5Tuwtd2zOSgWaUdXjkuVwbe3qqcdETo60+1nSVMekq//LIXVA==}
     engines: {node: '>=12', npm: '>=6'}
     peerDependencies:
@@ -1855,7 +1853,7 @@ packages:
     dependencies:
       '@types/node': 17.0.43
       cosmiconfig: 7.0.1
-      ts-node: 10.8.1_sg2ukyc6p547g74ru6fclbyzsu
+      ts-node: 10.8.1_91b545605e7f79f37f91a78a25871995
       typescript: 4.7.3
     transitivePeerDependencies:
       - '@swc/core'
@@ -1938,22 +1936,12 @@ packages:
 
   /debug/2.6.9:
     resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==}
-    peerDependencies:
-      supports-color: '*'
-    peerDependenciesMeta:
-      supports-color:
-        optional: true
     dependencies:
       ms: 2.0.0
     dev: true
 
   /debug/3.2.7:
     resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==}
-    peerDependencies:
-      supports-color: '*'
-    peerDependenciesMeta:
-      supports-color:
-        optional: true
     dependencies:
       ms: 2.1.3
     dev: true
@@ -2469,54 +2457,29 @@ packages:
     dependencies:
       debug: 3.2.7
       resolve: 1.22.0
-    transitivePeerDependencies:
-      - supports-color
     dev: true
 
-  /eslint-module-utils/2.7.3_cfsupm63rr3qvqifljk6nmy67u:
+  /eslint-module-utils/2.7.3:
     resolution: {integrity: sha512-088JEC7O3lDZM9xGe0RerkOMd0EjFl+Yvd1jPWIkMT5u3H9+HC34mWWPnqPrN13gieT9pBOO+Qt07Nb/6TresQ==}
     engines: {node: '>=4'}
-    peerDependencies:
-      '@typescript-eslint/parser': '*'
-      eslint-import-resolver-node: '*'
-      eslint-import-resolver-typescript: '*'
-      eslint-import-resolver-webpack: '*'
-    peerDependenciesMeta:
-      '@typescript-eslint/parser':
-        optional: true
-      eslint-import-resolver-node:
-        optional: true
-      eslint-import-resolver-typescript:
-        optional: true
-      eslint-import-resolver-webpack:
-        optional: true
     dependencies:
-      '@typescript-eslint/parser': 5.28.0_sfmgizikprcxt7r54j7cnzjamu
       debug: 3.2.7
-      eslint-import-resolver-node: 0.3.6
       find-up: 2.1.0
-    transitivePeerDependencies:
-      - supports-color
     dev: true
 
-  /eslint-plugin-import/2.26.0_wyrfqmvemfacbroyi3ypviy7f4:
+  /eslint-plugin-import/2.26.0_eslint@8.17.0:
     resolution: {integrity: sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA==}
     engines: {node: '>=4'}
     peerDependencies:
-      '@typescript-eslint/parser': '*'
       eslint: ^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8
-    peerDependenciesMeta:
-      '@typescript-eslint/parser':
-        optional: true
     dependencies:
-      '@typescript-eslint/parser': 5.28.0_sfmgizikprcxt7r54j7cnzjamu
       array-includes: 3.1.5
       array.prototype.flat: 1.3.0
       debug: 2.6.9
       doctrine: 2.1.0
       eslint: 8.17.0
       eslint-import-resolver-node: 0.3.6
-      eslint-module-utils: 2.7.3_cfsupm63rr3qvqifljk6nmy67u
+      eslint-module-utils: 2.7.3
       has: 1.0.3
       is-core-module: 2.9.0
       is-glob: 4.0.3
@@ -2524,13 +2487,9 @@ packages:
       object.values: 1.1.5
       resolve: 1.22.0
       tsconfig-paths: 3.14.1
-    transitivePeerDependencies:
-      - eslint-import-resolver-typescript
-      - eslint-import-resolver-webpack
-      - supports-color
     dev: true
 
-  /eslint-plugin-prettier/4.0.0_nguwan5pqsajixjz57ffz7bkde:
+  /eslint-plugin-prettier/4.0.0_69a96037af8480945d39efca5cfc2a19:
     resolution: {integrity: sha512-98MqmCJ7vJodoQK359bqQWaxOE0CS8paAz/GgjaZLyex4TTk3g9HugoO89EqWCrFiOqn9EVvcoo7gZzONCWVwQ==}
     engines: {node: '>=6.0.0'}
     peerDependencies:
@@ -2793,8 +2752,6 @@ packages:
       parseurl: 1.3.3
       statuses: 1.5.0
       unpipe: 1.0.0
-    transitivePeerDependencies:
-      - supports-color
     dev: true
 
   /find-up/2.1.0:
@@ -4236,7 +4193,7 @@ packages:
     engines: {node: '>=8.6'}
     dev: true
 
-  /pinia/2.0.14_ub5l46u3nefphax5x2tezui4oq:
+  /pinia/2.0.14_typescript@4.6.3+vue@3.2.37:
     resolution: {integrity: sha512-0nPuZR4TetT/WcLN+feMSjWJku3SQU7dBbXC6uw+R6FLQJCsg+/0pzXyD82T1FmAYe0lsx+jnEDQ1BLgkRKlxA==}
     peerDependencies:
       '@vue/composition-api': ^1.4.0
@@ -4919,7 +4876,7 @@ packages:
     engines: {node: '>=8'}
     dev: true
 
-  /ts-node/10.8.1_sg2ukyc6p547g74ru6fclbyzsu:
+  /ts-node/10.8.1_91b545605e7f79f37f91a78a25871995:
     resolution: {integrity: sha512-Wwsnao4DQoJsN034wePSg5nZiw4YKXf56mPIAeD6wVmiv+RytNSWqc2f3fKvcUoV+Yn2+yocD71VOfQHbmVX4g==}
     hasBin: true
     peerDependencies:
@@ -5439,7 +5396,7 @@ packages:
       '@vue/shared': 3.2.37
     dev: false
 
-  /vue3-lazyload/0.2.5-beta_2yymnzrok6eda47acnj2yjm3ae:
+  /vue3-lazyload/0.2.5-beta_d630c6e62e57883073e01353ac259b01:
     resolution: {integrity: sha512-GVhJfL9Hcu+AvWsYmUwODivvt+gzpT0ztgAzZaUduoiTaGCv/qzhr0VwAQXfjGF3XFYFyOJsHlAi3/WE0P8XTQ==}
     peerDependencies:
       '@vue/compiler-sfc': '>=3.0.0'

+ 7 - 2
src/api/axios.ts

@@ -25,6 +25,11 @@ const axiosInstance = axios.create({
 
 axiosInstance.interceptors.request.use(
   (config: AxiosRequestConfig) => {
+    // TODO 芋艿:临时代码
+    config.headers = {
+      ...config.headers,
+      'tenant-id': 1
+    }
     // 白名单校验
     if (includes(fetchAllowList, config.url)) return config
     // 获取 token
@@ -58,7 +63,7 @@ axiosInstance.interceptors.response.use(
     if (code === undefined || code === null) return Promise.resolve(res)
 
     // 成功
-    if (code === ResultEnum.SUCCESS) {
+    if (code === ResultEnum.SUCCESS || code === ResultEnum.DATA_SUCCESS) {
       return Promise.resolve(res.data)
     }
 
@@ -74,7 +79,7 @@ axiosInstance.interceptors.response.use(
       redirectErrorPage(code)
       return Promise.resolve(res.data)
     }
-    
+
     // 提示错误
     window['$message'].error(window['$t']((res.data as any).msg))
     return Promise.resolve(res.data)

+ 3 - 2
src/api/path/system.api.ts

@@ -1,12 +1,13 @@
 import { http } from '@/api/http'
 import { httpErrorHandle } from '@/utils'
 import { RequestHttpEnum, ModuleTypeEnum } from '@/enums/httpEnum'
-import { LoginResult } from './system'
+import { AuthLoginRespVO } from './system'
 
 // * 登录
 export const loginApi = async (data: object) => {
   try {
-    const res = await http(RequestHttpEnum.POST)<LoginResult>(`${ModuleTypeEnum.SYSTEM}/login`, data)
+    const res = await http(RequestHttpEnum.POST)<AuthLoginRespVO>(`${ModuleTypeEnum.SYSTEM}/auth/login`, data)
+    console.log(res)
     return res
   } catch (err) {
     httpErrorHandle()

+ 19 - 0
src/api/path/system.d.ts

@@ -24,3 +24,22 @@ export interface LoginResult {
     id: string
   }
 }
+
+export interface AuthLoginRespVO {
+  /**
+   * 用户编号
+   */
+  userId: number
+  /**
+   * 访问令牌
+   */
+  accessToken: string
+  /**
+   * 刷新令牌
+   */
+  refreshToken: string
+  /**
+   * 过期时间
+   */
+  expiresTime: number
+}

+ 2 - 1
src/enums/httpEnum.ts

@@ -1,6 +1,7 @@
 // 模块 Path 前缀分类
 export enum ModuleTypeEnum {
-  SYSTEM = 'sys',
+  // SYSTEM = 'sys',
+  SYSTEM = 'system',
   PROJECT = 'project',
 }
 

+ 1 - 1
src/settings/httpSetting.ts

@@ -1,2 +1,2 @@
 // 请求前缀
-export const axiosPre = '/api/goview'
+export const axiosPre = '/admin-api'

+ 2 - 2
src/store/modules/systemStore/systemStore.d.ts

@@ -9,7 +9,7 @@ export enum SystemStoreUserInfoEnum {
 export interface UserInfoType {
   [SystemStoreUserInfoEnum.USER_TOKEN]?: string,
   [SystemStoreUserInfoEnum.TOKEN_NAME]?: string,
-  [SystemStoreUserInfoEnum.USER_ID]?: string,
+  [SystemStoreUserInfoEnum.USER_ID]?: number,
   [SystemStoreUserInfoEnum.USER_NAME]?: string,
   [SystemStoreUserInfoEnum.NICK_NAME]?: string,
 }
@@ -28,4 +28,4 @@ export enum SystemStoreEnum {
 export interface SystemStoreType {
   [SystemStoreEnum.USER_INFO]: UserInfoType
   [SystemStoreEnum.FETCH_INFO]: FetchInfoType
-}
+}

+ 12 - 10
src/views/login/index.vue

@@ -149,7 +149,7 @@ const t = window['$t']
 
 const formInline = reactive({
   username: 'admin',
-  password: 'admin',
+  password: 'admin123',
 })
 
 const rules = {
@@ -203,25 +203,27 @@ const handleSubmit = async (e: Event) => {
     if (!errors) {
       const { username, password } = formInline
       loading.value = true
-      // 提交请求
-      const res = await loginApi({
+      // 提交请求【登录】
+      const loginRes = await loginApi({
         username,
         password
       })
-      if(res && res.data) {
-        const { tokenValue, tokenName } = res.data.token
-        const { nickname, username, id } = res.data.userinfo
+      if(loginRes && loginRes.data) {
+        const id = loginRes.data.userId
+        const token = loginRes.data.accessToken
+        const username = '芋道源码'
+        const nickname = '芋道源码'
 
-        // 存储到 pinia 
+        // 存储到 pinia
         systemStore.setItem(SystemStoreEnum.USER_INFO, {
-          [SystemStoreUserInfoEnum.USER_TOKEN]: tokenValue,
-          [SystemStoreUserInfoEnum.TOKEN_NAME]: tokenName,
+          [SystemStoreUserInfoEnum.USER_TOKEN]: token,
+          [SystemStoreUserInfoEnum.TOKEN_NAME]: '',
           [SystemStoreUserInfoEnum.USER_ID]: id,
           [SystemStoreUserInfoEnum.USER_NAME]: username,
           [SystemStoreUserInfoEnum.NICK_NAME]: nickname,
           t
         })
-        
+
         window['$message'].success(t('login.login_success'))
         routerTurnByName(PageEnum.BASE_HOME_NAME, true)
       }