Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
enoyee
Scriptable
提交
35550305
S
Scriptable
项目概览
enoyee
/
Scriptable
通知
9
Star
0
Fork
3
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Scriptable
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
35550305
编写于
12月 22, 2022
作者:
AndroidLeaves
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
上级
4003231b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
63 addition
and
97 deletion
+63
-97
_LSP.js
_LSP.js
+1
-27
桌面启动.js
桌面启动.js
+62
-70
未找到文件。
_LSP.js
浏览文件 @
35550305
...
...
@@ -8,7 +8,7 @@
*/
// 当前环境版本号
const
VERSION
=
2022122
0
const
VERSION
=
2022122
2
// 组件配置文件名
const
settingConfigName
=
'
settings.json
'
;
// 组件默认配置
...
...
@@ -1824,32 +1824,6 @@ class BaseWidget {
this
.
logDivider
();
return
response
}
/**
* 节假日信息
* @returns 节假日信息
*/
holidayInfo
=
async
()
=>
{
let
holiday
=
{
isHoliday
:
false
,
lunarDate
:
''
,
holiday_cn
:
''
};
const
url
=
'
https://api.apihubs.cn/holiday/get?cn=1&size=31
'
;
const
holidayJsonData
=
await
this
.
httpGet
(
url
);
if
(
holidayJsonData
.
code
===
0
)
{
const
dateStr
=
getDateStr
(
new
Date
(),
'
yyyyMMdd
'
);
const
list
=
holidayJsonData
.
data
.
list
;
list
.
forEach
(
element
=>
{
let
lunar_date_cn
=
element
.
lunar_date_cn
;
let
index
=
lunar_date_cn
.
lastIndexOf
(
'
年
'
)
+
1
;
holiday
.
lunarDate
=
lunar_date_cn
.
slice
(
index
);
holiday
.
holiday_cn
=
element
.
holiday_cn
;
if
(
element
.
date
==
dateStr
)
{
holiday
.
isHoliday
=
element
.
workday
==
2
;
}
});
}
console
.
log
(
`🚀 节假日信息:
${
JSON
.
stringify
(
holiday
)}
`
);
this
.
logDivider
();
return
holiday
;
}
// ***************************************************
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
...
...
桌面启动.js
浏览文件 @
35550305
...
...
@@ -3,7 +3,7 @@
// icon-color: red; icon-glyph: user-astronaut;
/**
* Author:LSP
* Date:2022-12-
15
* Date:2022-12-
22
*/
// -------------------------------------------------------
// 是否是开发环境,配合手机端调试使用,正式发布设置为false
...
...
@@ -28,15 +28,14 @@ class Widget extends BaseWidget {
defaultPreference
=
{
caiyun
:
'
UR8ASaplvIwavDfR
'
,
weatherIco
:
'
0
'
,
covArea
:
'
440100
'
,
temperatureFontColor
:
'
#FFFFFF
'
,
temperatureFontSize
:
'
34
'
,
dateFontColor
:
'
#FFFEF9
'
,
dateFontSize
:
'
13
'
,
weatherFontColor
:
'
#F9F4DC
'
,
weatherFontSize
:
'
12
'
,
cov
FontColor
:
'
#F1939C
'
,
cov
FontSize
:
'
13
'
,
holiday
FontColor
:
'
#F1939C
'
,
holiday
FontSize
:
'
13
'
,
quickFontSize
:
'
11
'
,
quickFontColor
:
'
#FFFFFF
'
,
quickConfigs
:
[
...
...
@@ -67,15 +66,14 @@ class Widget extends BaseWidget {
getValueByKey
=
(
key
)
=>
this
.
readWidgetSetting
()[
key
]
??
this
.
defaultPreference
[
key
];
caiyun
=
()
=>
this
.
getValueByKey
(
'
caiyun
'
);
weatherIco
=
()
=>
this
.
getValueByKey
(
'
weatherIco
'
);
covArea
=
()
=>
this
.
getValueByKey
(
'
covArea
'
);
temperatureFontColor
=
()
=>
this
.
getValueByKey
(
'
temperatureFontColor
'
);
temperatureFontSize
=
()
=>
this
.
getValueByKey
(
'
temperatureFontSize
'
);
dateFontColor
=
()
=>
this
.
getValueByKey
(
'
dateFontColor
'
);
dateFontSize
=
()
=>
this
.
getValueByKey
(
'
dateFontSize
'
);
weatherFontColor
=
()
=>
this
.
getValueByKey
(
'
weatherFontColor
'
);
weatherFontSize
=
()
=>
this
.
getValueByKey
(
'
weatherFontSize
'
);
covFontColor
=
()
=>
this
.
getValueByKey
(
'
cov
FontColor
'
);
covFontSize
=
()
=>
this
.
getValueByKey
(
'
cov
FontSize
'
);
holidayFontColor
=
()
=>
this
.
getValueByKey
(
'
holiday
FontColor
'
);
holidayFontSize
=
()
=>
this
.
getValueByKey
(
'
holiday
FontSize
'
);
quickFontSize
=
()
=>
this
.
getValueByKey
(
'
quickFontSize
'
);
quickFontColor
=
()
=>
this
.
getValueByKey
(
'
quickFontColor
'
);
...
...
@@ -129,14 +127,6 @@ class Widget extends BaseWidget {
needLoading
:
false
,
default
:
(
this
.
weatherIco
()
>=
1
&&
this
.
weatherIco
()
<=
10
)
?
`第
${
this
.
weatherIco
()}
套图标`
:
'
随机
'
,
},
{
name
:
'
covArea
'
,
label
:
'
疫情地区
'
,
type
:
'
cell
'
,
icon
:
{
name
:
'
location
'
,
color
:
'
#ff5400
'
,
},
needLoading
:
false
,
default
:
this
.
covArea
(),
},
{
name
:
'
quickStart
'
,
label
:
'
快捷启动
'
,
...
...
@@ -253,29 +243,29 @@ class Widget extends BaseWidget {
default
:
this
.
weatherFontColor
(),
},
{
name
:
'
cov
FontSize
'
,
label
:
'
疫情
文字大小
'
,
name
:
'
holiday
FontSize
'
,
label
:
'
节假日
文字大小
'
,
type
:
'
cell
'
,
icon
:
'
https://gitcode.net/enoyee/scriptable/-/raw/master/img/ic
_corona_virus
.png
'
,
icon
:
'
https://gitcode.net/enoyee/scriptable/-/raw/master/img/ic
on_holiday
.png
'
,
needLoading
:
false
,
alert
:
{
title
:
'
疫情
文字大小
'
,
title
:
'
节假日
文字大小
'
,
options
:
[
{
key
:
'
cov
FontSize
'
,
key
:
'
holiday
FontSize
'
,
hint
:
'
请输入字号
'
,
}
]
},
default
:
this
.
cov
FontSize
(),
default
:
this
.
holiday
FontSize
(),
},
{
name
:
'
cov
FontColor
'
,
label
:
'
疫情
文字颜色
'
,
name
:
'
holiday
FontColor
'
,
label
:
'
节假日
文字颜色
'
,
type
:
'
color
'
,
icon
:
'
https://gitcode.net/enoyee/scriptable/-/raw/master/img/ic
_corona_virus
.png
'
,
icon
:
'
https://gitcode.net/enoyee/scriptable/-/raw/master/img/ic
on_holiday
.png
'
,
needLoading
:
false
,
default
:
this
.
cov
FontColor
(),
default
:
this
.
holiday
FontColor
(),
},
]
},
...
...
@@ -289,26 +279,6 @@ class Widget extends BaseWidget {
insertDesc
=
(
this
.
weatherIco
()
>=
1
&&
this
.
weatherIco
()
<=
10
)
?
`第
${
this
.
weatherIco
()}
套图标`
:
'
随机
'
;
break
case
'
covArea
'
:
const
_alertID
=
await
this
.
generateAlert
(
'
疫情地区
'
,
'
疫情数据对应的地区设置
\n
默认展示为广州
\n
其他地区请点击地区编码查询后填入
'
,
[
'
查看编码
'
,
'
填写编码
'
]
);
if
(
_alertID
===
0
)
{
await
Safari
.
openInApp
(
'
http://www.gov.cn/test/2011-08/22/content_1930111.htm
'
,
false
);
}
else
{
await
this
.
generateInputAlert
({
title
:
'
疫情地区
'
,
options
:
[{
hint
:
'
请输入地区编码
'
,
value
:
''
}]
},
async
(
inputArr
)
=>
{
const
area
=
inputArr
[
0
].
value
;
widgetSetting
.
covArea
=
area
;
insertDesc
=
area
;
});
}
break
;
case
'
quickStart
'
:
const
ufm
=
this
.
useFileManager
();
const
index
=
await
this
.
presentSheet
({
...
...
@@ -457,8 +427,8 @@ class Widget extends BaseWidget {
const
lunarInfo
=
await
this
.
getLunarInfo
()
// 请求彩云
const
weatherInfo
=
await
this
.
getWeather
();
//
请求新冠疫情数据
const
cov
=
await
this
.
getCov
();
//
节假日
const
holidayInfo
=
await
this
.
holidayInfo
();
// ========================================
stack
.
addSpacer
();
let
weatherStack
=
stack
.
addStack
();
...
...
@@ -498,13 +468,13 @@ class Widget extends BaseWidget {
textWidget
.
font
=
Font
.
regularSystemFont
(
this
.
scaleFontSize
(
Number
(
this
.
weatherFontSize
()),
text
.
length
,
50
));
textWidget
.
lineLimit
=
2
;
// ------------------------------------------------
text
=
`
${
cov
.
cityName
}
确诊:
${
cov
.
mainland_confirmed_incr
}
,无症状:
${
cov
.
asymptomatic_incr
}
`
;
text
=
holidayInfo
;
stack
.
addSpacer
(
6
);
textWidget
=
stack
.
addText
(
text
);
textWidget
.
url
=
'
https://so.toutiao.com/search?keyword=%E7%96%AB%E6%83%85%E5%AE%9E%E6%97%B6%E6%9C%80%E6%96%B0%E9%80%9A%E6%8A%A5
'
;
textWidget
.
textColor
=
new
Color
(
this
.
cov
FontColor
());
textWidget
.
url
=
'
calshow://
'
;
textWidget
.
textColor
=
new
Color
(
this
.
holiday
FontColor
());
textWidget
.
font
=
Font
.
regularSystemFont
(
this
.
scaleFontSize
(
Number
(
this
.
covFontSize
()),
text
.
length
,
15
));
textWidget
.
font
=
Font
.
regularSystemFont
(
Number
(
this
.
holidayFontSize
()
));
textWidget
.
lineLimit
=
1
;
// ------------------------------------------------
stack
.
addSpacer
();
...
...
@@ -513,26 +483,48 @@ class Widget extends BaseWidget {
// --------------------------NET START--------------------------
/**
*
获取头条疫情数据
* @returns
*
节假日信息
* @returns
节假日信息
*/
getCov
=
async
()
=>
{
const
areaCache
=
this
.
covArea
();
const
url
=
`https://i.snssdk.com/ncov/city_data/?recent_days=90&city_code=
${
areaCache
}
&only_history=0`
;
const
covJsonData
=
await
this
.
httpGet
(
url
);
const
cityData
=
covJsonData
.
city_data
;
const
currentData
=
cityData
.
current
;
const
cityName
=
cityData
.
name
;
const
dateStr
=
this
.
getDateStr
(
new
Date
(
currentData
.
update_time
*
1000
),
'
MM月dd HH:mm
'
);
// 确诊:mainland_confirmed_incr,无症状:asymptomatic_incr,现有:treating
const
{
mainland_confirmed_incr
,
asymptomatic_incr
,
treating
,
updateTimeStr
=
dateStr
}
=
currentData
;
return
{
cityName
,
mainland_confirmed_incr
:
mainland_confirmed_incr
===
'
待公布
'
?
'
--
'
:
mainland_confirmed_incr
,
asymptomatic_incr
:
asymptomatic_incr
===
'
待公布
'
?
'
--
'
:
asymptomatic_incr
,
treating
,
updateTimeStr
,
};
holidayInfo
=
async
()
=>
{
const
currDate
=
new
Date
();
let
url
=
'
https://api.apihubs.cn/holiday/get?field=date,workday,holiday_legal,holiday_today,holiday_recess,holiday,weekend&order_by=1&cn=1&size=31
'
;
let
holidayJsonData
=
await
this
.
httpGet
(
url
);
if
(
holidayJsonData
.
code
===
0
)
{
let
dateStr
=
this
.
getDateStr
(
currDate
,
'
yyyyMMdd
'
);
let
list
=
holidayJsonData
.
data
.
list
;
let
currItem
=
list
.
find
(
item
=>
item
.
date
==
dateStr
);
if
(
currItem
.
workday_cn
==
'
非工作日
'
)
{
return
'
`周末啦~~Have fun(๑•̀ㅂ•́)و✧
'
;
}
let
currIndex
=
list
.
indexOf
(
currItem
);
let
remainArr
=
list
.
slice
(
currIndex
,
list
.
size
);
let
notWorkday
=
remainArr
.
find
(
item
=>
item
.
workday_cn
==
'
非工作日
'
);
console
.
log
(
JSON
.
stringify
(
remainArr
));
// TODO
if
(
notWorkday
==
undefined
)
{
let
nexMonth
=
''
;
const
currMonth
=
currDate
.
getMonth
()
+
1
;
if
(
currMonth
==
12
)
{
nexMonth
=
`
${
currDate
.
getFullYear
()
+
1
}${
this
.
getDateStr
(
currDate
,
'
MM
'
)}
`
;
}
url
=
`https://api.apihubs.cn/holiday/get?field=date,workday,holiday_legal,holiday_today,holiday_recess,holiday,weekend&order_by=1&month=
${
nexMonth
}
&cn=1&size=31`
;
holidayJsonData
=
await
this
.
httpGet
(
url
);
notWorkday
=
remainArr
.
find
(
item
=>
item
.
workday_cn
==
'
非工作日
'
);
}
let
currDayFullYear
=
currItem
.
date_cn
.
replace
(
'
年
'
,
'
-
'
).
replace
(
'
月
'
,
'
-
'
).
replace
(
'
日
'
,
''
);
let
notWorkdayFullYear
=
notWorkday
.
date_cn
.
replace
(
'
年
'
,
'
-
'
).
replace
(
'
月
'
,
'
-
'
).
replace
(
'
日
'
,
''
);
let
remainDay
=
(
new
Date
(
notWorkdayFullYear
)
-
new
Date
(
currDayFullYear
))
/
86400
/
1000
;
let
holidayTips
=
notWorkday
.
holiday_cn
==
'
非节假日
'
?
notWorkday
.
weekend_cn
:
notWorkday
.
holiday_cn
+
'
假期
'
;
console
.
log
(
`还有
${
remainDay
}
天到
${
holidayTips
}
`
);
return
`还有
${
remainDay
}
天到
${
holidayTips
}
ヽ(;´Д`)ノ`
;
}
return
'
接口数据飞到外太空了ヽ(;´Д`)ノ
'
;
}
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录