From 704bfa1c8aa14725fc5e5902115486b35abe3d26 Mon Sep 17 00:00:00 2001 From: 3970260761 <3970260761@qq.com> Date: Tue, 10 Nov 2026 20:27:55 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AE=BE=E7=BD=AE=E5=86=85=E8=81=94?= =?UTF-8?q?=E5=88=B0=E9=A6=96=E9=A1=B5=EF=BC=8C=E5=88=A0=E9=99=A4=E8=B0=A2?= =?UTF-8?q?=E8=B0=A2=E6=94=AF=E6=8C=81=E6=A8=AA=E5=B9=85=20(v2.1.4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 设置内容(同步桥接/悬浮按钮/自建站点/历史入口)从抽屉移出,直接铺在首页 - 删除首页「谢谢支持」分享横幅与 GitHub/分享文案 - 顶栏移除「设置」按钮,设置抽屉组件一并删除 --- CHANGELOG.md | 7 + packages/extension/manifest.json | 2 +- packages/extension/package.json | 2 +- .../src/popup/components/SettingsDrawer.tsx | 317 ------------------ .../src/popup/components/SettingsPanel.tsx | 264 +++++++++++++++ .../extension/src/popup/pages/HomeNew.tsx | 70 +--- 6 files changed, 279 insertions(+), 383 deletions(-) delete mode 100644 packages/extension/src/popup/components/SettingsDrawer.tsx create mode 100644 packages/extension/src/popup/components/SettingsPanel.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index 01ee0cf..c8321ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## v2.1.4 (2026-10-23) + +- ✨ 设置内容全部**移出抽屉、内联到首页**(同步桥接状态/Token/地址、悬浮按钮、自建站点、历史入口直接可见) +- 🗑️ 删除首页「谢谢支持」分享横幅(含分享/GitHub 文案);顶栏「设置」按钮与设置抽屉一并移除 + +--- + ## v2.1.3 (2026-10-23) - 🆕 新增「窗口」入口:扩展可在**独立窗口**中打开并常驻保持(不随点击外部关闭,适合长期盯同步桥接/公众号在线状态) diff --git a/packages/extension/manifest.json b/packages/extension/manifest.json index 6bd1b92..b4b20ee 100644 --- a/packages/extension/manifest.json +++ b/packages/extension/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 3, "name": "文章同步助手", "description": "一键同步文章到知乎、头条、掘金等 20+ 平台,支持公众号多账号保持在线", - "version": "2.1.3", + "version": "2.1.4", "icons": { "16": "assets/icon-16.png", "48": "assets/icon-48.png", diff --git a/packages/extension/package.json b/packages/extension/package.json index 2358398..ea8de46 100644 --- a/packages/extension/package.json +++ b/packages/extension/package.json @@ -1,6 +1,6 @@ { "name": "@wechatsync/extension", - "version": "2.1.3", + "version": "2.1.4", "private": true, "description": "微信公众号同步助手 Chrome 扩展", "type": "module", diff --git a/packages/extension/src/popup/components/SettingsDrawer.tsx b/packages/extension/src/popup/components/SettingsDrawer.tsx deleted file mode 100644 index 53c13ee..0000000 --- a/packages/extension/src/popup/components/SettingsDrawer.tsx +++ /dev/null @@ -1,317 +0,0 @@ -import { useState, useEffect, useRef } from 'react' -import { X, Plug, PlugZap, Plus, Trash2, ChevronRight } from 'lucide-react' -import { cn } from '@/lib/utils' -import { trackFeatureDiscovery } from '../../lib/analytics' - -interface SettingsDrawerProps { - open: boolean - onClose: () => void -} - -interface McpStatus { - enabled: boolean - connected: boolean - token?: string - serverUrl?: string -} - -interface CMSAccount { - id: string - name: string - type: string - url: string -} - -export function SettingsDrawer({ open, onClose }: SettingsDrawerProps) { - const [mcpStatus, setMcpStatus] = useState({ enabled: true, connected: false }) - const [cmsAccounts, setCmsAccounts] = useState([]) - const [loading, setLoading] = useState(false) - const [floatingButtonEnabled, setFloatingButtonEnabled] = useState(false) - const [serverUrlInput, setServerUrlInput] = useState('') - const serverUrlTimer = useRef | null>(null) - - // 获取状态 - useEffect(() => { - if (!open) return - - // MCP 状态 - chrome.runtime.sendMessage({ type: 'MCP_STATUS' }, (response) => { - if (response && !response.error) { - setMcpStatus({ - enabled: response.enabled ?? false, - connected: response.connected ?? false, - token: response.token, - serverUrl: response.serverUrl, - }) - setServerUrlInput(response.serverUrl || '') - } - }) - - // CMS 账户 - chrome.storage.local.get('cmsAccounts', (result) => { - setCmsAccounts(result.cmsAccounts || []) - }) - - // 悬浮按钮设置 - chrome.storage.local.get('floatingButtonEnabled', (result) => { - setFloatingButtonEnabled(result.floatingButtonEnabled ?? false) - }) - }, [open]) - - // MCP 状态轮询 + 通知 background 加速重连 - useEffect(() => { - if (!open || !mcpStatus.enabled) return - - // 通知 background:用户正在关注,加速重连 - chrome.runtime.sendMessage({ type: 'MCP_WATCH_START' }) - - const interval = setInterval(() => { - chrome.runtime.sendMessage({ type: 'MCP_STATUS' }, (response) => { - if (response && !response.error) { - setMcpStatus(prev => ({ ...prev, connected: response.connected ?? false })) - } - }) - }, 3000) - - return () => { - clearInterval(interval) - // 设置页关闭,恢复正常重连策略 - chrome.runtime.sendMessage({ type: 'MCP_WATCH_STOP' }) - } - }, [open, mcpStatus.enabled]) - - // 同步桥接锁定为「始终连接」:点击只会确保开启,无法关闭 - const toggleMcp = async () => { - setLoading(true) - // 追踪 MCP 功能发现 - trackFeatureDiscovery('mcp', 'settings').catch(() => {}) - - chrome.runtime.sendMessage({ type: 'MCP_ENABLE' }, (response) => { - setLoading(false) - if (response?.success) { - setMcpStatus(prev => ({ - ...prev, - enabled: true, - token: response.token ?? prev.token, // 保存返回的 token - })) - } - }) - } - - // 服务器地址变更(防抖 800ms) - const handleServerUrlChange = (value: string) => { - setServerUrlInput(value) - if (serverUrlTimer.current) { - clearTimeout(serverUrlTimer.current) - } - serverUrlTimer.current = setTimeout(() => { - chrome.runtime.sendMessage({ - type: 'MCP_SET_SERVER_URL', - payload: { url: value.trim() }, - }) - setMcpStatus(prev => ({ ...prev, serverUrl: value.trim() })) - }, 800) - } - - // 切换悬浮按钮 - const toggleFloatingButton = () => { - const next = !floatingButtonEnabled - setFloatingButtonEnabled(next) - chrome.storage.local.set({ floatingButtonEnabled: next }) - } - - // 删除 CMS 账户 - const deleteCmsAccount = async (id: string) => { - // 直接从 storage 读取最新数据,避免多窗口操作时覆盖 - const storage = await chrome.storage.local.get('cmsAccounts') - const accounts: CMSAccount[] = storage.cmsAccounts || [] - const updated = accounts.filter(a => a.id !== id) - await chrome.storage.local.set({ cmsAccounts: updated }) - await chrome.storage.local.remove(`cms_pwd_${id}`) - setCmsAccounts(updated) - } - - if (!open) return null - - return ( - <> - {/* 遮罩 */} -
- - {/* 抽屉 */} -
- {/* 头部 */} -
-

设置

- -
- - {/* 内容 */} -
- {/* 同步桥接设置 */} -
-

同步桥接

- -
-
- {mcpStatus.connected ? ( - - ) : ( - - )} -
-

CLI / MCP 连接

-

- {mcpStatus.enabled - ? mcpStatus.connected - ? '已连接' - : '等待连接...' - : '未启用'} -

-
-
- - -
- -
-

- 供 CLI 和 MCP Server 通过 WebSocket 桥接同步文章 —— 始终连接,已锁定不可关闭 -

- {mcpStatus.token && ( -
-

Token:

- - {mcpStatus.token} - -
- )} -
-

服务器地址 (留空使用本地默认):

- handleServerUrlChange(e.target.value)} - placeholder="ws://192.168.68.19:9600" - className="w-full bg-background p-1.5 rounded border border-border text-xs font-mono focus:outline-none focus:ring-1 focus:ring-primary" - /> -
-
-
- - {/* 悬浮同步按钮 */} -
-

网页功能

- -
-
-

悬浮同步按钮

-

在网页右下角显示快捷同步按钮

-
- -
-
- - {/* CMS 账户 */} -
-
-

自建站点

- -
- - {cmsAccounts.length === 0 ? ( -

- 暂无自建站点 -

- ) : ( -
- {cmsAccounts.map(account => ( -
-
-

{account.name}

-

{account.url}

-
- -
- ))} -
- )} -
- - {/* 历史记录 */} -
- -
- -
-
- - ) -} diff --git a/packages/extension/src/popup/components/SettingsPanel.tsx b/packages/extension/src/popup/components/SettingsPanel.tsx new file mode 100644 index 0000000..7b7f1ab --- /dev/null +++ b/packages/extension/src/popup/components/SettingsPanel.tsx @@ -0,0 +1,264 @@ +import { useState, useEffect, useRef } from 'react' +import { Plug, PlugZap, Plus, Trash2, ChevronRight } from 'lucide-react' +import { cn } from '@/lib/utils' +import { trackFeatureDiscovery } from '../../lib/analytics' + +interface McpStatus { + enabled: boolean + connected: boolean + token?: string + serverUrl?: string +} + +interface CMSAccount { + id: string + name: string + type: string + url: string +} + +/** + * 设置面板(内联版)—— 从原设置抽屉移出,直接展示在首页上。 + * 同步桥接锁定为始终连接,不可关闭。 + */ +export function SettingsPanel() { + const [mcpStatus, setMcpStatus] = useState({ enabled: true, connected: false }) + const [cmsAccounts, setCmsAccounts] = useState([]) + const [loading, setLoading] = useState(false) + const [floatingButtonEnabled, setFloatingButtonEnabled] = useState(false) + const [serverUrlInput, setServerUrlInput] = useState('') + const serverUrlTimer = useRef | null>(null) + + // 获取状态(面板常驻,挂载即加载) + useEffect(() => { + // MCP 状态 + chrome.runtime.sendMessage({ type: 'MCP_STATUS' }, (response) => { + if (response && !response.error) { + setMcpStatus({ + enabled: response.enabled ?? false, + connected: response.connected ?? false, + token: response.token, + serverUrl: response.serverUrl, + }) + setServerUrlInput(response.serverUrl || '') + } + }) + + // CMS 账户 + chrome.storage.local.get('cmsAccounts', (result) => { + setCmsAccounts(result.cmsAccounts || []) + }) + + // 悬浮按钮设置 + chrome.storage.local.get('floatingButtonEnabled', (result) => { + setFloatingButtonEnabled(result.floatingButtonEnabled ?? false) + }) + }, []) + + // MCP 状态轮询 + 通知 background 加速重连 + useEffect(() => { + // 通知 background:用户正在关注,加速重连 + chrome.runtime.sendMessage({ type: 'MCP_WATCH_START' }) + + const interval = setInterval(() => { + chrome.runtime.sendMessage({ type: 'MCP_STATUS' }, (response) => { + if (response && !response.error) { + setMcpStatus(prev => ({ ...prev, connected: response.connected ?? false })) + } + }) + }, 3000) + + return () => { + clearInterval(interval) + // 面板卸载,恢复正常重连策略 + chrome.runtime.sendMessage({ type: 'MCP_WATCH_STOP' }) + } + }, []) + + // 桥接始终连接:点击只确保开启,不会关闭 + const toggleMcp = async () => { + if (loading) return + setLoading(true) + try { + chrome.runtime.sendMessage({ type: 'MCP_ENABLE' }, () => { + setMcpStatus(prev => ({ ...prev, enabled: true })) + }) + } finally { + setLoading(false) + } + } + + // 服务器地址输入(防抖保存) + const handleServerUrlChange = (value: string) => { + setServerUrlInput(value) + trackFeatureDiscovery('mcp_server_url_input', 'home_panel') + if (serverUrlTimer.current) clearTimeout(serverUrlTimer.current) + serverUrlTimer.current = setTimeout(() => { + chrome.storage.local.set({ mcpServerUrl: value }, () => { + chrome.runtime.sendMessage({ type: 'MCP_SET_SERVER_URL', serverUrl: value }) + }) + }, 600) + } + + // 悬浮按钮开关 + const toggleFloatingButton = () => { + const next = !floatingButtonEnabled + setFloatingButtonEnabled(next) + chrome.storage.local.set({ floatingButtonEnabled: next }) + } + + // 删除 CMS 账户 + const deleteCmsAccount = (id: string) => { + const next = cmsAccounts.filter(a => a.id !== id) + setCmsAccounts(next) + chrome.storage.local.set({ cmsAccounts: next }) + } + + return ( +
+ {/* 同步桥接设置 */} +
+

同步桥接

+ +
+
+ {mcpStatus.connected ? ( + + ) : ( + + )} +
+

CLI / MCP 连接

+

+ {mcpStatus.enabled + ? mcpStatus.connected + ? '已连接' + : '等待连接...' + : '未启用'} +

+
+
+ + +
+ +
+

+ 供 CLI 和 MCP Server 通过 WebSocket 桥接同步文章 —— 始终连接,已锁定不可关闭 +

+ {mcpStatus.token && ( +
+

Token:

+ + {mcpStatus.token} + +
+ )} +
+

服务器地址 (留空使用本地默认):

+ handleServerUrlChange(e.target.value)} + placeholder="ws://192.168.68.19:9600" + className="w-full bg-background p-1.5 rounded border border-border text-xs font-mono focus:outline-none focus:ring-1 focus:ring-primary" + /> +
+
+
+ + {/* 悬浮同步按钮 */} +
+

网页功能

+ +
+
+

悬浮同步按钮

+

在网页右下角显示快捷同步按钮

+
+ +
+
+ + {/* CMS 账户 */} +
+
+

自建站点

+ +
+ + {cmsAccounts.length === 0 ? ( +

+ 暂无自建站点 +

+ ) : ( +
+ {cmsAccounts.map(account => ( +
+
+

{account.name}

+

{account.url}

+
+ +
+ ))} +
+ )} +
+ + {/* 历史记录 */} +
+ +
+
+ ) +} diff --git a/packages/extension/src/popup/pages/HomeNew.tsx b/packages/extension/src/popup/pages/HomeNew.tsx index cd15104..9a77508 100644 --- a/packages/extension/src/popup/pages/HomeNew.tsx +++ b/packages/extension/src/popup/pages/HomeNew.tsx @@ -1,12 +1,12 @@ import { useEffect, useState } from 'react' import { useNavigate } from 'react-router-dom' -import { Settings, Plus, Clock, X, Download, Info, Wifi, Maximize2 } from 'lucide-react' +import { Plus, Clock, X, Download, Info, Wifi, Maximize2 } from 'lucide-react' import { useSyncStore } from '../stores/sync' -import { SettingsDrawer } from '../components/SettingsDrawer' +import { SettingsPanel } from '../components/SettingsPanel' import { SyncDialog } from '@/components/sync-dialog' import type { Platform as DialogPlatform } from '@/components/sync-dialog' import { cn } from '@/lib/utils' -import { trackPageView, trackFeatureDiscovery } from '../../lib/analytics' +import { trackPageView } from '../../lib/analytics' import { createLogger } from '../../lib/logger' import { getCachedUpdateInfo, dismissUpdate, type UpdateCheckResult } from '../../lib/version-check' @@ -36,14 +36,12 @@ export function HomeNew() { checkRateLimit, } = useSyncStore() - const [settingsOpen, setSettingsOpen] = useState(false) const [rateLimitWarning, setRateLimitWarning] = useState(null) const [allPlatforms, setAllPlatforms] = useState([]) const [updateInfo, setUpdateInfo] = useState(null) const [floatingEnabled, setFloatingEnabled] = useState(false) const [isFirstSync, setIsFirstSync] = useState(false) - const [showShareTip, setShowShareTip] = useState(false) // Load data useEffect(() => { @@ -62,12 +60,9 @@ export function HomeNew() { } catch {} loadAllPlatforms() loadArticle() - chrome.storage.local.get(['floatingButtonEnabled', 'syncHistory', 'dismissedShareTip'], (r) => { + chrome.storage.local.get(['floatingButtonEnabled', 'syncHistory'], (r) => { setFloatingEnabled(r.floatingButtonEnabled ?? false) setIsFirstSync(!r.syncHistory || r.syncHistory.length === 0) - if (!r.dismissedShareTip) { - setShowShareTip(true) - } }) const cached = await getCachedUpdateInfo() if (cached?.hasUpdate && cached.info) { @@ -175,16 +170,6 @@ export function HomeNew() { 窗口 - @@ -228,48 +213,8 @@ export function HomeNew() {
)} - {/* Share / welcome banner (first time only) */} - {showShareTip && ( -
-
- -

谢谢支持!

-

- 如果觉得本工具不错,还请分享给你的朋友! -
- 如果你是开发者,欢迎参与进来{' '} - - GitHub - -

-
-

- by{' '} - - fun - -

-
-
- )} + {/* 设置(已从抽屉移出,直接内联在首页) */} + {/* SyncDialog — the unified sync flow */} )} - {/* Settings drawer */} - setSettingsOpen(false)} /> - {/* Rate limit warning (non-blocking toast) */} {rateLimitWarning && (