forked from github/dataease
perf: iframe嵌入式编辑资源
This commit is contained in:
parent
7adbecbc64
commit
2a2d419f1c
@ -59,6 +59,7 @@ const loadComponent = () => {
|
||||
importProxy(byteArray)
|
||||
})
|
||||
.catch(() => {
|
||||
emits('loadFail')
|
||||
showNolic()
|
||||
})
|
||||
.finally(() => {
|
||||
@ -77,6 +78,7 @@ const pluginProxy = ref(null)
|
||||
const invokeMethod = param => {
|
||||
pluginProxy.value['invokeMethod'](param)
|
||||
}
|
||||
const emits = defineEmits(['loadFail'])
|
||||
defineExpose({
|
||||
invokeMethod
|
||||
})
|
||||
|
@ -189,6 +189,10 @@ service.interceptors.response.use(
|
||||
}
|
||||
router.push(`/login?redirect=${queryRedirectPath}`)
|
||||
}
|
||||
} else if (response?.config?.url.startsWith('/xpackComponent/content')) {
|
||||
console.error(
|
||||
"never mind this error about '/xpackComponent/content', just a reminder to support the official license"
|
||||
)
|
||||
}
|
||||
|
||||
return Promise.reject(response.data.msg)
|
||||
@ -209,6 +213,10 @@ service.interceptors.response.use(
|
||||
message: error.message,
|
||||
showClose: true
|
||||
})
|
||||
} else if (error?.config?.url.startsWith('/xpackComponent/content')) {
|
||||
console.error(
|
||||
"never mind this error about '/xpackComponent/content', just a reminder to support the official license"
|
||||
)
|
||||
}
|
||||
|
||||
error.config.loading && tryHideLoading(permissionStore.getCurrentPath)
|
||||
@ -225,7 +233,7 @@ service.interceptors.response.use(
|
||||
if (header.has('DE-FORBIDDEN-FLAG')) {
|
||||
showMsg('当前用户权限配置已变更,请刷新页面', '-changed-')
|
||||
}
|
||||
return Promise.reject(error)
|
||||
return Promise.resolve()
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -23,13 +23,8 @@ const { start, done } = useNProgress()
|
||||
const { loadStart, loadDone } = usePageLoading()
|
||||
|
||||
const whiteList = ['/login', '/de-link', '/chart-view'] // 不重定向白名单
|
||||
const embeddedWhiteList = [
|
||||
'/dvCanvas',
|
||||
'/dashboard',
|
||||
'/dataset-embedded',
|
||||
'/dataset-form',
|
||||
'/dataset-embedded-form'
|
||||
]
|
||||
const embeddedWindowWhiteList = ['/dvCanvas', '/dashboard']
|
||||
const embeddedRouteWhiteList = ['/dataset-embedded', '/dataset-form', '/dataset-embedded-form']
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
start()
|
||||
loadStart()
|
||||
@ -106,14 +101,22 @@ router.beforeEach(async (to, from, next) => {
|
||||
}
|
||||
} else {
|
||||
const embeddedStore = useEmbedded()
|
||||
if (embeddedStore.getToken && appStore.getIsIframe && embeddedWhiteList.includes(to.path)) {
|
||||
if (
|
||||
embeddedStore.getToken &&
|
||||
appStore.getIsIframe &&
|
||||
embeddedRouteWhiteList.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/')) {
|
||||
} else if (
|
||||
embeddedWindowWhiteList.includes(to.path) ||
|
||||
whiteList.includes(to.path) ||
|
||||
to.path.startsWith('/de-link/')
|
||||
) {
|
||||
permissionStore.setCurrentPath(to.path)
|
||||
next()
|
||||
} else {
|
||||
|
@ -56,7 +56,8 @@ export const userStore = defineStore('embedded', {
|
||||
type: this.type,
|
||||
dvId: this.dvId,
|
||||
chartId: this.chartId,
|
||||
pid: this.pid
|
||||
pid: this.pid,
|
||||
resourceId: this.resourceId
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -92,6 +93,7 @@ export const userStore = defineStore('embedded', {
|
||||
this.dvId = data['dvId']
|
||||
this.chartId = data['chartId']
|
||||
this.pid = data['pid']
|
||||
this.resourceId = data['resourceId']
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -96,20 +96,11 @@ const onMobileConfig = () => {
|
||||
}
|
||||
|
||||
const loadFinish = ref(false)
|
||||
const newWindowHandler = ref(null)
|
||||
|
||||
let p = null
|
||||
const XpackLoaded = () => {
|
||||
p(true)
|
||||
}
|
||||
const XpackLoaded = () => p(true)
|
||||
// 全局监听按键事件
|
||||
onMounted(async () => {
|
||||
await new Promise(r => {
|
||||
if (!newWindowHandler?.value) {
|
||||
return r(null)
|
||||
}
|
||||
p = r
|
||||
})
|
||||
await new Promise(r => (p = r))
|
||||
loadFinish.value = true
|
||||
useEmitt({
|
||||
name: 'mobileConfig',
|
||||
@ -254,9 +245,9 @@ onUnmounted(() => {
|
||||
v-else-if="loadFinish && mobileConfig"
|
||||
></MobileConfigPanel>
|
||||
<XpackComponent
|
||||
ref="newWindowHandler"
|
||||
jsname="L2NvbXBvbmVudC9lbWJlZGRlZC1pZnJhbWUvTmV3V2luZG93SGFuZGxlcg=="
|
||||
@loaded="XpackLoaded"
|
||||
@load-fail="XpackLoaded"
|
||||
/>
|
||||
</template>
|
||||
|
||||
|
@ -200,19 +200,11 @@ const checkPer = async resourceId => {
|
||||
}
|
||||
|
||||
const loadFinish = ref(false)
|
||||
const newWindowHandler = ref(null)
|
||||
|
||||
let p = null
|
||||
const XpackLoaded = () => {
|
||||
p(true)
|
||||
}
|
||||
const XpackLoaded = () => p(true)
|
||||
onMounted(async () => {
|
||||
await new Promise(r => {
|
||||
if (!newWindowHandler?.value) {
|
||||
return r(null)
|
||||
}
|
||||
p = r
|
||||
})
|
||||
await new Promise(r => (p = r))
|
||||
loadFinish.value = true
|
||||
window.addEventListener('blur', releaseAttachKey)
|
||||
if (editMode.value === 'edit') {
|
||||
@ -389,9 +381,9 @@ eventBus.on('handleNew', handleNew)
|
||||
</el-container>
|
||||
</div>
|
||||
<XpackComponent
|
||||
ref="newWindowHandler"
|
||||
jsname="L2NvbXBvbmVudC9lbWJlZGRlZC1pZnJhbWUvTmV3V2luZG93SGFuZGxlcg=="
|
||||
@loaded="XpackLoaded"
|
||||
@load-fail="XpackLoaded"
|
||||
/>
|
||||
</template>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user