优化web库的体积
This commit is contained in:
@@ -1,14 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<section class="mainContent">
|
<section class="mainContent">
|
||||||
<el-tabs class="layout" type="card" :value="currentTab" @tab-click="handleTabClick"
|
<el-tabs class="layout" type="card" :value="currentTab" @tab-click="handleTabClick" @tab-remove="handleTabRemove">
|
||||||
@tab-remove="handleTabRemove">
|
<el-tab-pane label="首页" name="0"/>
|
||||||
<el-tab-pane label="默认页" class="layoutItem">
|
<el-tab-pane v-for="op in tabs" :key="op.name" :name="op.name" :label="op.label" lazy closable/>
|
||||||
<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 v-if="currentTab==op.name"/>
|
|
||||||
</el-tab-pane>
|
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
|
<div class="fill">
|
||||||
|
<router-view/>
|
||||||
|
<ai-empty v-if="currentTab=='0'">欢迎使用村微产品库</ai-empty>
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -33,18 +32,22 @@ export default {
|
|||||||
$route: {
|
$route: {
|
||||||
immediate: true,
|
immediate: true,
|
||||||
handler() {
|
handler() {
|
||||||
this.getTabs("route")
|
this.getTabs()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleTabClick({name}) {
|
handleTabClick({name}) {
|
||||||
let {name: route, query, hash} = this.tabs.find(e => e.name == name),
|
if (name == '0') {
|
||||||
exps = []
|
this.$router.push("/")
|
||||||
query.id && exps.push(query.id)
|
} else {
|
||||||
hash && exps.push(hash)
|
let {name: route, query, hash} = this.tabs.find(e => e.name == name),
|
||||||
let reg = new RegExp(`(${exps.join("|")})`, 'g')
|
exps = []
|
||||||
this.$router.push({name: route.replace(reg, ''), query, hash})
|
query.id && exps.push(query.id)
|
||||||
|
hash && exps.push(hash)
|
||||||
|
let reg = new RegExp(`(${exps.join("|")})`, 'g')
|
||||||
|
this.$router.push({name: route.replace(reg, ''), query, hash})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
handleTabRemove(id = this.currentTab) {
|
handleTabRemove(id = this.currentTab) {
|
||||||
let tabs = JSON.parse(JSON.stringify(this.tabs)),
|
let tabs = JSON.parse(JSON.stringify(this.tabs)),
|
||||||
@@ -55,9 +58,8 @@ export default {
|
|||||||
}
|
}
|
||||||
this.tabs.splice(index, 1)
|
this.tabs.splice(index, 1)
|
||||||
},
|
},
|
||||||
getTabs(from) {
|
getTabs() {
|
||||||
let {name, query, hash} = this.$route
|
let {name, query, hash} = this.$route
|
||||||
console.log(`getTabs>>>>>>>>>%s>>>>>>>%s`, from, name)
|
|
||||||
let tab = this.tabs.find(e => e.name == this.currentTab),
|
let tab = this.tabs.find(e => e.name == this.currentTab),
|
||||||
tabName = [name, query?.id, hash].join("")
|
tabName = [name, query?.id, hash].join("")
|
||||||
if (tab) {
|
if (tab) {
|
||||||
@@ -68,6 +70,9 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
beforeRouteUpdate(to, from) {
|
||||||
|
console.log(to, from)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -75,9 +80,10 @@ export default {
|
|||||||
.mainContent {
|
.mainContent {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
::v-deep.layout {
|
::v-deep.layout {
|
||||||
height: 100%;
|
|
||||||
background: #F5F6F9;
|
background: #F5F6F9;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -95,7 +101,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.el-tabs__item {
|
.el-tabs__item {
|
||||||
padding: 0 8px 0 12px;
|
padding: 0 8px 0 12px !important;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
min-width: 130px;
|
min-width: 130px;
|
||||||
height: 36px;
|
height: 36px;
|
||||||
@@ -146,15 +152,6 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-tabs__content {
|
|
||||||
flex: 1;
|
|
||||||
min-height: 0;
|
|
||||||
|
|
||||||
.el-tab-pane {
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import store from "../store";
|
import store from "../store";
|
||||||
import {waiting} from "../utils";
|
import {waiting} from "../utils";
|
||||||
import appEntry from "../views/apps/appEntry";
|
import appEntry from "../views/appEntry";
|
||||||
import router from "./router";
|
import router from "./router";
|
||||||
import axios from "./axios";
|
import axios from "./axios";
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
<template>
|
|
||||||
<router-view />
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
name: "index"
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
Reference in New Issue
Block a user