|
@@ -1,5 +1,5 @@
|
|
|
<script setup lang="ts">
|
|
|
-import { onMounted, onUnmounted, useTemplateRef, watch } from 'vue';
|
|
|
+import { onMounted, onUnmounted, ref, useTemplateRef, watch } from 'vue';
|
|
|
|
|
|
import { useViewVisible } from '@/hooks/view-visible';
|
|
|
import { EnvAreaMsgType, getEnvAreaMsgType } from '@/utils/env-area';
|
|
@@ -19,7 +19,7 @@ const emit = defineEmits<{
|
|
|
|
|
|
const { visible, showView, hideView } = useViewVisible();
|
|
|
const iframeRef = useTemplateRef('editorIframe');
|
|
|
-let isIframeLoaded = false;
|
|
|
+const isIframeLoaded = ref(false);
|
|
|
|
|
|
onMounted(() => {
|
|
|
window.addEventListener('message', handleIframeMsg);
|
|
@@ -30,7 +30,7 @@ onUnmounted(() => {
|
|
|
});
|
|
|
|
|
|
watch(visible, () => {
|
|
|
- if (visible.value && isIframeLoaded) {
|
|
|
+ if (visible.value && isIframeLoaded.value) {
|
|
|
sendAreaData();
|
|
|
}
|
|
|
});
|
|
@@ -39,7 +39,7 @@ const handleIframeMsg = (e: MessageEvent<IframeMsg>) => {
|
|
|
const { msgType } = e.data;
|
|
|
|
|
|
if (msgType === getEnvAreaMsgType(EnvAreaMsgType.EditLoaded)) {
|
|
|
- isIframeLoaded = true;
|
|
|
+ isIframeLoaded.value = true;
|
|
|
sendAreaData();
|
|
|
} else if (msgType === getEnvAreaMsgType(EnvAreaMsgType.EditOutdoorTempHumidity)) {
|
|
|
emit('openOutdoorDrawer');
|
|
@@ -78,6 +78,7 @@ defineExpose({
|
|
|
:footer="null"
|
|
|
>
|
|
|
<iframe ref="editorIframe" src="http://localhost:88/env-area"></iframe>
|
|
|
+ <ASpin v-if="!isIframeLoaded" class="center-loading env-area-editor-loading" :spinning="true" />
|
|
|
</AModal>
|
|
|
</template>
|
|
|
|
|
@@ -111,5 +112,10 @@ defineExpose({
|
|
|
border: none;
|
|
|
border-radius: 8px;
|
|
|
}
|
|
|
+
|
|
|
+ .env-area-editor-loading {
|
|
|
+ background-color: #fff;
|
|
|
+ border-radius: 8px;
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|