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
8 changes: 4 additions & 4 deletions .github/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## MPider v2.0.2
## MPider v2.0.3

- 修复下载失败文章阻断批量导出的问题。
- 新增标题与下载状态筛选,支持跨页全选。
- 其他体验改进和问题修复。
- 新增扫码加入交流群入口,方便交流与反馈。
- 新增可关闭的滑入广告,关闭后 1 小时再次展示。
- 其他体验改进。

提供 Windows x64 安装版与便携版。
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

本页记录面向使用者的功能与已知限制。开发完成、实机验证和正式发布分别说明,发行状态以 [GitHub Releases](https://github.com/areyoubugcoder/mpider/releases) 为准。

## v2.0.3

- 新增扫码加入交流群入口,方便交流与反馈。
- 新增可关闭的滑入广告,关闭后 1 小时再次展示。
- 其他体验改进。

## v2.0.2

- 修复下载失败文章阻断批量导出的问题。
Expand Down
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ members = ["crates/article-md", "crates/core", "src-tauri"]

[workspace.package]
edition = "2021"
version = "2.0.2"
version = "2.0.3"
license = "MIT"
repository = "https://github.com/areyoubugcoder/mpider"

Expand Down
8 changes: 5 additions & 3 deletions docs/advertisements.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 底部广告位
# 广告展示

广告内容维护在 [`config/advertisements.json`](../config/advertisements.json)。发布到 GitHub 的 `main` 后,已安装应用会在启动时及每 30 分钟读取该文件的公开 Raw 地址,无需重新打包。

Expand All @@ -25,7 +25,7 @@

所有字段必填。配置总大小最多 32 KiB,`version` 固定为 `1`,轮播间隔为 5~60 秒的整数。最多 12 条广告,按文件顺序播放;`id` 唯一、最多 64 字符,完整文案最多 160 字符,`compact_title` 为旧版窄窗口保留兼容、最多 80 字符,链接最多 2048 字符且必须为不带用户名和密码的 HTTPS 链接。

修改 `title`、`url` 即可更换文案和目标地址;增加或移除 `items` 条目即可调整广告数量。单条 `enabled: false` 暂停该条广告;顶层 `enabled: false`、空列表或所有条目停投时隐藏广告位,其余状态栏保留。反馈入口独立放在左侧菜单。
修改 `title`、`url` 即可更换文案和目标地址;增加或移除 `items` 条目即可调整广告数量。单条 `enabled: false` 暂停该条广告;顶层 `enabled: false`、空列表或所有条目停投时隐藏广告位,其余状态栏保留。“加入交流群”入口独立放在左侧菜单,点击展示 QQ 入群二维码。

配置只支持纯文字和链接,不支持 HTML、脚本或远程图片。任意条目不合规时整份远程配置不予采用,保留之前有效内容。

Expand All @@ -35,8 +35,10 @@
- 多条广告按配置间隔向上循环,过渡为 650 毫秒;单条静态显示。广告动画独立于 Windows/RDP 的减少动态效果设置,不修改系统动画偏好。配置更新后从第一条开始。
- 长广告在固定宽度内以省略号展示,不做横向滚动。悬停或键盘聚焦时暂停轮播,通过浮层显示当前完整文案和目标地址,浮层本身不新增网络请求。
- 不显示“推荐”标签、图标、暂停或上一条/下一条按钮。没有有效广告时隐藏整个广告位,不增加空白广告行。
- 主窗口另外提供右下角滑入卡片,与底栏共用广告配置和请求缓存。卡片按配置间隔轮播,悬停或键盘聚焦时暂停;不会自动抢占焦点,点击“了解更多”才打开目标网站。
- 关闭卡片后冷却 1 小时,到期重新滑入。关闭时间保存在本机,切换页面、更新广告内容或重启应用均不重置冷却;休眠恢复后按实际经过时间判断。关闭卡片不影响底栏轮播,停投配置同时隐藏两种广告展示。
- 读取超时为 5 秒。HTTP 错误、JSON 损坏、格式不合规或网络不可达均回退,不弹错误、不阻塞工作台。
- 最近有效配置在本机缓存 7 天;缓存损坏、过期、来自未来或存储不可用时使用内置内容。缓存仅包含广告配置及保存时间。
- 最近有效配置在本机缓存 7 天;缓存损坏、过期、来自未来或存储不可用时使用内置内容。广告配置缓存仅包含配置及保存时间;滑入卡片的关闭时间单独保存。存储不可写时,卡片冷却仍在本次运行中生效。
- 应用启动及每 30 分钟会向 GitHub 发送公开配置请求,不携带 Cookie、页面来源、账号、日志或会话材料。GitHub 仍会收到访问 IP 等常规网络信息;没有广告曝光统计或点击上报。只有点击广告才打开目标网站。

## 本地验证
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { toast } from "sonner";
import { DownloadQueueBar } from "@/components/DownloadQueueBar";
import { ExportQueueBar } from "@/components/ExportQueueBar";
import { ProjectLinks } from "@/components/ProjectLinks";
import { AdvertisementCard } from "@/components/AdvertisementCard";
import { UpdateProvider, UpdateIndicator } from "@/components/AppUpdater";
import { AboutDialog } from "@/components/AboutDialog";
import { version as bundledVersion } from "../../package.json";
Expand Down Expand Up @@ -39,6 +40,7 @@ export function App() {
const push = useQuery({ queryKey: ["push-monitor"], queryFn: pushStatus, refetchInterval: 2000 });
return <UpdateProvider><div className="flex h-screen flex-col overflow-hidden bg-background text-foreground">
<div className="flex min-h-0 flex-1"><Sidebar onAbout={() => setAboutOpen(true)} showLaboratory={showLaboratory} view={view} onNav={next => { if (next === "logs") setLogExperiment(null); if (next === "articles") setArticleSource(""); setView(next); }} />
<div className="relative flex min-h-0 min-w-0 flex-1 flex-col">
<main className="min-h-0 min-w-0 flex-1 overflow-y-auto px-6 py-5">
{snapshot.error && <p role="alert" className="mb-4 rounded-lg border border-destructive p-3 text-sm">无法读取持久化工作台:{String(snapshot.error)}。请检查数据库和后台日志。</p>}
{!!snapshot.data && snapshot.data.policy.cooldown_until > Date.now() / 1000 && <p role="status" className="mb-4 rounded-lg border p-3 text-sm text-warning">全局冷却至 {new Date(snapshot.data.policy.cooldown_until * 1000).toLocaleString()},列表、文章下载和图片请求等待;推送解析遵从文章间隔及预算。</p>}
Expand All @@ -53,6 +55,8 @@ export function App() {
{view === "logs" && <SystemLogs initialExperimentId={logExperiment} />}
{view === "faq" && <Faq onNav={setView} />}
</main>
<AdvertisementCard />
</div>
</div>
<footer className="flex h-10 shrink-0 items-center gap-3 border-t px-3 text-xs text-muted-foreground">
<ProjectLinks />
Expand Down
Binary file added frontend/src/assets/feedback-group-qr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 71 additions & 0 deletions frontend/src/components/AdvertisementCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { useEffect, useState } from "react";
import { ArrowUpRight, X } from "lucide-react";
import { ExternalLink } from "@/components/ExternalLink";
import { advertisementStorage, useAdvertisements } from "@/lib/use-advertisements";
import { ADVERTISEMENT_DISMISSAL_KEY, advertisementCooldownRemaining, readAdvertisementDismissal, saveAdvertisementDismissal } from "@/lib/advertisement-dismissal";
import type { AdvertisementConfig } from "@/lib/advertisements";

function CardContent({ config, onClose }: { config: AdvertisementConfig; onClose: () => void }) {
const items = config.items.filter(item => item.enabled);
const [index, setIndex] = useState(0);
const [hovered, setHovered] = useState(false);
const [focused, setFocused] = useState(false);
const current = items[index % items.length];
useEffect(() => {
if (items.length < 2 || hovered || focused) return;
const timer = setInterval(() => setIndex(value => (value + 1) % items.length), config.interval_seconds * 1000);
return () => clearInterval(timer);
}, [items.length, config.interval_seconds, hovered, focused]);
if (!current) return null;
return <aside aria-label="产品推荐" className="pointer-events-auto w-80 max-w-full rounded-xl border bg-background p-5 shadow-lg animate-in slide-in-from-right-full duration-500"
onMouseEnter={() => setHovered(true)} onMouseLeave={() => setHovered(false)}
onFocusCapture={() => setFocused(true)} onBlurCapture={event => { if (!event.currentTarget.contains(event.relatedTarget as Node | null)) setFocused(false); }}>
<div className="mb-3 flex items-center justify-between gap-3">
<span className="text-xs text-muted-foreground">产品推荐 · 广告</span>
<button type="button" aria-label="关闭广告,1 小时后再次展示" title="关闭,1 小时后再次展示" onClick={onClose}
className="-mr-2 -mt-2 flex size-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
<X className="size-4" aria-hidden="true" />
</button>
</div>
<p className="break-words text-sm font-semibold leading-relaxed">{current.compact_title}</p>
<p className="mt-2 break-words text-sm leading-relaxed text-muted-foreground">{current.title}</p>
<ExternalLink href={current.url} className="mt-4 inline-flex items-center gap-1 text-sm font-medium">了解更多<ArrowUpRight className="size-4" aria-hidden="true" /></ExternalLink>
</aside>;
}

export function AdvertisementCard() {
const config = useAdvertisements();
const [dismissedAt, setDismissedAt] = useState(() => readAdvertisementDismissal(advertisementStorage()));
const [coolingDown, setCoolingDown] = useState(() => advertisementCooldownRemaining(dismissedAt) > 0);
useEffect(() => {
let timer: ReturnType<typeof setTimeout> | undefined;
const check = () => {
clearTimeout(timer);
const remaining = advertisementCooldownRemaining(dismissedAt);
setCoolingDown(remaining > 0);
if (remaining > 0) timer = setTimeout(check, remaining);
};
check();
window.addEventListener("focus", check);
document.addEventListener("visibilitychange", check);
return () => { clearTimeout(timer); window.removeEventListener("focus", check); document.removeEventListener("visibilitychange", check); };
}, [dismissedAt]);
useEffect(() => {
const sync = (event: StorageEvent) => {
if (event.key === ADVERTISEMENT_DISMISSAL_KEY || event.key === null) {
const timestamp = readAdvertisementDismissal(advertisementStorage());
setDismissedAt(timestamp);
setCoolingDown(advertisementCooldownRemaining(timestamp) > 0);
}
};
window.addEventListener("storage", sync);
return () => window.removeEventListener("storage", sync);
}, []);
if (coolingDown || !config.enabled || !config.items.some(item => item.enabled)) return null;
return <div className="pointer-events-none absolute inset-0 z-30 flex items-end justify-end overflow-hidden p-4">
<CardContent key={JSON.stringify(config)} config={config} onClose={() => {
setCoolingDown(true);
setDismissedAt(saveAdvertisementDismissal(advertisementStorage()));
}} />
</div>;
}
21 changes: 3 additions & 18 deletions frontend/src/components/ProjectLinks.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
/** 单行底栏左侧广告位:独立向上轮播,长文省略,悬停或聚焦浮层展示全文。 */
import { useEffect, useId, useRef, useState } from "react";
import { useQuery } from "@tanstack/react-query";
import bundledConfig from "../../../config/advertisements.json";
import { ExternalLink } from "@/components/ExternalLink";
import { Popover, PopoverAnchor, PopoverContent } from "@/components/ui/popover";
import { ADVERTISEMENTS_REFRESH_MS, loadAdvertisementConfig, readAdvertisementCache, type AdvertisementConfig } from "@/lib/advertisements";
import type { AdvertisementConfig } from "@/lib/advertisements";
import { useAdvertisements } from "@/lib/use-advertisements";

const TRANSITION_MS = 650;
function localStorageIfAvailable() {
try { return window.localStorage; } catch { return undefined; }
}

function AdvertisementSlot({ config }: { config: AdvertisementConfig }) {
const promotions = config.items.filter(item => item.enabled);
Expand Down Expand Up @@ -79,18 +75,7 @@ function AdvertisementSlot({ config }: { config: AdvertisementConfig }) {
}

export function ProjectLinks() {
const config = useQuery({
queryKey: ["advertisements"],
queryFn: () => loadAdvertisementConfig({ fallback: bundledConfig as AdvertisementConfig, storage: localStorageIfAvailable(),
url: import.meta.env.DEV ? import.meta.env.VITE_ADVERTISEMENTS_URL : undefined }),
initialData: () => readAdvertisementCache(localStorageIfAvailable()) || bundledConfig as AdvertisementConfig,
initialDataUpdatedAt: 0,
staleTime: ADVERTISEMENTS_REFRESH_MS,
refetchInterval: ADVERTISEMENTS_REFRESH_MS,
refetchIntervalInBackground: true,
refetchOnWindowFocus: false,
retry: false,
}).data;
const config = useAdvertisements();
if (!config.enabled || !config.items.some(item => item.enabled)) return null;
return <nav aria-label="产品广告" className="w-[clamp(11rem,26vw,23rem)] min-w-0 shrink-0 text-xs">
<AdvertisementSlot key={JSON.stringify(config)} config={config} />
Expand Down
21 changes: 16 additions & 5 deletions frontend/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import {
import { cn } from "@/lib/utils";
import type { View } from "@/views/types";
import appIcon from "@/assets/app-icon.png";
import { ExternalLink } from "@/components/ExternalLink";
import { PROJECT_LINKS } from "@/lib/project-links";
import feedbackQr from "@/assets/feedback-group-qr.png";
import { Dialog, DialogTrigger, DialogContent, DialogHeader, DialogTitle, DialogDescription } from "@/components/ui/dialog";

interface NavItem {
key: View;
Expand Down Expand Up @@ -98,9 +98,20 @@ export function Sidebar({
))}
</nav>
<div className="mx-3 mb-3 flex flex-col gap-0.5">
<ExternalLink href={PROJECT_LINKS.issues} title="在 GitHub 创建 Issue(不会自动上传日志)" className="flex items-center gap-2.5 rounded-lg px-2.5 py-2 text-left text-sm text-sidebar-foreground hover:bg-sidebar-accent/50 hover:no-underline focus-visible:ring-sidebar-ring">
<MessageSquarePlus className="size-4 shrink-0 opacity-80" aria-hidden="true" /><span>反馈问题</span>
</ExternalLink>
<Dialog>
<DialogTrigger asChild>
<button type="button" className="flex items-center gap-2.5 rounded-lg px-2.5 py-2 text-left text-sm hover:bg-sidebar-accent/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sidebar-ring">
<MessageSquarePlus className="size-4 shrink-0 opacity-80" aria-hidden="true" /><span>加入交流群</span>
</button>
</DialogTrigger>
<DialogContent className="max-h-[calc(100vh-2rem)] max-w-sm overflow-y-auto">
<DialogHeader>
<DialogTitle>加入 MPider 交流群</DialogTitle>
<DialogDescription>扫码加入 QQ 群,交流使用心得、提出建议,一起把 MPider 做得更好。</DialogDescription>
</DialogHeader>
<img src={feedbackQr} alt="MPider 交流群入群二维码" className="mx-auto w-full max-w-72 rounded-xl" />
</DialogContent>
</Dialog>
<button type="button" onClick={onAbout} className="flex items-center gap-2.5 rounded-lg px-2.5 py-2 text-left text-sm hover:bg-sidebar-accent/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sidebar-ring">
<Info className="size-4 shrink-0 opacity-80" /><span>关于</span>
</button>
Expand Down
24 changes: 24 additions & 0 deletions frontend/src/lib/advertisement-dismissal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/** 滑入广告的关闭时间独立于内容缓存,刷新配置或重启不会重置冷却。 */
export const ADVERTISEMENT_DISMISSAL_KEY = "mpider.advertisement-dismissed-at.v1";
export const ADVERTISEMENT_COOLDOWN_MS = 60 * 60 * 1000;
type Storage = Pick<globalThis.Storage, "getItem" | "setItem">;

export function readAdvertisementDismissal(storage?: Storage): number | null {
try {
const value = storage?.getItem(ADVERTISEMENT_DISMISSAL_KEY);
if (!value) return null;
const timestamp = Number(value);
return Number.isSafeInteger(timestamp) && timestamp > 0 ? timestamp : null;
} catch { return null; }
}

export function advertisementCooldownRemaining(dismissedAt: number | null, now = Date.now()): number {
if (dismissedAt === null || !Number.isSafeInteger(dismissedAt) || dismissedAt <= 0) return 0;
// 系统时钟回拨时最多等待一小时,避免异常时间导致长期隐藏。
return Math.min(ADVERTISEMENT_COOLDOWN_MS, Math.max(0, dismissedAt + ADVERTISEMENT_COOLDOWN_MS - now));
}

export function saveAdvertisementDismissal(storage?: Storage, now = Date.now()): number {
try { storage?.setItem(ADVERTISEMENT_DISMISSAL_KEY, String(now)); } catch { /* 内存状态仍维持本次运行的冷却。 */ }
return now;
}
22 changes: 22 additions & 0 deletions frontend/src/lib/use-advertisements.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { useQuery } from "@tanstack/react-query";
import bundledConfig from "../../../config/advertisements.json";
import { ADVERTISEMENTS_REFRESH_MS, loadAdvertisementConfig, readAdvertisementCache, type AdvertisementConfig } from "./advertisements";

export function advertisementStorage() {
try { return window.localStorage; } catch { return undefined; }
}

export function useAdvertisements() {
return useQuery({
queryKey: ["advertisements"],
queryFn: () => loadAdvertisementConfig({ fallback: bundledConfig as AdvertisementConfig, storage: advertisementStorage(),
url: import.meta.env.DEV ? import.meta.env.VITE_ADVERTISEMENTS_URL : undefined }),
initialData: () => readAdvertisementCache(advertisementStorage()) || bundledConfig as AdvertisementConfig,
initialDataUpdatedAt: 0,
staleTime: ADVERTISEMENTS_REFRESH_MS,
refetchInterval: ADVERTISEMENTS_REFRESH_MS,
refetchIntervalInBackground: true,
refetchOnWindowFocus: false,
retry: false,
}).data;
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mpider-desktop",
"private": true,
"version": "2.0.2",
"version": "2.0.3",
"type": "module",
"packageManager": "pnpm@10.29.2",
"description": "mpider 桌面外壳的前端 + Tauri CLI(前端源码在 frontend/,Tauri 壳在 src-tauri/)",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "MPider",
"version": "2.0.2",
"version": "2.0.3",
"identifier": "io.github.areyoubugcoder.mpider",
"build": {
"frontendDist": "../frontend/dist",
Expand Down
Loading