11<script lang="ts" setup>
22import {ref } from " vue" ;
33import MarketView from ' @/views/market/index.vue'
4+ import WorkbenchView from ' @/views/workbench/workbench.vue'
45import Text from " @/components/normal/Text.vue" ;
56import router from " @/router" ;
67import Snackbar from " @/components/normal/Snackbar.vue" ;
78
89// 导航栏
910const currentIndex = ref (0 )
1011const tabs = [
11- { name: ' market' , component: MarketView },
12- { name: ' home' , component: MarketView },
12+ { name: ' market' , local: ' /market ' },
13+ { name: ' home' , local: ' /market ' },
1314]
15+ // 通过tab切换内容展示
1416const selectTab = (index : any ) => {
1517 currentIndex .value = index ;
1618}
@@ -33,23 +35,22 @@ const authStore = useAuthStore();
3335 :key =" index"
3436 class =" tab-button"
3537 :class =" { active: currentIndex === index }"
36- @click =" selectTab( index)"
38+ @click =" router.push(tabs[ index].local )"
3739 >
3840 <Text >{{ tab.name }}</Text >
3941 </div >
42+ <div class =" search" >
43+ <input placeholder =" Search" />
44+ </div >
4045 </nav >
4146 <nav class =" side flex" >
4247 <button v-if =" !authStore.isLoggedIn" @click =" router.push('/login')" >login</button >
4348 <button v-else @click =" router.push('/personal')" >头像</button >
49+ <button class =" workBtn" @click =" router.push('/workbench')" >我的工作台</button >
4450 </nav >
4551 </header >
4652 <div class =" tabs-content" >
47- <component
48- v-for =" (tab, index) in tabs"
49- :key =" index"
50- :is =" tab.component"
51- :v-if =" currentIndex === index"
52- />
53+ <RouterView ></RouterView >
5354 </div >
5455 </div >
5556</template >
@@ -68,18 +69,29 @@ const authStore = useAuthStore();
6869 display : flex ;
6970 background-color : #FFFBDD ;
7071 height :70px ;
71- }
72- .side {
73- flex :1 ;
74- }
75- .tab-button {
76- cursor : pointer ;
77- user-select : none ;
78- transition : background-color 0.3s ;
79- }
72+ .side {
73+ flex :1 ;
74+ }
75+ .tab-button {
76+ cursor : pointer ;
77+ user-select : none ;
78+ transition : background-color 0.3s ;
79+ }
8080
81- .tab-button.active {
82- background-color : #f4efd3 ;
83- border-bottom : 2px solid #f4efd3 ;
81+ .tab-button.active {
82+ background-color : #f4efd3 ;
83+ border-bottom : 2px solid #f4efd3 ;
84+ }
85+ .search {
86+ background-color : rgba (0 , 0 , 0 , 0.07 );
87+ padding : 10px 30px ;
88+ border-radius : 10px ;
89+ margin-left :20px ;
90+ }
91+ .workBtn {
92+ margin-left :20px ;
93+ border : 1px solid #3a3a3a ;
94+ }
8495}
96+
8597 </style >
0 commit comments