Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
wangxiaolu-sfa-ui
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
sfa
wangxiaolu-sfa-ui
Commits
6cae6489
提交
6cae6489
authored
12月 30, 2024
作者:
lidongxu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(levitatedsphere): 重构悬浮工具球
从 Vue2 重构成 Vue3 的语法
上级
d292a5f1
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
64 行增加
和
72 行删除
+64
-72
index.vue
src/components/ECharts/GroupLegend/index.vue
+9
-11
index.vue
src/components/LevitatedSphere/index.vue
+55
-61
没有找到文件。
src/components/ECharts/GroupLegend/index.vue
浏览文件 @
6cae6489
...
...
@@ -15,9 +15,8 @@
</div>
</
template
>
<
script
>
export
default
{
props
:
{
<
script
setup
>
defineProps
({
/**
* 数据格式: [
* { // 每一列组
...
...
@@ -38,7 +37,7 @@ export default {
* orient: '一组内的排列方式' // verticalAlign 垂直排列(默认),horizontal 水平排列
* }
* ]
*/
*/
legendData
:
{
type
:
Array
,
default
:
()
=>
[]
...
...
@@ -47,13 +46,11 @@ export default {
type
:
String
,
default
:
'horizontal'
// 每组之间排列方式: verticalAlign 垂直,horizontal 水平
}
},
methods
:
{
handleClick
(
item
)
{
})
const
emit
=
defineEmits
([
'clickItem'
]);
const
handleClick
=
(
item
)
=>
{
item
.
effective
=
!
item
.
effective
this
.
$emit
(
'clickItem'
)
}
}
emit
(
'clickItem'
,
item
)
}
</
script
>
...
...
@@ -179,7 +176,8 @@ export default {
.e-icon
{
background
:
lightgray
!
important
;
border-color
:
lightgray
!
important
;
&
:before
{
&
:before
{
border-color
:
lightgray
!
important
;
}
}
...
...
src/components/LevitatedSphere/index.vue
浏览文件 @
6cae6489
...
...
@@ -22,10 +22,8 @@
</div>
</
template
>
<
script
>
export
default
{
name
:
'LevitatedSphere'
,
props
:
{
<
script
setup
>
const
props
=
defineProps
({
itemWidth
:
{
// 悬浮按钮宽度
type
:
Number
,
...
...
@@ -46,76 +44,68 @@ export default {
type
:
Number
,
default
:
0.85
,
}
},
data
()
{
return
{
top
:
0
,
left
:
0
,
clientWidth
:
0
,
clientHeight
:
0
,
drawer
:
false
,
downPoint
:
{},
upPoint
:
{}
};
},
created
()
{
this
.
resize
()
},
mounted
()
{
window
.
addEventListener
(
'resize'
,
this
.
resize
)
this
.
$nextTick
(()
=>
{
const
sphereBtn
=
this
.
$refs
.
levitatedSphere
;
})
const
levitatedSphere
=
ref
(
null
)
const
top
=
ref
(
0
)
const
left
=
ref
(
0
)
const
clientWidth
=
ref
(
0
)
const
clientHeight
=
ref
(
0
)
const
drawer
=
ref
(
false
)
const
downPoint
=
reactive
({})
const
upPoint
=
reactive
({})
const
resize
=
()
=>
{
clientWidth
.
value
=
document
.
documentElement
.
clientWidth
;
clientHeight
.
value
=
document
.
documentElement
.
clientHeight
;
left
.
value
=
clientWidth
.
value
-
props
.
itemWidth
-
props
.
gapWidth
;
top
.
value
=
clientHeight
.
value
*
props
.
coefficientHeight
;
}
resize
()
onMounted
(()
=>
{
window
.
addEventListener
(
'resize'
,
resize
)
})
nextTick
(()
=>
{
let
isDown
=
false
sphereBtn
.
addEventListener
(
'mousedown'
,
(
e
)
=>
{
levitatedSphere
.
value
.
addEventListener
(
'mousedown'
,
(
e
)
=>
{
e
.
preventDefault
();
sphereBtn
.
style
.
transition
=
'none'
;
this
.
downPoint
=
{
x
:
e
.
clientX
,
y
:
e
.
clientY
};
levitatedSphere
.
value
.
style
.
transition
=
'none'
;
downPoint
.
x
=
e
.
clientX
downPoint
.
y
=
e
.
clientY
isDown
=
true
});
})
// 在拖拽过程中,组件应该跟随手指的移动而移动
window
.
addEventListener
(
'mousemove'
,
(
e
)
=>
{
e
.
preventDefault
();
if
(
isDown
)
{
let
touch
=
e
;
// 限制 left 和 top 的值,使其不会超出可视区域
this
.
left
=
Math
.
max
(
this
.
gapWidth
,
Math
.
min
(
touch
.
clientX
-
20
,
this
.
clientWidth
-
this
.
itemWidth
-
thi
s
.
gapWidth
));
this
.
top
=
Math
.
max
(
0
,
Math
.
min
(
touch
.
clientY
-
25
,
this
.
clientHeight
-
thi
s
.
itemHeight
));
left
.
value
=
Math
.
max
(
props
.
gapWidth
,
Math
.
min
(
touch
.
clientX
-
20
,
clientWidth
.
value
-
props
.
itemWidth
-
prop
s
.
gapWidth
));
top
.
value
=
Math
.
max
(
0
,
Math
.
min
(
touch
.
clientY
-
25
,
clientHeight
.
value
-
prop
s
.
itemHeight
));
}
});
// 拖拽结束后,重新调整组件的位置并重新设置过渡动画
window
.
addEventListener
(
'mouseup'
,
(
e
)
=>
{
sphereBtn
.
style
.
transition
=
'all 0.5s'
;
if
(
this
.
left
>
document
.
documentElement
.
clientWidth
/
2
)
{
this
.
left
=
document
.
documentElement
.
clientWidth
-
this
.
itemWidth
-
thi
s
.
gapWidth
;
levitatedSphere
.
value
.
style
.
transition
=
'all 0.5s'
;
if
(
left
.
value
>
document
.
documentElement
.
clientWidth
/
2
)
{
left
.
value
=
document
.
documentElement
.
clientWidth
-
props
.
itemWidth
-
prop
s
.
gapWidth
;
}
else
{
this
.
left
=
thi
s
.
gapWidth
;
left
.
value
=
prop
s
.
gapWidth
;
}
isDown
=
false
this
.
upPoint
=
{
x
:
e
.
clientX
,
y
:
e
.
clientY
};
});
});
},
beforeDestroy
()
{
window
.
removeEventListener
(
'resize'
,
this
.
resize
)
},
methods
:
{
resize
()
{
this
.
clientWidth
=
document
.
documentElement
.
clientWidth
;
this
.
clientHeight
=
document
.
documentElement
.
clientHeight
;
this
.
left
=
this
.
clientWidth
-
this
.
itemWidth
-
this
.
gapWidth
;
this
.
top
=
this
.
clientHeight
*
this
.
coefficientHeight
;
},
handleClick
()
{
if
(
this
.
downPoint
.
x
===
this
.
upPoint
.
x
&&
this
.
downPoint
.
y
===
this
.
upPoint
.
y
)
{
this
.
drawer
=
!
this
.
drawer
}
}
upPoint
.
x
=
e
.
clientX
upPoint
.
y
=
e
.
clientY
})
});
onBeforeUnmount
(()
=>
{
window
.
removeEventListener
(
'resize'
,
resize
)
})
const
handleClick
=
()
=>
{
if
(
downPoint
.
x
===
upPoint
.
x
&&
downPoint
.
y
===
upPoint
.
y
)
{
drawer
.
value
=
!
drawer
.
value
}
}
</
script
>
...
...
@@ -139,9 +129,12 @@ export default {
padding
:
10px
;
display
:
grid
;
grid-template-columns
:
repeat
(
3
,
1fr
);
grid-template-rows
:
repeat
(
auto-fill
,
30px
);
/* 明确指定行高为100px */
grid-auto-rows
:
30px
;
/* 自动生成的行高也为100px */
grid-gap
:
20px
5px
;
/* 上下间距20px,左右间距5px */
grid-template-rows
:
repeat
(
auto-fill
,
30px
);
/* 明确指定行高为100px */
grid-auto-rows
:
30px
;
/* 自动生成的行高也为100px */
grid-gap
:
20px
5px
;
/* 上下间距20px,左右间距5px */
width
:
100%
;
.el-button
{
...
...
@@ -149,6 +142,7 @@ export default {
margin
:
0
;
}
}
@media
(
max-width
:
768px
)
{
.wrap
{
width
:
30px
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论