Commit 90db83e12e3d8e74d8d2f3786f197a2ed2e23c6f
1 parent
9c43d9fa
feat: add qrcode login
Showing
7 changed files
with
49 additions
and
8 deletions
yudao-ui-admin-vue3/src/locales/en.ts
| @@ -124,6 +124,7 @@ export default { | @@ -124,6 +124,7 @@ export default { | ||
| 124 | getSmsCode: 'Get SMS Code', | 124 | getSmsCode: 'Get SMS Code', |
| 125 | btnMobile: 'Mobile sign in', | 125 | btnMobile: 'Mobile sign in', |
| 126 | btnQRCode: 'QR code sign in', | 126 | btnQRCode: 'QR code sign in', |
| 127 | + qrcode: 'Scan the QR code to log in', | ||
| 127 | btnRegister: 'Sign up', | 128 | btnRegister: 'Sign up', |
| 128 | SmsSendMsg: 'code has been sent' | 129 | SmsSendMsg: 'code has been sent' |
| 129 | }, | 130 | }, |
yudao-ui-admin-vue3/src/locales/zh-CN.ts
| @@ -124,6 +124,7 @@ export default { | @@ -124,6 +124,7 @@ export default { | ||
| 124 | getSmsCode: '获取验证码', | 124 | getSmsCode: '获取验证码', |
| 125 | btnMobile: '手机登录', | 125 | btnMobile: '手机登录', |
| 126 | btnQRCode: '二维码登录', | 126 | btnQRCode: '二维码登录', |
| 127 | + qrcode: '扫描二维码登录', | ||
| 127 | btnRegister: '注册', | 128 | btnRegister: '注册', |
| 128 | SmsSendMsg: '验证码已发送' | 129 | SmsSendMsg: '验证码已发送' |
| 129 | }, | 130 | }, |
yudao-ui-admin-vue3/src/views/Login/Login.vue
| 1 | <script setup lang="ts"> | 1 | <script setup lang="ts"> |
| 2 | -import { LoginForm, MobileForm, RegisterForm } from './components' | 2 | +import { LoginForm, MobileForm, RegisterForm, QrCodeForm } from './components' |
| 3 | import { ThemeSwitch } from '@/components/ThemeSwitch' | 3 | import { ThemeSwitch } from '@/components/ThemeSwitch' |
| 4 | import { LocaleDropdown } from '@/components/LocaleDropdown' | 4 | import { LocaleDropdown } from '@/components/LocaleDropdown' |
| 5 | import { useI18n } from '@/hooks/web/useI18n' | 5 | import { useI18n } from '@/hooks/web/useI18n' |
| @@ -66,6 +66,8 @@ const appStore = useAppStore() | @@ -66,6 +66,8 @@ const appStore = useAppStore() | ||
| 66 | <LoginForm class="p-20px h-auto m-auto <xl:(rounded-3xl light:bg-white)" /> | 66 | <LoginForm class="p-20px h-auto m-auto <xl:(rounded-3xl light:bg-white)" /> |
| 67 | <!-- 手机登录 --> | 67 | <!-- 手机登录 --> |
| 68 | <MobileForm class="p-20px h-auto m-auto <xl:(rounded-3xl light:bg-white)" /> | 68 | <MobileForm class="p-20px h-auto m-auto <xl:(rounded-3xl light:bg-white)" /> |
| 69 | + <!-- 二维码登录 --> | ||
| 70 | + <QrCodeForm class="p-20px h-auto m-auto <xl:(rounded-3xl light:bg-white)" /> | ||
| 69 | <!-- 注册 --> | 71 | <!-- 注册 --> |
| 70 | <RegisterForm class="p-20px h-auto m-auto <xl:(rounded-3xl light:bg-white)" /> | 72 | <RegisterForm class="p-20px h-auto m-auto <xl:(rounded-3xl light:bg-white)" /> |
| 71 | </div> | 73 | </div> |
yudao-ui-admin-vue3/src/views/Login/components/LoginForm.vue
| @@ -246,7 +246,9 @@ onMounted(async () => { | @@ -246,7 +246,9 @@ onMounted(async () => { | ||
| 246 | </el-button> | 246 | </el-button> |
| 247 | </el-col> | 247 | </el-col> |
| 248 | <el-col :span="8"> | 248 | <el-col :span="8"> |
| 249 | - <el-button class="w-[100%]">{{ t('login.btnQRCode') }}</el-button> | 249 | + <el-button class="w-[100%]" @click="setLoginState(LoginStateEnum.QR_CODE)"> |
| 250 | + {{ t('login.btnQRCode') }} | ||
| 251 | + </el-button> | ||
| 250 | </el-col> | 252 | </el-col> |
| 251 | <el-col :span="8"> | 253 | <el-col :span="8"> |
| 252 | <el-button class="w-[100%]" @click="setLoginState(LoginStateEnum.REGISTER)"> | 254 | <el-button class="w-[100%]" @click="setLoginState(LoginStateEnum.REGISTER)"> |
yudao-ui-admin-vue3/src/views/Login/components/QrCodeForm.vue
0 → 100644
| 1 | +<script setup lang="ts"> | ||
| 2 | +import { computed, unref } from 'vue' | ||
| 3 | +import { ElRow, ElCol, ElCard, ElDivider } from 'element-plus' | ||
| 4 | +import { useI18n } from '@/hooks/web/useI18n' | ||
| 5 | +import { useLoginState, LoginStateEnum } from './useLogin' | ||
| 6 | +import LoginFormTitle from './LoginFormTitle.vue' | ||
| 7 | +import { Qrcode } from '@/components/Qrcode' | ||
| 8 | +import logoImg from '@/assets/imgs/logo.png' | ||
| 9 | + | ||
| 10 | +const { t } = useI18n() | ||
| 11 | +const { handleBackLogin, getLoginState } = useLoginState() | ||
| 12 | +const getShow = computed(() => unref(getLoginState) === LoginStateEnum.QR_CODE) | ||
| 13 | +</script> | ||
| 14 | + | ||
| 15 | +<template> | ||
| 16 | + <el-row v-show="getShow" style="maring-left: -10px; maring-right: -10px"> | ||
| 17 | + <el-col :span="24" style="padding-left: 10px; padding-right: 10px"> | ||
| 18 | + <LoginFormTitle style="width: 100%" /> | ||
| 19 | + </el-col> | ||
| 20 | + <el-col :span="24" style="padding-left: 10px; padding-right: 10px"> | ||
| 21 | + <el-card shadow="hover" class="mb-10px text-center"> | ||
| 22 | + <Qrcode :logo="logoImg" /> | ||
| 23 | + </el-card> | ||
| 24 | + </el-col> | ||
| 25 | + <el-divider class="enter-x">{{ t('login.qrcode') }}</el-divider> | ||
| 26 | + <el-col :span="24" style="padding-left: 10px; padding-right: 10px"> | ||
| 27 | + <div class="w-[100%] mt-15px"> | ||
| 28 | + <el-button class="w-[100%]" @click="handleBackLogin"> | ||
| 29 | + {{ t('sys.login.backSignIn') }} | ||
| 30 | + </el-button> | ||
| 31 | + </div> | ||
| 32 | + </el-col> | ||
| 33 | + </el-row> | ||
| 34 | +</template> |
yudao-ui-admin-vue3/src/views/Login/components/RegisterForm.vue
| @@ -121,20 +121,20 @@ const loginRegister = async () => { | @@ -121,20 +121,20 @@ const loginRegister = async () => { | ||
| 121 | 121 | ||
| 122 | <template #code="form"> | 122 | <template #code="form"> |
| 123 | <div class="w-[100%] flex"> | 123 | <div class="w-[100%] flex"> |
| 124 | - <ElInput v-model="form['code']" :placeholder="t('login.codePlaceholder')" /> | 124 | + <el-input v-model="form['code']" :placeholder="t('login.codePlaceholder')" /> |
| 125 | </div> | 125 | </div> |
| 126 | </template> | 126 | </template> |
| 127 | 127 | ||
| 128 | <template #register> | 128 | <template #register> |
| 129 | <div class="w-[100%]"> | 129 | <div class="w-[100%]"> |
| 130 | - <ElButton type="primary" class="w-[100%]" :loading="loading" @click="loginRegister"> | 130 | + <el-button type="primary" class="w-[100%]" :loading="loading" @click="loginRegister"> |
| 131 | {{ t('login.register') }} | 131 | {{ t('login.register') }} |
| 132 | - </ElButton> | 132 | + </el-button> |
| 133 | </div> | 133 | </div> |
| 134 | <div class="w-[100%] mt-15px"> | 134 | <div class="w-[100%] mt-15px"> |
| 135 | - <ElButton class="w-[100%]" @click="handleBackLogin"> | 135 | + <el-button class="w-[100%]" @click="handleBackLogin"> |
| 136 | {{ t('login.hasUser') }} | 136 | {{ t('login.hasUser') }} |
| 137 | - </ElButton> | 137 | + </el-button> |
| 138 | </div> | 138 | </div> |
| 139 | </template> | 139 | </template> |
| 140 | </Form> | 140 | </Form> |
yudao-ui-admin-vue3/src/views/Login/components/index.ts
| @@ -2,5 +2,6 @@ import LoginForm from './LoginForm.vue' | @@ -2,5 +2,6 @@ import LoginForm from './LoginForm.vue' | ||
| 2 | import MobileForm from './MobileForm.vue' | 2 | import MobileForm from './MobileForm.vue' |
| 3 | import LoginFormTitle from './LoginFormTitle.vue' | 3 | import LoginFormTitle from './LoginFormTitle.vue' |
| 4 | import RegisterForm from './RegisterForm.vue' | 4 | import RegisterForm from './RegisterForm.vue' |
| 5 | +import QrCodeForm from './QrCodeForm.vue' | ||
| 5 | 6 | ||
| 6 | -export { LoginForm, MobileForm, LoginFormTitle, RegisterForm } | 7 | +export { LoginForm, MobileForm, LoginFormTitle, RegisterForm, QrCodeForm } |