Commit 542b52da by gyy

缓存

parent 8499a687
......@@ -10,49 +10,27 @@
{{item}}
</div>
</div>
<div class="y_default_start">
<div class="main_left" :style="{height: clientHeight + 'px'}">
<el-menu
:default-active="$route.path" :router="isRoute"
class="el-menu-vertical-demo"
@open="handleOpen"
@close="handleClose" v-for="(item, index) in leftMenuList">
<el-submenu :index="item.name">
<template slot="title">
<i class="el-icon-location"></i>
<span>{{item.name}}</span>
</template>
<el-menu-item :class="$route.path===sub.path?'orderCtg_list_now':''" :index="sub.path" v-for="(sub, subIndex) in item.pageList">{{sub.name}}</el-menu-item>
</el-submenu>
</el-menu>
</div>
<!-- 侧边栏结束 -->
<div class="main_right" :style="{width: clientWidth + 'px'}">
<div class="crumbs">
<div class="y_flex_start" >
<div @click="toleft"><</div>
<div style="width: 100%; overflow: hidden;">
<div class="y_flex_start crumbs_text">
<div class="crumbs_list" v-for="(item, index) in Array.from(visitedViews)" :class="isActive(item)?'crumbs_active':''" @contextmenu.prevent="openMenu(item,$event)">
<router-link :to="item.path">{{item.name}}</router-link>
<span class="crumbs_close" @click="closeSelectedTag(item)">×</span>
</div>
</div>
</div>
<div @click="toright">></div>
</div>
<ul v-show="visible" :style="{left:left+'px'}" class="contextmenu">
<li>刷新</li>
<li @click="closeSelectedTag(selectedTag)">关闭</li>
<li @click="closeOthersTags">关闭其他</li>
<li @click="closeAllTags">关闭所有</li>
</ul>
</div>
<!--<nuxt class="content"/>-->
<keep-alive include='managers'>
<router-view class="content"></router-view>
</keep-alive>
</div>
<div class="main_left">
<el-menu
:default-active="$route.path" :router="isRoute"
class="el-menu-vertical-demo"
@open="handleOpen"
@close="handleClose" v-for="(item, index) in leftMenuList">
<el-submenu :index="item.name">
<template slot="title">
<i class="el-icon-location"></i>
<span>{{item.name}}</span>
</template>
<el-menu-item @click="toDes" :class="$route.path===sub.path?'orderCtg_list_now':''" :index="sub.path" v-for="(sub, subIndex) in item.pageList">{{sub.name}}</el-menu-item>
</el-submenu>
</el-menu>
</div>
<!-- 侧边栏结束 -->
<div class="main_right">
<!--<nuxt class="content"/>-->
<keep-alive :include='cachedViews'>
<router-view class="content" :key="key"></router-view>
</keep-alive>
</div>
</div>
</div>
......@@ -86,40 +64,11 @@ export default {
}
},
computed: {
visitedViews() {
// return this.$store.state.systemTags.sVisitedViews
if (this.tabNow === 0) {
return this.$store.state.systemTags.sVisitedViews
} else if (this.tabNow === 1) {
return this.$store.state.goodsTags.gVisitedViews
} else if (this.tabNow === 2) {
return this.$store.state.orderTags.oVisitedViews
} else {
return this.$store.state.financalTags.fVisitedViews
}
}
// leftMenuList() {
// if (this.tabNow === 0) {
// return this.systemList
// } else if (this.tabNow === 1) {
// return this.goodManageList
// } else if (this.tabNow === 2) {
// return this.orderList
// } else {
// return this.financeList
// }
// }
},
watch: {
$route() {
this.addViewTags()
cachedViews() {
return this.$store.state.tagView.cachedViews
},
visible(value) {
if (value) {
document.body.addEventListener('click', this.closeMenu)
} else {
document.body.removeEventListener('click', this.closeMenu)
}
key() {
return this.$route.fullPath
}
},
methods: {
......@@ -140,109 +89,6 @@ export default {
},
handleClose() {
},
generateRoute() {
if (this.$route.name) {
return this.$route
}
return false
},
// 向tag中添加打开的页面名称
addViewTags() {
const route = this.generateRoute()
if (!route) {
return false
}
// this.$store.dispatch('sAddVisitedViews', route)
if (this.tabNow === 0) {
this.$store.dispatch('sAddVisitedViews', route)
} else if (this.tabNow === 1) {
this.$store.dispatch('gAddVisitedViews', route)
} else if (this.tabNow === 2) {
this.$store.dispatch('oAddVisitedViews', route)
} else {
this.$store.dispatch('fAddVisitedViews', route)
}
},
// 判断是否为当前页面
isActive(route) {
return route.path === this.$route.path
},
// 关闭当前tag中的页面
closeSelectedTag(view) {
let delVisitedViews
if (this.tabNow === 0) {
delVisitedViews = 'sDelVisitedViews'
} else if (this.tabNow === 1) {
delVisitedViews = 'gDelVisitedViews'
} else if (this.tabNow === 2) {
delVisitedViews = 'oDelVisitedViews'
} else {
delVisitedViews = 'fDelVisitedViews'
}
this.$store.dispatch(delVisitedViews, view).then((views) => {
if (this.isActive(view)) {
const latestView = views.slice(-1)[0]
if (latestView) {
this.$router.push(latestView)
} else {
this.$router.push('/')
}
}
})
},
// 右键打开
openMenu(tag, e) {
this.visible = true
this.selectedTag = tag
let clientWidth = document.documentElement.clientWidth * 0.1
this.left = e.clientX - clientWidth + 40 // 15: margin right
console.log(e.clientX)
console.log(clientWidth)
},
// 关闭其他
closeOthersTags() {
this.$router.push(this.selectedTag)
let delOthersViews
if (this.tabNow === 0) {
delOthersViews = 'sDelOthersViews'
} else if (this.tabNow === 1) {
delOthersViews = 'gDelOthersViews'
} else if (this.tabNow === 2) {
delOthersViews = 'oDelOthersViews'
} else {
delOthersViews = 'fDelOthersViews'
}
this.$store.dispatch(delOthersViews, this.selectedTag)
},
moveToCurrentTag() {
const tags = this.$refs.tag
this.$nextTick(() => {
for (const tag of tags) {
if (tag.to.path === this.$route.path) {
this.$refs.scrollPane.moveToTarget(tag.$el)
break
}
}
})
},
// 关闭所有
closeAllTags() {
let delAllViews
if (this.tabNow === 0) {
delAllViews = 'sDelAllViews'
} else if (this.tabNow === 1) {
delAllViews = 'gDelAllViews'
} else if (this.tabNow === 2) {
delAllViews = 'oDelAllViews'
} else {
delAllViews = 'fDelAllViews'
}
this.$store.dispatch(delAllViews)
this.$router.push('/')
},
closeMenu() {
this.visible = false
},
// 获取列表数据
getOrderCtg: async function () {
console.log('get data ==== ')
......@@ -285,27 +131,11 @@ export default {
},
// 获取窗口可视范围的高度
getClientHeight() {
// let clientHeight = 0
// if (document.body.clientHeight && document.documentElement.clientHeight) {
// clientHeight = (document.body.clientHeight < document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight
// } else {
// clientHeight = (document.body.clientHeight > document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight
// }
this.clientHeight = document.documentElement.clientHeight - 76
this.clientWidth = document.documentElement.clientWidth - 240
},
toleft() {
if (this.moveNum !== 0) {
this.moveNum ++
let root = document.getElementsByClassName('crumbs_text')[0]
root.style.cssText = 'transform: translateX(' + this.moveLength * this.moveNum + 'px);'
}
},
toright() {
console.log(this.visitedViews.length)
this.moveNum --
let root = document.getElementsByClassName('crumbs_text')[0]
root.style.cssText = 'transform: translateX(' + this.moveLength * this.moveNum + 'px);'
toDes() {
this.$store.dispatch('delAllViews')
}
},
mounted() {
......@@ -316,7 +146,6 @@ export default {
this.tabNow = parseInt(YCookie.readLocalCookie('tabNow'))
}
this.getOrderCtg()
this.addViewTags()
}
}
</script>
......@@ -380,30 +209,48 @@ export default {
background: #204077;
}
.nav_item{
color: #D4D4D4;
color: #ADB1B6;
overflow: hidden;
font-size: 14px;
position: relative;
width: 130px;
margin-left: 8px;
cursor: pointer;
height: 30px;
line-height: 30px;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
height: 40px;
line-height: 40px;
text-align: center;
}
.nav_active{
background: #E8E9EE;
color: #43478e;
/*background: #E8E9EE;*/
color: #FFFFFF;
font-weight: bold;
}
.main_left{
background: #E8E9EE;
width: 240px;
width: 230px;
position: fixed;
left: 0;
top: 97px;
bottom: 0;
z-index: 2;
display: block;
overflow-x: hidden;
overflow-y: auto;
background: #232936;
}
.main_left::-webkit-scrollbar {
display:none;
}
.main_right{
position: relative;
position: fixed;
left: 230px;
top: 97px;
bottom: 0;
z-index: 1;
right: 0;
overflow-y: auto;
display: block;
background: #edeeef;
}
.crumbs{
background: #E8E9EE;
......@@ -456,11 +303,9 @@ export default {
margin-bottom: 4px;
cursor: pointer;
}
.el-menu-item.is-active {
color: #303133;
}
.orderCtg_list_now{
color: #C01E00!important;
color: #FFFFFF!important;
background-color: #545a6b!important;
position: relative;
}
.contextmenu {
......@@ -488,14 +333,38 @@ export default {
.content{
width: 100%;
box-sizing: border-box;
border-top: 1px solid #000;
border-left: 1px solid #000;
position: absolute;
top: 31px;
bottom: 0px;
right: 0px;
padding: 0 10px;
}
.el-menu{
transition: all 0s!important;
}
/*侧边栏样式*/
.el-submenu__title, .el-menu{
background: #232936;
width: 230px;
}
.el-submenu__title{
color: #ADB1B6;
}
.el-icon-location{
display: none!important;
}
.el-menu-item{
color: #8B8B90;
}
.el-menu-item.is-active {
color: #8B8B90;
}
.el-submenu__title:hover{
background-color: #545a6b;
color: #FFFFFF;
}
.el-menu-item:hover {
background-color: #545a6b;
color: #FFFFFF;
}
</style>
<template>
<div class="container">
<div v-for="item in unpayList">{{item.name}}</div>
<div @click="toDetail">详情</div>
<div class="pagination-container">
<el-pagination
:current-page="pagination.page"
:page-sizes="[10,20,30, 50]"
:page-size="pagination.size"
:total="total"
background
layout="total, sizes, prev, pager, next, jumper"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"/>
</div>
</div>
</template>
<script>
import requestApi from '../../../../assets/js/requestApi.js'
export default {
data() {
return {
total: 80,
pagination: {
page: 1,
size: 10
},
unpayList: []
}
},
methods: {
getList: async function () {
let param = {
storeId: 25,
categoryId: 0,
pageNo: this.pagination.page,
pageSize: this.pagination.size
}
let obj = await requestApi.getList(this, param)
this.unpayList = obj.data.result
},
handleSizeChange(val) {
this.pagination.size = val
this.getList()
},
handleCurrentChange(val) {
this.pagination.page = val
this.getList()
},
toDetail() {
this.$router.push({
path: 'laps-detail'
})
console.log(this.$route)
this.$store.dispatch('addVisitedViews', this.$route)
console.log(this.$store.state.tagView.cachedViews[0])
}
},
mounted() {
this.getList()
console.log('00')
}
// activated() {
// let cachedViews = this.$store.state.tagView.cachedViews[0]
// if (cachedViews === this.$route.name) {
// console.log('--缓存--')
// } else {
// console.log('--不缓存--')
// this.pagination.page = 1
// this.pagination.size = 10
// this.getList()
// }
// }
}
</script>
<style scoped>
.edit-input {
padding-right: 100px;
}
.cancel-btn {
position: absolute;
right: 15px;
top: 10px;
}
</style>
<template>
<section class="container">
<h1 class="title">
{{$route.name}}
</h1>
<page></page>
</section>
</template>
<script>
import page from './components/page.vue'
export default {
name: 'good-laps-goods-search',
components: {
page
},
methods: {}
}
</script>
<style scoped>
</style>
<template>
<div class="container">
<div>{{count}}</div>
<button @click="b">plus</button>
</div>
<section class="container">
<nuxt-link to="goods-search">返回</nuxt-link>
</section>
</template>
<script>
export default {
data() {
return {
count: 1
}
},
methods: {
b() {
this.count++
export default {
data() {
return {}
},
methods: {
}
}
}
</script>
<style scoped>
.title
{
margin: 50px 0;
}
</style>
<template>
<div>
<div @click="toDetail">详情</div>
<div>{{count}}</div>
<button @click="add">plus</button>
</div>
</template>
<script>
export default {
data() {
return {
count: 1
}
},
methods: {
add() {
this.count++
},
toDetail() {
this.$router.push({
path: 'order-detail'
})
console.log(this.$route)
this.$store.dispatch('addVisitedViews', this.$route)
console.log(this.$store.state.tagView.cachedViews[0])
}
}
// activated() {
// let cachedViews = this.$store.state.tagView.cachedViews[0]
// if (cachedViews === this.$route.name) {
// console.log('--缓存--')
// } else {
// console.log('--不缓存--')
// this.count = 1
// }
// }
}
</script>
<style>
</style>
<template>
<section class="container">
<h1 class="title">
{{$route.name}}
</h1>
<nuxt-link to="package-search">返回</nuxt-link>
</section>
</template>
<script>
export default {
data() {
return {}
},
methods: {
}
}
</script>
<style scoped>
.title
{
......
......@@ -3,9 +3,21 @@
<h1 class="title">
{{$route.name}}
</h1>
<zj></zj>
</section>
</template>
<script>
import zj from './component/zj.vue'
export default {
name: 'order-package-package-search',
components: {
zj
},
methods: {}
}
</script>
<style scoped>
.title
{
......
......@@ -3,12 +3,21 @@
<h1 class="title">
{{$route.name}}
</h1>
<page></page>
</section>
</template>
<style scoped>
.title
{
margin: 50px 0;
<script>
import page from './components/page.vue'
export default {
name: 'sys-homepage-ads',
components: {
page
},
methods: {}
}
</script>
<style scoped>
</style>
<template>
<div class="container">
<div v-for="item in unpayList">{{item.name}}</div>
<div @click="toDetail">详情</div>
<div class="pagination-container">
<el-pagination
:current-page="pagination.page"
:page-sizes="[10,20,30, 50]"
:page-size="pagination.size"
:total="total"
background
layout="total, sizes, prev, pager, next, jumper"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"/>
</div>
</div>
</template>
<script>
import requestApi from '../../../../assets/js/requestApi.js'
export default {
data() {
return {
total: 80,
pagination: {
page: 1,
size: 10
},
unpayList: []
}
},
methods: {
getList: async function () {
let param = {
storeId: 25,
categoryId: 0,
pageNo: this.pagination.page,
pageSize: this.pagination.size
}
let obj = await requestApi.getList(this, param)
this.unpayList = obj.data.result
},
handleSizeChange(val) {
this.pagination.size = val
this.getList()
},
handleCurrentChange(val) {
this.pagination.page = val
this.getList()
},
toDetail() {
this.$router.push({
path: 'home-detail'
})
console.log(this.$route)
this.$store.dispatch('addVisitedViews', this.$route)
console.log(this.$store.state.tagView.cachedViews[0])
}
},
mounted() {
this.getList()
console.log('00')
}
// activated() {
// let cachedViews = this.$store.state.tagView.cachedViews[0]
// if (cachedViews === this.$route.name) {
// console.log('--缓存--')
// } else {
// console.log('--不缓存--')
// this.pagination.page = 1
// this.pagination.size = 10
// this.getList()
// }
// }
}
</script>
<style scoped>
.edit-input {
padding-right: 100px;
}
.cancel-btn {
position: absolute;
right: 15px;
top: 10px;
}
</style>
<template>
<section class="container">
<nuxt-link to="ads">返回</nuxt-link>
</section>
</template>
<script>
export default {
data() {
return {}
},
methods: {
}
}
</script>
<style scoped>
.title
{
margin: 50px 0;
}
</style>
......@@ -19,7 +19,6 @@
<script>
import requestApi from '../../../../assets/js/requestApi.js'
export default {
name: 'aaa',
data() {
return {
total: 80,
......@@ -53,18 +52,26 @@ export default {
this.$router.push({
path: 'detail'
})
console.log(this.$route)
this.$store.dispatch('addVisitedViews', this.$route)
console.log(this.$store.state.tagView.cachedViews[0])
}
},
mounted() {
this.getList()
console.log('00')
},
activated() {
this.pagination.page = 1
this.pagination.size = 10
this.getList()
console.log('------')
}
// activated() {
// let cachedViews = this.$store.state.tagView.cachedViews[0]
// if (cachedViews === this.$route.name) {
// console.log('--缓存--')
// } else {
// console.log('--不缓存--')
// this.pagination.page = 1
// this.pagination.size = 10
// this.getList()
// }
// }
}
</script>
......
......@@ -3,16 +3,11 @@
<h1 class="title">
{{$route.name}}
</h1>
<zj></zj>
</section>
</template>
<script>
import zj from './components/zj.vue'
export default {
components: {
zj
},
methods: {}
}
</script>
......
......@@ -10,7 +10,7 @@
<script>
import page from './components/page.vue'
export default {
name: 'managers',
name: 'sys-usr-managers',
components: {
page
},
......
const getters = {
sVisitedViews: state => state.systemTags.sVisitedViews,
sCachedViews: state => state.systemTags.sCachedViews,
gVisitedViews: state => state.goodsTags.gVisitedViews,
gCachedViews: state => state.goodsTags.gCachedViews,
oVisitedViews: state => state.orderTags.oVisitedViews,
oCachedViews: state => state.orderTags.oCachedViews,
fVisitedViews: state => state.financalTags.fVisitedViews,
fCachedViews: state => state.financalTags.fCachedViews
visitedViews: state => state.tagView.visitedViews,
cachedViews: state => state.tagView.cachedViews
}
export default getters
import Vue from 'vue'
import Vuex from 'vuex'
import systemTags from './modules/system-tags'
import usrAuth from './modules/usr-auth'
import goodsTags from './modules/goods-tags'
import orderTags from './modules/order-tags'
import financalTags from './modules/financal-tags'
import tagView from './modules/tagView'
import getters from './getters'
Vue.use(Vuex)
......@@ -14,10 +11,7 @@ const store = () => {
return new Vuex.Store({
modules: {
usrAuth,
systemTags,
goodsTags,
orderTags,
financalTags
tagView
},
getters
})
......
const financalTags = {
state: {
fVisitedViews: [],
fCachedViews: []
},
mutations: {
F_ADD_VISITED_VIEWS: (state, view) => {
if (state.fVisitedViews.some(v => v.path === view.path)) return
if (view.path === '/') return
state.fVisitedViews.push(
Object.assign({}, view, {
title: view.meta.title || 'no-name'
})
)
if (!view.meta.noCache) {
state.fCachedViews.push(view.name)
}
},
F_DEL_VISITED_VIEWS: (state, view) => {
for (const [i, v] of state.fVisitedViews.entries()) {
if (v.path === view.path) {
state.fVisitedViews.splice(i, 1)
break
}
}
for (const i of state.fCachedViews) {
if (i === view.name) {
const index = state.fCachedViews.indexOf(i)
state.fCachedViews.splice(index, 1)
break
}
}
},
F_DEL_OTHERS_VIEWS: (state, view) => {
for (const [i, v] of state.fVisitedViews.entries()) {
if (v.path === view.path) {
state.fVisitedViews = state.fVisitedViews.slice(i, i + 1)
break
}
}
for (const i of state.fCachedViews) {
if (i === view.name) {
const index = state.fCachedViews.indexOf(i)
state.fCachedViews = state.fCachedViews.slice(index, index + 1)
break
}
}
},
F_DEL_ALL_VIEWS: state => {
state.fVisitedViews = []
state.fCachedViews = []
}
},
actions: {
fAddVisitedViews({ commit }, view) {
commit('F_ADD_VISITED_VIEWS', view)
},
fDelVisitedViews({ commit, state }, view) {
return new Promise(resolve => {
commit('F_DEL_VISITED_VIEWS', view)
resolve([...state.fVisitedViews])
})
},
fDelOthersViews({ commit, state }, view) {
return new Promise(resolve => {
commit('F_DEL_OTHERS_VIEWS', view)
resolve([...state.fVisitedViews])
})
},
fDelAllViews({ commit, state }) {
return new Promise(resolve => {
commit('F_DEL_ALL_VIEWS')
resolve([...state.fVisitedViews])
})
}
}
}
export default financalTags
const goodsTags = {
state: {
gVisitedViews: [],
gCachedViews: []
},
mutations: {
G_ADD_VISITED_VIEWS: (state, view) => {
if (state.gVisitedViews.some(v => v.path === view.path)) return
if (view.path === '/') return
state.gVisitedViews.push(
Object.assign({}, view, {
title: view.meta.title || 'no-name'
})
)
if (!view.meta.noCache) {
state.gCachedViews.push(view.name)
}
},
G_DEL_VISITED_VIEWS: (state, view) => {
for (const [i, v] of state.gVisitedViews.entries()) {
if (v.path === view.path) {
state.gVisitedViews.splice(i, 1)
break
}
}
for (const i of state.gCachedViews) {
if (i === view.name) {
const index = state.gCachedViews.indexOf(i)
state.gCachedViews.splice(index, 1)
break
}
}
},
G_DEL_OTHERS_VIEWS: (state, view) => {
for (const [i, v] of state.gVisitedViews.entries()) {
if (v.path === view.path) {
state.gVisitedViews = state.gVisitedViews.slice(i, i + 1)
break
}
}
for (const i of state.gCachedViews) {
if (i === view.name) {
const index = state.gCachedViews.indexOf(i)
state.gCachedViews = state.gCachedViews.slice(index, index + 1)
break
}
}
},
G_DEL_ALL_VIEWS: state => {
state.gVisitedViews = []
state.gCachedViews = []
}
},
actions: {
gAddVisitedViews({ commit }, view) {
commit('G_ADD_VISITED_VIEWS', view)
},
gDelVisitedViews({ commit, state }, view) {
return new Promise(resolve => {
commit('G_DEL_VISITED_VIEWS', view)
resolve([...state.gVisitedViews])
})
},
gDelOthersViews({ commit, state }, view) {
return new Promise(resolve => {
commit('G_DEL_OTHERS_VIEWS', view)
resolve([...state.gVisitedViews])
})
},
gDelAllViews({ commit, state }) {
return new Promise(resolve => {
commit('G_DEL_ALL_VIEWS')
resolve([...state.gVisitedViews])
})
}
}
}
export default goodsTags
const orderTags = {
state: {
oVisitedViews: [],
oCachedViews: []
},
mutations: {
O_ADD_VISITED_VIEWS: (state, view) => {
if (state.oVisitedViews.some(v => v.path === view.path)) return
if (view.path === '/') return
state.oVisitedViews.push(
Object.assign({}, view, {
title: view.meta.title || 'no-name'
})
)
if (!view.meta.noCache) {
state.oCachedViews.push(view.name)
}
},
O_DEL_VISITED_VIEWS: (state, view) => {
for (const [i, v] of state.oVisitedViews.entries()) {
if (v.path === view.path) {
state.oVisitedViews.splice(i, 1)
break
}
}
for (const i of state.oCachedViews) {
if (i === view.name) {
const index = state.oCachedViews.indexOf(i)
state.oCachedViews.splice(index, 1)
break
}
}
},
O_DEL_OTHERS_VIEWS: (state, view) => {
for (const [i, v] of state.oVisitedViews.entries()) {
if (v.path === view.path) {
state.oVisitedViews = state.oVisitedViews.slice(i, i + 1)
break
}
}
for (const i of state.oCachedViews) {
if (i === view.name) {
const index = state.oCachedViews.indexOf(i)
state.oCachedViews = state.oCachedViews.slice(index, index + 1)
break
}
}
},
O_DEL_ALL_VIEWS: state => {
state.oVisitedViews = []
state.oCachedViews = []
}
},
actions: {
oAddVisitedViews({ commit }, view) {
commit('O_ADD_VISITED_VIEWS', view)
},
oDelVisitedViews({ commit, state }, view) {
return new Promise(resolve => {
commit('O_DEL_VISITED_VIEWS', view)
resolve([...state.oVisitedViews])
})
},
oDelOthersViews({ commit, state }, view) {
return new Promise(resolve => {
commit('O_DEL_OTHERS_VIEWS', view)
resolve([...state.oVisitedViews])
})
},
oDelAllViews({ commit, state }) {
return new Promise(resolve => {
commit('O_DEL_ALL_VIEWS')
resolve([...state.oVisitedViews])
})
}
}
}
export default orderTags
const systemTags = {
state: {
sVisitedViews: [],
sCachedViews: []
},
mutations: {
S_ADD_VISITED_VIEWS: (state, view) => {
if (state.sVisitedViews.some(v => v.path === view.path)) return
if (view.path === '/') return
state.sVisitedViews.push(
Object.assign({}, view, {
title: view.meta.title || 'no-name'
})
)
if (!view.meta.noCache) {
state.sCachedViews.push(view.name)
}
},
S_DEL_VISITED_VIEWS: (state, view) => {
for (const [i, v] of state.sVisitedViews.entries()) {
if (v.path === view.path) {
state.sVisitedViews.splice(i, 1)
break
}
}
for (const i of state.sCachedViews) {
if (i === view.name) {
const index = state.sCachedViews.indexOf(i)
state.sCachedViews.splice(index, 1)
break
}
}
},
S_DEL_OTHERS_VIEWS: (state, view) => {
for (const [i, v] of state.sVisitedViews.entries()) {
if (v.path === view.path) {
state.sVisitedViews = state.sVisitedViews.slice(i, i + 1)
break
}
}
for (const i of state.sCachedViews) {
if (i === view.name) {
const index = state.sCachedViews.indexOf(i)
state.sCachedViews = state.sCachedViews.slice(index, index + 1)
break
}
}
},
S_DEL_ALL_VIEWS: state => {
state.sVisitedViews = []
state.sCachedViews = []
}
},
actions: {
sAddVisitedViews({ commit }, view) {
commit('S_ADD_VISITED_VIEWS', view)
},
sDelVisitedViews({ commit, state }, view) {
return new Promise(resolve => {
commit('S_DEL_VISITED_VIEWS', view)
resolve([...state.sVisitedViews])
})
},
sDelOthersViews({ commit, state }, view) {
return new Promise(resolve => {
commit('S_DEL_OTHERS_VIEWS', view)
resolve([...state.sVisitedViews])
})
},
sDelAllViews({ commit, state }) {
return new Promise(resolve => {
commit('S_DEL_ALL_VIEWS')
resolve([...state.sVisitedViews])
})
}
}
}
export default systemTags
const tagView = {
state: {
visitedViews: [],
cachedViews: []
},
mutations: {
F_ADD_VISITED_VIEWS: (state, view) => {
if (state.visitedViews.some(v => v.path === view.path)) return
if (view.path === '/') return
state.visitedViews.push(
Object.assign({}, view, {
title: view.meta.title || 'no-name'
})
)
if (!view.meta.noCache) {
state.cachedViews.push(view.name)
}
},
F_DEL_ALL_VIEWS: state => {
state.visitedViews = []
state.cachedViews = []
}
},
actions: {
addVisitedViews({ commit }, view) {
commit('F_ADD_VISITED_VIEWS', view)
},
delAllViews({ commit, state }) {
return new Promise(resolve => {
commit('F_DEL_ALL_VIEWS')
resolve([...state.visitedViews])
})
}
}
}
export default tagView
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment