Skip to content

Commit 2dc6da8

Browse files
fix: Add loading prompt for embedded page #622
1 parent 8a143ed commit 2dc6da8

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

frontend/src/views/embedded/page.vue

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<template>
2-
<div :class="dynamicType === 4 ? 'sqlbot--embedded-page' : 'sqlbot-embedded-assistant-page'">
2+
<div
3+
v-loading="divLoading"
4+
:class="dynamicType === 4 ? 'sqlbot--embedded-page' : 'sqlbot-embedded-assistant-page'"
5+
>
36
<chat-component
47
v-if="!loading"
58
ref="chatRef"
@@ -13,7 +16,7 @@
1316
</template>
1417
<script setup lang="ts">
1518
import ChatComponent from '@/views/chat/index.vue'
16-
import { nextTick, onBeforeMount, onBeforeUnmount, reactive, ref } from 'vue'
19+
import { nextTick, onBeforeMount, onBeforeUnmount, reactive, ref, watch } from 'vue'
1720
import { useRoute } from 'vue-router'
1821
import { assistantApi } from '@/api/assistant'
1922
import { useAssistantStore } from '@/stores/assistant'
@@ -47,6 +50,7 @@ const validator = ref({
4750
token: '',
4851
})
4952
const loading = ref(true)
53+
const divLoading = ref(true)
5054
const eventName = 'sqlbot_embedded_event'
5155
const communicationCb = async (event: any) => {
5256
if (event.data?.eventName === eventName) {
@@ -80,6 +84,17 @@ const communicationCb = async (event: any) => {
8084
}
8185
}
8286
}
87+
88+
watch(
89+
() => loading.value,
90+
(val) => {
91+
nextTick(() => {
92+
setTimeout(() => {
93+
divLoading.value = val
94+
}, 1000)
95+
})
96+
}
97+
)
8398
const createChat = () => {
8499
chatRef.value?.createNewChat()
85100
}

0 commit comments

Comments
 (0)