forked from github/dataease
fix(嵌入式): 嵌入式iframe局部刷新
This commit is contained in:
parent
72675fb4ed
commit
a6b3d808c5
17
core/core-frontend/src/utils/ParseUrl.ts
Normal file
17
core/core-frontend/src/utils/ParseUrl.ts
Normal file
@ -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 }
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user