From 202244a879aa0677c1d7e210166d636b6f1ac0de Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Wed, 20 Mar 2024 12:14:38 +0800 Subject: [PATCH] =?UTF-8?q?perf(=E6=95=B0=E6=8D=AE=E9=9B=86):=20iframe?= =?UTF-8?q?=E5=B5=8C=E5=85=A5=E5=BC=8F=E7=BC=96=E8=BE=91=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=9B=86=E8=B7=AF=E7=94=B1=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/core-frontend/src/permission.ts | 24 +++++++++++++------ core/core-frontend/src/router/index.ts | 11 +++++++-- .../visualized/data/dataset/form/index.vue | 8 +++++-- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/core/core-frontend/src/permission.ts b/core/core-frontend/src/permission.ts index 0268984fe1..23155b62c8 100644 --- a/core/core-frontend/src/permission.ts +++ b/core/core-frontend/src/permission.ts @@ -10,7 +10,7 @@ import { useCache } from '@/hooks/web/useCache' import { isMobile } from '@/utils/utils' import { interactiveStoreWithOut } from '@/store/modules/interactive' import { useAppearanceStoreWithOut } from '@/store/modules/appearance' - +import { useEmbedded } from '@/store/modules/embedded' const appearanceStore = useAppearanceStoreWithOut() const { wsCache } = useCache() const permissionStore = usePermissionStoreWithOut() @@ -23,7 +23,13 @@ const { start, done } = useNProgress() const { loadStart, loadDone } = usePageLoading() const whiteList = ['/login', '/de-link', '/chart-view'] // 不重定向白名单 -const embeddedWhiteList = ['/dvCanvas', '/dashboard'] +const embeddedWhiteList = [ + '/dvCanvas', + '/dashboard', + '/dataset-embedded', + '/dataset-form', + '/dataset-embedded-form' +] router.beforeEach(async (to, from, next) => { start() loadStart() @@ -99,11 +105,15 @@ router.beforeEach(async (to, from, next) => { next(nextData) } } else { - if ( - embeddedWhiteList.includes(to.path) || - whiteList.indexOf(to.path) !== -1 || - to.path.startsWith('/de-link/') - ) { + const embeddedStore = useEmbedded() + if (embeddedStore.getToken && appStore.getIsIframe && embeddedWhiteList.includes(to.path)) { + if (to.path.includes('/dataset-form')) { + next({ path: '/dataset-embedded-form', query: to.query }) + return + } + permissionStore.setCurrentPath(to.path) + next() + } else if (whiteList.indexOf(to.path) !== -1 || to.path.startsWith('/de-link/')) { permissionStore.setCurrentPath(to.path) next() } else { diff --git a/core/core-frontend/src/router/index.ts b/core/core-frontend/src/router/index.ts index a6d785a921..0428ac6371 100644 --- a/core/core-frontend/src/router/index.ts +++ b/core/core-frontend/src/router/index.ts @@ -70,8 +70,15 @@ export const routes: AppRouteRecordRaw[] = [ component: () => import('@/views/common/DeResourceTree.vue') }, { - path: '/dataset', - name: 'dataset', + path: '/dataset-embedded', + name: 'dataset-embedded', + hidden: true, + meta: {}, + component: () => import('@/views/visualized/data/dataset/index.vue') + }, + { + path: '/dataset-embedded-form', + name: 'dataset-embedded-form', hidden: true, meta: {}, component: () => import('@/views/visualized/data/dataset/form/index.vue') diff --git a/core/core-frontend/src/views/visualized/data/dataset/form/index.vue b/core/core-frontend/src/views/visualized/data/dataset/form/index.vue index 837e151f8e..5335bd54eb 100644 --- a/core/core-frontend/src/views/visualized/data/dataset/form/index.vue +++ b/core/core-frontend/src/views/visualized/data/dataset/form/index.vue @@ -27,6 +27,8 @@ import CreatDsGroup from './CreatDsGroup.vue' import { guid, getFieldName, timeTypes, type DataSource } from './util' import { fieldType } from '@/utils/attr' import { cancelMap } from '@/config/axios/service' +import { useEmbedded } from '@/store/modules/embedded' +import { useAppStoreWithOut } from '@/store/modules/app' import { getDatasourceList, getTables, @@ -49,7 +51,8 @@ interface Field { originName: string deType: number } - +const appStore = useAppStoreWithOut() +const embeddedStore = useEmbedded() const { t } = useI18n() const route = useRoute() const { push } = useRouter() @@ -217,8 +220,9 @@ const getDsName = (id: string) => { } const pushDataset = () => { + const routeName = embeddedStore.getToken && appStore.getIsIframe ? 'dataset-embedded' : 'dataset' push({ - name: 'dataset', + name: routeName, params: { id: nodeInfo.id }