Commit 542b52da by gyy

缓存

parent 8499a687
...@@ -10,8 +10,7 @@ ...@@ -10,8 +10,7 @@
{{item}} {{item}}
</div> </div>
</div> </div>
<div class="y_default_start"> <div class="main_left">
<div class="main_left" :style="{height: clientHeight + 'px'}">
<el-menu <el-menu
:default-active="$route.path" :router="isRoute" :default-active="$route.path" :router="isRoute"
class="el-menu-vertical-demo" class="el-menu-vertical-demo"
...@@ -22,40 +21,19 @@ ...@@ -22,40 +21,19 @@
<i class="el-icon-location"></i> <i class="el-icon-location"></i>
<span>{{item.name}}</span> <span>{{item.name}}</span>
</template> </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-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-submenu>
</el-menu> </el-menu>
</div> </div>
<!-- 侧边栏结束 --> <!-- 侧边栏结束 -->
<div class="main_right" :style="{width: clientWidth + 'px'}"> <div class="main_right">
<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"/>--> <!--<nuxt class="content"/>-->
<keep-alive include='managers'> <keep-alive :include='cachedViews'>
<router-view class="content"></router-view> <router-view class="content" :key="key"></router-view>
</keep-alive> </keep-alive>
</div> </div>
</div> </div>
</div> </div>
</div>
</template> </template>
<script> <script>
...@@ -86,40 +64,11 @@ export default { ...@@ -86,40 +64,11 @@ export default {
} }
}, },
computed: { computed: {
visitedViews() { cachedViews() {
// return this.$store.state.systemTags.sVisitedViews return this.$store.state.tagView.cachedViews
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()
}, },
visible(value) { key() {
if (value) { return this.$route.fullPath
document.body.addEventListener('click', this.closeMenu)
} else {
document.body.removeEventListener('click', this.closeMenu)
}
} }
}, },
methods: { methods: {
...@@ -140,109 +89,6 @@ export default { ...@@ -140,109 +89,6 @@ export default {
}, },
handleClose() { 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 () { getOrderCtg: async function () {
console.log('get data ==== ') console.log('get data ==== ')
...@@ -285,27 +131,11 @@ export default { ...@@ -285,27 +131,11 @@ export default {
}, },
// 获取窗口可视范围的高度 // 获取窗口可视范围的高度
getClientHeight() { 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.clientHeight = document.documentElement.clientHeight - 76
this.clientWidth = document.documentElement.clientWidth - 240 this.clientWidth = document.documentElement.clientWidth - 240
}, },
toleft() { toDes() {
if (this.moveNum !== 0) { this.$store.dispatch('delAllViews')
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);'
} }
}, },
mounted() { mounted() {
...@@ -316,7 +146,6 @@ export default { ...@@ -316,7 +146,6 @@ export default {
this.tabNow = parseInt(YCookie.readLocalCookie('tabNow')) this.tabNow = parseInt(YCookie.readLocalCookie('tabNow'))
} }
this.getOrderCtg() this.getOrderCtg()
this.addViewTags()
} }
} }
</script> </script>
...@@ -380,30 +209,48 @@ export default { ...@@ -380,30 +209,48 @@ export default {
background: #204077; background: #204077;
} }
.nav_item{ .nav_item{
color: #D4D4D4; color: #ADB1B6;
overflow: hidden; overflow: hidden;
font-size: 14px; font-size: 14px;
position: relative; position: relative;
width: 130px; width: 130px;
margin-left: 8px; margin-left: 8px;
cursor: pointer; cursor: pointer;
height: 30px; height: 40px;
line-height: 30px; line-height: 40px;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
text-align: center; text-align: center;
} }
.nav_active{ .nav_active{
background: #E8E9EE; /*background: #E8E9EE;*/
color: #43478e; color: #FFFFFF;
font-weight: bold; font-weight: bold;
} }
.main_left{ .main_left{
background: #E8E9EE; 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{ .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{ .crumbs{
background: #E8E9EE; background: #E8E9EE;
...@@ -456,11 +303,9 @@ export default { ...@@ -456,11 +303,9 @@ export default {
margin-bottom: 4px; margin-bottom: 4px;
cursor: pointer; cursor: pointer;
} }
.el-menu-item.is-active {
color: #303133;
}
.orderCtg_list_now{ .orderCtg_list_now{
color: #C01E00!important; color: #FFFFFF!important;
background-color: #545a6b!important;
position: relative; position: relative;
} }
.contextmenu { .contextmenu {
...@@ -488,14 +333,38 @@ export default { ...@@ -488,14 +333,38 @@ export default {
.content{ .content{
width: 100%; width: 100%;
box-sizing: border-box; box-sizing: border-box;
border-top: 1px solid #000;
border-left: 1px solid #000;
position: absolute; position: absolute;
top: 31px; top: 31px;
bottom: 0px; bottom: 0px;
right: 0px; right: 0px;
padding: 0 10px;
} }
.el-menu{ .el-menu{
transition: all 0s!important; 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> </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> <template>
<div class="container"> <section class="container">
<div>{{count}}</div> <nuxt-link to="goods-search">返回</nuxt-link>
<button @click="b">plus</button> </section>
</div>
</template> </template>
<script> <script>
export default { export default {
data() { data() {
return { return {}
count: 1
}
}, },
methods: { methods: {
b() {
this.count++
} }
} }
}
</script> </script>
<style scoped> <style scoped>
.title
{
margin: 50px 0;
}
</style> </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> <template>
<section class="container"> <section class="container">
<h1 class="title"> <nuxt-link to="package-search">返回</nuxt-link>
{{$route.name}}
</h1>
</section> </section>
</template> </template>
<script>
export default {
data() {
return {}
},
methods: {
}
}
</script>
<style scoped> <style scoped>
.title .title
{ {
......
...@@ -3,9 +3,21 @@ ...@@ -3,9 +3,21 @@
<h1 class="title"> <h1 class="title">
{{$route.name}} {{$route.name}}
</h1> </h1>
<zj></zj>
</section> </section>
</template> </template>
<script>
import zj from './component/zj.vue'
export default {
name: 'order-package-package-search',
components: {
zj
},
methods: {}
}
</script>
<style scoped> <style scoped>
.title .title
{ {
......
...@@ -3,12 +3,21 @@ ...@@ -3,12 +3,21 @@
<h1 class="title"> <h1 class="title">
{{$route.name}} {{$route.name}}
</h1> </h1>
<page></page>
</section> </section>
</template> </template>
<style scoped> <script>
.title import page from './components/page.vue'
{ export default {
margin: 50px 0; name: 'sys-homepage-ads',
components: {
page
},
methods: {}
} }
</script>
<style scoped>
</style> </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 @@ ...@@ -19,7 +19,6 @@
<script> <script>
import requestApi from '../../../../assets/js/requestApi.js' import requestApi from '../../../../assets/js/requestApi.js'
export default { export default {
name: 'aaa',
data() { data() {
return { return {
total: 80, total: 80,
...@@ -53,18 +52,26 @@ export default { ...@@ -53,18 +52,26 @@ export default {
this.$router.push({ this.$router.push({
path: 'detail' path: 'detail'
}) })
console.log(this.$route)
this.$store.dispatch('addVisitedViews', this.$route)
console.log(this.$store.state.tagView.cachedViews[0])
} }
}, },
mounted() { mounted() {
this.getList() this.getList()
console.log('00') 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> </script>
......
...@@ -3,16 +3,11 @@ ...@@ -3,16 +3,11 @@
<h1 class="title"> <h1 class="title">
{{$route.name}} {{$route.name}}
</h1> </h1>
<zj></zj>
</section> </section>
</template> </template>
<script> <script>
import zj from './components/zj.vue'
export default { export default {
components: {
zj
},
methods: {} methods: {}
} }
</script> </script>
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<script> <script>
import page from './components/page.vue' import page from './components/page.vue'
export default { export default {
name: 'managers', name: 'sys-usr-managers',
components: { components: {
page page
}, },
......
const getters = { const getters = {
sVisitedViews: state => state.systemTags.sVisitedViews, visitedViews: state => state.tagView.visitedViews,
sCachedViews: state => state.systemTags.sCachedViews, cachedViews: state => state.tagView.cachedViews
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
} }
export default getters export default getters
import Vue from 'vue' import Vue from 'vue'
import Vuex from 'vuex' import Vuex from 'vuex'
import systemTags from './modules/system-tags'
import usrAuth from './modules/usr-auth' import usrAuth from './modules/usr-auth'
import goodsTags from './modules/goods-tags' import tagView from './modules/tagView'
import orderTags from './modules/order-tags'
import financalTags from './modules/financal-tags'
import getters from './getters' import getters from './getters'
Vue.use(Vuex) Vue.use(Vuex)
...@@ -14,10 +11,7 @@ const store = () => { ...@@ -14,10 +11,7 @@ const store = () => {
return new Vuex.Store({ return new Vuex.Store({
modules: { modules: {
usrAuth, usrAuth,
systemTags, tagView
goodsTags,
orderTags,
financalTags
}, },
getters 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