增加视图模式切换demo

This commit is contained in:
qxz 2020-05-15 10:20:09 +08:00
parent 05bf9d6aaa
commit 3754ac2a84
2 changed files with 70 additions and 24 deletions

View File

@ -1,44 +1,66 @@
<template> <template>
<nav class="breadcrumb is-hidden-mobile is-hidden-touch" aria-label="breadcrumbs"> <div>
<ul> <nav
<li> class="breadcrumb is-hidden-mobile is-hidden-touch level g2-breadcrumb"
<a v-show="navs && navs.length>0" @click="go('/'+index+':/')">{{$t('index')}}</a> aria-label="breadcrumbs"
</li> >
<li <div class="level-left">
v-for="(item,index) in navs" <div class="level-item">
:class="(index+1)==navs.length?'is-active':''" <ul>
v-bind:key="index" <li>
> <a @click="go('/'+index+':/')">{{$t('index')}}</a>
<a v-if="(index+1)==navs.length" aria-current="page" href="#">{{item.title}}</a> </li>
<a v-else @click="go(item.path)">{{item.title}}</a> <li
</li> v-for="(item,index) in navs"
</ul> :class="(index+1)==navs.length?'is-active':''"
</nav> v-bind:key="index"
>
<a v-if="(index+1)==navs.length" aria-current="page" href="#">{{item.title}}</a>
<a v-else @click="go(item.path)">{{item.title}}</a>
</li>
</ul>
</div>
</div>
<div class="level-right">
<div
class="level-item"
v-show="$route.meta.view==='list'"
:title="$route.meta.view==='list'?'列表视图':'网格视图'"
@click="changeView"
>
<span class="icon">
<i :class="'fa'+(listMode ? ' fa-th': ' fa-th-list')" aria-hidden="true"></i>
</span>
</div>
</div>
</nav>
</div>
</template> </template>
<script> <script>
import { decode64 } from "@utils/AcrouUtil"; import { decode64 } from "@utils/AcrouUtil";
export default { export default {
props: ["name"], props: ["name"],
data: function() { data: function () {
return { return {
navs: [], navs: [],
index: "/" index: "/",
listMode: true
}; };
}, },
mounted() { mounted () {
this.render(); this.render();
}, },
watch: { watch: {
$route: "render" $route: "render"
}, },
methods: { methods: {
go(path) { go (path) {
this.$router.push({ this.$router.push({
path: path path: path
}); });
}, },
render() { render () {
this.index = this.$route.params.id; this.index = this.$route.params.id;
let cmd = this.$route.params.cmd let cmd = this.$route.params.cmd
// //
@ -47,7 +69,7 @@ export default {
return; return;
} }
let path = this.$route.path let path = this.$route.path
if(cmd){ if (cmd) {
path = decode64(this.$route.params.path) path = decode64(this.$route.params.path)
} }
var arr = path.trim("/").split("/"); var arr = path.trim("/").split("/");
@ -74,7 +96,29 @@ export default {
} }
this.navs = navs; this.navs = navs;
} }
},
changeView () {
this.listMode = !this.listMode;
} }
} }
}; };
</script> </script>
<style lang="scss" scoped>
.g2-breadcrumb {
border-bottom: 2px solid whitesmoke;
height: 100%;
padding: 0 0.75em;
}
.level-right {
.level-item {
border-radius: 50%;
height: 40px;
width: 40px;
&:hover {
border: 1px dotted transparent;
background: rgba(0, 0, 0, 0.12);
text-decoration: none;
}
}
}
</style>

View File

@ -10,7 +10,9 @@
>goindex-theme-acrou</a> >goindex-theme-acrou</a>
<span class="tag is-light"> <span class="tag is-light">
MIT &nbsp; MIT &nbsp;
<i class="fab fa-github"></i> <span class="icon">
<i class="fab fa-github"></i>
</span>
</span> </span>
</div> </div>
</div> </div>
@ -23,7 +25,7 @@
export default { export default {
props: {}, props: {},
watch: {}, watch: {},
data: function() { data: function () {
return { return {
content: "" content: ""
}; };