From 8a62c4ab0881fa99b29d4483c56d97ac2196b26d Mon Sep 17 00:00:00 2001
From: btea <2356281422@qq.com>
Date: Sun, 2 Jun 2024 08:11:31 +0800
Subject: [PATCH 3/6] feat: update height
---
src/SplitPane.vue | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/SplitPane.vue b/src/SplitPane.vue
index 68c98a9c..2a230492 100644
--- a/src/SplitPane.vue
+++ b/src/SplitPane.vue
@@ -42,7 +42,7 @@ function dragMove(e: MouseEvent) {
const dp = position - startPosition
state.split = startSplit + +((dp / totalSize) * 100).toFixed(2)
- state.viewHeight = rightView.value.offsetHeight
+ state.viewHeight = rightView.value.offsetHeight - 38
state.viewWidth = rightView.value.offsetWidth
}
}
@@ -52,7 +52,7 @@ function dragEnd() {
}
onMounted(() => {
- state.viewHeight = rightView.value.offsetHeight
+ state.viewHeight = rightView.value.offsetHeight - 38
state.viewWidth = rightView.value.offsetWidth
})
From 00a83973f6f6b8fbcb835034f41a591455a0f056 Mon Sep 17 00:00:00 2001
From: btea <2356281422@qq.com>
Date: Mon, 3 Jun 2024 07:13:22 +0800
Subject: [PATCH 4/6] feat: update
---
src/SplitPane.vue | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/SplitPane.vue b/src/SplitPane.vue
index 2a230492..03afcc87 100644
--- a/src/SplitPane.vue
+++ b/src/SplitPane.vue
@@ -42,8 +42,9 @@ function dragMove(e: MouseEvent) {
const dp = position - startPosition
state.split = startSplit + +((dp / totalSize) * 100).toFixed(2)
- state.viewHeight = rightView.value.offsetHeight - 38
- state.viewWidth = rightView.value.offsetWidth
+ const viewElement = rightView.value.querySelector('iframe')
+ state.viewHeight = viewElement.offsetHeight
+ state.viewWidth = viewElement.offsetWidth
}
}
@@ -52,8 +53,9 @@ function dragEnd() {
}
onMounted(() => {
- state.viewHeight = rightView.value.offsetHeight - 38
- state.viewWidth = rightView.value.offsetWidth
+ const viewElement = rightView.value.querySelector('iframe')
+ state.viewHeight = viewElement.offsetHeight
+ state.viewWidth = viewElement.offsetWidth
})
From fb972dd1adbff184addb73fe997a30ade9f681a1 Mon Sep 17 00:00:00 2001
From: btea <2356281422@qq.com>
Date: Mon, 3 Jun 2024 21:09:59 +0800
Subject: [PATCH 5/6] feat: update
---
src/Repl.vue | 14 +++++++++++++-
src/SplitPane.vue | 24 ++++++++++++++----------
src/output/Output.vue | 2 +-
src/output/Preview.vue | 2 +-
4 files changed, 29 insertions(+), 13 deletions(-)
diff --git a/src/Repl.vue b/src/Repl.vue
index 92c6840a..0d7673a4 100644
--- a/src/Repl.vue
+++ b/src/Repl.vue
@@ -60,6 +60,7 @@ if (!props.editor) {
}
const outputRef = ref
>()
+const splitPaneRef = ref>()
props.store.init()
@@ -75,6 +76,13 @@ provide('clear-console', toRef(props, 'clearConsole'))
provide('preview-options', props.previewOptions)
provide('theme', toRef(props, 'theme'))
provide('preview-theme', toRef(props, 'previewTheme'))
+
+function changeSize() {
+ if (outputRef.value?.previewRef?.container) {
+ splitPaneRef.value?.changeViewSize(outputRef.value.previewRef.container)
+ }
+}
+
/**
* Reload the preview iframe
*/
@@ -87,7 +95,11 @@ defineExpose({ reload })
-
+
diff --git a/src/SplitPane.vue b/src/SplitPane.vue
index 03afcc87..9fc4b413 100644
--- a/src/SplitPane.vue
+++ b/src/SplitPane.vue
@@ -1,12 +1,14 @@
@@ -80,7 +85,6 @@ onMounted(() => {
diff --git a/src/output/Output.vue b/src/output/Output.vue
index da613737..058d7d64 100644
--- a/src/output/Output.vue
+++ b/src/output/Output.vue
@@ -37,7 +37,7 @@ function reload() {
previewRef.value?.reload()
}
-defineExpose({ reload })
+defineExpose({ reload, previewRef })
diff --git a/src/output/Preview.vue b/src/output/Preview.vue
index e345d07b..a86eb827 100644
--- a/src/output/Preview.vue
+++ b/src/output/Preview.vue
@@ -286,7 +286,7 @@ function reload() {
sandbox.contentWindow?.location.reload()
}
-defineExpose({ reload })
+defineExpose({ reload, container })
From a8dc256cbc15fc0d2970b16335d72cf41ba3f801 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?=
Date: Tue, 4 Jun 2024 13:43:36 +0800
Subject: [PATCH 6/6] refactor
---
src/Repl.vue | 14 ++------------
src/SplitPane.vue | 21 ++++++++++++++-------
2 files changed, 16 insertions(+), 19 deletions(-)
diff --git a/src/Repl.vue b/src/Repl.vue
index 0d7673a4..30e0bc20 100644
--- a/src/Repl.vue
+++ b/src/Repl.vue
@@ -60,7 +60,6 @@ if (!props.editor) {
}
const outputRef = ref>()
-const splitPaneRef = ref>()
props.store.init()
@@ -76,12 +75,7 @@ provide('clear-console', toRef(props, 'clearConsole'))
provide('preview-options', props.previewOptions)
provide('theme', toRef(props, 'theme'))
provide('preview-theme', toRef(props, 'previewTheme'))
-
-function changeSize() {
- if (outputRef.value?.previewRef?.container) {
- splitPaneRef.value?.changeViewSize(outputRef.value.previewRef.container)
- }
-}
+provide('preview-ref', () => outputRef.value?.previewRef?.container)
/**
* Reload the preview iframe
@@ -95,11 +89,7 @@ defineExpose({ reload })
-
+
diff --git a/src/SplitPane.vue b/src/SplitPane.vue
index 9fc4b413..0cf34ca0 100644
--- a/src/SplitPane.vue
+++ b/src/SplitPane.vue
@@ -1,14 +1,20 @@