mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2026-02-05 18:15:28 +08:00
v3.7.2 版本代码合并
This commit is contained in:
@ -4,14 +4,17 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { isOAuth2AppEnv, sysOAuth2Login } from '/@/views/sys/login/useLogin';
|
||||
import { isOAuth2AppEnv, sysOAuth2Callback, sysOAuth2Login } from '/@/views/sys/login/useLogin';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { PageEnum } from '/@/enums/pageEnum';
|
||||
import { router } from '/@/router';
|
||||
import { useUserStore } from '/@/store/modules/user';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
import {getTenantId} from "/@/utils/auth";
|
||||
import { getAuthCache, getTenantId, getToken } from "/@/utils/auth";
|
||||
import { requestAuthCode } from 'dingtalk-jsapi';
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { OAUTH2_THIRD_LOGIN_TENANT_ID } from "/@/enums/cacheEnum";
|
||||
|
||||
const isOAuth = ref<boolean>(isOAuth2AppEnv());
|
||||
const env = ref<any>({ thirdApp: false, wxWork: false, dingtalk: false });
|
||||
@ -55,7 +58,8 @@
|
||||
} else if (env.value.wxWork) {
|
||||
sysOAuth2Login('wechat_enterprise');
|
||||
} else if (env.value.dingtalk) {
|
||||
sysOAuth2Login('dingtalk');
|
||||
//新版钉钉登录
|
||||
dingdingLogin();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -84,4 +88,43 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 钉钉登录
|
||||
*/
|
||||
function dingdingLogin() {
|
||||
//先获取钉钉的企业id,如果没有配置 还是走原来的逻辑,走原来的逻辑 需要判断存不存在token,存在token直接去首页
|
||||
let tenantId = getAuthCache(OAUTH2_THIRD_LOGIN_TENANT_ID) || 0;
|
||||
let url = `/sys/thirdLogin/get/corpId/clientId?tenantId=${tenantId}`;
|
||||
//update-begin---author:wangshuai---date:2024-12-09---for:不要使用getAction online里面的,要用defHttp---
|
||||
defHttp.get({ url:url },{ isTransformResponse: false }).then((res) => {
|
||||
//update-end---author:wangshuai---date:2024-12-09---for:不要使用getAction online里面的,要用defHttp---
|
||||
if (res.success) {
|
||||
if(res.result && res.result.corpId && res.result.clientId){
|
||||
requestAuthCode({ corpId: res.result.corpId, clientId: res.result.clientId }).then((res) => {
|
||||
let { code } = res;
|
||||
sysOAuth2Callback(code);
|
||||
});
|
||||
}else{
|
||||
toOldAuthLogin();
|
||||
}
|
||||
} else {
|
||||
toOldAuthLogin();
|
||||
}
|
||||
}).catch((err) => {
|
||||
toOldAuthLogin();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 旧版钉钉登录
|
||||
*/
|
||||
function toOldAuthLogin() {
|
||||
let token = getToken();
|
||||
if (token) {
|
||||
router.replace({ path: PageEnum.BASE_HOME });
|
||||
} else {
|
||||
sysOAuth2Login('dingtalk');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user