The only downloader you need. 下载器的集大成者。
TypeScript asyncasynciobittorentbtcross-platformdownload-managerdownloaderfluent-designftphttp3magnetpyqtpyside6pythonqtquicreactsoftwarestreaming
feat(Browser Extension): 顶栏改为 Fluent 风格并压缩高度
XiaoYouChRe91d673137c2
diff --git a/browser_extension/GLOSSARY.md b/browser_extension/GLOSSARY.mdindex 57cba915..23b7f8de 100644--- a/browser_extension/GLOSSARY.md+++ b/browser_extension/GLOSSARY.md@@ -10,7 +10,7 @@ Chromium / Firefox 浏览器扩展。捕获页面中的可下载资源,通过**cat-catch**:嵌入的第三方开源扩展,提供两个能力面:媒体播放控制,以及按 tab 手动开启的页面工具(录制、缓存捕捉、Deep Search 等)。-不参与 Download Button 的默认路径;MSE Probe 参照 cat-catch 重写为独立实现,只发信号不缓存数据。+不参与 Media Button 的默认路径;MSE Probe 参照 cat-catch 重写为独立实现,只发信号不缓存数据。_Avoid_: 把 cat-catch 功能与自研 Page Media 系统混为一谈**Deep Search**:@@ -61,10 +61,10 @@ _Avoid_: category、filter type**Page Media**:Content script 侧的媒体检测和归因系统。检测页面中正在播放的媒体,将网络 URL归因到具体的 video 元素,为用户提供下载按钮。由四个协作层组成:-MSE Probe → Attribution Engine → Download Button,Resolution Strategy 提供按站点的解析逻辑。-Page Media 与 Resource 不是两条独立路径:Download Button 以本 tab 的 Resource 作为兜底候选,+MSE Probe → Attribution Engine → Media Button,Resolution Strategy 提供按站点的解析逻辑。+Page Media 与 Resource 不是两条独立路径:Media Button 以本 tab 的 Resource 作为兜底候选,发送时复用 Resource 的请求头;Page Media 也为 Resource 补充时长、尺寸和封面。-Download Button 失败时,Popup 资源面板是用户手动挑选的兜底。+Media Button 失败时,Popup 资源面板是用户手动挑选的兜底。**MSE Probe**:观察浏览器媒体流内部机制,将事件通过 Attribution Signal 报告给 Attribution Engine。@@ -110,9 +110,10 @@ _Avoid_: content lock、origin file跨 session 的 URL 所有权账本。仲裁多个 Video Session 争抢同一 URL 的情况(如预加载场景中多个视频共享相同的 CDN URL)。-**Download Button**:+**Media Button**:悬浮在活跃媒体上的下载按钮。点击时请求 Attribution Engine 解析,-获取 Resolution 后发送到 Resource Bridge 转发给桌面。+获取 Resolution 后发送到 Resource Bridge 转发给桌面。用户可在 Popup 中全局开关。+_Avoid_: Download Button、下载按钮**Resolution Strategy**:按站点分发的下载解析逻辑(YouTube、Instagram/Facebook、generic)。diff --git a/browser_extension/app/src/popup/components/ConnectionStatus.tsx b/browser_extension/app/src/popup/components/ConnectionStatus.tsxnew file mode 100644index 00000000..8ce04829--- /dev/null+++ b/browser_extension/app/src/popup/components/ConnectionStatus.tsx@@ -0,0 +1,91 @@+import {Button, makeStyles, Spinner, tokens, Tooltip, typographyStyles} from "@fluentui/react-components";+import {+ CheckmarkCircleRegular,+ OpenRegular,+ PlugDisconnectedRegular,+ WarningRegular,+} from "@fluentui/react-icons";++import type {DesktopConnectionState} from "../../shared/types";+import type {AccentTone} from "../../shared/utils";+import {connectionLabel, connectionTone} from "../../shared/utils";++const TONE_COLORS: Record<AccentTone, string> = {+ neutral: tokens.colorNeutralForeground3,+ info: tokens.colorNeutralForeground3,+ success: tokens.colorStatusSuccessForeground1,+ warning: tokens.colorStatusWarningForeground1,+ danger: tokens.colorStatusDangerForeground1,+};++const useStyles = makeStyles({+ root: {+ display: "flex",+ alignItems: "center",+ gap: "4px",+ minWidth: 0,+ },+ icon: {+ display: "flex",+ flexShrink: 0,+ fontSize: "16px",+ },+ label: {+ ...typographyStyles.caption1,+ color: tokens.colorNeutralForeground2,+ overflow: "hidden",+ textOverflow: "ellipsis",+ whiteSpace: "nowrap",+ },+ launch: {+ flexShrink: 0,+ },+});++export function ConnectionStatus({+ state,+ message,+ pendingCount,+ onLaunchDesktop,+}: {+ state: DesktopConnectionState;+ message: string;+ pendingCount: number;+ onLaunchDesktop: () => void;+}) {+ const styles = useStyles();+ const tone = connectionTone(state);++ const label = state === "connected" ? chrome.i18n.getMessage("connected") : connectionLabel(state, message);+ const text = pendingCount > 0 ? chrome.i18n.getMessage("pendingQueueBadge", [label, String(pendingCount)]) : label;+ const icon =+ tone === "info" ? (+ <Spinner size="extra-tiny" />+ ) : tone === "success" ? (+ <CheckmarkCircleRegular />+ ) : tone === "warning" || tone === "danger" ? (+ <WarningRegular />+ ) : (+ <PlugDisconnectedRegular />+ );++ return (+ <div className={styles.root}>+ <span className={styles.icon} style={{ color: TONE_COLORS[tone] }}>+ {icon}+ </span>+ <Tooltip content={text} relationship="description">+ <span className={styles.label}>{text}</span>+ </Tooltip>+ <Tooltip content={chrome.i18n.getMessage("launchDesktop")} relationship="label">+ <Button+ className={styles.launch}+ appearance="subtle"+ icon={<OpenRegular />}+ size="small"+ onClick={onLaunchDesktop}+ />+ </Tooltip>+ </div>+ );+}diff --git a/browser_extension/app/src/popup/components/ConnectionStatusBadge.tsx b/browser_extension/app/src/popup/components/ConnectionStatusBadge.tsxdeleted file mode 100644index 965feda3..00000000--- a/browser_extension/app/src/popup/components/ConnectionStatusBadge.tsx+++ /dev/null@@ -1,72 +0,0 @@-import {Badge, Button, makeStyles, Spinner} from "@fluentui/react-components";-import {- CheckmarkCircleRegular,- OpenRegular,- PlugDisconnectedRegular,- WarningRegular,-} from "@fluentui/react-icons";--import type {DesktopConnectionState} from "../../shared/types";-import {connectionLabel, connectionTone} from "../../shared/utils";-import {toneToBadgeColor} from "../fluent";--const useStyles = makeStyles({- root: {- display: "flex",- alignItems: "center",- gap: "6px",- whiteSpace: "nowrap",- },-});--export function ConnectionStatusBadge({- state,- message,- pendingCount,- onLaunchDesktop,-}: {- state: DesktopConnectionState;- message: string;- pendingCount?: number;- onLaunchDesktop?: () => void;-}) {- const styles = useStyles();- const tone = connectionTone(state);- const hasPending = (pendingCount ?? 0) > 0;-- const label = state === "connected" ? chrome.i18n.getMessage("connected") : connectionLabel(state, message);- const icon =- tone === "info" ? (- <Spinner size="tiny" />- ) : tone === "success" ? (- <CheckmarkCircleRegular />- ) : tone === "warning" || tone === "danger" ? (- <WarningRegular />- ) : (- <PlugDisconnectedRegular />- );-- const badgeText = hasPending ? chrome.i18n.getMessage("pendingQueueBadge", [String(label), String(pendingCount)]) : label;-- return (- <div className={styles.root}>- <Badge- appearance={tone === "neutral" ? "outline" : "tint"}- color={toneToBadgeColor(tone)}- icon={icon}- size="large"- >- {badgeText}- </Badge>- {onLaunchDesktop && (- <Button- appearance="subtle"- aria-label={chrome.i18n.getMessage("launchDesktop")}- icon={<OpenRegular />}- size="small"- onClick={onLaunchDesktop}- />- )}- </div>- );-}diff --git a/browser_extension/app/src/popup/components/Header.tsx b/browser_extension/app/src/popup/components/Header.tsxindex a0a154b7..f35aedf3 100644--- a/browser_extension/app/src/popup/components/Header.tsx+++ b/browser_extension/app/src/popup/components/Header.tsx@@ -1,49 +1,73 @@import type {SelectTabData, SwitchOnChangeData} from "@fluentui/react-components";-import {Button, Divider, makeStyles, Switch, Tab, TabList} from "@fluentui/react-components";-import {ArrowDownloadRegular, GlobeRegular, ImageRegular, SettingsRegular, WrenchRegular,} from "@fluentui/react-icons";+import {makeStyles, Switch, Tab, TabList, tokens, Tooltip} from "@fluentui/react-components";+import {+ ArrowDownloadFilled,+ ArrowDownloadRegular,+ bundleIcon,+ GlobeFilled,+ GlobeRegular,+ ImageFilled,+ ImageRegular,+ SettingsFilled,+ SettingsRegular,+ WrenchFilled,+ WrenchRegular,+} from "@fluentui/react-icons";import type {DesktopConnectionState, PopupView} from "../../shared/types";-import {ConnectionStatusBadge} from "./ConnectionStatusBadge";+import {ConnectionStatus} from "./ConnectionStatus";++const TasksIcon = bundleIcon(ArrowDownloadFilled, ArrowDownloadRegular);+const ResourcesIcon = bundleIcon(GlobeFilled, GlobeRegular);+const ImagesIcon = bundleIcon(ImageFilled, ImageRegular);+const AdvancedIcon = bundleIcon(WrenchFilled, WrenchRegular);+const SettingsIcon = bundleIcon(SettingsFilled, SettingsRegular);++const TAB_INSET = "6px";+const EDGE = "12px";const useStyles = makeStyles({root: {- paddingTop: "8px",- paddingBottom: "0",- },- topRow: {- display: "flex",- alignItems: "center",- justifyContent: "space-between",- gap: "4px",- paddingLeft: "8px",- paddingRight: "4px",- marginBottom: "8px",- overflow: "hidden",+ paddingTop: "4px",+ paddingBottom: "4px",+ backgroundColor: tokens.colorNeutralBackground2,+ borderBottom: `${tokens.strokeWidthThin} solid ${tokens.colorNeutralStroke2}`,},nav: {- minWidth: 0,- flex: 1,+ paddingLeft: TAB_INSET,+ paddingRight: TAB_INSET,overflowX: "auto",scrollbarWidth: "none",},- bottomRow: {+ settingsTab: {+ marginLeft: "auto",+ },+ statusRow: {display: "flex",alignItems: "center",justifyContent: "space-between",- gap: "8px",- paddingLeft: "8px",- paddingRight: "4px",- overflow: "hidden",+ gap: EDGE,+ height: "28px",+ paddingLeft: EDGE,+ paddingRight: EDGE,},switches: {display: "flex",alignItems: "center",- gap: "4px",+ gap: EDGE,+ flexShrink: 0,whiteSpace: "nowrap",- minWidth: 0,},- divider: {- width: "100%",- marginTop: "8px",+ switch: {+ alignItems: "center",+ },+ switchIndicator: {+ margin: 0,+ },+ switchLabel: {+ paddingTop: 0,+ paddingBottom: 0,+ paddingLeft: 0,+ paddingRight: "8px",},});@@ -52,10 +76,10 @@ const NAV_ITEMS: Array<{label: string;icon: React.JSX.Element;}> = [- { key: "tasks", label: chrome.i18n.getMessage("navTasks"), icon: <ArrowDownloadRegular /> },- { key: "resources", label: chrome.i18n.getMessage("navResources"), icon: <GlobeRegular /> },- { key: "images", label: chrome.i18n.getMessage("navImages"), icon: <ImageRegular /> },- { key: "advanced", label: chrome.i18n.getMessage("navAdvanced"), icon: <WrenchRegular /> },+ { key: "tasks", label: chrome.i18n.getMessage("navTasks"), icon: <TasksIcon /> },+ { key: "resources", label: chrome.i18n.getMessage("navResources"), icon: <ResourcesIcon /> },+ { key: "images", label: chrome.i18n.getMessage("navImages"), icon: <ImagesIcon /> },+ { key: "advanced", label: chrome.i18n.getMessage("navAdvanced"), icon: <AdvancedIcon /> },];export function Header({@@ -89,30 +113,25 @@ export function Header({return (<header className={styles.root}>- <div className={styles.topRow}>- <TabList- className={styles.nav}- appearance="subtle-circular"- selectedValue={currentView === "settings" ? undefined : currentView}- onTabSelect={(_event, data: SelectTabData) => onViewChange(data.value as PopupView)}- >- {NAV_ITEMS.map((item) => (- <Tab key={item.key} value={item.key} icon={item.icon}>- {item.label}- </Tab>- ))}- </TabList>-- <Button- appearance={currentView === "settings" ? "primary" : "secondary"}- icon={<SettingsRegular />}- aria-label={chrome.i18n.getMessage("settings")}- onClick={() => onViewChange("settings")}- />- </div>+ <TabList+ className={styles.nav}+ appearance="transparent"+ size="small"+ selectedValue={currentView}+ onTabSelect={(_event, data: SelectTabData) => onViewChange(data.value as PopupView)}+ >+ {NAV_ITEMS.map((item) => (+ <Tab key={item.key} value={item.key} icon={item.icon}>+ {item.label}+ </Tab>+ ))}+ <Tooltip content={chrome.i18n.getMessage("settings")} relationship="label">+ <Tab className={styles.settingsTab} value="settings" icon={<SettingsIcon />} />+ </Tooltip>+ </TabList>- <div className={styles.bottomRow}>- <ConnectionStatusBadge+ <div className={styles.statusRow}>+ <ConnectionStatusstate={connectionState}message={connectionMessage}pendingCount={pendingTaskCount}@@ -121,22 +140,27 @@ export function Header({<div className={styles.switches}><Switch+ className={styles.switch}+ indicator={{ className: styles.switchIndicator }}+ size="small"checked={isMediaButtonEnabled}disabled={isMediaButtonBusy}- label={chrome.i18n.getMessage("mediaButtonLabel")}+ label={{ className: styles.switchLabel, children: chrome.i18n.getMessage("mediaButtonLabel") }}labelPosition="before"onChange={(_event, data: SwitchOnChangeData) => onMediaButtonToggle(Boolean(data.checked))}/><Switch+ className={styles.switch}+ indicator={{ className: styles.switchIndicator }}+ size="small"checked={shouldTakeDownloads}disabled={isTakeDownloadsBusy}- label={chrome.i18n.getMessage("takeOverDownloads")}+ label={{ className: styles.switchLabel, children: chrome.i18n.getMessage("takeOverDownloads") }}labelPosition="before"onChange={(_event, data: SwitchOnChangeData) => onTakeDownloadsToggle(Boolean(data.checked))}/></div></div>- <Divider className={styles.divider} /></header>);}diff --git a/browser_extension/app/src/popup/fluent.ts b/browser_extension/app/src/popup/fluent.tsindex fa8fa5f2..7172e7f2 100644--- a/browser_extension/app/src/popup/fluent.ts+++ b/browser_extension/app/src/popup/fluent.ts@@ -24,7 +24,7 @@ import {} from "@fluentui/react-icons";import type {AdvancedFeatureKey} from "../shared/types";-import type {AccentTone, VisualKind} from "../shared/utils";+import type {VisualKind} from "../shared/utils";const VISUAL_ICON_MAP: Record<VisualKind, ComponentType> = {download: DocumentArrowDownRegular,@@ -55,21 +55,6 @@ export function featureIcon(key: AdvancedFeatureKey) {return FEATURE_ICON_MAP[key];}-export function toneToBadgeColor(tone: AccentTone): NonNullable<BadgeProps["color"]> {- switch (tone) {- case "success":- return "success";- case "info":- return "informative";- case "warning":- return "warning";- case "danger":- return "danger";- default:- return "subtle";- }-}-export function taskStatusToBadgeColor(status: string): NonNullable<BadgeProps["color"]> {switch (status) {case "completed":