Skip to content

Commit 6ba9abe

Browse files
Merge pull request #40 from jinwandalaohu66/submission/2_0_mn37c7pr
2 parents 4a57d0c + b8e70bf commit 6ba9abe

2 files changed

Lines changed: 125 additions & 2 deletions

File tree

script_library/index.json

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"format_version": 1,
3-
"data_version": 17,
4-
"updated": "2026-03-22T19:54:07.067Z",
3+
"data_version": 18,
4+
"updated": "2026-03-23T13:08:52.777Z",
55
"announcement": null,
66
"categories": [
77
{
@@ -587,6 +587,29 @@
587587
"updated": null,
588588
"status": "active",
589589
"lines": 971
590+
},
591+
{
592+
"id": "2_0_mn37c7pr",
593+
"name": "联通小组件2.0",
594+
"name_en": "联通小组件2.0",
595+
"desc": "联通流量小组件显示,无需每次打开软件进行刷新,它会自己后台悄悄的更新哦,根据需要填写的脚本里有提示,注意查看。",
596+
"desc_en": "联通流量小组件显示,无需每次打开软件进行刷新,它会自己后台悄悄的更新哦,根据需要填写的脚本里有提示,注意查看。",
597+
"category": "widgets",
598+
"file": "scripts/widgets/2_0_mn37c7pr.py",
599+
"thumbnail": null,
600+
"version": 1,
601+
"file_type": "py",
602+
"author": "Silence",
603+
"author_en": "Silence",
604+
"tags": [
605+
"community"
606+
],
607+
"requires": [],
608+
"min_app_version": "1.5.0",
609+
"added": "2026-03-23",
610+
"updated": null,
611+
"status": "active",
612+
"lines": 100
590613
}
591614
]
592615
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# 2026-3-23 by.Silence 测试设备16.2 14pm
2+
import requests
3+
from widget import Widget, family
4+
from widget import SMALL, MEDIUM, LARGE, CIRCULAR, RECTANGULAR
5+
from datetime import datetime
6+
7+
8+
def get_unicom_data():
9+
url = '自行填写'
10+
headers = {
11+
'Host': 'm.client.10010.com',
12+
'User-Agent': '自行填写',
13+
'Cookie': '自行填写'
14+
}
15+
try:
16+
res = requests.get(url, headers=headers, timeout=5)
17+
if res.status_code == 200:
18+
data = res.json()
19+
flow = data.get('flowResource', {}).get('flowPersent', '0')
20+
fee = data.get('feeResource', {}).get('feePersent', '0')
21+
voice = data.get('voiceResource', {}).get('voicePersent', '0')
22+
t = data.get("flush_date_time", "").split(" ")[-1] if " " in data.get("flush_date_time", "") else "刚刚"
23+
return True, flow, fee, voice, t
24+
except:
25+
pass
26+
return False, "0", "0", "0", "--"
27+
28+
29+
def get_date_tip():
30+
now = datetime.now()
31+
week_list = ["周一", "周二", "周三", "周四", "周五", "周六", "周日"]
32+
week_day = week_list[now.weekday()]
33+
month_day = now.strftime("%m月%d日")
34+
35+
year_start = datetime(now.year, 1, 1)
36+
year_end = datetime(now.year+1, 1, 1)
37+
year_pass = (now - year_start).total_seconds()
38+
year_total = (year_end - year_start).total_seconds()
39+
year_percent = int((year_pass / year_total) * 100)
40+
return f"{week_day} {month_day} · 今年已过{year_percent}%"
41+
42+
43+
success, flow, fee, voice, update_time = get_unicom_data()
44+
date_tip = get_date_tip()
45+
46+
w = Widget(
47+
background=("#FFFFFF", "#0B0F1A"),
48+
padding=16
49+
)
50+
51+
if family == MEDIUM:
52+
with w.hstack(spacing=0):
53+
54+
55+
with w.vstack(align="leading", spacing=0):
56+
with w.hstack(spacing=6, align="center"):
57+
w.icon("antenna.radiowaves.left.and.right", size=16, color="#E63946")
58+
w.text("中国联通", size=14, weight="bold", color=("#111", "#EEE"), max_lines=1)
59+
60+
w.spacer(14)
61+
w.text("剩余通用流量", size=12, color=("#64748B", "#94A3B8"), max_lines=1)
62+
w.spacer(4)
63+
64+
with w.hstack(spacing=4, align="bottom"):
65+
w.text(flow, size=36, weight="bold", design="rounded", color=("#000", "#FFF"), max_lines=1)
66+
w.text("GB", size=14, weight="bold", color="#E63946", max_lines=1)
67+
68+
69+
w.spacer(8)
70+
w.text(date_tip, size=11, color=("#94A3B8", "#64748B"), max_lines=1)
71+
72+
w.spacer()
73+
74+
75+
with w.vstack(align="leading", spacing=10):
76+
w.spacer(6)
77+
78+
with w.hstack(spacing=8, align="center"):
79+
w.icon("yensign.circle.fill", size=14, color="#F59E0B")
80+
w.text(f"{fee} 元", size=11, weight="semibold", color="#F59E0B", max_lines=1)
81+
82+
with w.hstack(spacing=8, align="center"):
83+
w.icon("phone.fill", size=14, color="#10B981")
84+
w.text(f"{voice} 分钟", size=11, weight="semibold", color="#10B981", max_lines=1)
85+
86+
with w.hstack(spacing=8, align="center"):
87+
w.icon("clock", size=14, color=("#94A3B8", "#64748B"))
88+
w.text(update_time, size=11, color=("#94A3B8", "#64748B"), max_lines=1)
89+
90+
91+
if not success:
92+
w = Widget(background=("#FFFFFF", "#0B0F1A"), padding=16)
93+
with w.vstack(align="center", spacing=8):
94+
w.spacer()
95+
w.icon("wifi.exclamationmark", size=30, color=("#64748B", "#94A3B8"))
96+
w.text("数据获取失败", size=14, weight="semibold", color=("#111", "#EEE"), max_lines=1)
97+
w.text("请更新Cookie", size=12, color=("#64748B", "#94A3B8"), max_lines=1)
98+
w.spacer()
99+
100+
w.render(url="pythonide://")

0 commit comments

Comments
 (0)