mirror of
https://git.openapi.site/https://github.com/desirecore/market.git
synced 2026-12-05 23:39:28 +08:00
feat(ai-news-radar): 调和冲突并升级本地 MIT 包至 3c663dd (2026.12.01) (#418)
## 概述 / Summary 手工三方调和并升级 `ai-news-radar` 本地 MIT 派生包:`LearnPrompt/ai-news-radar` `689395109cc962a27c369bdd6fa50d1e090eb319`(`2026.11.24`)→ `3c663ddab7da78e62365e1ee0e58f34cc9cef09a`(`2026.12.01`,与 `9fda56e8c82aca27e2e0fecbbe383a231a89311f` 相比所有受跟踪代码/文档文件逐字节一致,仅 `data/*` 有新快照)。 ### 冲突调和与同步明细 1. **`assets/styles.css`**:合入上游新增的「今天值得做」卡片样式,并与上游逐字节对齐(消除此前仅 1 处末尾空行差异,避免后续 CSS 更新再次触发冲突)。 2. **`classic/index.html`**:合入上游新区块与静态资源版本号,继续保留适配 `<base href="../">` 的 `./assets/service-status.*` 路径修正。 3. **`README.md` / `references/upstream-project-readme*.md` / `docs/SOURCE_COVERAGE.md`**:根目录 `README.md` 保留本地安装说明;上游新 `README.md`、`README.en.md` 与 `docs/SOURCE_COVERAGE.md` 同步到对应引用位置,保留引用声明头与固定 commit 链接。 4. **同步其余受跟踪上游文件 & 补齐新引用资源**:同步 `scripts/update_news.py`、`index.html`、`assets/app.js`、`assets/service-status.js`、`assets/view-mode.js`、`classic/assets/app.js`、`classic/assets/styles.css`;补齐新版 `index.html` 引用的 `assets/i18n.js`、`assets/i18n/zh.js`、`assets/i18n/en.js`(避免断链)。继续排除 `#350` 明确不安装的 `data/`、测试与上游工作流。 5. **元数据与映射同步**:同步更新 `config/verified-updates.v1.json`、`skills/ai-news-radar/UPSTREAM.md`、`skills/ai-news-radar/catalog-metadata.v1.json`。 ## 验证 / Validation - `python3 -B skills/ai-news-radar/scripts/update_news.py --help` - `uv run --offline --quiet --with pytest --with pyyaml --with jsonschema python -m pytest scripts/catalog/test_tracked_updates.py -q` - `uv run --offline --quiet scripts/catalog/validate_catalog_metadata.py --require-complete` - `uv run --offline --quiet scripts/i18n/validate-i18n.py` - `uv run --offline --quiet scripts/i18n/translate.py --check` - `git diff --check` 合并后可关闭仅记录阻断状态的旧草稿 [#399](https://github.com/desirecore/market/pull/399)。
This commit is contained in:
1 parent
be8d8307af
commit
0e9ae3b4a1
20 files changed
+1918
-291
No files matched your search
@@ -118,6 +118,8 @@ const SOURCE_KINDS = {
|
||||
aihot: { label: "AI HOT", tone: "hot" },
|
||||
aibreakfast: { label: "日报", tone: "newsletter" },
|
||||
followbuilders: { label: "Builders/X", tone: "builders" },
|
||||
github_trending: { label: "GitHub Trending", tone: "builders" },
|
||||
producthunt: { label: "Product Hunt", tone: "aihub" },
|
||||
xapi: { label: "X API", tone: "builders" },
|
||||
socialdata_x: { label: "X 搜索", tone: "builders" },
|
||||
tikhub_douyin: { label: "抖音", tone: "creator" },
|
||||
@@ -210,6 +212,100 @@ function isUnsafeStory(story) {
|
||||
return refs.some((ref) => isUnsafeContent(ref));
|
||||
}
|
||||
|
||||
// Today's projects are optional and load independently from the news timeline.
|
||||
const todayProjectsListEl = document.getElementById("todayProjectsList");
|
||||
const todayProjectsMetaEl = document.getElementById("todayProjectsMeta");
|
||||
|
||||
function todayProjectsDate(now = new Date()) {
|
||||
const parts = new Intl.DateTimeFormat("en-US", {
|
||||
timeZone: "Asia/Taipei", year: "numeric", month: "2-digit", day: "2-digit",
|
||||
}).formatToParts(now);
|
||||
const value = (type) => parts.find((part) => part.type === type).value;
|
||||
return `${value("year")}-${value("month")}-${value("day")}`;
|
||||
}
|
||||
|
||||
function todayProjectUrl(value) {
|
||||
if (typeof value !== "string") return "";
|
||||
try {
|
||||
const url = new URL(value);
|
||||
return ["http:", "https:"].includes(url.protocol) ? url.href : "";
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
function renderTodayProjects(payload, failed = false) {
|
||||
if (!todayProjectsListEl || !todayProjectsMetaEl) return;
|
||||
todayProjectsListEl.replaceChildren();
|
||||
todayProjectsMetaEl.textContent = "";
|
||||
const current = payload?.date === todayProjectsDate();
|
||||
const items = current && Array.isArray(payload?.items) ? payload.items : [];
|
||||
// Project names and recommendations need the same last-mile safety gate as news.
|
||||
const visible = safeItems(items.filter((item) => item && typeof item === "object").map((item) => ({
|
||||
...item, title: item.project_name, title_zh: item.recommend_reason_zh, title_original: item.summary,
|
||||
}))).filter((item) => typeof item.project_name === "string" && item.project_name.trim()
|
||||
&& typeof item.recommend_reason_zh === "string" && item.recommend_reason_zh.trim()
|
||||
&& todayProjectUrl(item.url)).slice(0, 4);
|
||||
if (!visible.length) {
|
||||
const empty = document.createElement("p");
|
||||
empty.className = "today-projects-empty";
|
||||
const sourcesFailed = Array.isArray(payload?.sources) && payload.sources.length > 0
|
||||
&& payload.sources.every((source) => source?.ok === false);
|
||||
empty.textContent = failed || sourcesFailed ? "项目数据暂时加载失败,请稍后再试。"
|
||||
: payload && !current ? "今天的项目推荐更新中。" : "今天暂无合适的项目推荐。";
|
||||
todayProjectsListEl.appendChild(empty);
|
||||
return;
|
||||
}
|
||||
todayProjectsMetaEl.textContent = `${visible.length} 个项目`;
|
||||
visible.forEach((item) => {
|
||||
const card = document.createElement("article");
|
||||
card.className = "today-project-card";
|
||||
const heading = document.createElement("div");
|
||||
heading.className = "today-project-heading";
|
||||
const name = document.createElement("h3");
|
||||
name.textContent = item.project_name.trim();
|
||||
const source = document.createElement("span");
|
||||
source.className = "today-project-source";
|
||||
source.textContent = (item.site_name || "项目来源")
|
||||
+ (item.site_id === "producthunt" && item.recency_basis === "updated_at" ? " · 近期更新" : "");
|
||||
heading.append(name, source);
|
||||
const recommendation = document.createElement("p");
|
||||
recommendation.className = "today-project-reason";
|
||||
recommendation.textContent = item.recommend_reason_zh.trim();
|
||||
const link = document.createElement("a");
|
||||
link.className = "today-project-link";
|
||||
link.href = todayProjectUrl(item.url);
|
||||
link.target = "_blank";
|
||||
link.rel = "noopener noreferrer";
|
||||
link.textContent = "打开项目 ↗";
|
||||
link.setAttribute("aria-label", `打开项目:${item.project_name.trim()}`);
|
||||
card.append(heading, recommendation, link);
|
||||
todayProjectsListEl.appendChild(card);
|
||||
});
|
||||
}
|
||||
|
||||
async function initTodayProjects() {
|
||||
if (!todayProjectsListEl) return;
|
||||
const controller = new AbortController();
|
||||
const timeout = setTimeout(() => controller.abort(), 12000);
|
||||
try {
|
||||
const res = await fetch(`${dataUrl("data/today-projects.json")}?t=${Date.now()}`, {
|
||||
signal: controller.signal,
|
||||
});
|
||||
if (!res.ok) throw new Error(`加载 today-projects.json 失败: ${res.status}`);
|
||||
const payload = await res.json();
|
||||
if (!payload || typeof payload.date !== "string" || !Array.isArray(payload.items)) {
|
||||
throw new Error("项目数据格式错误");
|
||||
}
|
||||
renderTodayProjects(payload);
|
||||
} catch {
|
||||
renderTodayProjects(null, true);
|
||||
} finally {
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
}
|
||||
// End of today's projects module.
|
||||
|
||||
function fmtTime(iso) {
|
||||
if (!iso) return "时间未知";
|
||||
const d = new Date(iso);
|
||||
@@ -1056,6 +1152,7 @@ function reasonText(item) {
|
||||
}
|
||||
|
||||
function timelineIso(item) {
|
||||
if (item.site_id === "producthunt" && item.recency_basis === "updated_at") return item.updated_at || "";
|
||||
const published = item.published_at || "";
|
||||
const seen = item.first_seen_at || "";
|
||||
const generated = state.generatedAt || "";
|
||||
@@ -1069,6 +1166,11 @@ function timelineIso(item) {
|
||||
return published || seen;
|
||||
}
|
||||
|
||||
function itemTimeText(item, fallback = "") {
|
||||
return (item.site_id === "producthunt" && item.recency_basis === "updated_at" ? "更新于 " : "")
|
||||
+ fmtTime(timelineIso(item) || fallback);
|
||||
}
|
||||
|
||||
function timelineMs(item) {
|
||||
const d = new Date(timelineIso(item));
|
||||
return Number.isNaN(d.getTime()) ? 0 : d.getTime();
|
||||
@@ -1332,7 +1434,7 @@ function buildBoleLead(row) {
|
||||
top.className = "bole-lead-top";
|
||||
const kicker = document.createElement("span");
|
||||
kicker.className = "bole-kicker";
|
||||
kicker.textContent = `${labelText(item)} · ${fmtTime(timelineIso(item))}`;
|
||||
kicker.textContent = `${labelText(item)} · ${itemTimeText(item)}`;
|
||||
const scoreEl = document.createElement("strong");
|
||||
scoreEl.className = `bole-score-orb ${scoreTone(score)}`;
|
||||
scoreEl.innerHTML = `<span>${score}</span><small>分</small>`;
|
||||
@@ -1364,7 +1466,7 @@ function buildBoleTimelineRow(row, rank) {
|
||||
|
||||
const time = document.createElement("time");
|
||||
time.className = "bole-row-time";
|
||||
time.textContent = fmtTime(timelineIso(item));
|
||||
time.textContent = itemTimeText(item);
|
||||
|
||||
const body = document.createElement("div");
|
||||
body.className = "bole-row-body";
|
||||
@@ -2081,7 +2183,7 @@ function buildTopStoryCard(row, rank) {
|
||||
// it on primary_item. Fall back to that aggregate time so Top 3 never shows
|
||||
// "时间未知" when the story itself has a verified latest/earliest timestamp.
|
||||
const storyTimeline = row.story?.latest_at || row.story?.earliest_at || "";
|
||||
time.textContent = fmtTime(timelineIso(item) || storyTimeline);
|
||||
time.textContent = itemTimeText(item, storyTimeline);
|
||||
const primarySource = itemSourceRefs(item, row)[0];
|
||||
const score = document.createElement("strong");
|
||||
const displayScore = row.story
|
||||
@@ -2142,7 +2244,7 @@ function buildIntelCard(item, rank) {
|
||||
rankEl.className = "intel-card-rank";
|
||||
rankEl.textContent = `#${rank}`;
|
||||
const time = document.createElement("time");
|
||||
time.textContent = fmtTime(timelineIso(item));
|
||||
time.textContent = itemTimeText(item);
|
||||
const score = scorePercent(item);
|
||||
const scoreEl = document.createElement("strong");
|
||||
scoreEl.className = `intel-score ${scoreTone(score)}`;
|
||||
@@ -2224,7 +2326,7 @@ function renderItemNode(item, context = {}) {
|
||||
metaRow.insertBefore(itemTagChip(label), sourceEl);
|
||||
});
|
||||
|
||||
node.querySelector(".time").textContent = fmtTime(item.published_at || item.first_seen_at);
|
||||
node.querySelector(".time").textContent = itemTimeText(item);
|
||||
|
||||
const titleEl = node.querySelector(".title");
|
||||
const zh = (item.title_zh || "").trim();
|
||||
@@ -3131,4 +3233,5 @@ function renderDataSourceIndicator() {
|
||||
}
|
||||
|
||||
renderDataSourceIndicator();
|
||||
initTodayProjects();
|
||||
init();
|
||||
@@ -2782,3 +2782,92 @@ summary:focus-visible {
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* Compact project recommendations, shared by the mobile and classic views. */
|
||||
.today-projects-list {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
padding: 16px 18px;
|
||||
}
|
||||
|
||||
#todayProjectsMeta {
|
||||
color: var(--muted);
|
||||
font-size: 13px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.today-project-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
min-width: 0;
|
||||
padding: 16px;
|
||||
border: 1px solid var(--line-soft);
|
||||
border-radius: var(--radius);
|
||||
background: var(--surface-soft);
|
||||
}
|
||||
|
||||
.today-project-heading {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: baseline;
|
||||
gap: 6px 10px;
|
||||
}
|
||||
|
||||
.today-project-heading h3 {
|
||||
margin: 0;
|
||||
font-size: 16px;
|
||||
line-height: 1.45;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.today-project-source {
|
||||
color: var(--muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.today-project-reason {
|
||||
margin: 0;
|
||||
color: var(--ink-soft);
|
||||
font-size: 14px;
|
||||
line-height: 1.65;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.today-project-link {
|
||||
align-self: flex-start;
|
||||
margin-top: auto;
|
||||
color: var(--accent);
|
||||
font-size: 13px;
|
||||
font-weight: 650;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.today-project-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.today-project-link:focus-visible {
|
||||
outline: 2px solid var(--accent);
|
||||
outline-offset: 4px;
|
||||
}
|
||||
|
||||
.today-projects-empty {
|
||||
grid-column: 1 / -1;
|
||||
margin: 0;
|
||||
color: var(--muted);
|
||||
font-size: 14px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.today-projects-list {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.today-project-card {
|
||||
padding: 14px;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user