7979 </div >
8080 </div >
8181 <div v-if =" showQrCodeTab" >
82- <QrCodeTab :tabs =" orgOptions" />
82+ <QrCodeTab :tabs =" orgOptions" />
8383 </div >
8484 <div class =" login-gradient-divider lighter mt-24" v-if =" modeList.length > 1" >
8585 <span >{{ $t('views.login.moreMethod') }}</span >
9898 'font-size': item === 'OAUTH2' ? '8px' : '10px',
9999 color: theme.themeInfo?.theme,
100100 }"
101- >{{ item }}</span
101+ >{{ item }}</span
102102 >
103103 </el-button >
104104 <el-button
108108 class =" login-button-circle color-secondary"
109109 @click =" changeMode('QR_CODE')"
110110 >
111- <img src =" @/assets/scan/icon_qr_outlined.svg" width =" 25px" />
111+ <img src =" @/assets/scan/icon_qr_outlined.svg" width =" 25px" />
112112 </el-button >
113113 <el-button
114114 v-if =" item === '' && loginMode !== ''"
125125 </login-layout >
126126</template >
127127<script setup lang="ts">
128- import { onMounted , ref , onBeforeMount } 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 } 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'
132132import LoginContainer from ' @/layout/login-layout/LoginContainer.vue'
133133import LoginLayout from ' @/layout/login-layout/LoginLayout.vue'
134134import loginApi from ' @/api/user/login'
135135import authApi from ' @/api/system-settings/auth-setting'
136- import { t , getBrowserLang } from ' @/locales'
136+ import {t , getBrowserLang } from ' @/locales'
137137import useStore from ' @/stores'
138- import { useI18n } from ' vue-i18n'
138+ import {useI18n } from ' vue-i18n'
139139import QrCodeTab from ' @/views/login/scanCompinents/QrCodeTab.vue'
140- import { MsgConfirm , MsgError } from ' @/utils/message.ts'
140+ import {MsgConfirm , MsgError } from ' @/utils/message.ts'
141141import * as dd from ' dingtalk-jsapi'
142- import { loadScript } from ' @/utils/common'
142+ import {loadScript } from ' @/utils/common'
143+ import {hasPermission } from " @/utils/permission" ;
144+ import {RoleConst } from " @/utils/permission/data.ts" ;
143145
144146const router = useRouter ()
145- const { login, user, theme } = useStore ()
146- const { locale } = useI18n ({ useScope: ' global' })
147+ const {login, user, theme} = useStore ()
148+ const {locale} = useI18n ({useScope: ' global' })
147149const loading = ref <boolean >(false )
148150
149151const identifyCode = ref <string >(' ' )
@@ -184,13 +186,18 @@ const loginHandle = () => {
184186 if (loginMode .value === ' LDAP' ) {
185187 login .asyncLdapLogin (loginForm .value , loading ).then (() => {
186188 locale .value = localStorage .getItem (' MaxKB-locale' ) || getBrowserLang () || ' en-US'
187- router .push ({ name: ' home' })
189+ router .push ({name: ' home' })
188190 })
189191 } else {
190192 login .asyncLogin (loginForm .value , loading ).then (() => {
191193 locale .value = localStorage .getItem (' MaxKB-locale' ) || getBrowserLang () || ' en-US'
192194 localStorage .setItem (' workspace_id' , ' default' )
193- router .push ({ name: ' home' })
195+ if (hasPermission ([RoleConst .ADMIN , RoleConst .EXTENDS_ADMIN ], ' OR' )) {
196+ router .push ({name: ' user' })
197+ } else {
198+ router .push ({name: ' home' })
199+ }
200+
194201 })
195202 }
196203 })
@@ -273,7 +280,8 @@ function redirectAuth(authType: string) {
273280 window .location .href = url
274281 }
275282 })
276- .catch (() => {})
283+ .catch (() => {
284+ })
277285 })
278286}
279287
@@ -348,10 +356,10 @@ onMounted(() => {
348356 const handleDingTalk = () => {
349357 const code = params .get (' corpId' )
350358 if (code ) {
351- dd .runtime .permission .requestAuthCode ({ corpId: code }).then ((res ) => {
359+ dd .runtime .permission .requestAuthCode ({corpId: code }).then ((res ) => {
352360 console .log (' DingTalk client request success:' , res )
353361 login .dingOauth2Callback (res .code ).then (() => {
354- router .push ({ name: ' home' })
362+ router .push ({name: ' home' })
355363 })
356364 })
357365 }
@@ -364,7 +372,7 @@ onMounted(() => {
364372 appId: appId ,
365373 success : (res : any ) => {
366374 login .larkCallback (res .code ).then (() => {
367- router .push ({ name: ' home' })
375+ router .push ({name: ' home' })
368376 })
369377 },
370378 fail : (error : any ) => {
@@ -384,11 +392,11 @@ onMounted(() => {
384392 scopeList: [],
385393 success : (res : any ) => {
386394 login .larkCallback (res .code ).then (() => {
387- router .push ({ name: ' home' })
395+ router .push ({name: ' home' })
388396 })
389397 },
390398 fail : (error : any ) => {
391- const { errno } = error
399+ const {errno} = error
392400 if (errno === 103 ) {
393401 callRequestAuthCode ()
394402 }
0 commit comments