diff --git a/packages/devtools-kit/src/core/index.ts b/packages/devtools-kit/src/core/index.ts index c85af3b1..05d81645 100644 --- a/packages/devtools-kit/src/core/index.ts +++ b/packages/devtools-kit/src/core/index.ts @@ -56,7 +56,7 @@ export function initDevTools() { }, ] - if (devtoolsAppRecords.value.length === 1) { + if (devtoolsAppRecords.value.length >= 1) { await setActiveAppRecord(devtoolsAppRecords.value[0]) devtoolsState.connected = true devtoolsHooks.callHook(DevToolsHooks.APP_CONNECTED) @@ -65,6 +65,11 @@ export function initDevTools() { hook.on.vueAppUnmount(async (app) => { const activeRecords = devtoolsAppRecords.value.filter(appRecord => appRecord.app !== app) + // #356 should disconnect when all apps are unmounted + if (activeRecords.length === 0) { + devtoolsState.connected = false + return + } devtoolsAppRecords.value = activeRecords if (devtoolsAppRecords.active.app === app) await setActiveAppRecord(activeRecords[0]) diff --git a/packages/playground/multi-app/src/main.ts b/packages/playground/multi-app/src/main.ts index 61ab5943..65ea9acb 100644 --- a/packages/playground/multi-app/src/main.ts +++ b/packages/playground/multi-app/src/main.ts @@ -8,8 +8,10 @@ import 'uno.css' const app = createApp(App) -const app2 = createApp(App2) - app.mount('#app') -app2.mount('#app2') +setTimeout(() => { + app.unmount() + app.mount('#app') + createApp(App2).mount('#app2') +}, 500)