From 7003a9e98b3573ef1bdcf5abd4317af22f0a1169 Mon Sep 17 00:00:00 2001 From: bymyself Date: Thu, 6 Mar 2025 02:26:14 -0700 Subject: [PATCH] refactor --- src/components/webviews/WebviewContainer.vue | 4 ++-- src/stores/webviewStore.ts | 17 ++++++----------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/components/webviews/WebviewContainer.vue b/src/components/webviews/WebviewContainer.vue index c22dc04cd..139d4824c 100644 --- a/src/components/webviews/WebviewContainer.vue +++ b/src/components/webviews/WebviewContainer.vue @@ -3,7 +3,7 @@ { - const registeredWebviews = ref>({}) + const registeredWebviews = shallowRef>({}) const activeWebviewId = ref(null) const activeWebview = computed(() => @@ -29,8 +30,7 @@ export const useWebviewStore = defineStore('webview', () => { const registerWebview = (webview: Webview) => { registeredWebviews.value[webview.id] = { ...webview, - component: markRaw(webview.component), - props: webview.props + component: markRaw(webview.component) } } @@ -42,7 +42,6 @@ export const useWebviewStore = defineStore('webview', () => { const webview = registeredWebviews.value[id] if (!webview) return - // If this is the active webview, clear the active webview if (activeWebviewId.value === id) { activeWebviewId.value = null } @@ -60,17 +59,14 @@ export const useWebviewStore = defineStore('webview', () => { if (!webview) return if (props) { - webview.props = { - ...webview.props, - ...props - } + webview.props = merge(webview.props, props) } activeWebviewId.value = id } /** - * Hide a webview + * Hide a webview by ID * @param id The ID of the webview to hide */ const hideWebview = (id: string) => { @@ -87,7 +83,6 @@ export const useWebviewStore = defineStore('webview', () => { } return { - registeredWebviews, activeWebviewId, activeWebview, hasActiveWebview,