1.工具栏的某个工具如果有二级菜单,改为通过点击工具展开和收起;
This commit is contained in:
parent
4827a7da46
commit
ed8b76fe5f
|
@ -11,16 +11,16 @@
|
||||||
v-for="tool in options"
|
v-for="tool in options"
|
||||||
:key="tool.id"
|
:key="tool.id"
|
||||||
class="tool-wrapper"
|
class="tool-wrapper"
|
||||||
:class="{'open': isOpen}"
|
:class="{'open': isOpen, 'active': tool.expand}"
|
||||||
>
|
>
|
||||||
<!-- 主工具按钮 -->
|
<!-- 主工具按钮 -->
|
||||||
<div class="tool-button" @click="tool.name && bus.emit(`toolbar_${tool.name}`, params)">
|
<div class="tool-button" @click="mainToolClick(tool)">
|
||||||
<el-image class="tool-icon" :src="tool.icon" fit="contain" />
|
<el-image class="tool-icon" :src="tool.icon" fit="contain" />
|
||||||
</div>
|
</div>
|
||||||
<!-- 主工具名称 (右侧淡入淡出) -->
|
<!-- 主工具名称 (右侧淡入淡出) -->
|
||||||
<div class="tool-name main-name">{{ tool.label }}</div>
|
<div class="tool-name main-name">{{ tool.label }}</div>
|
||||||
<!-- 二级工具菜单 (左侧淡入淡出) -->
|
<!-- 二级工具菜单 (左侧淡入淡出) -->
|
||||||
<div v-if="tool.subtools && tool.subtools?.length > 0" class="toolbar submenu">
|
<div v-if="tool.subtools && tool.subtools?.length > 0" class="toolbar submenu" :class="{'active': tool.expand}">
|
||||||
<!-- 遍历二级工具按钮 -->
|
<!-- 遍历二级工具按钮 -->
|
||||||
<div
|
<div
|
||||||
v-for="subtool in tool.subtools"
|
v-for="subtool in tool.subtools"
|
||||||
|
@ -102,7 +102,6 @@ import toolbarWatersourceIcon from '@/assets/icons/toolbar_watersource.png';
|
||||||
import toolbarRoadIcon from '@/assets/icons/toolbar_road.png';
|
import toolbarRoadIcon from '@/assets/icons/toolbar_road.png';
|
||||||
import toolbarKeyareaIcon from '@/assets/icons/toolbar_keyarea.png';
|
import toolbarKeyareaIcon from '@/assets/icons/toolbar_keyarea.png';
|
||||||
// 气象效果图标
|
// 气象效果图标
|
||||||
import toolbarSunnyIcon from '@/assets/icons/toolbar_sunny.png';
|
|
||||||
import toolbarRainIcon from '@/assets/icons/toolbar_rain.png';
|
import toolbarRainIcon from '@/assets/icons/toolbar_rain.png';
|
||||||
import toolbarSnowIcon from '@/assets/icons/toolbar_snow.png';
|
import toolbarSnowIcon from '@/assets/icons/toolbar_snow.png';
|
||||||
import toolbarFogIcon from '@/assets/icons/toolbar_fog.png';
|
import toolbarFogIcon from '@/assets/icons/toolbar_fog.png';
|
||||||
|
@ -128,6 +127,7 @@ const options = ref([
|
||||||
id: 1,
|
id: 1,
|
||||||
icon: baseDrawIcon,
|
icon: baseDrawIcon,
|
||||||
label: '基础绘制',
|
label: '基础绘制',
|
||||||
|
expand: false,
|
||||||
subtools: [
|
subtools: [
|
||||||
{
|
{
|
||||||
id: 11,
|
id: 11,
|
||||||
|
@ -186,6 +186,7 @@ const options = ref([
|
||||||
id: 2,
|
id: 2,
|
||||||
icon: forestDrawIcon,
|
icon: forestDrawIcon,
|
||||||
label: '森防绘制',
|
label: '森防绘制',
|
||||||
|
expand: false,
|
||||||
subtools: [
|
subtools: [
|
||||||
{
|
{
|
||||||
id: 21,
|
id: 21,
|
||||||
|
@ -249,30 +250,28 @@ const options = ref([
|
||||||
id: 3,
|
id: 3,
|
||||||
icon: weatherIcon,
|
icon: weatherIcon,
|
||||||
label: '气象效果',
|
label: '气象效果',
|
||||||
|
expand: false,
|
||||||
subtools: [
|
subtools: [
|
||||||
{
|
{
|
||||||
id: 31,
|
id: 31,
|
||||||
name: 'sunny',
|
name: 'rain',
|
||||||
label: '晴天',
|
label: '下雨',
|
||||||
icon: toolbarSunnyIcon
|
icon: toolbarRainIcon,
|
||||||
|
active: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 32,
|
id: 32,
|
||||||
name: 'rain',
|
name: 'snow',
|
||||||
label: '下雨',
|
label: '下雪',
|
||||||
icon: toolbarRainIcon
|
icon: toolbarSnowIcon,
|
||||||
|
active: false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 33,
|
id: 33,
|
||||||
name: 'snow',
|
|
||||||
label: '下雪',
|
|
||||||
icon: toolbarSnowIcon
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 34,
|
|
||||||
name: 'fog',
|
name: 'fog',
|
||||||
label: '起雾',
|
label: '起雾',
|
||||||
icon: toolbarFogIcon
|
icon: toolbarFogIcon,
|
||||||
|
active: false
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -311,6 +310,25 @@ const toolbarClear = () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const mainToolClick = (tool) => {
|
||||||
|
// 触发工具事件
|
||||||
|
tool.name && bus.emit(`toolbar_${tool.name}`, params)
|
||||||
|
|
||||||
|
// 修改子工具栏的展开状态
|
||||||
|
if(tool.expand) {
|
||||||
|
tool.expand = false;
|
||||||
|
} else {
|
||||||
|
tool.expand = true;
|
||||||
|
options.value.forEach(item => {
|
||||||
|
if(item.id !== tool.id) {
|
||||||
|
item.expand = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
watch(() => props.viewer, (v) => {
|
watch(() => props.viewer, (v) => {
|
||||||
if (v) {
|
if (v) {
|
||||||
viewer = v;
|
viewer = v;
|
||||||
|
@ -445,7 +463,8 @@ watch(() => props.viewer, (v) => {
|
||||||
border-radius: 0 0 16px 16px;
|
border-radius: 0 0 16px 16px;
|
||||||
padding-bottom: 5px;
|
padding-bottom: 5px;
|
||||||
}
|
}
|
||||||
&:hover {
|
&:hover,
|
||||||
|
&.active {
|
||||||
background-color: rgba($color: #FFD700, $alpha: .5);
|
background-color: rgba($color: #FFD700, $alpha: .5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -466,6 +485,16 @@ watch(() => props.viewer, (v) => {
|
||||||
right: 100%;
|
right: 100%;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
transition: opacity 0.3s ease, transform 0.3s ease; /* 动画持续时间和缓动函数 */
|
transition: opacity 0.3s ease, transform 0.3s ease; /* 动画持续时间和缓动函数 */
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
pointer-events: all;
|
||||||
|
transition-delay: 0.1s; /* 延迟 */
|
||||||
|
|
||||||
|
& > .tool-wrapper {
|
||||||
|
height: 40px;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* 二级工具名称的定位 (左侧) */
|
/* 二级工具名称的定位 (左侧) */
|
||||||
.sub-name {
|
.sub-name {
|
||||||
|
@ -473,15 +502,15 @@ watch(() => props.viewer, (v) => {
|
||||||
transform: translateX(0); /* 初始位置 */
|
transform: translateX(0); /* 初始位置 */
|
||||||
}
|
}
|
||||||
/* 当主 tool-wrapper 被 hover 且包含二级菜单时,显示二级菜单 */
|
/* 当主 tool-wrapper 被 hover 且包含二级菜单时,显示二级菜单 */
|
||||||
.tool-wrapper:hover > .submenu {
|
// .tool-wrapper:hover > .submenu {
|
||||||
pointer-events: all;
|
// pointer-events: all;
|
||||||
transition-delay: 0.1s; /* 延迟 */
|
// transition-delay: 0.1s; /* 延迟 */
|
||||||
|
|
||||||
& > .tool-wrapper {
|
// & > .tool-wrapper {
|
||||||
height: 40px;
|
// height: 40px;
|
||||||
opacity: 1;
|
// opacity: 1;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* 当二级 tool-wrapper 被 hover 时,显示二级工具名称 */
|
/* 当二级 tool-wrapper 被 hover 时,显示二级工具名称 */
|
||||||
/* 注意这里的选择器,因为二级名称在二级 tool-wrapper 内部 */
|
/* 注意这里的选择器,因为二级名称在二级 tool-wrapper 内部 */
|
||||||
|
|
Loading…
Reference in New Issue