Commit c85b40ee by gyy

缓存方案1

parent e2152f75
...@@ -87,6 +87,7 @@ export default { ...@@ -87,6 +87,7 @@ export default {
}, },
// 获取角色权限列表 // 获取角色权限列表
roleAuthList(obj) { return this.wRequest('/xhr/getMenus', obj) }, roleAuthList(obj) { return this.wRequest('/xhr/getMenus', obj) },
getList(obj, param) { return this.wRequest('/goods/listPage.json', obj, param) },
server_getConfig(key) { server_getConfig(key) {
if (process.env.WD_ENV === 'production') { if (process.env.WD_ENV === 'production') {
var configp = require('../config/config-prod.json') var configp = require('../config/config-prod.json')
......
...@@ -23,13 +23,13 @@ ...@@ -23,13 +23,13 @@
<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="select(sub.path)" :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>
</keep-alive> </keep-alive>
<!-- 侧边栏结束 --> <!-- 侧边栏结束 -->
<div class="main_right"> <div class="main_right" :style="{width: clientWidth + 'px'}">
<div class="crumbs"> <div class="crumbs">
<div class="y_flex_start" > <div class="y_flex_start" >
<div @click="toleft"><</div> <div @click="toleft"><</div>
...@@ -50,7 +50,14 @@ ...@@ -50,7 +50,14 @@
<li @click="closeAllTags">关闭所有</li> <li @click="closeAllTags">关闭所有</li>
</ul> </ul>
</div> </div>
<nuxt class="content"/> <!--<nuxt class="content"/>-->
<keep-alive v-if="keepAlive === '1'">
<router-view class="content"></router-view>
</keep-alive>
<router-view class="content1" v-if="keepAlive !== '1'"></router-view>
<!--<keep-alive>
<router-view class="content"></router-view>
</keep-alive>-->
</div> </div>
</div> </div>
</div> </div>
...@@ -74,13 +81,15 @@ export default { ...@@ -74,13 +81,15 @@ export default {
orderList: [], orderList: [],
financeList: [], financeList: [],
clientHeight: 0, clientHeight: 0,
clientWidth: 0,
visible: false, visible: false,
left: 0, left: 0,
selectedTag: {}, selectedTag: {},
leftMenuList: [], leftMenuList: [],
isRoute: true, isRoute: true,
moveLength: 130, moveLength: 130,
moveNum: 0 moveNum: 0,
keepAlive: '2'
} }
}, },
computed: { computed: {
...@@ -290,6 +299,7 @@ export default { ...@@ -290,6 +299,7 @@ export default {
// clientHeight = (document.body.clientHeight > document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight // 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
}, },
toleft() { toleft() {
if (this.moveNum !== 0) { if (this.moveNum !== 0) {
...@@ -299,10 +309,26 @@ export default { ...@@ -299,10 +309,26 @@ export default {
} }
}, },
toright() { toright() {
console.log(this.visitedViews.length)
this.moveNum -- this.moveNum --
let root = document.getElementsByClassName('crumbs_text')[0] let root = document.getElementsByClassName('crumbs_text')[0]
root.style.cssText = 'transform: translateX(' + this.moveLength * this.moveNum + 'px);' root.style.cssText = 'transform: translateX(' + this.moveLength * this.moveNum + 'px);'
},
select(e) {
console.log(e)
if (e === '/sys/usr/managers') {
YCookie.setLocalCookie('keepAlive', '1')
} else {
YCookie.setLocalCookie('keepAlive', '2')
} }
console.log(YCookie.readLocalCookie('keepAlive'))
console.log('aaaaaaaaaaaaaaa')
}
},
updated() {
this.keepAlive = YCookie.readLocalCookie('keepAlive')
console.log('-----------')
console.log(this.keepAlive)
}, },
mounted() { mounted() {
this.getClientHeight() this.getClientHeight()
...@@ -395,11 +421,10 @@ export default { ...@@ -395,11 +421,10 @@ export default {
font-weight: bold; font-weight: bold;
} }
.main_left{ .main_left{
width: 13%;
background: #E8E9EE; background: #E8E9EE;
width: 240px;
} }
.main_right{ .main_right{
width: 87%;
position: relative; position: relative;
} }
.crumbs{ .crumbs{
......
...@@ -2,6 +2,7 @@ var merge = require('webpack-merge') ...@@ -2,6 +2,7 @@ var merge = require('webpack-merge')
var baseConfig = require('./nuxt.config.js') var baseConfig = require('./nuxt.config.js')
module.exports = merge(baseConfig, { module.exports = merge(baseConfig, {
proxy: { proxy: {
'/xhr/': 'http://yapi.yang800.cn/mock/31' '/xhr/': 'http://yapi.yang800.cn/mock/31',
'/goods/': 'https://m.yang800.com/backend/xhr'
} }
}) })
<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'
import YCookie from '../../../../assets/js/yCookie.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: 'detail'
})
YCookie.setLocalCookie('keepAlive', '1')
console.log('1111111111111111111111111')
console.log(YCookie.readLocalCookie('keepAlive'))
}
},
mounted() {
this.getList()
console.log('00')
}
}
</script>
<style scoped>
.edit-input {
padding-right: 100px;
}
.cancel-btn {
position: absolute;
right: 15px;
top: 10px;
}
</style>
<template>
<div class="container">
<div>{{count}}</div>
<button @click="b">plus</button>
</div>
</template>
<script>
export default {
data() {
return {
count: 1
}
},
methods: {
b() {
this.count++
}
}
}
</script>
<style scoped>
</style>
<template>
<section class="container">
<nuxt-link to="managers">返回</nuxt-link>
</section>
</template>
<script>
import YCookie from '../../../assets/js/yCookie.js'
export default {
data() {
return {}
},
methods: {
},
// 详情页面的beforeRouteLeave钩子函数
beforeRouteLeave(to, from, next) {
console.log(to.name)
if (to.name === 'sys-usr-managers') {
YCookie.setLocalCookie('keepAlive', '1')
console.log('详情页面的beforeRouteLeave钩子函数')
console.log(YCookie.readLocalCookie('keepAlive'))
}
next()
}
}
</script>
<style scoped>
.title
{
margin: 50px 0;
}
</style>
...@@ -3,9 +3,20 @@ ...@@ -3,9 +3,20 @@
<h1 class="title"> <h1 class="title">
{{$route.name}} {{$route.name}}
</h1> </h1>
<zj></zj>
</section> </section>
</template> </template>
<script>
import zj from './components/zj.vue'
export default {
components: {
zj
},
methods: {}
}
</script>
<style scoped> <style scoped>
.title .title
{ {
......
<template> <template>
<section class="container"> <div class="app-container">
<h1 class="title"> <h1 class="title">
{{$route.name}} {{$route.name}}
</h1> </h1>
</section> <page></page>
</div>
</template> </template>
<style scoped> <script>
.title import page from './components/page.vue'
{ export default {
margin: 50px 0; components: {
page
},
methods: {}
} }
</script>
<style scoped>
</style> </style>
...@@ -3,9 +3,29 @@ ...@@ -3,9 +3,29 @@
<h1 class="title"> <h1 class="title">
{{$route.name}} {{$route.name}}
</h1> </h1>
<div class="block">
<el-pagination
:current-page="currentPage"
:page-sizes="[100, 200, 300, 400]"
:page-size="100"
:total="400"
background
layout="total, sizes, prev, pager, next"/>
</div>
</section> </section>
</template> </template>
<script>
export default {
data() {
return {
currentPage: 5
}
}
}
</script>
<style scoped> <style scoped>
.title .title
{ {
......
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