fix: 处理 window.bpmnInstances 有时候为 undefined 问题

pull/155/head
duxz 2023-05-25 15:34:13 +08:00
parent 9f0065f89f
commit 6b3de50c69
1 changed files with 21 additions and 21 deletions

View File

@ -110,18 +110,18 @@ const timer = ref()
provide('prefix', props.prefix)
provide('width', props.width)
const bpmnInstances = () => (window as any)?.bpmnInstances
const initModels = () => {
// console.log(props, 'props')
// console.log(props.bpmnModeler, 'sakdjjaskdsajdkasdjkadsjk')
// modeler moddle
// nextTick(() => {
if (!props.bpmnModeler) {
// props.bpmnModeler initModels
const unwatchBpmn = watch(
() => props.bpmnModeler,
() => {
//
timer.value = setTimeout(() => initModels(), 10)
return
}
if (timer.value) {
clearTimeout(timer.value)
if (!props.bpmnModeler) {
console.log('缺少props.bpmnModeler')
return
}
console.log('props.bpmnModeler 有值了!!!')
const w = window as any
w.bpmnInstances = {
modeler: props.bpmnModeler,
@ -134,12 +134,16 @@ const initModels = () => {
replace: props.bpmnModeler.get('replace'),
selection: props.bpmnModeler.get('selection')
}
}
console.log(bpmnInstances(), 'window.bpmnInstances')
getActiveElement()
// })
}
console.log(bpmnInstances(), 'window.bpmnInstances')
getActiveElement()
unwatchBpmn()
},
{
immediate: true
}
)
const getActiveElement = () => {
// bpmn:Process
initFormOnChanged(null)
@ -187,11 +191,7 @@ const initFormOnChanged = (element) => {
)
formVisible.value = elementType.value === 'UserTask' || elementType.value === 'StartEvent'
}
onMounted(() => {
setTimeout(() => {
initModels()
}, 100)
})
onBeforeUnmount(() => {
const w = window as any
w.bpmnInstances = null