From c720b1dff9cb1f44719f8cd9ae84eca5e4cf4593 Mon Sep 17 00:00:00 2001 From: xingyu Date: Tue, 6 Dec 2022 21:30:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=B8=89=E6=96=B9=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E6=9C=AA=E6=90=BA=E5=B8=A6=E7=A7=9F=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-ui-admin-vue3/src/api/login/index.ts | 2 +- .../src/views/Login/components/LoginForm.vue | 123 +++++++++++------- yudao-ui-admin/src/views/login.vue | 48 +++++-- 3 files changed, 110 insertions(+), 63 deletions(-) diff --git a/yudao-ui-admin-vue3/src/api/login/index.ts b/yudao-ui-admin-vue3/src/api/login/index.ts index 36b7d01c4..6ff93e428 100644 --- a/yudao-ui-admin-vue3/src/api/login/index.ts +++ b/yudao-ui-admin-vue3/src/api/login/index.ts @@ -57,7 +57,7 @@ export const smsLoginApi = (data: SmsLoginVO) => { } // 社交授权的跳转 -export const socialAuthRedirectApi = (type: string, redirectUri: string) => { +export const socialAuthRedirectApi = (type: number, redirectUri: string) => { return request.get({ url: '/system/auth/social-auth-redirect?type=' + type + '&redirectUri=' + redirectUri }) diff --git a/yudao-ui-admin-vue3/src/views/Login/components/LoginForm.vue b/yudao-ui-admin-vue3/src/views/Login/components/LoginForm.vue index 124cc5fb1..b6a99f04a 100644 --- a/yudao-ui-admin-vue3/src/views/Login/components/LoginForm.vue +++ b/yudao-ui-admin-vue3/src/views/Login/components/LoginForm.vue @@ -16,7 +16,7 @@ - + - - {{ t('login.login') }} - + - - {{ t('login.btnMobile') }} - + - - {{ t('login.btnQRCode') }} - + - - {{ t('login.btnRegister') }} - + @@ -103,32 +113,13 @@
- - -
@@ -154,6 +145,7 @@ import { useRouter } from 'vue-router' import type { RouteLocationNormalizedLoaded } from 'vue-router' import { useI18n } from '@/hooks/web/useI18n' import { useIcon } from '@/hooks/web/useIcon' +import { useMessage } from '@/hooks/web/useMessage' import { required } from '@/utils/formRules' import * as authUtil from '@/utils/auth' import { decrypt } from '@/utils/jsencrypt' @@ -162,8 +154,13 @@ import { Verify } from '@/components/Verifition' import { usePermissionStore } from '@/store/modules/permission' import * as LoginApi from '@/api/login' import { LoginStateEnum, useLoginState, useFormValid } from './useLogin' +import { XButton } from '@/components/XButton' const { t } = useI18n() +const message = useMessage() +const iconHouse = useIcon({ icon: 'ep:house' }) +const iconAvatar = useIcon({ icon: 'ep:avatar' }) +const iconLock = useIcon({ icon: 'ep:lock' }) const formLogin = ref() const { validForm } = useFormValid(formLogin) const { setLoginState, getLoginState } = useLoginState() @@ -171,9 +168,6 @@ const { currentRoute, push } = useRouter() const permissionStore = usePermissionStore() const redirect = ref('') const loginLoading = ref(false) -const iconHouse = useIcon({ icon: 'ep:house' }) -const iconAvatar = useIcon({ icon: 'ep:avatar' }) -const iconLock = useIcon({ icon: 'ep:lock' }) const verify = ref() const captchaType = ref('blockPuzzle') // blockPuzzle 滑块 clickWord 点击文字 @@ -201,6 +195,25 @@ const loginData = reactive({ } }) +const socialList = [ + { + icon: 'ant-design:github-filled', + type: 0 + }, + { + icon: 'ant-design:wechat-filled', + type: 30 + }, + { + icon: 'ant-design:alipay-circle-filled', + type: 0 + }, + { + icon: 'ant-design:dingtalk-circle-filled', + type: 20 + } +] + // 获取验证码 const getCode = async () => { // 情况一,未开启:则直接登录 @@ -214,8 +227,10 @@ const getCode = async () => { } //获取租户ID const getTenantId = async () => { - const res = await LoginApi.getTenantIdByNameApi(loginData.loginForm.tenantName) - authUtil.setTenantId(res) + if (loginData.tenantEnable === 'true') { + const res = await LoginApi.getTenantIdByNameApi(loginData.loginForm.tenantName) + authUtil.setTenantId(res) + } } // 记住我 const getCookie = () => { @@ -279,14 +294,24 @@ const handleLogin = async (params) => { } // 社交登录 -const doSocialLogin = async (type: string) => { - loginLoading.value = true - // 计算 redirectUri - const redirectUri = - location.origin + '/social-login?type=' + type + '&redirect=' + (redirect.value || '/') - // 进行跳转 - const res = await LoginApi.socialAuthRedirectApi(type, encodeURIComponent(redirectUri)) - window.location.href = res +const doSocialLogin = async (type: number) => { + if (type === 0) { + message.error('此方式未配置') + } else { + loginLoading.value = true + if (loginData.tenantEnable === 'true') { + await message.prompt('请输入租户名称', t('common.reminder')).then(async ({ value }) => { + const res = await LoginApi.getTenantIdByNameApi(value) + authUtil.setTenantId(res) + }) + } + // 计算 redirectUri + const redirectUri = + location.origin + '/social-login?type=' + type + '&redirect=' + (redirect.value || '/') + // 进行跳转 + const res = await LoginApi.socialAuthRedirectApi(type, encodeURIComponent(redirectUri)) + window.location.href = res + } } watch( () => currentRoute.value, diff --git a/yudao-ui-admin/src/views/login.vue b/yudao-ui-admin/src/views/login.vue index 280cbd2d7..b7b76aaba 100644 --- a/yudao-ui-admin/src/views/login.vue +++ b/yudao-ui-admin/src/views/login.vue @@ -53,10 +53,10 @@ -