perf: 页面高度足够时只滚动项目部分

This commit is contained in:
kuaifan 2022-02-24 09:02:42 +08:00
parent 35b1c12bb5
commit ea028ea1a1
2 changed files with 72 additions and 34 deletions

View File

@ -54,7 +54,7 @@
<DropdownItem divided name="signout" style="color:#f40">{{$L('退出登录')}}</DropdownItem> <DropdownItem divided name="signout" style="color:#f40">{{$L('退出登录')}}</DropdownItem>
</DropdownMenu> </DropdownMenu>
</Dropdown> </Dropdown>
<ul class="overlay-y" @scroll="listScroll()"> <ul :class="overlayClass" @scroll="handleClickTopOperateOutside">
<li @click="toggleRoute('dashboard')" :class="classNameRoute('dashboard')"> <li @click="toggleRoute('dashboard')" :class="classNameRoute('dashboard')">
<i class="taskfont">&#xe6fb;</i> <i class="taskfont">&#xe6fb;</i>
<div class="menu-title">{{$L('仪表盘')}}</div> <div class="menu-title">{{$L('仪表盘')}}</div>
@ -73,20 +73,14 @@
<i class="taskfont">&#xe6f3;</i> <i class="taskfont">&#xe6f3;</i>
<div class="menu-title">{{$L('文件')}}</div> <div class="menu-title">{{$L('文件')}}</div>
</li> </li>
<li class="menu-project" ref="projectWrapper"> <li ref="projectWrapper" class="menu-project">
<ul> <ul :class="overlayClass" @scroll="handleClickTopOperateOutside">
<li <li
v-for="(item, key) in projectLists" v-for="(item, key) in projectLists"
:key="key" :key="key"
:class="classNameRoute('project/' + item.id, openMenu[item.id])" :class="classNameProject(item)"
@click="toggleRoute('project/' + item.id)" @click="toggleRoute('project/' + item.id)"
@contextmenu.prevent.stop="handleRightClick($event, item)" @contextmenu.prevent.stop="handleRightClick($event, item)">
>
<div
:class="{
top: item.top_at,
operate: item.id == topOperateItem.id && topOperateVisible
}">
<div class="project-h1"> <div class="project-h1">
<em @click.stop="toggleOpenMenu(item.id)"></em> <em @click.stop="toggleOpenMenu(item.id)"></em>
<div class="title">{{item.name}}</div> <div class="title">{{item.name}}</div>
@ -104,7 +98,6 @@
<Progress :percent="item.task_percent" :stroke-width="6" /> <Progress :percent="item.task_percent" :stroke-width="6" />
</p> </p>
</div> </div>
</div>
</li> </li>
</ul> </ul>
<Loading v-if="loadIng > 0"/> <Loading v-if="loadIng > 0"/>
@ -125,7 +118,7 @@
</li> </li>
</ul> </ul>
<div <div
v-if="projectTotal > 50" v-if="projectTotal > 20"
class="manage-project-search" class="manage-project-search"
:class="{loading:projectKeyLoading > 0}"> :class="{loading:projectKeyLoading > 0}">
<Input prefix="ios-search" v-model="projectKeyValue" :placeholder="$L('共' + projectTotal + '个项目,搜索...')" clearable /> <Input prefix="ios-search" v-model="projectKeyValue" :placeholder="$L('共' + projectTotal + '个项目,搜索...')" clearable />
@ -309,6 +302,7 @@ export default {
reportTabs: "my", reportTabs: "my",
reportUnreadNumber: 0, reportUnreadNumber: 0,
topOperateStyles: {}, topOperateStyles: {},
topOperateVisible: false, topOperateVisible: false,
topOperateItem: {}, topOperateItem: {},
@ -452,6 +446,13 @@ export default {
return { return {
maxHeight: (innerHeight - (innerHeight > 900 ? 200 : 70) - 20) + 'px' maxHeight: (innerHeight - (innerHeight > 900 ? 200 : 70) - 20) + 'px'
} }
},
overlayClass() {
return {
'overlay-y': true,
'overlay-none': this.topOperateVisible === true,
}
} }
}, },
@ -610,10 +611,20 @@ export default {
this.visibleMenu = visible this.visibleMenu = visible
}, },
classNameRoute(path, openMenu) { classNameRoute(path) {
return {
"active": this.curPath == '/manage/' + path,
};
},
classNameProject(item) {
let path = 'project/' + item.id;
let openMenu = this.openMenu[item.id];
return { return {
"active": this.curPath == '/manage/' + path, "active": this.curPath == '/manage/' + path,
"open-menu": openMenu === true, "open-menu": openMenu === true,
"top": item.top_at,
"operate": item.id == this.topOperateItem.id && this.topOperateVisible
}; };
}, },
@ -810,9 +821,10 @@ export default {
} }
document.addEventListener(visibilityChangeEvent, visibilityChangeListener); document.addEventListener(visibilityChangeEvent, visibilityChangeListener);
}, },
handleRightClick(event, item) { handleRightClick(event, item) {
this.handleClickTopOperateOutside(); this.handleClickTopOperateOutside();
this.topOperateItem = $A.isJson(item) ? item : {}; this.topOperateItem = item;
this.$nextTick(() => { this.$nextTick(() => {
const projectWrap = this.$refs.projectWrapper; const projectWrap = this.$refs.projectWrapper;
const projectBounding = projectWrap.getBoundingClientRect(); const projectBounding = projectWrap.getBoundingClientRect();
@ -823,6 +835,7 @@ export default {
this.topOperateVisible = true; this.topOperateVisible = true;
}) })
}, },
handleClickTopOperateOutside() { handleClickTopOperateOutside() {
this.topOperateVisible = false; this.topOperateVisible = false;
}, },
@ -835,15 +848,10 @@ export default {
}, },
}).then(() => { }).then(() => {
this.$store.dispatch("getProjects").catch(() => {}); this.$store.dispatch("getProjects").catch(() => {});
this.$Modal.remove();
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg, 301); $A.modalError(msg, 301);
this.$Modal.remove();
}); });
}, },
listScroll() {
this.topOperateVisible = false;
}
} }
} }
</script> </script>

View File

@ -100,11 +100,14 @@
flex: 1; flex: 1;
width: 100%; width: 100%;
margin-top: 16px; margin-top: 16px;
overflow: auto; display: flex;
flex-direction: column;
overflow: hidden !important;
> li { > li {
flex-shrink: 0;
display: flex; display: flex;
align-items: center; align-items: center;
height: 38px; height: 30px;
color: #6b6e72; color: #6b6e72;
cursor: pointer; cursor: pointer;
position: relative; position: relative;
@ -128,27 +131,35 @@
margin-left: 12px; margin-left: 12px;
transform: scale(0.9); transform: scale(0.9);
} }
&:first-child {
margin-top: 12px;
}
&.active {
background-color: #ffffff;
}
&.menu-project { &.menu-project {
flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
height: auto; padding: 10px 0 0;
padding: 14px 0 0;
cursor: default; cursor: default;
> ul { > ul {
width: 100%; width: 100%;
overflow: auto;
> li { > li {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
margin: 4px auto;
list-style: none; list-style: none;
cursor: pointer; cursor: pointer;
margin: 3px auto;
border: 2px solid transparent;
.project-h1 { .project-h1 {
position: relative; position: relative;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
padding: 0 8px 0 30px; padding: 0 8px 0 28px;
border-radius: 4px; border-radius: 4px;
> em { > em {
position: absolute; position: absolute;
@ -187,7 +198,7 @@
.project-h2 { .project-h2 {
display: none; display: none;
margin: 16px 4px; margin: 16px 4px;
padding: 0 8px 0 26px; padding: 0 8px 0 24px;
cursor: default; cursor: default;
> p { > p {
display: flex; display: flex;
@ -226,11 +237,11 @@
display: block; display: block;
} }
} }
.top { &.top {
background-color: #EEEFF1; background-color: #EEEFF1;
} }
.operate { &.operate {
border:1px solid $primary-color; border-color: $primary-color;
} }
} }
} }
@ -247,15 +258,12 @@
display: flex; display: flex;
} }
} }
&.active {
background-color: #ffffff;
}
} }
} }
.manage-project-search { .manage-project-search {
width: 80%; width: 80%;
padding: 0 3px; padding: 0 3px;
margin: 12px 0 -2px; margin: 8px 0 -2px;
border-radius: 12px; border-radius: 12px;
background-color: #ffffff; background-color: #ffffff;
overflow: hidden; overflow: hidden;
@ -338,6 +346,28 @@
} }
} }
@media (max-height: 640px) {
.page-manage {
.manage-box-menu {
> ul {
overflow: auto !important;
&.overlay-y {
overflow-y: overlay !important;
}
> li {
&.menu-project {
> ul {
overflow: visible !important;
}
}
}
}
.manage-project-search {
margin-top: 12px;
}
}
}
}
@media (max-width: 768px) { @media (max-width: 768px) {
.page-manage { .page-manage {