diff --git a/core/core-frontend/src/permission.ts b/core/core-frontend/src/permission.ts index 9c0e6cfffd..6481aa0d65 100644 --- a/core/core-frontend/src/permission.ts +++ b/core/core-frontend/src/permission.ts @@ -23,7 +23,7 @@ const { start, done } = useNProgress() const { loadStart, loadDone } = usePageLoading() const whiteList = ['/login', '/de-link', '/chart-view'] // 不重定向白名单 -const embeddedWindowWhiteList = ['/dvCanvas', '/dashboard', '/preview'] +const embeddedWindowWhiteList = ['/dvCanvas', '/dashboard', '/preview', '/dataset-embedded-form'] const embeddedRouteWhiteList = ['/dataset-embedded', '/dataset-form', '/dataset-embedded-form'] router.beforeEach(async (to, from, next) => { start() diff --git a/core/core-frontend/src/views/chart/components/editor/dataset-select/DatasetSelect.vue b/core/core-frontend/src/views/chart/components/editor/dataset-select/DatasetSelect.vue index 7c288a92b0..f0f707672a 100644 --- a/core/core-frontend/src/views/chart/components/editor/dataset-select/DatasetSelect.vue +++ b/core/core-frontend/src/views/chart/components/editor/dataset-select/DatasetSelect.vue @@ -5,12 +5,9 @@ import { Plus, Search } from '@element-plus/icons-vue' import { useI18n } from '@/hooks/web/useI18n' import { useAppStoreWithOut } from '@/store/modules/app' import _ from 'lodash' -import { useRouter } from 'vue-router' import { getDatasetTree } from '@/api/dataset' import { ElFormItem, FormInstance } from 'element-plus-secondary' -const { resolve } = useRouter() - const props = withDefaults( defineProps<{ themes?: EditorTheme @@ -44,7 +41,12 @@ const initDataset = () => { }) } -const emits = defineEmits(['update:modelValue', 'update:stateObj', 'onDatasetChange']) +const emits = defineEmits([ + 'update:modelValue', + 'update:stateObj', + 'onDatasetChange', + 'addDsWindow' +]) const _modelValue = computed({ get() { @@ -151,8 +153,7 @@ const refresh = () => { initDataset() } const addDataset = () => { - const { href } = resolve('/dataset-form') - window.open(href, '_blank') + emits('addDsWindow') } const datasetSelectorPopover = ref() diff --git a/core/core-frontend/src/views/chart/components/editor/index.vue b/core/core-frontend/src/views/chart/components/editor/index.vue index 5fc2addb4e..175bf39016 100644 --- a/core/core-frontend/src/views/chart/components/editor/index.vue +++ b/core/core-frontend/src/views/chart/components/editor/index.vue @@ -51,7 +51,9 @@ import { useDraggable } from '@vueuse/core' import { set, concat, keys } from 'lodash-es' import { Field, getFieldByDQ } from '@/api/chart' import ChartTemplateInfo from '@/views/chart/components/editor/common/ChartTemplateInfo.vue' - +import { XpackComponent } from '@/components/plugin' +import { useEmbedded } from '@/store/modules/embedded' +const embeddedStore = useEmbedded() const snapshotStore = snapshotStoreWithOut() const dvMainStore = dvMainStoreWithOut() const { canvasCollapse, curComponent, componentData, editMode } = storeToRefs(dvMainStore) @@ -977,15 +979,34 @@ const saveResultFilter = () => { const collapseChange = type => { canvasCollapse.value[type] = !canvasCollapse.value[type] } - +const openHandler = ref(null) +const initOpenHandler = newWindow => { + if (openHandler?.value) { + const pm = { + methodName: 'initOpenHandler', + args: newWindow + } + openHandler.value.invokeMethod(pm) + } +} +const addDsWindow = () => { + const path = + embeddedStore.getToken && appStore.getIsIframe ? 'dataset-embedded-form' : '/dataset-form' + let routeData = router.resolve(path) + const newWindow = window.open(routeData.href, '_blank') + initOpenHandler(newWindow) +} const editDs = () => { + const path = + embeddedStore.getToken && appStore.getIsIframe ? 'dataset-embedded-form' : '/dataset-form' let routeData = router.resolve({ - path: '/dataset-form', + path: path, query: { id: view.value.tableId } }) - window.open(routeData.href, '_blank') + const newWindow = window.open(routeData.href, '_blank') + initOpenHandler(newWindow) } const showQuotaEditCompare = item => { @@ -1846,6 +1867,7 @@ const onRefreshChange = val => { :state-obj="state" v-model="view.tableId" :themes="themes" + @add-ds-window="addDsWindow" @onDatasetChange="recordSnapshotInfo('calcData')" /> @@ -2211,6 +2233,7 @@ const onRefreshChange = val => { +