79
79
</div >
80
80
</div >
81
81
<div v-if =" showQrCodeTab" >
82
- <QrCodeTab :tabs =" orgOptions" />
82
+ <QrCodeTab :tabs =" orgOptions" />
83
83
</div >
84
84
<div class =" login-gradient-divider lighter mt-24" v-if =" modeList.length > 1" >
85
85
<span >{{ $t('views.login.moreMethod') }}</span >
98
98
'font-size': item === 'OAUTH2' ? '8px' : '10px',
99
99
color: theme.themeInfo?.theme,
100
100
}"
101
- >{{ item }}</span
101
+ >{{ item }}</span
102
102
>
103
103
</el-button >
104
104
<el-button
108
108
class =" login-button-circle color-secondary"
109
109
@click =" changeMode('QR_CODE')"
110
110
>
111
- <img src =" @/assets/icon_qr_outlined.svg" width =" 25px" />
111
+ <img src =" @/assets/icon_qr_outlined.svg" width =" 25px" />
112
112
</el-button >
113
113
<el-button
114
114
v-if =" item === '' && loginMode !== ''"
125
125
</login-layout >
126
126
</template >
127
127
<script setup lang="ts">
128
- import {onMounted , ref , onBeforeMount , computed } from ' vue'
129
- import {useRoute , useRouter } from ' vue-router'
130
- import type {FormInstance , FormRules } from ' element-plus'
131
- import type {LoginRequest } from ' @/api/type/login'
128
+ import { onMounted , ref , onBeforeMount , computed } from ' vue'
129
+ import { useRoute , useRouter } from ' vue-router'
130
+ import type { FormInstance , FormRules } from ' element-plus'
131
+ import type { LoginRequest } from ' @/api/type/login'
132
132
import LoginContainer from ' @/layout/login-layout/LoginContainer.vue'
133
133
import LoginLayout from ' @/layout/login-layout/LoginLayout.vue'
134
134
import loginApi from ' @/api/user/login'
135
135
import authApi from ' @/api/system-settings/auth-setting'
136
- import {t , getBrowserLang } from ' @/locales'
136
+ import { t , getBrowserLang } from ' @/locales'
137
137
import useStore from ' @/stores'
138
- import {useI18n } from ' vue-i18n'
138
+ import { useI18n } from ' vue-i18n'
139
139
import QrCodeTab from ' @/views/login/scanCompinents/QrCodeTab.vue'
140
- import {MsgConfirm , MsgError } from ' @/utils/message.ts'
140
+ import { MsgConfirm , MsgError } from ' @/utils/message.ts'
141
141
import * as dd from ' dingtalk-jsapi'
142
- import {loadScript } from ' @/utils/common'
143
- import {hasPermission } from " @/utils/permission" ;
144
- import {RoleConst } from " @/utils/permission/data.ts" ;
142
+ import { loadScript } from ' @/utils/common'
145
143
146
144
const router = useRouter ()
147
- const {login, user, theme} = useStore ()
148
- const {locale} = useI18n ({useScope: ' global' })
145
+ const { login, user, theme } = useStore ()
146
+ const { locale } = useI18n ({ useScope: ' global' })
149
147
const loading = ref <boolean >(false )
150
148
151
149
const identifyCode = ref <string >(' ' )
@@ -182,20 +180,32 @@ const rules = ref<FormRules<LoginRequest>>({
182
180
})
183
181
184
182
const loginHandle = () => {
185
- loginFormRef .value ?.validate ().then (() => {
186
- if (loginMode .value === ' LDAP' ) {
187
- login .asyncLdapLogin (loginForm .value , loading ).then (() => {
188
- locale .value = localStorage .getItem (' MaxKB-locale' ) || getBrowserLang () || ' en-US'
189
- router .push ({name: ' home' })
190
- })
191
- } else {
192
- login .asyncLogin (loginForm .value , loading ).then (() => {
193
- locale .value = localStorage .getItem (' MaxKB-locale' ) || getBrowserLang () || ' en-US'
194
- localStorage .setItem (' workspace_id' , ' default' )
195
- router .push ({name: ' home' })
196
- })
197
- }
198
- })
183
+ loading .value = true
184
+ loginFormRef .value
185
+ ?.validate ()
186
+ .then (() => {
187
+ if (loginMode .value === ' LDAP' ) {
188
+ login .asyncLdapLogin (loginForm .value ).then (() => {
189
+ locale .value = localStorage .getItem (' MaxKB-locale' ) || getBrowserLang () || ' en-US'
190
+ loading .value = false
191
+ router .push ({ name: ' home' })
192
+ }).catch (() => {
193
+ loading .value = false
194
+ })
195
+ } else {
196
+ login .asyncLogin (loginForm .value ).then (() => {
197
+ locale .value = localStorage .getItem (' MaxKB-locale' ) || getBrowserLang () || ' en-US'
198
+ localStorage .setItem (' workspace_id' , ' default' )
199
+ loading .value = false
200
+ router .push ({ name: ' home' })
201
+ }).catch (() => {
202
+ loading .value = false
203
+ })
204
+ }
205
+ })
206
+ .catch (() => {
207
+ loading .value = false
208
+ })
199
209
}
200
210
201
211
function makeCode() {
@@ -227,13 +237,13 @@ function uuidv4() {
227
237
return v .toString (16 )
228
238
})
229
239
}
230
- const newDefaultSlogan= computed (()=> {
231
- const default_login= ' 强大易用的企业级智能体平台'
232
- if (! theme .themeInfo ?.slogan || default_login == theme .themeInfo ?.slogan ){
233
- return t (' theme.defaultSlogan' )
234
- } else {
235
- return theme .themeInfo ?.slogan
236
- }
240
+ const newDefaultSlogan = computed (() => {
241
+ const default_login = ' 强大易用的企业级智能体平台'
242
+ if (! theme .themeInfo ?.slogan || default_login == theme .themeInfo ?.slogan ) {
243
+ return t (' theme.defaultSlogan' )
244
+ } else {
245
+ return theme .themeInfo ?.slogan
246
+ }
237
247
})
238
248
function redirectAuth(authType : string ) {
239
249
if (authType === ' LDAP' || authType === ' ' ) {
@@ -282,8 +292,7 @@ function redirectAuth(authType: string) {
282
292
window .location .href = url
283
293
}
284
294
})
285
- .catch (() => {
286
- })
295
+ .catch (() => {})
287
296
})
288
297
}
289
298
@@ -358,10 +367,10 @@ onMounted(() => {
358
367
const handleDingTalk = () => {
359
368
const code = params .get (' corpId' )
360
369
if (code ) {
361
- dd .runtime .permission .requestAuthCode ({corpId: code }).then ((res ) => {
370
+ dd .runtime .permission .requestAuthCode ({ corpId: code }).then ((res ) => {
362
371
console .log (' DingTalk client request success:' , res )
363
372
login .dingOauth2Callback (res .code ).then (() => {
364
- router .push ({name: ' home' })
373
+ router .push ({ name: ' home' })
365
374
})
366
375
})
367
376
}
@@ -374,7 +383,7 @@ onMounted(() => {
374
383
appId: appId ,
375
384
success : (res : any ) => {
376
385
login .larkCallback (res .code ).then (() => {
377
- router .push ({name: ' home' })
386
+ router .push ({ name: ' home' })
378
387
})
379
388
},
380
389
fail : (error : any ) => {
@@ -394,11 +403,11 @@ onMounted(() => {
394
403
scopeList: [],
395
404
success : (res : any ) => {
396
405
login .larkCallback (res .code ).then (() => {
397
- router .push ({name: ' home' })
406
+ router .push ({ name: ' home' })
398
407
})
399
408
},
400
409
fail : (error : any ) => {
401
- const {errno} = error
410
+ const { errno } = error
402
411
if (errno === 103 ) {
403
412
callRequestAuthCode ()
404
413
}
0 commit comments