forked from github/dataease
perf: 优化公共链接iframe嵌入
This commit is contained in:
parent
602905cfe4
commit
c0d84fe024
@ -14,12 +14,13 @@ import io.dataease.constant.AuthConstant;
|
||||
import io.dataease.constant.BusiResourceEnum;
|
||||
import io.dataease.exception.DEException;
|
||||
import io.dataease.license.config.XpackInteract;
|
||||
import io.dataease.share.dao.auto.mapper.XpackShareMapper;
|
||||
import io.dataease.utils.*;
|
||||
import io.dataease.license.utils.LicenseUtil;
|
||||
import io.dataease.share.dao.auto.entity.XpackShare;
|
||||
import io.dataease.share.dao.auto.mapper.XpackShareMapper;
|
||||
import io.dataease.share.dao.ext.mapper.XpackShareExtMapper;
|
||||
import io.dataease.share.dao.ext.po.XpackSharePO;
|
||||
import io.dataease.share.util.LinkTokenUtil;
|
||||
import io.dataease.utils.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
@ -125,7 +126,6 @@ public class XpackShareManage {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public IPage<XpackSharePO> querySharePage(int goPage, int pageSize, VisualizationWorkbranchQueryRequest request) {
|
||||
Long uid = AuthUtils.getUser().getUserId();
|
||||
QueryWrapper<Object> queryWrapper = new QueryWrapper<>();
|
||||
@ -174,7 +174,7 @@ public class XpackShareManage {
|
||||
return pos.stream().map(po ->
|
||||
new XpackShareGridVO(
|
||||
po.getShareId(), po.getResourceId(), po.getName(), po.getCreator().toString(),
|
||||
po.getTime(), po.getExp(), 9,po.getExtFlag(),po.getType())).toList();
|
||||
po.getTime(), po.getExp(), 9, po.getExtFlag(), po.getType())).toList();
|
||||
}
|
||||
|
||||
private XpackShareManage proxy() {
|
||||
@ -182,6 +182,10 @@ public class XpackShareManage {
|
||||
}
|
||||
|
||||
public XpackShareProxyVO proxyInfo(XpackShareProxyRequest request) {
|
||||
boolean inIframeError = request.isInIframe() && !LicenseUtil.licenseValid();
|
||||
if (inIframeError) {
|
||||
return new XpackShareProxyVO();
|
||||
}
|
||||
QueryWrapper<XpackShare> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("uuid", request.getUuid());
|
||||
XpackShare xpackShare = xpackShareMapper.selectOne(queryWrapper);
|
||||
@ -192,7 +196,7 @@ public class XpackShareManage {
|
||||
response.addHeader(AuthConstant.LINK_TOKEN_KEY, linkToken);
|
||||
Integer type = xpackShare.getType();
|
||||
String typeText = (ObjectUtils.isNotEmpty(type) && type == 1) ? "dashboard" : "dataV";
|
||||
return new XpackShareProxyVO(xpackShare.getResourceId(), xpackShare.getCreator(), linkExp(xpackShare), pwdValid(xpackShare, request.getCiphertext()), typeText);
|
||||
return new XpackShareProxyVO(xpackShare.getResourceId(), xpackShare.getCreator(), linkExp(xpackShare), pwdValid(xpackShare, request.getCiphertext()), typeText, inIframeError);
|
||||
}
|
||||
|
||||
private boolean linkExp(XpackShare xpackShare) {
|
||||
|
9
core/core-frontend/src/views/share/link/IframeError.vue
Normal file
9
core/core-frontend/src/views/share/link/IframeError.vue
Normal file
@ -0,0 +1,9 @@
|
||||
<script lang="ts" setup>
|
||||
import EmptyBackground from '@/components/empty-background/src/EmptyBackground.vue'
|
||||
</script>
|
||||
<template>
|
||||
<EmptyBackground
|
||||
img-type="noneWhite"
|
||||
description="仅嵌入式版和企业版支持iframe方式内嵌公共链接"
|
||||
/>
|
||||
</template>
|
@ -1,5 +1,6 @@
|
||||
import request from '@/config/axios'
|
||||
import { useCache } from '@/hooks/web/useCache'
|
||||
import { isInIframe } from '@/utils/utils'
|
||||
const { wsCache } = useCache()
|
||||
export interface ProxyInfo {
|
||||
resourceId: string
|
||||
@ -7,6 +8,7 @@ export interface ProxyInfo {
|
||||
exp?: boolean
|
||||
pwdValid?: boolean
|
||||
type: string
|
||||
inIframeError: boolean
|
||||
}
|
||||
class ShareProxy {
|
||||
uuid: string
|
||||
@ -28,7 +30,8 @@ class ShareProxy {
|
||||
}
|
||||
const uuid = this.uuid
|
||||
const url = '/share/proxyInfo'
|
||||
const param = { uuid, ciphertext: null }
|
||||
const inIframe = isInIframe()
|
||||
const param = { uuid, ciphertext: null, inIframe }
|
||||
const ciphertext = wsCache.get(`link-${uuid}`)
|
||||
if (ciphertext) {
|
||||
param['ciphertext'] = ciphertext
|
||||
|
@ -1,6 +1,7 @@
|
||||
<template>
|
||||
<div class="link-container" v-loading="loading">
|
||||
<LinkError v-if="!loading && !linkExist" />
|
||||
<IframeError v-if="!loading && iframeError" />
|
||||
<LinkError v-else-if="!loading && !linkExist" />
|
||||
<Exp v-else-if="!loading && linkExp" />
|
||||
<PwdTips v-else-if="!loading && !pwdValid" />
|
||||
<PreviewCanvas
|
||||
@ -18,13 +19,21 @@ import { ProxyInfo, shareProxy } from './ShareProxy'
|
||||
import Exp from './exp.vue'
|
||||
import LinkError from './error.vue'
|
||||
import PwdTips from './pwd.vue'
|
||||
import IframeError from './IframeError.vue'
|
||||
const pcanvas = ref(null)
|
||||
const iframeError = ref(true)
|
||||
const linkExist = ref(false)
|
||||
const loading = ref(true)
|
||||
const linkExp = ref(false)
|
||||
const pwdValid = ref(false)
|
||||
onMounted(async () => {
|
||||
const proxyInfo = (await shareProxy.loadProxy()) as ProxyInfo
|
||||
if (proxyInfo?.inIframeError) {
|
||||
loading.value = false
|
||||
iframeError.value = true
|
||||
return
|
||||
}
|
||||
iframeError.value = false
|
||||
if (!proxyInfo?.resourceId) {
|
||||
loading.value = false
|
||||
return
|
||||
|
@ -19,4 +19,5 @@ public class XpackShareProxyRequest implements Serializable {
|
||||
private String uuid;
|
||||
@Schema(description = "密钥", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String ciphertext;
|
||||
private boolean inIframe;
|
||||
}
|
||||
|
@ -31,4 +31,5 @@ public class XpackShareProxyVO implements Serializable {
|
||||
private boolean pwdValid;
|
||||
@Schema(description = "类型")
|
||||
private String type;
|
||||
private boolean inIframeError = true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user