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
yudao-ui-admin-vue3/src/locales/zh-CN.ts
yudao-ui-admin-vue3/src/views/Login/Login.vue
| 1 | 1 | <script setup lang="ts"> |
| 2 | -import { LoginForm, MobileForm, RegisterForm } from './components' | |
| 2 | +import { LoginForm, MobileForm, RegisterForm, QrCodeForm } from './components' | |
| 3 | 3 | import { ThemeSwitch } from '@/components/ThemeSwitch' |
| 4 | 4 | import { LocaleDropdown } from '@/components/LocaleDropdown' |
| 5 | 5 | import { useI18n } from '@/hooks/web/useI18n' |
| ... | ... | @@ -66,6 +66,8 @@ const appStore = useAppStore() |
| 66 | 66 | <LoginForm class="p-20px h-auto m-auto <xl:(rounded-3xl light:bg-white)" /> |
| 67 | 67 | <!-- 手机登录 --> |
| 68 | 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 | 72 | <RegisterForm class="p-20px h-auto m-auto <xl:(rounded-3xl light:bg-white)" /> |
| 71 | 73 | </div> | ... | ... |
yudao-ui-admin-vue3/src/views/Login/components/LoginForm.vue
| ... | ... | @@ -246,7 +246,9 @@ onMounted(async () => { |
| 246 | 246 | </el-button> |
| 247 | 247 | </el-col> |
| 248 | 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 | 252 | </el-col> |
| 251 | 253 | <el-col :span="8"> |
| 252 | 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 | 121 | |
| 122 | 122 | <template #code="form"> |
| 123 | 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 | 125 | </div> |
| 126 | 126 | </template> |
| 127 | 127 | |
| 128 | 128 | <template #register> |
| 129 | 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 | 131 | {{ t('login.register') }} |
| 132 | - </ElButton> | |
| 132 | + </el-button> | |
| 133 | 133 | </div> |
| 134 | 134 | <div class="w-[100%] mt-15px"> |
| 135 | - <ElButton class="w-[100%]" @click="handleBackLogin"> | |
| 135 | + <el-button class="w-[100%]" @click="handleBackLogin"> | |
| 136 | 136 | {{ t('login.hasUser') }} |
| 137 | - </ElButton> | |
| 137 | + </el-button> | |
| 138 | 138 | </div> |
| 139 | 139 | </template> |
| 140 | 140 | </Form> | ... | ... |
yudao-ui-admin-vue3/src/views/Login/components/index.ts
| ... | ... | @@ -2,5 +2,6 @@ import LoginForm from './LoginForm.vue' |
| 2 | 2 | import MobileForm from './MobileForm.vue' |
| 3 | 3 | import LoginFormTitle from './LoginFormTitle.vue' |
| 4 | 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 } | ... | ... |