Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
basic-uniapp-v3
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
1
合并请求
1
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-uniapp-v3
Commits
8b340651
提交
8b340651
authored
4月 22, 2026
作者:
王定
浏览文件
操作
浏览文件
下载
差异文件
合并分支
上级
2c9e0a0e
13efb5af
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
45 行增加
和
10 行删除
+45
-10
weather.ts
src/api/model/weather.ts
+23
-1
echarts.module.js
src/components/Echarts/src/echarts.module.js
+14
-6
hook.ts
src/components/Echarts/src/hook.ts
+2
-2
index.vue
src/components/Echarts/src/index.vue
+6
-1
WeatherChartPopup.vue
src/pages/nongchang/detail/components/WeatherChartPopup.vue
+0
-0
index.vue
src/pages/nongchang/detail/index.vue
+0
-0
没有找到文件。
src/api/model/weather.ts
浏览文件 @
8b340651
import
{
weatherHttp
}
from
'/@/utils/http/axios'
import
{
otherHttp
,
weatherHttp
}
from
'/@/utils/http/axios'
const
API_KEY
=
'4fb5c9e814994516b6522419651f2e9e'
...
...
@@ -22,3 +22,25 @@ export function alarm(location: string) {
url
:
`/weatheralert/v1/current/
${
location
.
replace
(
','
,
'/'
)}
?key=
${
API_KEY
}
`
,
})
}
// 格点天气预报-日值(降雨、大风用)
export
function
gridForecastDaily
(
location
:
string
,
day
=
3
)
{
return
weatherHttp
.
get
({
url
:
`/v7/weather/
${
day
}
d?key=
${
API_KEY
}
&location=
${
location
}
`
,
})
}
// 格点天气预报-小时值(温度用)
export
function
gridForecastHourly
(
location
:
string
)
{
return
weatherHttp
.
get
({
url
:
`/v7/weather/24h?key=
${
API_KEY
}
&location=
${
location
}
`
,
})
}
// 强对流预报(自建接口)
export
function
severeForecast
(
lon
:
string
,
lat
:
string
)
{
return
otherHttp
.
get
({
url
:
'/weather/forecast'
,
params
:
{
lon
,
lat
},
},
{
isTransformResponse
:
false
})
}
src/components/Echarts/src/echarts.module.js
浏览文件 @
8b340651
...
...
@@ -13,17 +13,17 @@ export default {
},
methods
:
{
loadLibs
:
loadEchartsLibs
,
init
()
{
init
(
notMerge
)
{
// 如果已经初始化过了,就直接更新配置项
if
(
this
.
chart
&&
this
.
chart
.
setOption
)
{
this
.
chart
.
setOption
(
this
.
option
)
this
.
chart
.
setOption
(
this
.
option
,
{
notMerge
:
notMerge
||
false
}
)
return
}
// 初始化组件
const
chart
=
window
.
echarts
.
init
(
document
.
getElementById
(
this
.
option
.
id
))
// 设置图表配置项
chart
.
setOption
(
this
.
option
)
chart
.
setOption
(
this
.
option
,
{
notMerge
:
notMerge
||
false
}
)
this
.
chart
=
chart
},
changeOption
(
option
)
{
...
...
@@ -45,12 +45,20 @@ export default {
}
}
this
.
option
=
merge
(
this
.
option
,
option
)
const
notMerge
=
option
.
__notMerge
// 清除内部标记
delete
option
.
__notMerge
if
(
notMerge
)
{
this
.
option
=
option
}
else
{
this
.
option
=
merge
(
this
.
option
,
option
)
}
if
(
typeof
window
.
echarts
===
'object'
&&
typeof
window
.
echarts
.
init
===
'function'
)
{
this
.
init
()
this
.
init
(
notMerge
)
}
else
{
this
.
loadLibs
().
then
(()
=>
{
this
.
init
()
this
.
init
(
notMerge
)
})
}
},
...
...
src/components/Echarts/src/hook.ts
浏览文件 @
8b340651
...
...
@@ -44,10 +44,10 @@ export function useEcharts<T extends EchartsInstance, P extends EChartsOption>(
return
[
register
,
{
setOption
:
(
option
:
Partial
<
P
>
):
Promise
<
void
>
=>
{
setOption
:
(
option
:
Partial
<
P
>
,
opts
?:
{
notMerge
?:
boolean
;
lazyUpdate
?:
boolean
}
):
Promise
<
void
>
=>
{
return
new
Promise
((
resolve
)
=>
{
tryOnMounted
(()
=>
{
getInstance
()?.
setOption
(
option
)
getInstance
()?.
setOption
(
option
,
opts
)
resolve
()
})
})
...
...
src/components/Echarts/src/index.vue
浏览文件 @
8b340651
...
...
@@ -14,7 +14,7 @@
this
.
$emit
(
'register'
,
this
)
},
methods
:
{
setOption
(
option
)
{
setOption
(
option
,
opts
)
{
// 处理tooltip formatter函数序列化
if
(
option
.
tooltip
&&
typeof
option
.
tooltip
.
formatter
===
'function'
)
{
// 将函数转换为字符串,在视图层重新构建
...
...
@@ -25,6 +25,11 @@
id
:
this
.
id
,
...
option
,
}
// 保存 opts 供 renderjs 层使用
if
(
opts
?.
notMerge
!==
undefined
)
{
this
.
option
.
__notMerge
=
opts
.
notMerge
}
},
},
}
...
...
src/pages/nongchang/detail/components/WeatherChartPopup.vue
0 → 100644
浏览文件 @
8b340651
差异被折叠。
点击展开。
src/pages/nongchang/detail/index.vue
浏览文件 @
8b340651
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论