@@ -17,6 +17,9 @@ const banner = new URL('../assets/images/login-banner.png', import.meta.url).hre
1717const logo = new URL (' ../assets/images/logo.png' , import .meta .url ).href
1818const title = import .meta .env .VITE_APP_TITLE
1919
20+ // 登录方式,default 账号密码登录,qrcode 扫码登录
21+ const loginType = ref (' default' )
22+
2023// 表单类型,login 登录,register 注册,reset 重置密码
2124const formType = ref (' login' )
2225const loading = ref (false )
@@ -150,44 +153,62 @@ function testAccount(account: string) {
150153 <img :src =" banner" class =" banner" >
151154 </div >
152155 <ElForm v-show =" formType === 'login'" ref =" loginFormRef" :model =" loginForm" :rules =" loginRules" class =" login-form" >
153- <div class =" title-container" >
154- <h3 class =" title" >
155- 欢迎来到 {{ title }} ! 👋🏻
156- </h3 >
157- </div >
158- <div >
159- <ElFormItem prop =" account" >
160- <ElInput v-model =" loginForm.account" placeholder =" 用户名" type =" text" tabindex =" 1" >
161- <template #prefix >
162- <SvgIcon name =" i-ep:user" />
163- </template >
164- </ElInput >
165- </ElFormItem >
166- <ElFormItem prop =" password" >
167- <ElInput v-model =" loginForm.password" type =" password" placeholder =" 密码" tabindex =" 2" show-password @keyup.enter =" handleLogin" >
168- <template #prefix >
169- <SvgIcon name =" i-ep:lock" />
170- </template >
171- </ElInput >
172- </ElFormItem >
173- </div >
174- <div class =" flex-bar" >
175- <ElCheckbox v-model =" loginForm.remember" >
176- 记住我
177- </ElCheckbox >
178- <ElLink type =" primary" :underline =" false" @click =" formType = 'reset'" >
179- 忘记密码了?
180- </ElLink >
181- </div >
182- <ElButton :loading =" loading" type =" primary" size =" large" style =" width : 100% ;" @click.prevent =" handleLogin" >
183- 登录
184- </ElButton >
185- <div class =" sub-link" >
186- <span class =" text" >还没有帐号?</span >
187- <ElLink type =" primary" :underline =" false" @click =" formType = 'register'" >
188- 创建新帐号
189- </ElLink >
156+ <div class =" mb-6" >
157+ <HTabList
158+ v-model =" loginType" :options =" [
159+ { label: '账号密码登录', value: 'default' },
160+ { label: '扫码登录', value: 'qrcode' },
161+ ]"
162+ />
190163 </div >
164+ <template v-if =" loginType === ' default' " >
165+ <div class =" title-container" >
166+ <h3 class =" title" >
167+ 欢迎来到 {{ title }} ! 👋🏻
168+ </h3 >
169+ </div >
170+ <div >
171+ <ElFormItem prop =" account" >
172+ <ElInput v-model =" loginForm.account" placeholder =" 用户名" type =" text" tabindex =" 1" >
173+ <template #prefix >
174+ <SvgIcon name =" i-ep:user" />
175+ </template >
176+ </ElInput >
177+ </ElFormItem >
178+ <ElFormItem prop =" password" >
179+ <ElInput v-model =" loginForm.password" type =" password" placeholder =" 密码" tabindex =" 2" show-password @keyup.enter =" handleLogin" >
180+ <template #prefix >
181+ <SvgIcon name =" i-ep:lock" />
182+ </template >
183+ </ElInput >
184+ </ElFormItem >
185+ </div >
186+ <div class =" flex-bar" >
187+ <ElCheckbox v-model =" loginForm.remember" >
188+ 记住我
189+ </ElCheckbox >
190+ <ElLink type =" primary" :underline =" false" @click =" formType = 'reset'" >
191+ 忘记密码了?
192+ </ElLink >
193+ </div >
194+ <ElButton :loading =" loading" type =" primary" size =" large" style =" width : 100% ;" @click.prevent =" handleLogin" >
195+ 登录
196+ </ElButton >
197+ <div class =" sub-link" >
198+ <span class =" text" >还没有帐号?</span >
199+ <ElLink type =" primary" :underline =" false" @click =" formType = 'register'" >
200+ 创建新帐号
201+ </ElLink >
202+ </div >
203+ </template >
204+ <template v-else-if =" loginType === ' qrcode' " >
205+ <div class =" flex flex-col items-center" >
206+ <el-image src =" https://s2.loli.net/2024/04/26/GsahtuIZ9XOg5jr.png" class =" h-[250px] w-[250px]" />
207+ <div class =" mt-2 op-50" >
208+ 请使用微信扫码登录
209+ </div >
210+ </div >
211+ </template >
191212 <div style =" margin-top : 20px ; margin-bottom : -20px ; text-align : center ;" >
192213 <ElDivider >演示账号一键登录</ElDivider >
193214 <ElButton type =" primary" size =" small" plain @click =" testAccount('admin')" >
0 commit comments