feat(xpack): 钉钉工作台免登进入DataEase

This commit is contained in:
fit2cloud-chenyw 2022-12-05 13:44:59 +08:00
parent 0aabb23165
commit 4d4807b821
5 changed files with 90 additions and 8 deletions

View File

@ -80,8 +80,7 @@ public class XDingtalkServer {
return dingtalkXpackService.getQrParam();
}
@GetMapping("/callBack")
public ModelAndView callBack(@RequestParam("code") String code, @RequestParam("state") String state) {
private ModelAndView privateCallBack(String code, Boolean withoutLogin) {
ModelAndView modelAndView = new ModelAndView("redirect:/");
HttpServletResponse response = ServletUtils.response();
DingtalkXpackService dingtalkXpackService = null;
@ -95,7 +94,7 @@ public class XDingtalkServer {
if (!isOpen) {
DEException.throwException("未开启钉钉");
}
DingUserEntity dingUserEntity = dingtalkXpackService.userInfo(code);
DingUserEntity dingUserEntity = withoutLogin ? dingtalkXpackService.userInfoWithoutLogin(code) : dingtalkXpackService.userInfo(code);
String username = dingUserEntity.getUserid();
SysUserEntity sysUserEntity = authUserService.getUserByDingtalkId(username);
if (null == sysUserEntity) {
@ -139,6 +138,16 @@ public class XDingtalkServer {
return modelAndView;
}
@GetMapping("/callBackWithoutLogin")
public ModelAndView callBackWithoutLogin(@RequestParam("code") String code) {
return privateCallBack(code, true);
}
@GetMapping("/callBack")
public ModelAndView callBack(@RequestParam("code") String code, @RequestParam("state") String state) {
return privateCallBack(code, false);
}
private void bindError(HttpServletResponse response, String url, String errorMsg) {
Cookie cookie_error = new Cookie("DingtalkError", errorMsg);
cookie_error.setPath("/");

View File

@ -26,7 +26,7 @@ NProgress.configure({
showSpinner: false
}) // NProgress Configuration
const whiteList = ['/login', '/401', '/404', '/delink', '/nolic'] // no redirect whitelist
const whiteList = ['/login', '/401', '/404', '/delink', '/nolic', '/de-auto-login'] // no redirect whitelist
const routeBefore = (callBack) => {
let uiInfo = getSysUI()
@ -53,7 +53,7 @@ const routeBefore = (callBack) => {
callBack()
}
}
router.beforeEach(async(to, from, next) => routeBefore(() => {
router.beforeEach(async (to, from, next) => routeBefore(() => {
// start progress bar
NProgress.start()
const mobileIgnores = ['/delink']

View File

@ -91,6 +91,11 @@ export const constantRoutes = [
path: '/previewFullScreen',
component: () => import('@/components/canvas/components/editor/PreviewFullScreen'),
hidden: true
},
{
path: '/de-auto-login',
component: () => import('@/views/DeAutoLogin'),
hidden: true
}
// {
@ -208,11 +213,11 @@ export const constantRoutes = [
// ]
// },
// 404 page must be placed at the end !!!
// { path: '*', redirect: '/404', hidden: true }
// { path: '*', redirect: '/404', hidden: true }
]
const createRouter = () => new Router({
// mode: 'history', // require service support
// mode: 'history', // require service support
mode: 'hash',
scrollBehavior: () => ({ y: 0 }),
routes: constantRoutes

View File

@ -29,7 +29,7 @@ const actions = {
commit('SET_CURRENT_PATH', path)
}
}
export const fullScreenRouters = ['XpackThemeForm', 'system/datasource/DsForm', 'dataset/Form']
export const fullScreenRouters = ['XpackThemeForm', 'system/datasource/DsForm', 'dataset/Form', 'DeAutoLogin']
export const filterAsyncRouter = (routers) => { // 遍历后台传来的路由字符串,转换为组件对象
return routers.map(router => {
if (!fullScreenRouters.includes(router.component) && router.type === 1 && router.pid === 0 && router.component && router.component !== 'Layout') {

View File

@ -0,0 +1,68 @@
<template>
<div
v-loading="loading"
class="de-auto-login"
>
<plugin-com
v-if="dingtalkOpen && corpId"
ref="DTWithoutLogin"
:corp-id="corpId"
component-name="DTWithoutLogin"
/>
<div
v-if="!loading && !dingtalkOpen"
class="auto-login-missing"
>
<span>未开启钉钉</span>
</div>
<div
v-else-if="!loading && !corpId"
class="auto-login-missing"
>
<span>缺失企业ID参数</span>
</div>
</div>
</template>
<script>
import PluginCom from '@/views/system/plugin/PluginCom'
import { dingtalkStatus } from '@/api/user'
export default {
name: 'DeAutoLogin',
components: { PluginCom },
data() {
return {
corpId: null,
dingtalkOpen: false,
loading: true
}
},
created() {
this.corpId = this.$route.query.corpId
dingtalkStatus().then(res => {
if (res.success && res.data) {
this.dingtalkOpen = true
}
this.loading = false
}).catch(e => {
this.loading = false
})
},
methods: {
}
}
</script>
<style lang="scss" scoped>
.de-auto-login {
width: 100%;
height: 100vh;
.auto-login-missing {
text-align: center;
}
}
</style>