|
19 | 19 | class="mx-auto page-responsive-width mt-[-40px] md:px-0 relative" |
20 | 20 | v-loading="dataLoading" |
21 | 21 | > |
22 | | - <el-button |
| 22 | + <CsgButton |
23 | 23 | v-show="activeName == 'page' && repoDetailStore.endpoint" |
24 | | - color="#3250BD" |
25 | | - style="border-radius: var(--border-radius-md) !important" |
26 | | - class="absolute top-0 right-0 z-10 cursor-pointer text-white" |
| 24 | + class="btn btn-primary btn-sm absolute top-0 right-0 z-10" |
| 25 | + :name="$t('finetune.detail.notebook')" |
27 | 26 | @click="toNotebookPage" |
28 | | - >{{ $t('finetune.detail.notebook') }}</el-button |
29 | | - > |
| 27 | + /> |
30 | 28 | <el-tabs |
31 | 29 | v-model="activeName" |
32 | 30 | class="demo-tabs finetune-repo-tabs" |
|
37 | 35 | :label="$t('finetune.detail.tab1')" |
38 | 36 | name="page" |
39 | 37 | > |
40 | | - <div v-if="activeName === 'page'" class="pt-[24px]"> |
| 38 | + <div v-if="activeName === 'page'" class="pt-6 -mx-4"> |
41 | 39 | <iframe |
42 | 40 | v-if="repoDetailStore.endpoint" |
43 | 41 | :src="`${httpProtocal}://${repoDetailStore.proxyEndpoint}?jwt=${jwtToken}`" |
44 | 42 | width="100%" |
45 | | - height="700" |
| 43 | + :height="iframeHeight" |
46 | 44 | frameborder="0" |
47 | 45 | allowfullscreen |
| 46 | + class="block w-full" |
48 | 47 | > |
49 | 48 | </iframe> |
50 | 49 | <div |
51 | 50 | class="flex flex-col gap-6" |
52 | 51 | v-else |
53 | 52 | > |
54 | 53 | <div |
55 | | - class="flex items-center justify-start border border-gray-300 p-[16px] rounded-xl shadow-sm" |
| 54 | + class="flex items-center justify-start border border-gray-300 p-4 rounded-xl shadow-sm" |
56 | 55 | > |
57 | | - <div class="border border-gray-300 p-[10px] rounded-lg"> |
| 56 | + <div class="border border-gray-300 p-2 rounded-lg"> |
58 | 57 | <SvgIcon |
59 | 58 | name="finetune_tip" |
60 | 59 | width="20" |
61 | 60 | height="20" |
62 | 61 | /> |
63 | 62 | </div> |
64 | | - <div class="ml-[16px]"> |
65 | | - <p class="text-gray-700 text-sm font-medium mb-[4px]"> |
| 63 | + <div class="ml-4"> |
| 64 | + <p class="text-gray-700 text-sm font-medium mb-1"> |
66 | 65 | {{ $t('finetune.detail.noDataTip1') }} |
67 | 66 | </p> |
68 | 67 | <p class="text-gray-600 text-sm font-light"> |
|
119 | 118 | </template> |
120 | 119 |
|
121 | 120 | <script setup> |
122 | | - import { ref, inject, onBeforeMount, computed, provide, watch } from 'vue' |
| 121 | + import { ref, inject, onBeforeMount, computed, provide, watch, onMounted, onUnmounted } from 'vue' |
123 | 122 | import RepoHeader from '../shared/RepoHeader.vue' |
124 | 123 | import { useCookies } from 'vue3-cookies' |
125 | 124 | import { fetchEventSource } from '@microsoft/fetch-event-source' |
|
135 | 134 | import { useRepoTabStore } from '@/stores/RepoTabStore' |
136 | 135 | import { useRoute, useRouter } from 'vue-router' |
137 | 136 | import { validateTab } from '@/packs/utils' |
| 137 | + import CsgButton from '../shared/CsgButton.vue' |
138 | 138 |
|
139 | 139 | const props = defineProps({ |
140 | 140 | namespace: String, |
|
155 | 155 | const dataLoading = ref(false) |
156 | 156 | const finetuneResources = ref([]) |
157 | 157 | const finetuneResource = ref('') |
| 158 | + const iframeHeight = ref(700) // Default height |
158 | 159 | const allStatus = [ |
159 | 160 | 'Building', |
160 | 161 | 'Deploying', |
|
173 | 174 | const csghubServer = inject('csghubServer') |
174 | 175 | const httpProtocal = ENABLE_HTTPS === 'true' ? 'https' : 'http' |
175 | 176 |
|
| 177 | + // Function to calculate iframe height |
| 178 | + const calculateIframeHeight = () => { |
| 179 | + // Get viewport height |
| 180 | + const viewportHeight = window.innerHeight |
| 181 | + |
| 182 | + // Estimate fixed height parts to subtract |
| 183 | + // These values need to be adjusted based on actual page layout |
| 184 | + const headerHeight = 200 // RepoHeader approximate height |
| 185 | + const tabsHeight = 60 // Tabs navigation height |
| 186 | + const paddingAndMargin = 50 // Various padding and margin (reduced since iframe now fills container) |
| 187 | + |
| 188 | + // Calculate the height iframe should have |
| 189 | + const calculatedHeight = viewportHeight - headerHeight - tabsHeight - paddingAndMargin |
| 190 | + |
| 191 | + // Set minimum height to prevent being too small |
| 192 | + iframeHeight.value = Math.max(calculatedHeight, 700) |
| 193 | + } |
| 194 | +
|
| 195 | + // Recalculate height when window size changes |
| 196 | + const handleResize = () => { |
| 197 | + calculateIframeHeight() |
| 198 | + } |
| 199 | +
|
176 | 200 | const isSameRepo = computed(() => { |
177 | 201 | return ( |
178 | 202 | Number(props.finetuneId) === repoDetailStore.deployId && |
|
204 | 228 | return validTabs.value.includes(tab) |
205 | 229 | } |
206 | 230 |
|
207 | | - // 监听路由变化,当用户使用浏览器前进/后退按钮时更新tab |
| 231 | + // Listen for route changes, update tab when user uses browser forward/back buttons |
208 | 232 | watch(() => route.query.tab, (newTab) => { |
209 | 233 | const validatedTab = validateTab(newTab) |
210 | 234 | if (validatedTab && isValidTab(validatedTab) && validatedTab !== activeName.value) { |
|
378 | 402 | }) |
379 | 403 | }) |
380 | 404 |
|
| 405 | + onMounted(() => { |
| 406 | + calculateIframeHeight() |
| 407 | + window.addEventListener('resize', handleResize) |
| 408 | + }) |
| 409 | +
|
| 410 | + onUnmounted(() => { |
| 411 | + window.removeEventListener('resize', handleResize) |
| 412 | + }) |
| 413 | +
|
381 | 414 | provide('fetchRepoDetail', fetchRepoDetail) |
382 | 415 | </script> |
383 | 416 |
|
|
0 commit comments