Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions script_library/index.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"format_version": 1,
"data_version": 30,
"updated": "2026-03-27T10:08:56Z",
"data_version": 31,
"updated": "2026-03-27T15:15:38.324Z",
"announcement": null,
"categories": [
{
Expand Down Expand Up @@ -775,6 +775,29 @@
"updated": null,
"status": "active",
"lines": 98
},
{
"id": "script_mn91mn1t",
"name": "每日一词",
"name_en": "每日一词",
"desc": "每日一词",
"desc_en": "每日一词",
"category": "widgets",
"file": "scripts/widgets/script_mn91mn1t.py",
"thumbnail": null,
"version": 1,
"file_type": "py",
"author": "一只菜鸡",
"author_en": "一只菜鸡",
"tags": [
"community"
],
"requires": [],
"min_app_version": "1.5.0",
"added": "2026-03-27",
"updated": null,
"status": "active",
"lines": 113
}
]
}
113 changes: 113 additions & 0 deletions script_library/scripts/widgets/script_mn91mn1t.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
from widget import Widget, family, SMALL, MEDIUM, LARGE
import datetime
import ujson
import ssl

# 从网络获取古诗词名句
def get_quote():
try:
import urllib.request

ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE

opener = urllib.request.build_opener(
urllib.request.HTTPSHandler(context=ctx)
)

req = urllib.request.Request(
'https://v1.jinrishici.com/all.json',
headers={
'Accept': 'application/json',
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS like Mac OS X) AppleWebKit/605.1.15'
}
)

response = opener.open(req, timeout=10)

if response.status == 200:
raw_data = response.read()
data = ujson.loads(raw_data)
content = data['content']
origin = data['origin']
author = data['author']
category = data['category']
return content, f"「{origin}」{author}", category
except Exception as e:
print(f"获取诗词失败: {e}")

return None, None, None

quote, author, category = get_quote()

# 配色方案
bg = ("#F8FAFC", "#0F172A")
card_bg = ("#F1F5F9", "#1E293B")
primary = ("#0F172A", "#F8FAFC")
secondary = ("#475569", "#94A3B8")
weak = ("#94A3B8", "#64748B")
accent = ("#8B5CF6", "#A78BFA")

w = Widget(background=bg, padding=14)

if family == SMALL:
with w.vstack(spacing=0, align="center"):
w.spacer()
w.icon("pencil.and.outline", size=20, color=accent)
w.spacer(6)
w.text(quote if quote else "加载中...", size=15, weight="medium", color=primary,
max_lines=3, align="center")
w.spacer(4)
w.text(author if author else "", size=11, color=secondary, align="center")
w.spacer()

elif family == MEDIUM:
with w.vstack(spacing=0):
w.spacer()
with w.hstack(spacing=0):
with w.vstack(spacing=0, align="center"):
w.spacer()
w.icon("pencil.and.outline", size=28, color=accent)
w.spacer(6)
w.text("古诗词", size=11, color=weak)
w.spacer()
w.spacer(12)
with w.vstack(spacing=4, align="leading"):
w.spacer()
w.text(quote if quote else "网络不可用", size=16, weight="medium", color=primary,
max_lines=3)
w.text(author if author else "", size=12, color=secondary)
w.spacer()
w.spacer(8)
w.text(category if category else "", size=11, color=weak, align="trailing")
w.spacer()

else:
with w.vstack(spacing=0):
w.spacer()
with w.hstack(spacing=8):
w.icon("pencil.and.outline", size=22, color=accent)
w.text("每日诗词", size=18, weight="semibold",
color=("#334155", "#E2E8F0"))
w.spacer()
w.text(datetime.datetime.now().strftime("%Y/%m/%d"), size=13, color=weak)
w.spacer(16)

with w.card(background=card_bg, corner_radius=12, padding=16, spacing=0):
w.text(quote if quote else "无法获取诗词,请检查网络连接", size=20, weight="medium", color=primary,
max_lines=4)
w.spacer(10)
w.text(author if author else "", size=14, color=secondary)

w.spacer()

with w.hstack(spacing=0):
w.icon("leaf.fill", size=12, color="#10B981")
w.spacer(6)
w.text(category if category else "诗意的栖居", size=12, color=weak)
w.spacer()

w.spacer()

w.render()
Loading