|
28 | 28 | </template>
|
29 | 29 |
|
30 | 30 | <script setup>
|
31 |
| - import { ref, inject, nextTick, computed, onMounted } from 'vue' |
| 31 | + import { ref, inject, nextTick, computed, onMounted, watch } from 'vue' |
32 | 32 | import refreshJWT from '../../packs/refreshJWT.js'
|
33 | 33 | import { fetchEventSource } from '@microsoft/fetch-event-source';
|
34 | 34 | import { useCookies } from "vue3-cookies";
|
| 35 | + import useRepoDetailStore from '../../stores/RepoDetailStore.js' |
35 | 36 |
|
36 | 37 | const props = defineProps({
|
37 | 38 | instances: Array,
|
38 | 39 | modelId: String,
|
39 | 40 | deployId: Number
|
40 | 41 | })
|
41 | 42 |
|
| 43 | + const repoDetailStore = useRepoDetailStore() |
42 | 44 | const csghubServer = inject('csghubServer')
|
43 | 45 | const { cookies } = useCookies()
|
44 | 46 | const instanceLogDiv = ref(null)
|
45 | 47 | const instanceLogLineNum = ref(0)
|
46 | 48 | const isLogsSSEConnected = ref(false)
|
47 |
| -
|
48 | 49 | const currentInstance = computed(() => {
|
49 |
| - return props.instances ? props.instances[0]?.name : '' |
| 50 | + return repoDetailStore.activeInstance |
| 51 | + }) |
| 52 | +
|
| 53 | + watch([() => props.modelId, () => props.deployId], () => { |
| 54 | + if (currentInstance.value && isLogsSSEConnected.value === false) { |
| 55 | + syncInstanceLogs(currentInstance.value) |
| 56 | + } |
| 57 | + }) |
| 58 | +
|
| 59 | + watch(() => repoDetailStore.status, () => { |
| 60 | + if (currentInstance.value && isLogsSSEConnected.value === false) { |
| 61 | + syncInstanceLogs(currentInstance.value) |
| 62 | + } |
50 | 63 | })
|
51 | 64 |
|
52 | 65 | const syncInstanceLogs = (instanceName) => {
|
|
146 | 159 | }
|
147 | 160 |
|
148 | 161 | onMounted(() => {
|
149 |
| - if (!!currentInstance.value && isLogsSSEConnected.value === false) { |
| 162 | + if (currentInstance.value && isLogsSSEConnected.value === false) { |
150 | 163 | syncInstanceLogs(currentInstance.value)
|
151 | 164 | }
|
152 | 165 | })
|
|
0 commit comments