调整界面和底座风格基本保持一致
This commit is contained in:
		
							
								
								
									
										202
									
								
								examples/App.vue
									
									
									
									
									
								
							
							
						
						
									
										202
									
								
								examples/App.vue
									
									
									
									
									
								
							| @@ -1,21 +1,14 @@ | |||||||
| <template> | <template> | ||||||
|   <div id="app"> |   <div id="app"> | ||||||
|     <div class="header" v-if="showTools"> |     <header-nav v-if="showTools" :title="serveName"> | ||||||
|       <b v-text="serveName"/> |       <template #right> | ||||||
|       <el-button type="text" @click="showTools=false">隐藏工具栏</el-button> |         <div @click="showTools=false">隐藏工具栏</div> | ||||||
|       <el-button type="text" @click="handleLogin">点此登录</el-button> |         <div @click="handleLogin">点此登录</div> | ||||||
|     </div> |       </template> | ||||||
|     <el-row class="fill" type="flex"> |     </header-nav> | ||||||
|  |     <el-row class="fill mar-t48" type="flex"> | ||||||
|       <slider-nav v-if="showTools"/> |       <slider-nav v-if="showTools"/> | ||||||
|       <el-tabs class="layout fill" type="card" :value="currentTab" @tab-click="handleTabClick" |       <main-content class="fill"/> | ||||||
|                @tab-remove="handleTabRemove"> |  | ||||||
|         <el-tab-pane label="默认页" class="layoutItem"> |  | ||||||
|           <ai-empty>欢迎使用村微产品库</ai-empty> |  | ||||||
|         </el-tab-pane> |  | ||||||
|         <el-tab-pane v-for="op in tabs" :key="op.name" :closable="op.name!='工作台'" :name="op.name" :label="op.label" lazy> |  | ||||||
|           <router-view/> |  | ||||||
|         </el-tab-pane> |  | ||||||
|       </el-tabs> |  | ||||||
|     </el-row> |     </el-row> | ||||||
|     <div v-if="dialog" class="sign-box"> |     <div v-if="dialog" class="sign-box"> | ||||||
|       <ai-sign style="margin: auto" :instance="$axios" :action="{login}" |       <ai-sign style="margin: auto" :instance="$axios" :action="{login}" | ||||||
| @@ -26,14 +19,14 @@ | |||||||
| </template> | </template> | ||||||
|  |  | ||||||
| <script> | <script> | ||||||
| import {mapState} from "vuex"; |  | ||||||
| import SliderNav from "./components/sliderNav"; | import SliderNav from "./components/sliderNav"; | ||||||
|  | import MainContent from "./components/mainContent"; | ||||||
|  | import HeaderNav from "./components/headerNav"; | ||||||
|  |  | ||||||
| export default { | export default { | ||||||
|   name: 'app', |   name: 'app', | ||||||
|   components: {SliderNav}, |   components: {HeaderNav, MainContent, SliderNav}, | ||||||
|   computed: { |   computed: { | ||||||
|     ...mapState(['apps']), |  | ||||||
|     serveName() { |     serveName() { | ||||||
|       let names = { |       let names = { | ||||||
|         development: "村微产品库", |         development: "村微产品库", | ||||||
| @@ -41,33 +34,17 @@ export default { | |||||||
|       } |       } | ||||||
|       return names[process.env.NODE_ENV] |       return names[process.env.NODE_ENV] | ||||||
|     }, |     }, | ||||||
|     selectedApp() { |  | ||||||
|       return this.$route.matched.length > 0 |  | ||||||
|     }, |  | ||||||
|     login() { |     login() { | ||||||
|       let url = '/auth/oauth/token'; |       let url = '/auth/oauth/token'; | ||||||
|       /project\/sass/g.test(location.pathname) && (url += "?corpId=ww596787bb70f08288") |       /project\/sass/g.test(location.pathname) && (url += "?corpId=ww596787bb70f08288") | ||||||
|       return url |       return url | ||||||
|     }, |     }, | ||||||
|     currentTab() { |  | ||||||
|       let {name, query, hash} = this.$route |  | ||||||
|       return [name, query?.id, hash].join("") |  | ||||||
|     } |  | ||||||
|   }, |  | ||||||
|   watch: { |  | ||||||
|     $route: { |  | ||||||
|       immediate: true, |  | ||||||
|       handler(v) { |  | ||||||
|         this.getTabs(v) |  | ||||||
|       } |  | ||||||
|     }, |  | ||||||
|   }, |   }, | ||||||
|   data() { |   data() { | ||||||
|     return { |     return { | ||||||
|       token: "", |       token: "", | ||||||
|       dialog: false, |       dialog: false, | ||||||
|       showTools: true, |       showTools: true, | ||||||
|       tabs: [] |  | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|   methods: { |   methods: { | ||||||
| @@ -96,37 +73,8 @@ export default { | |||||||
|         this.dialog = true |         this.dialog = true | ||||||
|       }) |       }) | ||||||
|     }, |     }, | ||||||
|     handleTabClick(tab) { |  | ||||||
|       let to = {}, selectedTab = this.tabs.find(e => e.name == tab.name) |  | ||||||
|       if (selectedTab) { |  | ||||||
|         to = {...selectedTab, params: {tabclick: 1}} |  | ||||||
|       } else { |  | ||||||
|         let {name, query, hash} = tab |  | ||||||
|         to = {name, query, hash, params: {tabclick: 1}} |  | ||||||
|       } |  | ||||||
|       this.$router.push({...to}) |  | ||||||
|     }, |  | ||||||
|     handleTabRemove(id = this.currentTab) { |  | ||||||
|       let tabs = JSON.parse(JSON.stringify(this.tabs)), |  | ||||||
|           index = tabs?.findIndex(e => id == e.name) |  | ||||||
|       if (id == this.currentTab) { |  | ||||||
|         let next = tabs?.[index + 1] || tabs?.[index - 1] |  | ||||||
|         this.handleTabClick(next) |  | ||||||
|       } |  | ||||||
|       this.tabs.splice(index, 1) |  | ||||||
|     }, |  | ||||||
|     getTabs() { |  | ||||||
|       let {name, query, hash} = this.$route |  | ||||||
|       let tab = this.tabs.find(e => e.name == this.currentTab) |  | ||||||
|       if (tab) { |  | ||||||
|       } else if (name) { |  | ||||||
|         let menu = this.apps.find(e => e.name == name) |  | ||||||
|         this.tabs.push({name, query, hash, label: menu?.label}) |  | ||||||
|       } |  | ||||||
|     }, |  | ||||||
|   }, |   }, | ||||||
|   created() { |   created() { | ||||||
|     this.getTabs() |  | ||||||
|     this.token = localStorage.getItem("ui-token") |     this.token = localStorage.getItem("ui-token") | ||||||
|     if (this.token) this.getUserInfo() |     if (this.token) this.getUserInfo() | ||||||
|     wx = jWeixin |     wx = jWeixin | ||||||
| @@ -147,6 +95,10 @@ html, body { | |||||||
|   margin: 0; |   margin: 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | .mar-t48 { | ||||||
|  |   margin-top: 48px; | ||||||
|  | } | ||||||
|  |  | ||||||
| #app { | #app { | ||||||
|   font-family: 'Avenir', Helvetica, Arial, sans-serif; |   font-family: 'Avenir', Helvetica, Arial, sans-serif; | ||||||
|   -webkit-font-smoothing: antialiased; |   -webkit-font-smoothing: antialiased; | ||||||
| @@ -173,46 +125,6 @@ html, body { | |||||||
|     list-style-type: none; |     list-style-type: none; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   .menu { |  | ||||||
|     min-width: 200px; |  | ||||||
|     flex-shrink: 0; |  | ||||||
|     height: 100%; |  | ||||||
|     border-right: solid 1px #e6e6e6; |  | ||||||
|     background-color: #fff; |  | ||||||
|  |  | ||||||
|     .el-scrollbar__view { |  | ||||||
|       padding: 4px 8px; |  | ||||||
|       display: flex; |  | ||||||
|       flex-direction: column; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     .el-menu { |  | ||||||
|       border: none; |  | ||||||
|       flex: 1; |  | ||||||
|       min-height: 0; |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   & > .header { |  | ||||||
|     text-align: start; |  | ||||||
|     box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1); |  | ||||||
|     height: 43px; |  | ||||||
|     flex-shrink: 0; |  | ||||||
|     display: flex; |  | ||||||
|     align-items: center; |  | ||||||
|     padding: 0 16px; |  | ||||||
|     margin-bottom: 5px; |  | ||||||
|  |  | ||||||
|     & > b { |  | ||||||
|       flex: 1; |  | ||||||
|       min-width: 0; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     .el-input { |  | ||||||
|       max-width: 25%; |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   .sign-box { |   .sign-box { | ||||||
|     z-index: 99; |     z-index: 99; | ||||||
|     margin: -10px; |     margin: -10px; | ||||||
| @@ -223,90 +135,6 @@ html, body { | |||||||
|     height: 100%; |     height: 100%; | ||||||
|     background: rgba(0, 0, 0, 0.2); |     background: rgba(0, 0, 0, 0.2); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
| .layout { |  | ||||||
|   flex: 1; |  | ||||||
|   min-width: 0; |  | ||||||
|   height: 100%; |  | ||||||
|   background: #F5F6F9; |  | ||||||
|   display: flex; |  | ||||||
|   flex-direction: column; |  | ||||||
|  |  | ||||||
|   & > .el-tabs__header { |  | ||||||
|     margin-bottom: 0; |  | ||||||
|     background: linear-gradient(180deg, #FCFCFC 0%, #E0E2E4 100%); |  | ||||||
|     height: 40px; |  | ||||||
|     display: flex; |  | ||||||
|     align-items: flex-end; |  | ||||||
|     border: none; |  | ||||||
|  |  | ||||||
|     .el-tabs__nav { |  | ||||||
|       border: none; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     .el-tabs__item { |  | ||||||
|       padding: 0 8px 0 12px; |  | ||||||
|       text-align: left; |  | ||||||
|       min-width: 130px; |  | ||||||
|       height: 36px; |  | ||||||
|       line-height: 36px; |  | ||||||
|       border: none; |  | ||||||
|       color: #555; |  | ||||||
|       font-size: 12px; |  | ||||||
|  |  | ||||||
|       & + .el-tabs__item { |  | ||||||
|         margin-left: 2px; |  | ||||||
|       } |  | ||||||
|  |  | ||||||
|       .el-icon-close { |  | ||||||
|         float: right; |  | ||||||
|         width: auto; |  | ||||||
|         height: 100%; |  | ||||||
|         line-height: 36px; |  | ||||||
|         background: transparent; |  | ||||||
|         font-size: 16px; |  | ||||||
|         color: #89b; |  | ||||||
|  |  | ||||||
|         &:hover { |  | ||||||
|           color: #000; |  | ||||||
|         } |  | ||||||
|       } |  | ||||||
|  |  | ||||||
|       &.is-active { |  | ||||||
|         border: 1px solid #D8DCE3; |  | ||||||
|         border-bottom: none; |  | ||||||
|         border-radius: 4px 4px 0 0; |  | ||||||
|         background: #F5F6F9; |  | ||||||
|         color: #222; |  | ||||||
|  |  | ||||||
|         &:after { |  | ||||||
|           display: none; |  | ||||||
|         } |  | ||||||
|       } |  | ||||||
|  |  | ||||||
|       &:after { |  | ||||||
|         position: absolute; |  | ||||||
|         right: 0; |  | ||||||
|         content: " "; |  | ||||||
|         width: 1px; |  | ||||||
|         background: #D8DCE3; |  | ||||||
|         height: 24px; |  | ||||||
|         top: 50%; |  | ||||||
|         transform: translateY(-50%); |  | ||||||
|       } |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   .el-tabs__content { |  | ||||||
|     flex: 1; |  | ||||||
|     min-height: 0; |  | ||||||
|  |  | ||||||
|     .el-tab-pane { |  | ||||||
|       height: 100%; |  | ||||||
|     } |  | ||||||
|   } |  | ||||||
| } |  | ||||||
| </style> | </style> | ||||||
|   | |||||||
							
								
								
									
										
											BIN
										
									
								
								examples/assets/nav_bg.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								examples/assets/nav_bg.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 75 KiB | 
							
								
								
									
										271
									
								
								examples/components/headerNav.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										271
									
								
								examples/components/headerNav.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,271 @@ | |||||||
|  | <template> | ||||||
|  |   <div class="headerNav"> | ||||||
|  |     <div style="position: relative"> | ||||||
|  |       <ai-icon type="logo" :icon="'iconcunwei'"/> | ||||||
|  |       <ai-icon type="logo" :icon="'iconcunwei'" class="textShadow"/> | ||||||
|  |     </div> | ||||||
|  |     <span class="headerTitle">{{ title }}<div class="textShadow" v-html="title"/></span> | ||||||
|  |     <el-row type="flex" align="middle" class="toolbar"> | ||||||
|  |       <slot v-if="$slots.right" name="right"/> | ||||||
|  |     </el-row> | ||||||
|  |     <el-dropdown @visible-change="v=>isClick=v" @command="doMenu" class="rightDropdown"> | ||||||
|  |       <el-row type="flex" align="middle"> | ||||||
|  |         <el-avatar :src="user.info.avatar"> | ||||||
|  |           {{ user.info.name.slice(-2) }} | ||||||
|  |         </el-avatar> | ||||||
|  |         <span>{{ [user.info.name, user.info.roleName].join(" - ") }}</span> | ||||||
|  |         <i :class="dropdownIcon"/> | ||||||
|  |       </el-row> | ||||||
|  |       <el-dropdown-menu> | ||||||
|  |         <el-dropdown-item command="user">用户中心</el-dropdown-item> | ||||||
|  |         <el-dropdown-item command="signOut">退出</el-dropdown-item> | ||||||
|  |       </el-dropdown-menu> | ||||||
|  |     </el-dropdown> | ||||||
|  |   </div> | ||||||
|  | </template> | ||||||
|  |  | ||||||
|  | <script> | ||||||
|  | import {mapState} from "vuex"; | ||||||
|  |  | ||||||
|  | export default { | ||||||
|  |   name: 'headerNav', | ||||||
|  |   props: { | ||||||
|  |     title: {default: ""} | ||||||
|  |   }, | ||||||
|  |   data() { | ||||||
|  |     return { | ||||||
|  |       isClick: false, | ||||||
|  |       drawer: false,//抽屉 | ||||||
|  |       count: 0, | ||||||
|  |       filesList: [], | ||||||
|  |       fileName: '', | ||||||
|  |       badgeNum: 0, | ||||||
|  |       dvOptions: [] | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  |   computed: { | ||||||
|  |     ...mapState(['user']), | ||||||
|  |     dropdownIcon() { | ||||||
|  |       return this.isClick ? 'el-icon-caret-top' : 'el-icon-caret-bottom' | ||||||
|  |     }, | ||||||
|  |   }, | ||||||
|  |   methods: { | ||||||
|  |     // 获取最新的安卓、ios下载二维码 | ||||||
|  |     doMenu(comm) { | ||||||
|  |       switch (comm) { | ||||||
|  |         case 'signOut': | ||||||
|  |           //登出 | ||||||
|  |           this.$confirm("是否要登出?", {type: "warning"}).then(() => { | ||||||
|  |             this.$store.commit("SignOut") | ||||||
|  |           }).catch(() => { | ||||||
|  |           }) | ||||||
|  |           break; | ||||||
|  |         case 'user': | ||||||
|  |           this.$router.push({name: "个人中心"}) | ||||||
|  |           break; | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | </script> | ||||||
|  |  | ||||||
|  |  | ||||||
|  | <style lang="scss" scoped> | ||||||
|  | .headerNav { | ||||||
|  |   display: flex; | ||||||
|  |   align-items: center; | ||||||
|  |   width: 100%; | ||||||
|  |   background-image: url("../assets/nav_bg.png"); | ||||||
|  |   background-repeat: no-repeat; | ||||||
|  |   background-size: 100% 48px; | ||||||
|  |   position: fixed; | ||||||
|  |   z-index: 99; | ||||||
|  |   height: 48px; | ||||||
|  |   padding-left: 24px; | ||||||
|  |   box-sizing: border-box; | ||||||
|  |   top: 0; | ||||||
|  |   color: white; | ||||||
|  |   font-size: 14px; | ||||||
|  |  | ||||||
|  |   .AiIcon { | ||||||
|  |     font-size: 38px; | ||||||
|  |     width: auto; | ||||||
|  |     height: auto; | ||||||
|  |     background: linear-gradient(180deg, #FFFFFF 0%, #CCDBF6 100%); | ||||||
|  |     -webkit-background-clip: text; | ||||||
|  |     -webkit-text-fill-color: transparent; | ||||||
|  |  | ||||||
|  |     &:hover { | ||||||
|  |       color: white; | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   .headerTitle { | ||||||
|  |     flex: 1; | ||||||
|  |     min-width: 0; | ||||||
|  |     font-size: 24px; | ||||||
|  |     color: #FFF; | ||||||
|  |     line-height: 28px; | ||||||
|  |     background: linear-gradient(180deg, #FFFFFF 0%, #CCDBF6 100%); | ||||||
|  |     -webkit-background-clip: text; | ||||||
|  |     -webkit-text-fill-color: transparent; | ||||||
|  |     font-weight: bold; | ||||||
|  |     margin-left: 8px; | ||||||
|  |     position: relative; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   .textShadow { | ||||||
|  |     position: absolute; | ||||||
|  |     top: 0; | ||||||
|  |     text-shadow: 0 2px 0 #384DC3; | ||||||
|  |     color: transparent; | ||||||
|  |     z-index: -1; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   ::v-deep.toolbar { | ||||||
|  |     gap: 12px; | ||||||
|  |     margin-right: 32px; | ||||||
|  |  | ||||||
|  |     & > div { | ||||||
|  |       padding: 0 12px; | ||||||
|  |  | ||||||
|  |       &:hover { | ||||||
|  |         cursor: pointer; | ||||||
|  |         color: rgba(#fff, .8); | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   .el-dropdown { | ||||||
|  |     height: 48px; | ||||||
|  |     line-height: 48px; | ||||||
|  |     color: #fff; | ||||||
|  |     padding: 0 12px; | ||||||
|  |  | ||||||
|  |     &:hover { | ||||||
|  |       background-color: rgba(46, 51, 68, .15); | ||||||
|  |       color: white; | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   .el-image { | ||||||
|  |     margin: 12px 0 12px 16px; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |   .rightDropdown { | ||||||
|  |     font-size: 12px; | ||||||
|  |     padding: 0 16px; | ||||||
|  |     height: 48px; | ||||||
|  |     background: rgba(#fff, .1); | ||||||
|  |  | ||||||
|  |     .el-row { | ||||||
|  |       gap: 4px; | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | ::v-deep .downLoad_main { | ||||||
|  |   width: 100%; | ||||||
|  |   height: 100%; | ||||||
|  |   padding: 16px; | ||||||
|  |   box-sizing: border-box; | ||||||
|  |  | ||||||
|  |   .search_top { | ||||||
|  |     display: flex; | ||||||
|  |     justify-content: space-between; | ||||||
|  |     align-items: center; | ||||||
|  |     padding-bottom: 8px; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   .infinite-list { | ||||||
|  |     width: 100%; | ||||||
|  |     height: 100%; | ||||||
|  |  | ||||||
|  |     .infinite-list-item { | ||||||
|  |       width: 100%; | ||||||
|  |       padding: 8px; | ||||||
|  |       box-sizing: border-box; | ||||||
|  |       background: rgba(255, 255, 255, 1); | ||||||
|  |       border-radius: 4px; | ||||||
|  |       border: 1px solid rgba(208, 212, 220, 1); | ||||||
|  |       margin-bottom: 8px; | ||||||
|  |       display: flex; | ||||||
|  |       justify-content: space-between; | ||||||
|  |  | ||||||
|  |       .left { | ||||||
|  |         display: flex; | ||||||
|  |         justify-content: center; | ||||||
|  |         align-items: center; | ||||||
|  |         width: 30px; | ||||||
|  |  | ||||||
|  |         .svg { | ||||||
|  |           width: 24px; | ||||||
|  |           height: 24px; | ||||||
|  |           vertical-align: middle; | ||||||
|  |         } | ||||||
|  |       } | ||||||
|  |  | ||||||
|  |       .middle { | ||||||
|  |         flex: 1; | ||||||
|  |  | ||||||
|  |         .fileName { | ||||||
|  |           color: #333333; | ||||||
|  |           font-size: 14px; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         p:nth-child(2) { | ||||||
|  |           color: #999999; | ||||||
|  |           font-size: 12px; | ||||||
|  |  | ||||||
|  |           span { | ||||||
|  |             padding: 0 4px; | ||||||
|  |           } | ||||||
|  |  | ||||||
|  |           span:nth-child(2) { | ||||||
|  |             border-right: solid 1px #999999; | ||||||
|  |           } | ||||||
|  |  | ||||||
|  |           span:nth-child(3) { | ||||||
|  |             border-right: solid 1px #999999; | ||||||
|  |           } | ||||||
|  |         } | ||||||
|  |       } | ||||||
|  |  | ||||||
|  |       .right { | ||||||
|  |         display: flex; | ||||||
|  |         justify-content: center; | ||||||
|  |         align-items: center; | ||||||
|  |         font-size: 12px; | ||||||
|  |         width: 90px; | ||||||
|  |         text-align: center; | ||||||
|  |  | ||||||
|  |         span { | ||||||
|  |           color: #999999; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         i { | ||||||
|  |           display: block; | ||||||
|  |           width: 50px; | ||||||
|  |           color: #5088FF; | ||||||
|  |           font-size: 12px; | ||||||
|  |           cursor: pointer; | ||||||
|  |         } | ||||||
|  |       } | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   ::-webkit-scrollbar { | ||||||
|  |     width: 4px; | ||||||
|  |     background-color: #eee; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   ::-webkit-scrollbar-thumb { | ||||||
|  |     background-color: #8888; | ||||||
|  |  | ||||||
|  |   } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | </style> | ||||||
							
								
								
									
										162
									
								
								examples/components/mainContent.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										162
									
								
								examples/components/mainContent.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,162 @@ | |||||||
|  | <template> | ||||||
|  |   <section class="mainContent"> | ||||||
|  |     <el-tabs class="layout" type="card" :value="currentTab" @tab-click="handleTabClick" | ||||||
|  |              @tab-remove="handleTabRemove"> | ||||||
|  |       <el-tab-pane label="默认页" class="layoutItem"> | ||||||
|  |         <ai-empty>欢迎使用村微产品库</ai-empty> | ||||||
|  |       </el-tab-pane> | ||||||
|  |       <el-tab-pane v-for="op in tabs" :key="op.name" :closable="op.name!='工作台'" :name="op.name" :label="op.label" lazy> | ||||||
|  |         <router-view/> | ||||||
|  |       </el-tab-pane> | ||||||
|  |     </el-tabs> | ||||||
|  |   </section> | ||||||
|  | </template> | ||||||
|  |  | ||||||
|  | <script> | ||||||
|  | import {mapState} from "vuex"; | ||||||
|  |  | ||||||
|  | export default { | ||||||
|  |   name: "mainContent", | ||||||
|  |   computed: { | ||||||
|  |     ...mapState(['apps']), | ||||||
|  |     currentTab() { | ||||||
|  |       let {name, query, hash} = this.$route | ||||||
|  |       return [name, query?.id, hash].join("") | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  |   data() { | ||||||
|  |     return { | ||||||
|  |       tabs: [] | ||||||
|  |     } | ||||||
|  |   }, | ||||||
|  |   watch: { | ||||||
|  |     $route: { | ||||||
|  |       immediate: true, | ||||||
|  |       handler(v) { | ||||||
|  |         this.getTabs(v) | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |   }, | ||||||
|  |   methods: { | ||||||
|  |     handleTabClick(tab) { | ||||||
|  |       let to = {}, selectedTab = this.tabs.find(e => e.name == tab.name) | ||||||
|  |       if (selectedTab) { | ||||||
|  |         to = {...selectedTab, params: {tabclick: 1}} | ||||||
|  |       } else { | ||||||
|  |         let {name, query, hash} = tab | ||||||
|  |         to = {name, query, hash, params: {tabclick: 1}} | ||||||
|  |       } | ||||||
|  |       this.$router.push({...to}) | ||||||
|  |     }, | ||||||
|  |     handleTabRemove(id = this.currentTab) { | ||||||
|  |       let tabs = JSON.parse(JSON.stringify(this.tabs)), | ||||||
|  |           index = tabs?.findIndex(e => id == e.name) | ||||||
|  |       if (id == this.currentTab) { | ||||||
|  |         let next = tabs?.[index + 1] || tabs?.[index - 1] | ||||||
|  |         this.handleTabClick(next) | ||||||
|  |       } | ||||||
|  |       this.tabs.splice(index, 1) | ||||||
|  |     }, | ||||||
|  |     getTabs() { | ||||||
|  |       let {name, query, hash} = this.$route | ||||||
|  |       let tab = this.tabs.find(e => e.name == this.currentTab) | ||||||
|  |       if (tab) { | ||||||
|  |       } else if (name) { | ||||||
|  |         let menu = this.apps.find(e => e.name == name) | ||||||
|  |         this.tabs.push({name, query, hash, label: menu?.label}) | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|  |   }, | ||||||
|  |   created() { | ||||||
|  |     this.getTabs() | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | </script> | ||||||
|  |  | ||||||
|  | <style lang="scss" scoped> | ||||||
|  | .mainContent { | ||||||
|  |   height: 100%; | ||||||
|  |   width: 100%; | ||||||
|  |  | ||||||
|  |   ::v-deep.layout { | ||||||
|  |     height: 100%; | ||||||
|  |     background: #F5F6F9; | ||||||
|  |     display: flex; | ||||||
|  |     flex-direction: column; | ||||||
|  |  | ||||||
|  |     & > .el-tabs__header { | ||||||
|  |       margin-bottom: 0; | ||||||
|  |       background: linear-gradient(180deg, #FCFCFC 0%, #E0E2E4 100%); | ||||||
|  |       height: 40px; | ||||||
|  |       display: flex; | ||||||
|  |       align-items: flex-end; | ||||||
|  |       border: none; | ||||||
|  |  | ||||||
|  |       .el-tabs__nav { | ||||||
|  |         border: none; | ||||||
|  |       } | ||||||
|  |  | ||||||
|  |       .el-tabs__item { | ||||||
|  |         padding: 0 8px 0 12px; | ||||||
|  |         text-align: left; | ||||||
|  |         min-width: 130px; | ||||||
|  |         height: 36px; | ||||||
|  |         line-height: 36px; | ||||||
|  |         border: none; | ||||||
|  |         color: #555; | ||||||
|  |         font-size: 12px; | ||||||
|  |  | ||||||
|  |         & + .el-tabs__item { | ||||||
|  |           margin-left: 2px; | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         .el-icon-close { | ||||||
|  |           float: right; | ||||||
|  |           width: auto; | ||||||
|  |           height: 100%; | ||||||
|  |           line-height: 36px; | ||||||
|  |           background: transparent; | ||||||
|  |           font-size: 16px; | ||||||
|  |           color: #89b; | ||||||
|  |  | ||||||
|  |           &:hover { | ||||||
|  |             color: #000; | ||||||
|  |           } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         &.is-active { | ||||||
|  |           border: 1px solid #D8DCE3; | ||||||
|  |           border-bottom: none; | ||||||
|  |           border-radius: 4px 4px 0 0; | ||||||
|  |           background: #F5F6F9; | ||||||
|  |           color: #222; | ||||||
|  |  | ||||||
|  |           &:after { | ||||||
|  |             display: none; | ||||||
|  |           } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         &:after { | ||||||
|  |           position: absolute; | ||||||
|  |           right: 0; | ||||||
|  |           content: " "; | ||||||
|  |           width: 1px; | ||||||
|  |           background: #D8DCE3; | ||||||
|  |           height: 24px; | ||||||
|  |           top: 50%; | ||||||
|  |           transform: translateY(-50%); | ||||||
|  |         } | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     .el-tabs__content { | ||||||
|  |       flex: 1; | ||||||
|  |       min-height: 0; | ||||||
|  |  | ||||||
|  |       .el-tab-pane { | ||||||
|  |         height: 100%; | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | } | ||||||
|  | </style> | ||||||
		Reference in New Issue
	
	Block a user