指示器优化

This commit is contained in:
zqm
2026-01-21 10:33:59 +08:00
parent 975f8735d2
commit 30117b5ae0
3 changed files with 121 additions and 13 deletions

View File

@@ -194,6 +194,7 @@
<!-- 上区指示 --> <!-- 上区指示 -->
<svg <svg
:style="subAreaIndicatorStyle.topArea"
:width="edgeIndicatorStyle.indicatorTop.width" :width="edgeIndicatorStyle.indicatorTop.width"
:height="edgeIndicatorStyle.indicatorTop.height" :height="edgeIndicatorStyle.indicatorTop.height"
viewBox="0 0 40 40" viewBox="0 0 40 40"
@@ -224,6 +225,7 @@
<!-- 右区指示 --> <!-- 右区指示 -->
<svg <svg
:style="subAreaIndicatorStyle.rightArea"
:width="edgeIndicatorStyle.indicatorRight.width" :width="edgeIndicatorStyle.indicatorRight.width"
:height="edgeIndicatorStyle.indicatorRight.height" :height="edgeIndicatorStyle.indicatorRight.height"
viewBox="0 0 40 40" viewBox="0 0 40 40"
@@ -254,6 +256,7 @@
<!-- 下区指示 --> <!-- 下区指示 -->
<svg <svg
:style="subAreaIndicatorStyle.bottomArea"
:width="edgeIndicatorStyle.indicatorBottom.width" :width="edgeIndicatorStyle.indicatorBottom.width"
:height="edgeIndicatorStyle.indicatorBottom.height" :height="edgeIndicatorStyle.indicatorBottom.height"
viewBox="0 0 40 40" viewBox="0 0 40 40"
@@ -284,6 +287,7 @@
<!-- 左区指示 --> <!-- 左区指示 -->
<svg <svg
:style="subAreaIndicatorStyle.leftArea"
:width="edgeIndicatorStyle.indicatorLeft.width" :width="edgeIndicatorStyle.indicatorLeft.width"
:height="edgeIndicatorStyle.indicatorLeft.height" :height="edgeIndicatorStyle.indicatorLeft.height"
viewBox="0 0 40 40" viewBox="0 0 40 40"
@@ -412,6 +416,7 @@
<!-- 中心指示器独立于中心区域容器位于容器正中央 --> <!-- 中心指示器独立于中心区域容器位于容器正中央 -->
<svg <svg
v-if="!props.hideEdgeIndicators"
width="41" width="41"
height="41" height="41"
viewBox="0 0 40 40" viewBox="0 0 40 40"
@@ -477,6 +482,48 @@ const getSafeTargetRect = (targetRect) => {
// 安全版本的targetRect过滤掉可能的无效属性 // 安全版本的targetRect过滤掉可能的无效属性
const safeTargetRect = computed(() => getSafeTargetRect(props.targetRect)); const safeTargetRect = computed(() => getSafeTargetRect(props.targetRect));
// 子区域指示器位置计算(相对于.indicator-center-area
const subAreaIndicatorStyle = computed(() => {
const centerSize = 235; // 中心指示区尺寸 (indicator-center-area)
const padding = 8; // 内边距和间距
const centerOffset = centerSize / 2;
return {
// 上区指示器位于中心指示区顶部距离顶部padding像素
topArea: {
position: 'absolute',
top: `${padding}px`,
left: `${centerOffset}px`,
transform: 'translateX(-50%)',
zIndex: 2
},
// 下区指示器位于中心指示区底部距离底部padding像素
bottomArea: {
position: 'absolute',
bottom: `${padding}px`,
left: `${centerOffset}px`,
transform: 'translateX(-50%)',
zIndex: 2
},
// 左区指示器位于中心指示区左侧距离左侧padding像素
leftArea: {
position: 'absolute',
top: `${centerOffset}px`,
left: `${padding}px`,
transform: 'translateY(-50%)',
zIndex: 2
},
// 右区指示器位于中心指示区右侧距离右侧padding像素
rightArea: {
position: 'absolute',
top: `${centerOffset}px`,
right: `${padding}px`,
transform: 'translateY(-50%)',
zIndex: 2
}
};
});
// 处理鼠标进入指示器 // 处理鼠标进入指示器
const handleMouseEnter = (zone) => { const handleMouseEnter = (zone) => {
// 清除可能存在的离开定时器 // 清除可能存在的离开定时器
@@ -1048,9 +1095,9 @@ watch(activeDockZone, (newZone) => {
/* 上区指示器位于中心指示区上方指示器的上方4个像素处 */ /* 上区指示器位于中心指示区上方指示器的上方4个像素处 */
.dock-top-area { .dock-top-area {
position: absolute; position: absolute;
top: 51px; /* 向上偏移确保距离中心指示区上方指示器上边缘4个像素 */ top: 8px; /* 相对于indicator-center-area顶部的距离 */
left: 50%; left: 50%; /* 相对于indicator-center-area左侧50%的位置 */
transform: translateX(-50%); transform: translateX(-50%); /* 向左移动自身宽度的50%,实现水平居中 */
opacity: 0.7; /* 默认半透明 */ opacity: 0.7; /* 默认半透明 */
transition: opacity 0.2s; transition: opacity 0.2s;
z-index: 2; /* 确保在中心指示区上方 */ z-index: 2; /* 确保在中心指示区上方 */
@@ -1059,9 +1106,9 @@ watch(activeDockZone, (newZone) => {
/* 左区指示器位于中心指示区左侧指示器的右侧4个像素处 */ /* 左区指示器位于中心指示区左侧指示器的右侧4个像素处 */
.dock-left-area { .dock-left-area {
position: absolute; position: absolute;
top: 50%; top: 50%; /* 相对于indicator-center-area顶部50%的位置 */
left: 51px; /* 向右偏移确保距离中心指示区左侧指示器右边缘4个像素 */ left: 8px; /* 相对于indicator-center-area左侧的距离 */
transform: translateY(-50%); transform: translateY(-50%); /* 向上移动自身高度的50%,实现垂直居中 */
opacity: 0.7; /* 默认半透明 */ opacity: 0.7; /* 默认半透明 */
transition: opacity 0.2s; transition: opacity 0.2s;
z-index: 2; /* 确保在中心指示区上方 */ z-index: 2; /* 确保在中心指示区上方 */
@@ -1070,9 +1117,10 @@ watch(activeDockZone, (newZone) => {
/* 右区指示器位于中心指示区右侧指示器的左侧4个像素处 */ /* 右区指示器位于中心指示区右侧指示器的左侧4个像素处 */
.dock-right-area { .dock-right-area {
position: absolute; position: absolute;
top: 50%; top: 50%; /* 相对于indicator-center-area顶部50%的位置 */
right: 51px; /* 向左偏移确保距离中心指示区右侧指示器左边缘4个像素 */ right: 8px; /* 相对于indicator-center-area右侧的距离 */
transform: translateY(-50%); transform: translateY(-50%); /* 向上移动自身高度的50%,实现垂直居中 */
left: auto; /* 覆盖原有left属性 */
opacity: 0.7; /* 默认半透明 */ opacity: 0.7; /* 默认半透明 */
transition: opacity 0.2s; transition: opacity 0.2s;
z-index: 2; /* 确保在中心指示区上方 */ z-index: 2; /* 确保在中心指示区上方 */
@@ -1081,9 +1129,10 @@ watch(activeDockZone, (newZone) => {
/* 下区指示器位于中心指示区下方指示器的下方4个像素处 */ /* 下区指示器位于中心指示区下方指示器的下方4个像素处 */
.dock-bottom-area { .dock-bottom-area {
position: absolute; position: absolute;
bottom: 51px; /* 向上偏移确保距离中心指示区下方指示器下边缘4个像素 */ bottom: 8px; /* 相对于indicator-center-area底部的距离 */
left: 50%; left: 50%; /* 相对于indicator-center-area左侧50%的位置 */
transform: translateX(-50%); transform: translateX(-50%); /* 向左移动自身宽度的50%,实现水平居中 */
top: auto; /* 覆盖原有top属性 */
opacity: 0.7; /* 默认半透明 */ opacity: 0.7; /* 默认半透明 */
transition: opacity 0.2s; transition: opacity 0.2s;
z-index: 2; /* 确保在中心指示区上方 */ z-index: 2; /* 确保在中心指示区上方 */

View File

@@ -820,7 +820,7 @@ const getMainAreaResizeBarStyle = (resizeBar) => {
// 计算属性 // 计算属性
const hideEdgeIndicators = computed(() => { const hideEdgeIndicators = computed(() => {
return !hasAreasInMainContent.value; return false; // 始终显示边缘指示器
}); });
// 设置事件总线监听器 // 设置事件总线监听器

View File

@@ -0,0 +1,59 @@
/**
* 可取消的防抖函数实现
* @param {Function} func - 要执行的函数
* @param {number} wait - 等待时间(毫秒)
* @returns {Function} 防抖后的函数包含cancel方法
*/
export const debounce = (func, wait) => {
let timeout;
const debounced = function(...args) {
const context = this;
const later = () => {
timeout = null;
func.apply(context, args);
};
clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
// 添加取消方法
debounced.cancel = () => {
clearTimeout(timeout);
timeout = null;
};
return debounced;
};
/**
* 可取消的节流函数实现
* @param {Function} func - 要执行的函数
* @param {number} limit - 时间限制(毫秒)
* @returns {Function} 节流后的函数包含cancel方法
*/
export const throttle = (func, limit) => {
let inThrottle;
const throttled = function(...args) {
const context = this;
if (!inThrottle) {
func.apply(context, args);
inThrottle = true;
setTimeout(() => {
inThrottle = false;
}, limit);
}
};
// 添加取消方法
throttled.cancel = () => {
inThrottle = false;
};
return throttled;
};