Skip to content

Commit a1c2cd4

Browse files
vanoneanggongjs
authored andcommitted
Tool (#225)
* feat: 一键清除历史记录 * feat: search ui
1 parent 8b85c28 commit a1c2cd4

File tree

12 files changed

+385
-17
lines changed

12 files changed

+385
-17
lines changed

.env.development

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
ENV = 'development'
22

3-
VUE_APP_BASE_URL = 'http://localhost:5000/'
3+
VUE_APP_BASE_URL = 'http://koa.lin.colorful3.com/'

.env.production

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

22

3-
VUE_APP_BASE_URL = 'http://localhost:5000/'
3+
VUE_APP_BASE_URL = 'http://dev.lin.colorful3.com'

public/iconfont.css

Lines changed: 14 additions & 6 deletions
Large diffs are not rendered by default.

public/iconfont111.css

Lines changed: 201 additions & 0 deletions
Large diffs are not rendered by default.

src/assets/styles/realize/lin-variables.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
$theme: #3963bc;
22

33
/* 布局 */
4-
$sidebar-width: 175px;
4+
$sidebar-width: 190px;
55
$sidebar-background: #192a5e;
66

77
$navbar-height: 30px;

src/components/layout/ClearTab.vue

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<template>
2+
<div title="关闭全部历史记录" class="tab" @click="closeReuseTab">
3+
<i class="iconfont icon-moshubang"></i>
4+
</div>
5+
</template>
6+
7+
<script>
8+
export default {
9+
name: 'CloseTab',
10+
inject: ['eventBus'],
11+
methods: {
12+
closeReuseTab() {
13+
this.eventBus.$emit('clearTap')
14+
},
15+
},
16+
}
17+
</script>
18+
19+
<style lang="scss" scoped>
20+
.tab {
21+
cursor: pointer;
22+
margin-right: 10px;
23+
i {
24+
width: 40px;
25+
height: 40px;
26+
font-size: 20px;
27+
}
28+
}
29+
</style>

src/components/layout/NavBar.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<!-- 暂时放这里 -->
88
<div class="right-info">
99
<notify v-auth="'消息推送'" v-show="false" />
10+
<clear-tab></clear-tab>
1011
<screenfull />
1112
<user></user>
1213
</div>
@@ -19,6 +20,7 @@ import Notify from '@/components/notify/notify'
1920
import Breadcrumb from './Breadcrumb'
2021
import Screenfull from './Screenfull'
2122
import User from './User'
23+
import ClearTab from './ClearTab'
2224
2325
export default {
2426
name: 'NavBar',
@@ -28,6 +30,7 @@ export default {
2830
User,
2931
Notify,
3032
Screenfull,
33+
ClearTab,
3134
},
3235
}
3336
</script>

src/components/layout/ReuseTab.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ export default {
9797
},
9898
mounted() {
9999
this.init()
100+
this.eventBus.$on('clearTap', () => {
101+
this.histories = []
102+
})
100103
},
101104
methods: {
102105
init() {

src/components/layout/Screenfull.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="container">
2+
<div class="container" title="全屏/正常">
33
<i class="iconfont" :class="isFullscreen?'icon-quxiaoquanping':'icon-quanping'" @click="handleFullScreen"></i>
44
</div>
55
</template>

src/components/layout/SideBar.vue

Lines changed: 122 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,29 @@
77
<img src="../../assets/img/mobile-logo.png" alt="">
88
</div>
99
<div style="margin-bottom:50px">
10+
<div v-if="showSidebarSearch" style="margin-top: 15px">
11+
<div class="search-display" v-if="!showSearchList" @click="toSearch">
12+
<i class="el-icon-search"></i>
13+
</div>
14+
<el-select
15+
v-if="showSearchList"
16+
size="medium"
17+
filterable
18+
clearable
19+
:filter-method="search"
20+
v-model="sidebar"
21+
@change="handleChange"
22+
class="search"
23+
placeholder="请输入关键字"
24+
ref="searchInput">
25+
<el-option
26+
v-for="item in groups"
27+
:key="item.key"
28+
:label="item.title"
29+
:value="item.path">
30+
</el-option>
31+
</el-select>
32+
</div>
1033
<el-menu
1134
class="el-menu-vertical-demo"
1235
ref="meun"
@@ -30,7 +53,11 @@
3053

3154
<!-- 二级菜单 -->
3255
<template v-for="(subItem) in item.children">
33-
<el-submenu v-if="subItem.children" :key="idMap[subItem.name]" :index="idMap[subItem.name]" class="subMenuContent">
56+
<el-submenu
57+
v-if="subItem.children"
58+
:key="idMap[subItem.name]"
59+
:index="idMap[subItem.name]"
60+
class="subMenuContent">
3461
<template slot="title">
3562
<i class="iconfont icon-erjizhibiao"></i>
3663
<span slot="title" class="two-folder">{{subItem.title}}</span>
@@ -82,9 +109,29 @@
82109
<script>
83110
import { mapGetters } from 'vuex'
84111
import Utils from '@/lin/utils/util'
112+
import Config from '../../config/index'
85113
86114
export default {
87115
props: ['isCollapse'],
116+
data() {
117+
return {
118+
sidebar: '',
119+
groups: [],
120+
showSidebarSearch: Config.showSidebarSearch,
121+
showSearchList: false,
122+
}
123+
},
124+
inject: ['eventBus'],
125+
mounted() {
126+
this.eventBus.$on('removeSidebarSearch', () => {
127+
this.showSidebarSearch = false
128+
})
129+
this.eventBus.$on('showSidebarSearch', () => {
130+
if (Config.showSidebarSearch) {
131+
this.showSidebarSearch = true
132+
}
133+
})
134+
},
88135
methods: {
89136
goto(path) {
90137
this.$router.push({
@@ -94,6 +141,51 @@ export default {
94141
filterIcon(icon) {
95142
return icon.indexOf('/') !== -1
96143
},
144+
handleChange(val) {
145+
this.groups = []
146+
this.sidebar = ''
147+
this.showSearchList = false
148+
this.$router.push(val)
149+
},
150+
toSearch() {
151+
this.showSearchList = true
152+
setTimeout(() => {
153+
this.$refs.searchInput.focus()
154+
}, 200)
155+
},
156+
search(val) {
157+
if (!val) {
158+
this.showSearchList = false
159+
return
160+
}
161+
this.groups = []
162+
163+
// 深度遍历配置树, 摘取叶子节点作为路由部分
164+
function deepTravel(config, fuc) {
165+
if (Array.isArray(config)) {
166+
config.forEach((subConfig) => {
167+
deepTravel(subConfig, fuc)
168+
})
169+
} else if (config.children) {
170+
config.children.forEach((subConfig) => {
171+
deepTravel(subConfig, fuc)
172+
})
173+
} else {
174+
fuc(config)
175+
}
176+
}
177+
178+
deepTravel(this.sideBarList, (viewConfig) => {
179+
// 构造舞台view路由
180+
if (viewConfig.title.includes(val)) {
181+
const viewRouter = {}
182+
viewRouter.path = viewConfig.path
183+
viewRouter.title = viewConfig.title
184+
viewRouter.key = Math.random()
185+
this.groups.push(viewRouter)
186+
}
187+
})
188+
},
97189
},
98190
computed: {
99191
// 根据当前路由设置激活侧边栏
@@ -147,17 +239,21 @@ export default {
147239
width: 0px;
148240
height: 0px;
149241
}
242+
150243
.app-sidebar {
151244
background: #192a5e;
152-
&::-webkit-scrollbar {
245+
246+
&::-webkit-scrollbar {
153247
width: 0px;
154248
height: 0px;
155249
}
250+
156251
.subMenuContent {
157252
overflow: hidden;
158253
text-overflow: ellipsis;
159254
white-space: nowrap;
160255
}
256+
161257
.logo {
162258
width: $sidebar-width;
163259
height: $header-height;
@@ -169,9 +265,9 @@ export default {
169265
transition: all 0.5s ease-in-out;
170266
background-color: #122150;
171267
transition: all 0.3s linear;
172-
position:sticky;
173-
top:0;
174-
left:0;
268+
position: sticky;
269+
top: 0;
270+
left: 0;
175271
z-index: 99;
176272
177273
img {
@@ -211,5 +307,26 @@ export default {
211307
color: $submenu-title;
212308
height: $menuItem-height;
213309
}
310+
311+
.search-display {
312+
position: relative;
313+
width: 80%;
314+
margin: 0 auto;
315+
height: 36px;
316+
border-bottom: 1px $theme solid;
317+
cursor: pointer;
318+
319+
.el-icon-search {
320+
position: absolute;
321+
left: 1px;
322+
top: 10px;
323+
color: $theme;
324+
}
325+
}
326+
327+
.search {
328+
// margin-top: 20px;
329+
width: 80%;
330+
}
214331
}
215332
</style>

src/config/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const Config = {
44
openAutoJumpOut: true, // 是否开启无操作跳出
55
notLoginRoute: ['login'], // 无需登录即可访问的路由 name,
66
sideBarLevel: 3, // 侧边栏层级限制, 3表示三级, 可设置 2 和 3
7+
showSidebarSearch: true, // 默认打开侧边栏搜索
78
defaultRoute: '/about', // 默认打开的路由
89
}
910

src/views/home/Home.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,15 @@ import {
4343
const navBarHeight = 66 // header高度
4444
const reuseTabHeight = 70 // 历史记录栏高度
4545
const marginHeight = 20 // 历史记录栏与舞台的间距
46+
const sideBarWidth = '190px'
4647
const totalHeight = navBarHeight + reuseTabHeight + marginHeight
4748
4849
export default {
4950
name: 'layout',
5051
data() {
5152
return {
5253
isCollapse: false, // 左侧菜单栏是否折叠
53-
sideBarWidth: '175px', // 左侧菜单栏展开的宽度
54+
sideBarWidth, // 左侧菜单栏展开的宽度
5455
clientWidth: 0, // 页面宽度
5556
clientHeight: 0, // 页面高度
5657
foldState: false, // 控制左侧菜单栏按键
@@ -84,6 +85,11 @@ export default {
8485
// 控制菜单折叠
8586
changeSlidebarState() {
8687
this.isCollapse = !this.isCollapse
88+
if (this.isCollapse) {
89+
this.eventBus.$emit('removeSidebarSearch')
90+
} else {
91+
this.eventBus.$emit('showSidebarSearch')
92+
}
8793
this.foldState = !this.foldState
8894
},
8995
// 响应页面的宽度高度变化
@@ -97,7 +103,7 @@ export default {
97103
},
98104
watch: {
99105
isCollapse() {
100-
this.sideBarWidth = this.isCollapse === false ? '175px' : '64px'
106+
this.sideBarWidth = this.isCollapse === false ? sideBarWidth : '64px'
101107
},
102108
$route() {
103109
this.showBackTop = false

0 commit comments

Comments
 (0)