Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
basic-uniapp-v3
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-uniapp-v3
Commits
30d539dc
提交
30d539dc
authored
8月 26, 2023
作者:
test
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 优化 HandlerUtil 方法命名和 Type 定义
上级
f8cca341
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
39 行增加
和
13 行删除
+39
-13
index.ts
src/components/Map/Mapbox/index.ts
+31
-5
index.vue
src/pages/business/monitor/tem/index.vue
+4
-4
index.vue
src/pages/business/monitor/wind/index.vue
+4
-4
没有找到文件。
src/components/Map/Mapbox/index.ts
浏览文件 @
30d539dc
...
@@ -941,6 +941,29 @@ export interface MapboxInstance {
...
@@ -941,6 +941,29 @@ export interface MapboxInstance {
setLayoutProperty
:
(
layerId
:
string
,
name
:
string
,
value
:
any
)
=>
void
setLayoutProperty
:
(
layerId
:
string
,
name
:
string
,
value
:
any
)
=>
void
}
}
/**
* 站点数据类型定义
*/
export
interface
Station
extends
Recordable
{
/**
* key 用于标识站点是什么类型的数据(例如:降水量、气温...)
*/
key
:
string
value
:
string
|
number
suffix
?:
string
stationCode
?:
string
stationName
?:
string
city
:
string
cnty
:
string
lon
:
string
lat
:
string
}
/**
* 判断是否为非空对象
* @param obj 对象
* @returns 是否为非空对象
*/
function
isPlainObject
(
obj
:
any
)
{
function
isPlainObject
(
obj
:
any
)
{
if
(
typeof
obj
!==
'object'
||
obj
===
null
)
{
if
(
typeof
obj
!==
'object'
||
obj
===
null
)
{
return
false
return
false
...
@@ -950,9 +973,12 @@ function isPlainObject(obj: any) {
...
@@ -950,9 +973,12 @@ function isPlainObject(obj: any) {
return
proto
===
null
||
proto
===
Object
.
prototype
return
proto
===
null
||
proto
===
Object
.
prototype
}
}
/**
* 数据处理工具
*/
export
const
HandlerUtil
=
{
export
const
HandlerUtil
=
{
isPlainObject
,
isPlainObject
,
createDefault
GeoJSONFeatureData
(
station
:
Recordable
)
{
createDefault
PointFeature
(
station
:
Station
,
map
=
{}
as
Recordable
)
{
return
{
return
{
type
:
'Feature'
,
type
:
'Feature'
,
geometry
:
{
geometry
:
{
...
@@ -962,18 +988,18 @@ export const HandlerUtil = {
...
@@ -962,18 +988,18 @@ export const HandlerUtil = {
properties
:
{
properties
:
{
key
:
station
.
key
,
key
:
station
.
key
,
suffix
:
station
.
suffix
,
suffix
:
station
.
suffix
,
value
:
Number
(
station
.
value
)
,
value
:
station
.
value
,
popup
:
HandlerUtil
.
createDefault
StylePopupHtml
({
'{key}'
:
'{value}{suffix}'
},
station
),
popup
:
HandlerUtil
.
createDefault
PopupHtml
(
station
,
{
'{key}'
:
'{value}{suffix}'
,
...
map
}
),
},
},
}
}
},
},
create
DefaultGeoJSONSymbolSourceData
(
features
:
GeoJSON
.
Feature
<
GeoJSON
.
Geometry
>
[]
=
[])
{
create
FeatureCollection
(
features
:
GeoJSON
.
Feature
<
GeoJSON
.
Geometry
>
[]
=
[])
{
return
{
return
{
type
:
'FeatureCollection'
,
type
:
'FeatureCollection'
,
features
:
features
||
[],
features
:
features
||
[],
}
}
},
},
createDefault
StylePopupHtml
(
map
:
Recordable
,
station
:
Recordable
)
{
createDefault
PopupHtml
(
station
:
Station
,
map
:
Recordable
)
{
const
htmls
=
[
'<div class="custom-popup">'
]
const
htmls
=
[
'<div class="custom-popup">'
]
if
(
isPlainObject
(
station
))
{
if
(
isPlainObject
(
station
))
{
...
...
src/pages/business/monitor/tem/index.vue
浏览文件 @
30d539dc
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
import
{
TimeBarWidget
,
formatTime
,
useTimeBarWidget
}
from
'@/components/Map/Widgets/TimeBar'
import
{
TimeBarWidget
,
formatTime
,
useTimeBarWidget
}
from
'@/components/Map/Widgets/TimeBar'
import
{
ToolBoxWidget
,
useToolBoxWidget
}
from
'@/components/Map/Widgets/ToolBox'
import
{
ToolBoxWidget
,
useToolBoxWidget
}
from
'@/components/Map/Widgets/ToolBox'
import
{
BottomBarWidget
,
useBottomBarWidget
}
from
'@/components/Map/Widgets/BottomBar'
import
{
BottomBarWidget
,
useBottomBarWidget
}
from
'@/components/Map/Widgets/BottomBar'
import
type
{
MapboxInstance
}
from
'@/components/Map/Mapbox'
import
type
{
MapboxInstance
,
Station
}
from
'@/components/Map/Mapbox'
import
{
HandlerUtil
}
from
'@/components/Map/Mapbox'
import
{
HandlerUtil
}
from
'@/components/Map/Mapbox'
useShare
()
useShare
()
...
@@ -75,12 +75,12 @@
...
@@ -75,12 +75,12 @@
}),
}),
// 此处使用
// 此处使用
(
response
)
=>
{
(
response
)
=>
{
const
features
=
response
.
body
.
liveVos
.
map
(
function
(
item
)
{
const
features
=
response
.
body
.
liveVos
.
map
(
(
item
:
Station
)
=>
{
item
.
key
=
'气温'
item
.
key
=
'气温'
item
.
suffix
=
'°C'
item
.
suffix
=
'°C'
return
HandlerUtil
.
createDefault
GeoJSONFeatureData
(
item
)
return
HandlerUtil
.
createDefault
PointFeature
(
item
)
})
})
return
HandlerUtil
.
create
DefaultGeoJSONSymbolSourceData
(
features
)
return
HandlerUtil
.
create
FeatureCollection
(
features
)
},
},
)
)
...
...
src/pages/business/monitor/wind/index.vue
浏览文件 @
30d539dc
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
import
{
TimeBarWidget
,
formatTime
,
useTimeBarWidget
}
from
'@/components/Map/Widgets/TimeBar'
import
{
TimeBarWidget
,
formatTime
,
useTimeBarWidget
}
from
'@/components/Map/Widgets/TimeBar'
import
{
ToolBoxWidget
,
useToolBoxWidget
}
from
'@/components/Map/Widgets/ToolBox'
import
{
ToolBoxWidget
,
useToolBoxWidget
}
from
'@/components/Map/Widgets/ToolBox'
import
{
BottomBarWidget
,
useBottomBarWidget
}
from
'@/components/Map/Widgets/BottomBar'
import
{
BottomBarWidget
,
useBottomBarWidget
}
from
'@/components/Map/Widgets/BottomBar'
import
type
{
MapboxInstance
}
from
'@/components/Map/Mapbox'
import
type
{
MapboxInstance
,
Station
}
from
'@/components/Map/Mapbox'
import
{
HandlerUtil
}
from
'@/components/Map/Mapbox'
import
{
HandlerUtil
}
from
'@/components/Map/Mapbox'
import
{
useGlobSetting
}
from
'/@/hooks/setting'
import
{
useGlobSetting
}
from
'/@/hooks/setting'
...
@@ -124,12 +124,12 @@
...
@@ -124,12 +124,12 @@
}),
}),
// 此处使用
// 此处使用
(
response
)
=>
{
(
response
)
=>
{
const
features
=
response
.
body
.
liveVos
.
map
(
function
(
item
)
{
const
features
=
response
.
body
.
liveVos
.
map
(
(
item
:
Station
)
=>
{
item
.
key
=
'风速'
item
.
key
=
'风速'
item
.
suffix
=
'm/s'
item
.
suffix
=
'm/s'
return
HandlerUtil
.
createDefault
GeoJSONFeatureData
(
item
)
return
HandlerUtil
.
createDefault
PointFeature
(
item
)
})
})
return
HandlerUtil
.
create
DefaultGeoJSONSymbolSourceData
(
features
)
return
HandlerUtil
.
create
FeatureCollection
(
features
)
},
},
)
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论