Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
basic-uniapp-v3
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-uniapp-v3
Commits
1be73da7
提交
1be73da7
authored
8月 16, 2023
作者:
方治民
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore: 优化 hook 暴露方法的参数默认处理方式
上级
6fdd2839
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
40 行增加
和
22 行删除
+40
-22
_style.ts
src/components/Map/Mapbox/_style.ts
+0
-0
BottomBar.vue
...components/Map/Mapbox/widgets/BottomBar/src/BottomBar.vue
+10
-5
hook.ts
src/components/Map/Mapbox/widgets/BottomBar/src/hook.ts
+3
-2
hook.ts
src/components/Map/Mapbox/widgets/Legend/src/hook.ts
+3
-2
hook.ts
src/components/Map/Mapbox/widgets/SwitchControl/src/hook.ts
+2
-1
utils.ts
src/components/Map/Mapbox/widgets/utils.ts
+5
-0
index.vue
src/pages/business/monitor/rain/index.vue
+17
-12
没有找到文件。
src/components/Map/Mapbox/style.ts
→
src/components/Map/Mapbox/
_
style.ts
浏览文件 @
1be73da7
File moved
src/components/Map/Mapbox/widgets/BottomBar/src/BottomBar.vue
浏览文件 @
1be73da7
...
@@ -15,23 +15,25 @@
...
@@ -15,23 +15,25 @@
// 高度
// 高度
height
:
{
height
:
{
type
:
Number
,
type
:
Number
,
default
:
10
0
,
default
:
0
,
},
},
// 最高高度
// 最高高度
maxHeight
:
{
maxHeight
:
{
type
:
Number
,
type
:
Number
,
default
:
20
0
,
default
:
0
,
},
},
})
})
const
emits
=
defineEmits
([
'register'
])
const
emits
=
defineEmits
([
'register'
])
const
iHeight
=
computed
(()
=>
`
${
props
.
height
}
rpx`
)
const
iHeight
=
computed
(()
=>
`
${
data
.
height
}
rpx`
)
const
iMaxHeight
=
computed
(()
=>
`
${
props
.
maxHeight
}
rpx`
)
const
iMaxHeight
=
computed
(()
=>
`
${
data
.
maxHeight
}
rpx`
)
const
data
=
reactive
({
const
data
=
reactive
({
show
:
props
.
show
,
show
:
props
.
show
,
expand
:
props
.
expand
,
expand
:
props
.
expand
,
height
:
props
.
height
,
maxHeight
:
props
.
maxHeight
,
})
})
function
toggleShow
(
show
?:
boolean
)
{
function
toggleShow
(
show
?:
boolean
)
{
...
@@ -50,7 +52,8 @@
...
@@ -50,7 +52,8 @@
setProps
,
setProps
,
toggleShow
,
toggleShow
,
toggleExpand
,
toggleExpand
,
height
:
computed
(()
=>
(
data
.
show
?
`
${(
data
.
expand
?
props
.
maxHeight
:
props
.
height
)
+
60
}
rpx`
:
'1rpx'
)),
// TODO: 此处高度还需考虑底部安全区
height
:
computed
(()
=>
(
data
.
show
?
`
${(
data
.
expand
?
data
.
maxHeight
:
data
.
height
)
+
60
}
rpx`
:
'1rpx'
)),
})
})
</
script
>
</
script
>
...
@@ -127,6 +130,8 @@
...
@@ -127,6 +130,8 @@
align-items
:
center
;
align-items
:
center
;
width
:
100%
;
width
:
100%
;
height
:
calc
(
100%
-
60
rpx
-
20
rpx
);
height
:
calc
(
100%
-
60
rpx
-
20
rpx
);
overflow
:
hidden
;
position
:
relative
;
}
}
}
}
</
style
>
</
style
>
src/components/Map/Mapbox/widgets/BottomBar/src/hook.ts
浏览文件 @
1be73da7
import
{
getBooleanOrDefault
}
from
'../../utils'
import
type
{
BottomBarInstance
,
BottomBarProps
}
from
'./types'
import
type
{
BottomBarInstance
,
BottomBarProps
}
from
'./types'
import
{
isProdMode
}
from
'/@/utils/env'
import
{
isProdMode
}
from
'/@/utils/env'
...
@@ -41,10 +42,10 @@ export function useBottomBarWidget<T extends BottomBarInstance>(props: BottomBar
...
@@ -41,10 +42,10 @@ export function useBottomBarWidget<T extends BottomBarInstance>(props: BottomBar
getInstance
()?.
setProps
(
props
)
getInstance
()?.
setProps
(
props
)
},
},
toggleShow
:
(
show
?:
boolean
)
=>
{
toggleShow
:
(
show
?:
boolean
)
=>
{
getInstance
()?.
toggleShow
(
show
)
getInstance
()?.
toggleShow
(
getBooleanOrDefault
(
show
)
)
},
},
toggleExpand
:
(
expand
?:
boolean
)
=>
{
toggleExpand
:
(
expand
?:
boolean
)
=>
{
getInstance
()?.
toggleExpand
(
expand
)
getInstance
()?.
toggleExpand
(
getBooleanOrDefault
(
expand
)
)
},
},
}
as
T
,
}
as
T
,
]
]
...
...
src/components/Map/Mapbox/widgets/Legend/src/hook.ts
浏览文件 @
1be73da7
import
{
getBooleanOrDefault
}
from
'../../utils'
import
type
{
LegendInstance
,
LegendProps
,
Option
}
from
'./types'
import
type
{
LegendInstance
,
LegendProps
,
Option
}
from
'./types'
import
{
isProdMode
}
from
'/@/utils/env'
import
{
isProdMode
}
from
'/@/utils/env'
...
@@ -45,10 +46,10 @@ export function useLegendWidget<T extends LegendInstance>(props: LegendProps): [
...
@@ -45,10 +46,10 @@ export function useLegendWidget<T extends LegendInstance>(props: LegendProps): [
getInstance
()?.
setOption
(
option
)
getInstance
()?.
setOption
(
option
)
},
},
toggleShow
:
(
show
?:
boolean
)
=>
{
toggleShow
:
(
show
?:
boolean
)
=>
{
getInstance
()?.
toggleShow
(
show
)
getInstance
()?.
toggleShow
(
getBooleanOrDefault
(
show
)
)
},
},
toggleExpand
:
(
expand
?:
boolean
)
=>
{
toggleExpand
:
(
expand
?:
boolean
)
=>
{
getInstance
()?.
toggleExpand
(
expand
)
getInstance
()?.
toggleExpand
(
getBooleanOrDefault
(
expand
)
)
},
},
}
as
T
,
}
as
T
,
]
]
...
...
src/components/Map/Mapbox/widgets/SwitchControl/src/hook.ts
浏览文件 @
1be73da7
import
{
getBooleanOrDefault
}
from
'../../utils'
import
type
{
SwitchControlInstance
,
SwitchControlProps
}
from
'./types'
import
type
{
SwitchControlInstance
,
SwitchControlProps
}
from
'./types'
import
{
isProdMode
}
from
'/@/utils/env'
import
{
isProdMode
}
from
'/@/utils/env'
...
@@ -41,7 +42,7 @@ export function useSwitchControlWidget<T extends SwitchControlInstance>(
...
@@ -41,7 +42,7 @@ export function useSwitchControlWidget<T extends SwitchControlInstance>(
getInstance
()?.
setProps
(
props
)
getInstance
()?.
setProps
(
props
)
},
},
toggleShow
:
(
show
?:
boolean
)
=>
{
toggleShow
:
(
show
?:
boolean
)
=>
{
getInstance
()?.
toggleShow
(
show
)
getInstance
()?.
toggleShow
(
getBooleanOrDefault
(
show
)
)
},
},
prev
:
()
=>
{
prev
:
()
=>
{
getInstance
()?.
prev
()
getInstance
()?.
prev
()
...
...
src/components/Map/Mapbox/widgets/utils.ts
0 → 100644
浏览文件 @
1be73da7
import
{
isBoolean
}
from
'lodash-es'
export
function
getBooleanOrDefault
(
value
:
any
,
def
=
null
):
boolean
{
return
isBoolean
(
value
)
?
value
:
def
}
src/pages/business/monitor/rain/index.vue
浏览文件 @
1be73da7
...
@@ -36,21 +36,17 @@
...
@@ -36,21 +36,17 @@
const
[
registerBottomBarWidget
,
{
height
}]
=
useBottomBarWidget
({
const
[
registerBottomBarWidget
,
{
height
}]
=
useBottomBarWidget
({
show
:
true
,
show
:
true
,
expand
:
true
,
expand
:
true
,
height
:
1
0
0
,
height
:
1
5
0
,
maxHeight
:
2
0
0
,
maxHeight
:
2
4
0
,
})
})
function
testPackUp
()
{
toggleLegendWidgetExpand
()
}
</
script
>
</
script
>
<
template
>
<
template
>
<view
class=
"
bg-white h-100vh rain
"
>
<view
class=
"
page h-100vh bg-white
"
>
<!-- 地图组件 -->
<!-- 地图组件 -->
<Mapbox
:config=
"config"
/>
<Mapbox
:config=
"config"
/>
<!--
交互组件集
-->
<!--
地图上方所有小部件
-->
<view
class=
"widgets"
>
<view
class=
"widgets"
>
<!-- -->
<!-- -->
...
@@ -63,7 +59,7 @@
...
@@ -63,7 +59,7 @@
<!-- 底部 Bar 小部件 -->
<!-- 底部 Bar 小部件 -->
<BottomBarWidget
@
register=
"registerBottomBarWidget"
>
<BottomBarWidget
@
register=
"registerBottomBarWidget"
>
<!-- 内容 Slot -->
<!-- 内容 Slot -->
<view
class=
"c-coolGray"
@
tap=
"t
estPackUp
"
>
底部交互控件/展示内容
</view>
<view
class=
"c-coolGray"
@
tap=
"t
oggleLegendWidgetExpand
"
>
底部交互控件/展示内容
</view>
</BottomBarWidget>
</BottomBarWidget>
</view>
</view>
</view>
</view>
...
@@ -71,21 +67,30 @@
...
@@ -71,21 +67,30 @@
<
style
lang=
"scss"
scoped
>
<
style
lang=
"scss"
scoped
>
.widgets
{
.widgets
{
//
覆盖图例小部件的默认样式
:deep(.legend)
{
:deep(.legend)
{
bottom
:
calc
(
30
rpx
+
v-bind
(
height
));
bottom
:
calc
(
30
rpx
+
v-bind
(
height
));
//
如果底部使用
bottom-left
attribution
则需要加上
80rpx,默认显示在右侧,不会冲突
//
如果底部使用
bottom-left
attribution
则需要加上
80rpx,默认显示在右侧,不会冲突
//
bottom
:
calc
(
30
rpx
+
80
rpx
+
v-bind
(
height
));
//
bottom
:
calc
(
30
rpx
+
80
rpx
+
v-bind
(
height
));
}
}
//
覆盖底部
Bar
小部件的默认样式
//
:deep
(
.bottom-bar
)
{
//
}
//
前后切换小部件
//
:deep
(
.switch-control
)
{
//
}
}
}
.
rain
{
.
page
{
//
#ifdef
H5
//
#ifdef
H5
:
deep
(.
mapboxgl-ctrl-bottom-right
)
{
:
deep
(.
mapboxgl-ctrl-bottom-right
)
{
bottom
:
calc
(
30
rpx
+
5
0
rpx
+
v-bind
(
height
));
bottom
:
calc
(
8
0
rpx
+
v-bind
(
height
));
}
}
:deep
(
.mapboxgl-ctrl-bottom-left
)
{
:deep
(
.mapboxgl-ctrl-bottom-left
)
{
bottom
:
calc
(
30
rpx
+
5
0
rpx
+
v-bind
(
height
));
bottom
:
calc
(
8
0
rpx
+
v-bind
(
height
));
}
}
//
#endif
//
#endif
//
#ifdef
APP-PLUS
//
#ifdef
APP-PLUS
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论