Skip to content

Commit

Permalink
fix: update app initialization logic in devtools container management
Browse files Browse the repository at this point in the history
  • Loading branch information
陆德靖 authored and 陆德靖 committed Dec 21, 2024
1 parent 06f5d42 commit 0369952
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/overlay/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Component, App as VueAppType } from 'vue'
import { createApp, h } from 'vue'
import App from './App.vue'

let app: VueAppType
let app: VueAppType | null = null
function createDevToolsContainer(App: Component) {
const CONTAINER_ID = '__vue-devtools-container__'
const el = document.createElement('div')
Expand All @@ -25,15 +25,15 @@ const config = { childList: true, attributes: false }
const observer = new MutationObserver(callback)
observer.observe(targetNode, config)

let init = false
let isInitialized = false
function callback(mutationsList, observer) {
for (const mutation of mutationsList) {
if (mutation.type === 'childList' && init === false) {
if (mutation.type === 'childList' && isInitialized === false) {
if (app) {
app.unmount()
}
createDevToolsContainer(App)
init = true
isInitialized = true
observer.disconnect()
}
}
Expand Down

0 comments on commit 0369952

Please sign in to comment.