From 3571b5d49af02731fa51872077663cdab6855be8 Mon Sep 17 00:00:00 2001 From: Dianliang233 Date: Mon, 14 Oct 2024 15:59:40 +0800 Subject: [PATCH] More robust way of watching --- src/tools/chunkbase/App.vue | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/tools/chunkbase/App.vue b/src/tools/chunkbase/App.vue index a7db26c..0ce21cd 100644 --- a/src/tools/chunkbase/App.vue +++ b/src/tools/chunkbase/App.vue @@ -157,16 +157,6 @@ const edition = ref<'java' | 'bedrock'>('java') const iframe = useTemplateRef('iframe') -watch([edition], () => { - if (iframe.value === null) return - const src = iframe.value.src - iframe.value.src = '' - setTimeout(() => { - if (iframe.value === null) return - iframe.value.src = src - }) -}) - const chunkbaseUrl = computed(() => { const normalizedParams: Record = {} for (const [key, value] of Object.entries(params.value)) { @@ -196,6 +186,15 @@ const chunkbaseUrl = computed(() => { 'https://www.chunkbase.com/seed-map-embed', ).toString() }) + +watch([chunkbaseUrl], () => { + if (iframe.value === null) return + iframe.value.src = '' + setTimeout(() => { + if (iframe.value === null) return + iframe.value.src = chunkbaseUrl.value + }) +})