@@ -19,7 +19,7 @@ interface AccountLoginForm {
1919
2020defineOptions ({ name: ' AccountLogin' })
2121
22- const props = defineProps <{ loginConfig? : LoginConfig }>()
22+ const props = withDefaults ( defineProps <{ loginConfig? : LoginConfig ; preview ? : boolean }>(), { preview: false } )
2323
2424const route = useRoute ()
2525const router = useRouter ()
@@ -50,6 +50,7 @@ const accountLoginRules = reactive<FormRules<AccountLoginForm>>({
5050})
5151
5252const handleLogin = async () => {
53+ if (props .preview ) return
5354 if (! accountLoginFormRef .value ) return
5455
5556 await accountLoginFormRef .value .validate ((valid ) => {
@@ -88,13 +89,15 @@ const handleLogin = async () => {
8889}
8990
9091const refreshCaptcha = () => {
92+ if (props .preview ) return
9193 if (loginMethod .value === LOGIN_METHOD .LDAP ) return
9294 LoginApi .getCaptcha (accountLoginForm .username ).then ((res ) => {
9395 identifyCode .value = res .captcha
9496 })
9597}
9698
9799const selectLoginMethod = (method : LoginMethod ) => {
100+ if (props .preview ) return
98101 if (method !== LOGIN_METHOD .LOCAL && method !== LOGIN_METHOD .LDAP ) {
99102 void redirectExternalLogin (method , true )
100103 return
@@ -149,6 +152,7 @@ const getExternalLoginUrl = (authType: LoginMethod): Promise<string> => {
149152}
150153
151154onMounted (() => {
155+ if (props .preview ) return
152156 const loginMethods = accountLoginMethods .value
153157 if (route .query .login_mode !== ' manual' ) {
154158 const loginMethod = loginMethods [0 ]
@@ -160,22 +164,45 @@ onMounted(() => {
160164 </script >
161165
162166<template >
163- <div class =" flex h-full flex-col" >
167+ <div class =" account-login flex h-full flex-col" :class = " { 'is-preview': preview } " >
164168 <div class =" min-h-0 flex-1" >
165169 <h2 class =" mb-4" >
166170 {{ loginMethod === LOGIN_METHOD.LDAP ? 'LDAP 登录' : LOGIN_METHOD_LABELS[loginMethod] }}
167171 </h2 >
168172
169- <el-form ref =" accountLoginFormRef" :model =" accountLoginForm" :rules =" accountLoginRules" class =" login-form" @submit.prevent =" handleLogin" size =" large" >
173+ <el-form
174+ ref =" accountLoginFormRef"
175+ :model =" accountLoginForm"
176+ :rules =" accountLoginRules"
177+ :autocomplete =" preview ? 'off' : undefined"
178+ class =" login-form"
179+ size =" large"
180+ @submit.prevent =" handleLogin"
181+ >
170182 <el-form-item prop =" username" >
171- <el-input v-model =" accountLoginForm.username" placeholder =" 请输入用户名" @blur =" refreshCaptcha" />
183+ <el-input
184+ v-model =" accountLoginForm.username"
185+ :autocomplete =" preview ? 'off' : 'username'"
186+ :disabled =" preview"
187+ :readonly =" preview"
188+ placeholder =" 请输入用户名"
189+ @blur =" refreshCaptcha"
190+ />
172191 </el-form-item >
173192 <el-form-item prop =" password" >
174- <el-input v-model =" accountLoginForm.password" placeholder =" 请输入密码" show-password type =" password" />
193+ <el-input
194+ v-model =" accountLoginForm.password"
195+ :autocomplete =" preview ? 'new-password' : 'current-password'"
196+ :disabled =" preview"
197+ :readonly =" preview"
198+ placeholder =" 请输入密码"
199+ show-password
200+ type =" password"
201+ />
175202 </el-form-item >
176203 <div v-if =" loginMethod !== LOGIN_METHOD.LDAP && identifyCode" class =" flex gap-2" >
177204 <el-form-item prop =" captcha" class =" flex-1" >
178- <el-input v-model =" accountLoginForm.captcha" autocomplete =" off" placeholder =" 请输入验证码" />
205+ <el-input v-model =" accountLoginForm.captcha" autocomplete =" off" :disabled = " preview " placeholder =" 请输入验证码" :readonly = " preview " />
179206 </el-form-item >
180207 <img :src =" identifyCode" alt =" 验证码" class =" w-35 h-10 cursor-pointer border" @click =" refreshCaptcha" />
181208 </div >
@@ -199,4 +226,10 @@ onMounted(() => {
199226 </div >
200227</template >
201228
202- <style scoped lang="scss"></style >
229+ <style scoped lang="scss">
230+ .account-login.is-preview :deep(.el-input.is-disabled ) {
231+ .el-input__wrapper {
232+ background-color : var (--el-fill-color-blank );
233+ }
234+ }
235+ </style >
0 commit comments