|
@ -1,24 +1,34 @@ |
|
|
<template> |
|
|
<template> |
|
|
<div class="recent_pages"> |
|
|
<div class="recent_pages"> |
|
|
<h4><i class="iconfont icon-recent"></i>最近访问:</h4> |
|
|
<h4><i class="iconfont icon-recent"></i> |
|
|
|
|
|
<!-- <ContextMenu>最近访问:</ContextMenu> --> |
|
|
|
|
|
最近访问: |
|
|
|
|
|
</h4> |
|
|
<div class="history_buttons"> |
|
|
<div class="history_buttons"> |
|
|
<div class="btn_left" @click="onLeft" :class="{'disabled' : startIndex <= 0 }"><i class="iconfont icon-left"></i></div> |
|
|
<div class="btn_left" @click="onLeft" :class="{'disabled' : startIndex <= 0 }"><i |
|
|
|
|
|
class="iconfont icon-left"></i></div> |
|
|
<div class="list_box" ref="box"> |
|
|
<div class="list_box" ref="box"> |
|
|
<div class="list" :style="btnListStyle" ref="btnlist"> |
|
|
<div class="list" :style="btnListStyle" ref="btnlist"> |
|
|
<div class="unit" :class="isActive(item) ? 'active' : ''" v-for="item,index in recentPages" ref="unit"> |
|
|
<div class="unit" :class="isActive(item) ? 'active' : ''" v-for="item,index in recentPages" |
|
|
<p class="btn_main" @click="onClickItem(item)" :key="item.path" :style="{width:item.title.length*14+'px'}"> |
|
|
ref="unit"> |
|
|
|
|
|
<p class="btn_main" @click="onClickItem(item)" :key="item.path" |
|
|
|
|
|
:style="{width:item.title.length*14+'px'}"> |
|
|
{{item.title}} |
|
|
{{item.title}} |
|
|
</p> |
|
|
</p> |
|
|
|
|
|
<p class="btn_pin" :class="{active:item.isPinned}" @click="onPin(item)"><i></i></p> |
|
|
<i class="btn_close iconfont icon-guanbi" @click="onRemoveItem(item)"></i> |
|
|
<i class="btn_close iconfont icon-guanbi" @click="onRemoveItem(item)"></i> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
<div class="btn_right" @click="onRight" :class="{ 'disabled': lastIndex == -1 || lastIndex >= widthArr.length - 1 }"><i class="iconfont icon-right"></i></div> |
|
|
<div class="btn_right" @click="onRight" |
|
|
|
|
|
:class="{ 'disabled': lastIndex == -1 || lastIndex >= widthArr.length - 1 }"><i |
|
|
|
|
|
class="iconfont icon-right"></i></div> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
</template> |
|
|
</template> |
|
|
<script> |
|
|
<script> |
|
|
import { mapMutations, mapState } from 'vuex'; |
|
|
import { mapMutations, mapState } from 'vuex'; |
|
|
|
|
|
import ContextMenu from './ContextMenu.vue'; |
|
|
export default{ |
|
|
export default{ |
|
|
data(){ |
|
|
data(){ |
|
|
return { |
|
|
return { |
|
@ -31,6 +41,9 @@ export default{ |
|
|
currentIndex : -1 |
|
|
currentIndex : -1 |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
components:{ |
|
|
|
|
|
ContextMenu |
|
|
|
|
|
}, |
|
|
computed:{ |
|
|
computed:{ |
|
|
...mapState("menu", ["recentPages"]), |
|
|
...mapState("menu", ["recentPages"]), |
|
|
btnListStyle(){ |
|
|
btnListStyle(){ |
|
@ -86,19 +99,15 @@ export default{ |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
mounted(){ |
|
|
mounted(){ |
|
|
// 测试数据 |
|
|
|
|
|
// for (let i = 0; i < 30; i++) { |
|
|
|
|
|
// this.addRecent({ |
|
|
|
|
|
// title: `第${i}项菜单示例`, |
|
|
|
|
|
// path: "url" + i |
|
|
|
|
|
// }); |
|
|
|
|
|
// } |
|
|
|
|
|
}, |
|
|
}, |
|
|
methods:{ |
|
|
methods:{ |
|
|
...mapMutations("menu", ["addRecent","removeRecent"]), |
|
|
...mapMutations("menu", ["addRecent", "removeRecent","pinRecent"]), |
|
|
onClickItem(item){ |
|
|
onClickItem(item){ |
|
|
this.$route.path != item.path && this.$router.push(item.path); |
|
|
this.$route.path != item.path && this.$router.push(item.path); |
|
|
}, |
|
|
}, |
|
|
|
|
|
onPin(item){ |
|
|
|
|
|
this.pinRecent(item); |
|
|
|
|
|
}, |
|
|
onRemoveItem(item){ |
|
|
onRemoveItem(item){ |
|
|
this.removeRecent(item); |
|
|
this.removeRecent(item); |
|
|
if(this.$route.path == item.path){ |
|
|
if(this.$route.path == item.path){ |
|
@ -189,7 +198,7 @@ export default{ |
|
|
<style lang="scss" scoped> |
|
|
<style lang="scss" scoped> |
|
|
.recent_pages{ |
|
|
.recent_pages{ |
|
|
display: flex; flex-direction: row; align-items:stretch; padding: 0 20px; |
|
|
display: flex; flex-direction: row; align-items:stretch; padding: 0 20px; |
|
|
h4{ width: 110px; height: 32px; line-height: 32px; text-align: center; margin: 0; padding: 0; font-weight: bold; color: #3de8ff; |
|
|
h4{ width: 110px; height: 32px; line-height: 32px; text-align: center; margin: 0; padding: 0; font-weight: bold; color: #3de8ff; display: flex; align-items: center; justify-content: center; |
|
|
.iconfont{ margin-right: 3px;} |
|
|
.iconfont{ margin-right: 3px;} |
|
|
} |
|
|
} |
|
|
.history_buttons { |
|
|
.history_buttons { |
|
@ -225,7 +234,18 @@ export default{ |
|
|
border:1px solid #03a9b1; |
|
|
border:1px solid #03a9b1; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
.btn_pin{ |
|
|
|
|
|
position: absolute; |
|
|
|
|
|
left:0; |
|
|
|
|
|
bottom:0; |
|
|
|
|
|
width:16px; height: 10px; |
|
|
|
|
|
display: flex; align-items: center; justify-content: center; |
|
|
|
|
|
i{ |
|
|
|
|
|
display: block; |
|
|
|
|
|
width:6px; height: 6px; border-radius: 3px; |
|
|
|
|
|
} |
|
|
|
|
|
&.active i{ background-color: #FA0;} |
|
|
|
|
|
} |
|
|
.btn_close { |
|
|
.btn_close { |
|
|
position: absolute; |
|
|
position: absolute; |
|
|
right: 6px; |
|
|
right: 6px; |
|
|