1111 <LayoutContent :title =" $t (' website.websiteConfig' )" :back-name =" ' Website' " v-loading =" loading " >
1212 <template #app >
1313 <WebsiteStatus
14- v-if =" website .id > 0 "
14+ v-if =" website "
15+ :id =" id "
16+ @select =" selectWebsite "
1517 :primary-domain =" website .primaryDomain "
1618 :status =" website .status "
1719 :expire-date =" website .expireDate "
1820 />
1921 </template >
2022 <template #leftToolBar >
21- <el-button type =" primary" :plain =" index !== 'basic'" @click =" changeTab('basic')" >
23+ <el-button type =" primary" :plain =" props.tab !== 'basic'" @click =" changeTab('basic')" >
2224 {{ $t('website.basic') }}
2325 </el-button >
24- <el-button type =" primary" :plain =" index !== 'log'" @click =" changeTab('log')" >
26+ <el-button type =" primary" :plain =" props.tab !== 'log'" @click =" changeTab('log')" >
2527 {{ $t('commons.button.log') }}
2628 </el-button >
27- <el-button type =" primary" :plain =" index !== 'resource'" @click =" changeTab('resource')" >
29+ <el-button type =" primary" :plain =" props.tab !== 'resource'" @click =" changeTab('resource')" >
2830 {{ $t('website.source', 2) }}
2931 </el-button >
3032 </template >
3133 <template #main >
32- <MainDiv :heightDiff =" 260 " >
33- <Basic :website =" website " v-if =" index === ' basic' && website . id " :heightDiff =" 320 " ></Basic >
34- <Log :id =" id " v-if =" index === ' log' " ></Log >
35- <Resource :id =" id " v-if =" index === ' resource' " ></Resource >
34+ <MainDiv v-if = " website " :heightDiff =" 260 " >
35+ <Basic :website =" website " v-if =" props . tab === ' basic' " :heightDiff =" 320 " ></Basic >
36+ <Log :id =" id " v-if =" props . tab === ' log' " ></Log >
37+ <Resource :id =" id " v-if =" props . tab === ' resource' " ></Resource >
3638 </MainDiv >
3739 </template >
3840 </LayoutContent >
3941 </div >
4042</template >
4143
4244<script setup lang="ts">
43- import { onMounted , ref , watch } from ' vue' ;
45+ import { onMounted , ref } from ' vue' ;
4446import Basic from ' ./basic/index.vue' ;
4547import Resource from ' ./resource/index.vue' ;
4648import Log from ' ./log/index.vue' ;
4749import WebsiteStatus from ' @/views/website/website/status/index.vue' ;
4850import { getWebsite } from ' @/api/modules/website' ;
49- import { GetRuntime } from ' @/api/modules/runtime ' ;
51+ import type { Website } from ' @/api/interface/website ' ;
5052import { routerToNameWithParams } from ' @/utils/router' ;
5153import MainDiv from ' @/components/main-div/index.vue' ;
5254import { useGlobalStore } from ' @/composables/useGlobalStore' ;
@@ -66,34 +68,19 @@ const props = defineProps({
6668 },
6769});
6870
69- const id = ref (0 );
70- const index = ref (' basic' );
71- const website = ref <any >({});
72- const loading = ref (false );
73- const configPHP = ref (false );
71+ const id = Number (props .id );
72+ const website = ref <Website .WebsiteDTO >();
73+ const loading = ref (true );
7474
75- watch (index , (curr , old ) => {
76- if (curr != old ) {
77- changeTab (curr );
78- }
79- });
80-
81- const changeTab = (index : string ) => {
82- routerToNameWithParams (' WebsiteConfig' , { id: id .value , tab: index });
83- };
75+ const changeTab = (tab : string ) => routerToNameWithParams (' WebsiteConfig' , { id , tab });
76+ const selectWebsite = (id : number ) => routerToNameWithParams (' WebsiteConfig' , { id , tab: props .tab });
8477
8578onMounted (async () => {
86- index .value = props .tab ;
87- id .value = Number (props .id );
88- loading .value = true ;
89- const res = await getWebsite (id .value );
90- website .value = res .data ;
91- if (res .data .type === ' runtime' ) {
92- const runRes = await GetRuntime (res .data .runtimeID );
93- if (runRes .data .type == ' php' && runRes .data .resource === ' appstore' ) {
94- configPHP .value = true ;
95- }
79+ try {
80+ const { data } = await getWebsite (id );
81+ website .value = data ;
82+ } finally {
83+ loading .value = false ;
9684 }
97- loading .value = false ;
9885});
9986 </script >
0 commit comments