From a6b3d808c557968aab4eba6fc8873b3461823e57 Mon Sep 17 00:00:00 2001 From: dataeaseShu Date: Tue, 4 Jun 2024 18:37:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=B5=8C=E5=85=A5=E5=BC=8F):=20=E5=B5=8C?= =?UTF-8?q?=E5=85=A5=E5=BC=8Fiframe=E5=B1=80=E9=83=A8=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/core-frontend/src/utils/ParseUrl.ts | 17 ++++++++++++++ .../views/chart/components/views/index.vue | 9 ++++++++ .../src/views/common/DeResourceTree.vue | 23 +++++++++++++++---- .../src/views/template-market/index.vue | 8 +++++++ 4 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 core/core-frontend/src/utils/ParseUrl.ts diff --git a/core/core-frontend/src/utils/ParseUrl.ts b/core/core-frontend/src/utils/ParseUrl.ts new file mode 100644 index 0000000000..e2cd698eff --- /dev/null +++ b/core/core-frontend/src/utils/ParseUrl.ts @@ -0,0 +1,17 @@ +function parseUrl(url) { + const [pathname, params] = url.split('?') + const [_, path] = pathname.split('#/') + return { + path, + query: params + .split('&') + .map(ele => ele.split('=')) + .reduce((pre, next) => { + const [key, value] = next + pre[key] = value + return pre + }, {}) + } +} + +export { parseUrl } diff --git a/core/core-frontend/src/views/chart/components/views/index.vue b/core/core-frontend/src/views/chart/components/views/index.vue index 89ff4ef33a..31ccfc5c83 100644 --- a/core/core-frontend/src/views/chart/components/views/index.vue +++ b/core/core-frontend/src/views/chart/components/views/index.vue @@ -3,6 +3,7 @@ import { useI18n } from '@/hooks/web/useI18n' import ChartComponentG2Plot from './components/ChartComponentG2Plot.vue' import DeIndicator from '@/custom-component/indicator/DeIndicator.vue' import { useAppStoreWithOut } from '@/store/modules/app' +import router from '@/router' import { useEmbedded } from '@/store/modules/embedded' import { XpackComponent } from '@/components/plugin' import { @@ -29,6 +30,7 @@ import DrillPath from '@/views/chart/components/views/components/DrillPath.vue' import { ElIcon, ElInput, ElMessage } from 'element-plus-secondary' import { useFilter } from '@/hooks/web/useFilter' import { useCache } from '@/hooks/web/useCache' +import { parseUrl } from '@/utils/ParseUrl' import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain' import { cloneDeep } from 'lodash-es' @@ -50,6 +52,7 @@ const dvMainStore = dvMainStoreWithOut() let innerRefreshTimer = null const appStore = useAppStoreWithOut() const isDataEaseBi = computed(() => appStore.getIsDataEaseBi) +const isIframe = computed(() => appStore.getIsIframe) const emit = defineEmits(['onPointClick']) @@ -388,6 +391,7 @@ const jumpClick = param => { param.sourceFieldId = dimension.id let embeddedBaseUrl = '' const divSelf = isDataEaseBi.value && jumpInfo.jumpType === '_self' + const iframeSelf = isIframe.value && jumpInfo.jumpType === '_self' if (isDataEaseBi.value) { embeddedBaseUrl = embeddedStore.baseUrl } @@ -416,6 +420,11 @@ const jumpClick = param => { divEmbedded('Preview') return } + + if (iframeSelf) { + router.push(parseUrl(url)) + return + } windowsJump(url, jumpInfo.jumpType) } } else { diff --git a/core/core-frontend/src/views/common/DeResourceTree.vue b/core/core-frontend/src/views/common/DeResourceTree.vue index 704b27c0b1..d14853fd9b 100644 --- a/core/core-frontend/src/views/common/DeResourceTree.vue +++ b/core/core-frontend/src/views/common/DeResourceTree.vue @@ -16,6 +16,7 @@ import { interactiveStoreWithOut } from '@/store/modules/interactive' const interactiveStore = interactiveStoreWithOut() import router from '@/router' import { useI18n } from '@/hooks/web/useI18n' +import { parseUrl } from '@/utils/ParseUrl' import _ from 'lodash' import DeResourceCreateOptV2 from '@/views/common/DeResourceCreateOptV2.vue' import { useCache } from '@/hooks/web/useCache' @@ -301,6 +302,11 @@ const operation = (cmd: string, data: BusiTreeNode, nodeType: string) => { return } + if (isIframe.value) { + router.push(parseUrl(baseUrl)) + return + } + const newWindow = window.open(baseUrl, '_blank') initOpenHandler(newWindow) }) @@ -332,6 +338,11 @@ const addOperation = ( ) return } + + if (isIframe.value) { + router.push(parseUrl(data?.id ? baseUrl + `&pid=${data.id}` : baseUrl)) + return + } if (data?.id) { newWindow = window.open(baseUrl + `&pid=${data.id}`, '_blank') } else { @@ -371,10 +382,7 @@ const resourceEdit = resourceId => { } if (isIframe.value) { - router.push({ - path: curCanvasType.value === 'dataV' ? 'dvCanvas' : 'dashboard', - query: curCanvasType.value === 'dataV' ? { dvId: resourceId } : { resourceId } - }) + router.push(parseUrl(baseUrl + resourceId)) return } const newWindow = window.open(baseUrl + resourceId, '_blank') @@ -406,6 +414,13 @@ const resourceCreateFinish = templateData => { ) return } + + if (isIframe.value) { + router.push( + parseUrl(state.templateCreatePid ? baseUrl + `&pid=${state.templateCreatePid}` : baseUrl) + ) + return + } if (state.templateCreatePid) { newWindow = window.open(baseUrl + `&pid=${state.templateCreatePid}`, '_blank') } else { diff --git a/core/core-frontend/src/views/template-market/index.vue b/core/core-frontend/src/views/template-market/index.vue index 20769d4de1..d3527f2a99 100644 --- a/core/core-frontend/src/views/template-market/index.vue +++ b/core/core-frontend/src/views/template-market/index.vue @@ -169,7 +169,9 @@ import { nextTick, reactive, watch, onMounted, ref, computed } from 'vue' import { useI18n } from '@/hooks/web/useI18n' import { ElMessage } from 'element-plus-secondary' import { useCache } from '@/hooks/web/useCache' +import router from '@/router' import MarketPreviewV2 from '@/views/template-market/component/MarketPreviewV2.vue' +import { parseUrl } from '@/utils/ParseUrl' import { imgUrlTrans } from '@/utils/imgUtils' import CategoryTemplateV2 from '@/views/template-market/component/CategoryTemplateV2.vue' import { interactiveStoreWithOut } from '@/store/modules/interactive' @@ -192,6 +194,7 @@ const close = () => { const title = computed(() => (state.curPosition === 'branch' ? '模板中心' : '使用模板新建')) const isDataEaseBi = computed(() => appStore.getIsDataEaseBi) +const isIframe = computed(() => appStore.getIsIframe) const state = reactive({ initReady: true, curPosition: 'branch', @@ -454,6 +457,11 @@ const apply = template => { ) return } + + if (isIframe.value) { + router.push(parseUrl(state.pid ? baseUrl + `&pid=${state.pid}` : baseUrl)) + return + } if (state.pid) { newWindow = window.open(baseUrl + `&pid=${state.pid}`, '_blank') } else {