perf(数据集): iframe嵌入式编辑数据集路由切换

This commit is contained in:
fit2cloud-chenyw 2024-03-20 12:14:38 +08:00
parent 478892f762
commit 202244a879
3 changed files with 32 additions and 11 deletions

View File

@ -10,7 +10,7 @@ import { useCache } from '@/hooks/web/useCache'
import { isMobile } from '@/utils/utils' import { isMobile } from '@/utils/utils'
import { interactiveStoreWithOut } from '@/store/modules/interactive' import { interactiveStoreWithOut } from '@/store/modules/interactive'
import { useAppearanceStoreWithOut } from '@/store/modules/appearance' import { useAppearanceStoreWithOut } from '@/store/modules/appearance'
import { useEmbedded } from '@/store/modules/embedded'
const appearanceStore = useAppearanceStoreWithOut() const appearanceStore = useAppearanceStoreWithOut()
const { wsCache } = useCache() const { wsCache } = useCache()
const permissionStore = usePermissionStoreWithOut() const permissionStore = usePermissionStoreWithOut()
@ -23,7 +23,13 @@ const { start, done } = useNProgress()
const { loadStart, loadDone } = usePageLoading() const { loadStart, loadDone } = usePageLoading()
const whiteList = ['/login', '/de-link', '/chart-view'] // 不重定向白名单 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) => { router.beforeEach(async (to, from, next) => {
start() start()
loadStart() loadStart()
@ -99,11 +105,15 @@ router.beforeEach(async (to, from, next) => {
next(nextData) next(nextData)
} }
} else { } else {
if ( const embeddedStore = useEmbedded()
embeddedWhiteList.includes(to.path) || if (embeddedStore.getToken && appStore.getIsIframe && embeddedWhiteList.includes(to.path)) {
whiteList.indexOf(to.path) !== -1 || if (to.path.includes('/dataset-form')) {
to.path.startsWith('/de-link/') 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) permissionStore.setCurrentPath(to.path)
next() next()
} else { } else {

View File

@ -70,8 +70,15 @@ export const routes: AppRouteRecordRaw[] = [
component: () => import('@/views/common/DeResourceTree.vue') component: () => import('@/views/common/DeResourceTree.vue')
}, },
{ {
path: '/dataset', path: '/dataset-embedded',
name: 'dataset', name: 'dataset-embedded',
hidden: true,
meta: {},
component: () => import('@/views/visualized/data/dataset/index.vue')
},
{
path: '/dataset-embedded-form',
name: 'dataset-embedded-form',
hidden: true, hidden: true,
meta: {}, meta: {},
component: () => import('@/views/visualized/data/dataset/form/index.vue') component: () => import('@/views/visualized/data/dataset/form/index.vue')

View File

@ -27,6 +27,8 @@ import CreatDsGroup from './CreatDsGroup.vue'
import { guid, getFieldName, timeTypes, type DataSource } from './util' import { guid, getFieldName, timeTypes, type DataSource } from './util'
import { fieldType } from '@/utils/attr' import { fieldType } from '@/utils/attr'
import { cancelMap } from '@/config/axios/service' import { cancelMap } from '@/config/axios/service'
import { useEmbedded } from '@/store/modules/embedded'
import { useAppStoreWithOut } from '@/store/modules/app'
import { import {
getDatasourceList, getDatasourceList,
getTables, getTables,
@ -49,7 +51,8 @@ interface Field {
originName: string originName: string
deType: number deType: number
} }
const appStore = useAppStoreWithOut()
const embeddedStore = useEmbedded()
const { t } = useI18n() const { t } = useI18n()
const route = useRoute() const route = useRoute()
const { push } = useRouter() const { push } = useRouter()
@ -217,8 +220,9 @@ const getDsName = (id: string) => {
} }
const pushDataset = () => { const pushDataset = () => {
const routeName = embeddedStore.getToken && appStore.getIsIframe ? 'dataset-embedded' : 'dataset'
push({ push({
name: 'dataset', name: routeName,
params: { params: {
id: nodeInfo.id id: nodeInfo.id
} }