Bladeren bron

update 优化 !pr382 修复一些问题 完事流程逻辑

疯狂的狮子Li 1 jaar geleden
bovenliggende
commit
cc69786fd1

+ 7 - 5
src/api/login.ts

@@ -2,7 +2,9 @@ import request from '@/utils/request';
 import { AxiosPromise } from 'axios';
 import { LoginData, LoginResult, VerifyCodeResult, TenantInfo } from './types';
 import { UserInfo } from '@/api/system/user/types';
-import { da } from 'element-plus/es/locale';
+
+// pc端固定客户端授权id
+const clientId = 'e5cd7e4891bf95d1d19206ce24a7b32e';
 
 /**
  * @param data {LoginData}
@@ -11,7 +13,7 @@ import { da } from 'element-plus/es/locale';
 export function login(data: LoginData): AxiosPromise<LoginResult> {
   const params = {
     ...data,
-    clientId: data.clientId || 'e5cd7e4891bf95d1d19206ce24a7b32e',
+    clientId: data.clientId || clientId,
     grantType: data.grantType || 'password'
   };
   return request({
@@ -59,14 +61,14 @@ export function getCodeImg(): AxiosPromise<VerifyCodeResult> {
     timeout: 20000
   });
 }
+
 /**
  * 第三方登录
- * @param source 第三方登录类型
- * */
+ */
 export function callback(data: LoginData): AxiosPromise<any> {
   const LoginData = {
     ...data,
-    clientId: 'e5cd7e4891bf95d1d19206ce24a7b32e',
+    clientId: clientId,
     grantType: 'social'
   };
   return request({

+ 1 - 1
src/layout/components/SocialLogin/index.vue → src/layout/components/SocialCallback/index.vue

@@ -1,5 +1,5 @@
 <template>
-  <div v-loading="loading" class="social-login"></div>
+  <div v-loading="loading" class="social-callback"></div>
 </template>
 
 <script setup lang="ts">

+ 1 - 1
src/permission.ts

@@ -10,7 +10,7 @@ import useSettingsStore from '@/store/modules/settings';
 import usePermissionStore from '@/store/modules/permission';
 
 NProgress.configure({ showSpinner: false });
-const whiteList = ['/login', '/register', '/social-login'];
+const whiteList = ['/login', '/register', '/social-callback'];
 
 router.beforeEach(async (to, from, next) => {
   NProgress.start();

+ 2 - 2
src/router/index.ts

@@ -38,9 +38,9 @@ export const constantRoutes: RouteOption[] = [
     ]
   },
   {
-    path: '/social-login',
+    path: '/social-callback',
     hidden: true,
-    component: () => import('@/layout/components/SocialLogin/index.vue')
+    component: () => import('@/layout/components/SocialCallback/index.vue')
   },
   {
     path: '/login',

+ 5 - 7
src/views/login.vue

@@ -4,8 +4,7 @@
       <h3 class="title">RuoYi-Vue-Plus多租户管理系统</h3>
       <el-form-item prop="tenantId" v-if="tenantEnabled">
         <el-select v-model="loginForm.tenantId" filterable placeholder="请选择/输入公司名称" style="width: 100%">
-          <el-option v-for="item in tenantList" :key="item.tenantId" :label="item.companyName"
-            :value="item.tenantId"></el-option>
+          <el-option v-for="item in tenantList" :key="item.tenantId" :label="item.companyName" :value="item.tenantId"></el-option>
           <template #prefix><svg-icon icon-class="company" class="el-input__icon input-icon" /></template>
         </el-select>
       </el-form-item>
@@ -15,14 +14,12 @@
         </el-input>
       </el-form-item>
       <el-form-item prop="password">
-        <el-input v-model="loginForm.password" type="password" size="large" auto-complete="off" placeholder="密码"
-          @keyup.enter="handleLogin">
+        <el-input v-model="loginForm.password" type="password" size="large" auto-complete="off" placeholder="密码" @keyup.enter="handleLogin">
           <template #prefix><svg-icon icon-class="password" class="el-input__icon input-icon" /></template>
         </el-input>
       </el-form-item>
       <el-form-item prop="code" v-if="captchaEnabled">
-        <el-input v-model="loginForm.code" size="large" auto-complete="off" placeholder="验证码" style="width: 63%"
-          @keyup.enter="handleLogin">
+        <el-input v-model="loginForm.code" size="large" auto-complete="off" placeholder="验证码" style="width: 63%" @keyup.enter="handleLogin">
           <template #prefix><svg-icon icon-class="validCode" class="el-input__icon input-icon" /></template>
         </el-input>
         <div class="login-code">
@@ -193,7 +190,8 @@ watch(() => loginForm.value.tenantId, (val: string) => {
 const doSocialLogin = (type: string) => {
   authBinding(type).then((res: any) => {
     if (res.code === 200) {
-      window.location.href = res.msg;
+      // 获取授权地址跳转
+      window.location.href = res.data;
     } else {
       ElMessage.error(res.msg);
     }

+ 1 - 1
src/views/system/user/profile/thirdParty.vue

@@ -80,7 +80,7 @@ const unlockAuth = (row: any) => {
 const authUrl = (source: string) => {
   authBinding(source).then((res: any) => {
     if (res.code === 200) {
-      window.location.href = res.msg;
+      window.location.href = res.data;
     } else {
       ElMessage.error(res.msg);
     }