feat(plugin,ui): consolidate builtin.core, enforce Guest Tools toggle, and add QQ group entry

- Merge essential builtins (driver, default theme, start prep, host workarounds) into always-on system plugin builtin.core, with state.json and arg-ledger migration plus app-scoped workaround settings honored by both GUI and CLI.
- Ensure disabling builtin.bridge.guest-tools stops the localhost bridge without being restarted by feature callers, fix guesttools.Server Start/Close race, and reflect the disabled state in VMPage and SettingsModal.
- Add QQ community group entry in About settings with Windows tencent:// protocol detection, cached invite redirect resolution, and copy-ID fallback.
- Update docs/plugin-architecture.md, Wails bindings, and i18n strings.
This commit is contained in:
Nwflower committed 2026-11-29 09:54:51 -07:00
1 parent 007f2ac93c
commit 181c616909
35 files changed
+1432 -578

No files matched your search

+1
View File
@@ -910,6 +910,7 @@ export const App: React.FC = () => {
canDark={canDark}
onThemeMode={setThemeMode}
onSetLocale={setLang}
onCopy={copy}
onRefresh={refresh}
onError={fail}
/>
+81 -4
View File
@@ -1,14 +1,16 @@
import { Download } from 'lucide-react'
import { Copy, Download, ExternalLink } from 'lucide-react'
import React, { useEffect, useState } from 'react'
import { I18nKey, t } from '../i18n'
import { findOptimization, optBadgeClass, optStatusLabel } from '../lib/optimizations'
import { AppState, AppUpdateInfo, Locale } from '../types'
import { Button } from '../ui/controls'
import { Button, IconButton } from '../ui/controls'
import { Segmented, Switch } from '../ui/settings'
import { api } from '../wails'
export type ThemeMode = 'light' | 'dark' | 'system'
const QQ_GROUP_ID = '1136042744'
interface Props {
state: AppState
locale: Locale
@@ -17,18 +19,22 @@ interface Props {
canDark?: boolean
onThemeMode: (mode: ThemeMode) => void
onSetLocale: (l: Locale) => void
onCopy?: (text: string) => void
onRefresh: () => void
onError: (title: string, e: unknown) => void
}
export const AppSettingsPage: React.FC<Props> = ({
state, locale, themeMode, canLight = true, canDark = true, onThemeMode, onSetLocale, onRefresh, onError,
state, locale, themeMode, canLight = true, canDark = true, onThemeMode, onSetLocale, onCopy, onRefresh, onError,
}) => {
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
const { host, config, optimizations } = state
const [appUpdate, setAppUpdate] = useState<AppUpdateInfo | null>(null)
const [checkingUpdate, setCheckingUpdate] = useState(false)
const [updateErr, setUpdateErr] = useState('')
const [qqInstalled, setQQInstalled] = useState<boolean | null>(null)
const [openingQQ, setOpeningQQ] = useState(false)
const [qqLaunchErr, setQQLaunchErr] = useState('')
const pcoreOpt = findOptimization(optimizations, 'pcore_pin')
@@ -47,6 +53,11 @@ export const AppSettingsPage: React.FC<Props> = ({
useEffect(() => {
void runUpdateCheck(false)
let cancelled = false
api.CanOpenQQGroup()
.then((ok) => { if (!cancelled) setQQInstalled(!!ok) })
.catch(() => { if (!cancelled) setQQInstalled(false) })
return () => { cancelled = true }
}, [])
const guard = (fn: () => Promise<unknown>) => async () => {
@@ -63,6 +74,27 @@ export const AppSettingsPage: React.FC<Props> = ({
if (dir) await api.SetDataRoot(dir)
})
const openURL = (url: string) => {
api.OpenURL(url).catch((e) => onError(tr('failGeneric'), e))
}
const openQQGroup = async () => {
setOpeningQQ(true)
setQQLaunchErr('')
try {
await api.OpenQQGroup()
} catch (e) {
const msg = String(e).replace(/^Error:\s*/, '')
if (/qq not installed/i.test(msg)) {
setQQInstalled(false)
} else {
setQQLaunchErr(msg)
}
} finally {
setOpeningQQ(false)
}
}
return (
<div className="page rg-p-settings">
<header className="page-head">
@@ -180,7 +212,7 @@ export const AppSettingsPage: React.FC<Props> = ({
<Button
variant="primary"
icon={<Download size={14} aria-hidden="true" />}
onClick={() => guard(() => api.OpenURL(appUpdate.page_url || appUpdate.download_url || ''))()}
onClick={() => openURL(appUpdate.page_url || appUpdate.download_url || '')}
>
{tr('appDownloadUpdate')}
</Button>
@@ -191,6 +223,51 @@ export const AppSettingsPage: React.FC<Props> = ({
)}
</div>
</div>
<div className="row">
<div className="row-main">
<div className="row-title">
{tr('aboutQQGroup')} <span className="mono">{QQ_GROUP_ID}</span>
{qqInstalled === false && (
<span className="badge">{tr('aboutQQNotInstalled')}</span>
)}
</div>
{qqInstalled === false ? (
<div className="row-sub">{tr('aboutQQNotInstalledSub')}</div>
) : qqLaunchErr ? (
<div className="row-sub" title={qqLaunchErr}>{tr('aboutQQLaunchFailed')}</div>
) : (
<div className="row-sub">{tr('aboutQQGroupSub')}</div>
)}
</div>
<div className="row-right">
{qqInstalled && !qqLaunchErr ? (
<>
{onCopy && (
<IconButton
small
label={tr('aboutCopyQQGroup')}
icon={<Copy size={14} aria-hidden="true" />}
onClick={() => onCopy(QQ_GROUP_ID)}
/>
)}
<Button
busy={openingQQ}
icon={<ExternalLink size={14} aria-hidden="true" />}
onClick={() => void openQQGroup()}
>
{tr('aboutJoinQQGroup')}
</Button>
</>
) : onCopy ? (
<Button
icon={<Copy size={14} aria-hidden="true" />}
onClick={() => onCopy(QQ_GROUP_ID)}
>
{tr('aboutCopyQQGroup')}
</Button>
) : null}
</div>
</div>
</div>
</section>
</div>
+17 -8
View File
@@ -1,5 +1,5 @@
import {
AlertTriangle, BadgeCheck, Clipboard, Code2, Cpu, Disc3, FolderOpen, Keyboard,
AlertTriangle, BadgeCheck, Boxes, Clipboard, Code2, Cpu, Disc3, FolderOpen, Keyboard,
Layers, Monitor, PackagePlus, Palette, Puzzle, RefreshCw, RotateCcw, Search,
Settings2, Shield, ShieldAlert, ShieldCheck, Sparkles, Terminal, Trash2,
} from 'lucide-react'
@@ -33,6 +33,7 @@ interface PluginVisual {
}
function resolvePluginVisual(p: PluginInfo): PluginVisual {
if (p.system) return { tone: 'indigo', icon: <Boxes size={19} aria-hidden="true" /> }
const id = p.id.toLowerCase()
const perms = new Set((p.permissions ?? []).map((x) => x.name))
if (id.includes('theme') || perms.has('ui:script')) {
@@ -268,7 +269,11 @@ export const PluginsPage: React.FC<Props> = ({
return name.includes(q) || desc.includes(q) || p.id.toLowerCase().includes(q)
}
const builtins = useMemo(() => plugins.filter((p) => p.source === 'builtin'), [plugins])
// The always-on core goes first; the optional builtins keep backend order.
const builtins = useMemo(
() => plugins.filter((p) => p.source === 'builtin').sort((a, b) => Number(!!b.system) - Number(!!a.system)),
[plugins],
)
const external = useMemo(() => plugins.filter((p) => p.source !== 'builtin'), [plugins])
const filteredBuiltins = useMemo(() => builtins.filter(matchesFilter), [builtins, q, locale])
const filteredExternal = useMemo(() => external.filter(matchesFilter), [external, q, locale])
@@ -357,12 +362,16 @@ export const PluginsPage: React.FC<Props> = ({
onClick={() => setRemoveTarget(p)}
/>
)}
<Switch
label={locText(p.name, locale, p.id)}
disabled={busyID === p.id || (p.enabled && p.in_use) || (!!safeMode && !isBuiltin)}
checked={p.enabled}
onChange={(checked) => void togglePlugin(p, checked)}
/>
{p.system ? (
<span className="plugin-row-fixed">{tr('pluginAlwaysOn')}</span>
) : (
<Switch
label={locText(p.name, locale, p.id)}
disabled={busyID === p.id || (p.enabled && p.in_use) || (!!safeMode && !isBuiltin)}
checked={p.enabled}
onChange={(checked) => void togglePlugin(p, checked)}
/>
)}
</div>
</div>
)
+3 -2
View File
@@ -722,11 +722,12 @@ export const SettingsModal: React.FC<Props> = ({ locale, detail, stats, host, op
<Switch
label={tr('driveShareMaster')}
checked={!!driveSettings?.enabled}
disabled={!driveSettings || driveBusy}
disabled={!driveSettings || driveBusy || !!detail.guest_tools_disabled}
onChange={(enabled) => void updateDriveShares(enabled, selectedDrives())}
/>
}
/>
{detail.guest_tools_disabled && <div className="notice">{tr('gtStatusOffTip')}</div>}
{driveErr && <div className="notice" role="alert">{driveErr}</div>}
{driveSettings?.enabled && selectedDrives().length > 0 &&
(detail.guest_tools_agent_version ?? 0) < driveSettings.required_agent_version && (
@@ -739,7 +740,7 @@ export const SettingsModal: React.FC<Props> = ({ locale, detail, stats, host, op
key={drive.drive}
title={title}
desc={drive.system ? tr('driveShareSystem', { root: drive.root }) : tr('driveShareDrive', { root: drive.root })}
disabled={!driveSettings?.enabled || driveBusy}
disabled={!driveSettings?.enabled || driveBusy || !!detail.guest_tools_disabled}
reason={!driveSettings?.enabled ? tr('driveShareMasterOff') : undefined}
control={
<Switch
+9 -5
View File
@@ -756,12 +756,16 @@ export const VMPage: React.FC<Props> = ({
const gtMountMode = stats?.guest_tools_mount_mode || detail.guest_tools_mount_mode || ''
const gtSleepActive = stats?.guest_tools_sleep_guard ?? detail.guest_tools_sleep_active ?? false
const needsUpgrade = gtConnected && (detail.guest_tools_agent_version ?? 0) > 0 && (detail.guest_tools_agent_version ?? 0) < 3
// Plugin switched off: show the state and hide controls that would only fail.
const gtOff = !!detail.guest_tools_disabled
// One status word per state; how files are shared goes in the tooltip.
let gtTone: 'ok' | 'warn' | 'idle' = 'idle'
let gtStatus: string
let gtTip: string
if (needsUpgrade) {
if (gtOff) {
gtStatus = tr('gtStatusOff'); gtTip = tr('gtStatusOffTip')
} else if (needsUpgrade) {
gtTone = 'warn'; gtStatus = tr('gtStatusUpgrade'); gtTip = tr('guestToolsUpgradeHint')
} else if (gtConnected) {
gtTone = 'ok'; gtStatus = tr('gtStatusConnected')
@@ -772,7 +776,7 @@ export const VMPage: React.FC<Props> = ({
} else {
gtStatus = tr('gtStatusNone'); gtTip = tr('gtNotInstalledDesc')
}
const showInstallCmd = detail.guest_tools_attached && (!gtConnected || needsUpgrade)
const showInstallCmd = !gtOff && detail.guest_tools_attached && (!gtConnected || needsUpgrade)
const sshText = sshUser ? `ssh -p ${detail.ssh_port} ${sshUser}@127.0.0.1` : sshCommand(detail.ssh_port)
return (
@@ -830,7 +834,7 @@ export const VMPage: React.FC<Props> = ({
</Tip>
</div>
<div className="conn-ctrl">
{detail.guest_tools_attached ? (
{gtOff ? null : detail.guest_tools_attached ? (
<Button busy={busyAction === 'detachGuestTools'} disabled={busy} onClick={() => onAction('detachGuestTools')}>
{tr('detachGuestTools')}
</Button>
@@ -864,7 +868,7 @@ export const VMPage: React.FC<Props> = ({
</div>
</div>
)}
{tools && (
{tools && !gtOff && (
<div className="conn-row">
<div className="conn-main">
<span className="conn-title">{tr('sharedFolder')}</span>
@@ -876,7 +880,7 @@ export const VMPage: React.FC<Props> = ({
</div>
</div>
)}
{tools && (
{tools && !gtOff && (
<div className="conn-row">
<div className="conn-main">
<span className="conn-title">{tr('guestToolsPreventSleep')}</span>
+28 -42
View File
@@ -341,6 +341,13 @@ const dict = {
appCheckUpdate: '检查更新',
appDownloadUpdate: '前往下载',
appUpdateLookupFailed: '暂时无法连接 GitHub 检查更新',
aboutQQGroup: 'QQ 交流群',
aboutQQGroupSub: '点击直接拉起 QQ 加群,交流使用与问题反馈',
aboutQQNotInstalled: '未安装 QQ',
aboutQQNotInstalledSub: '未检测到本地 QQ,可复制群号手动搜索加入',
aboutQQLaunchFailed: '未能拉起 QQ,可复制群号手动搜索加入',
aboutCopyQQGroup: '复制群号',
aboutJoinQQGroup: '加入群聊',
whpxTitle: 'WHPX',
whpxReady: '就绪',
whpxNoHvShort: '未激活',
@@ -674,6 +681,8 @@ const dict = {
gtStatusWaitingTip: '在 macOS 里运行安装命令后会自动连接',
gtStatusEnabled: '已启用',
gtStatusNone: '未安装',
gtStatusOff: '已停用',
gtStatusOffTip: 'Guest Tools 传输服务已在插件页停用,剪贴板、共享文件夹与防休眠都不可用',
gtStatusUpgrade: '需要更新',
gtInstall: '安装…',
gtUpdate: '更新…',
@@ -710,11 +719,9 @@ const dict = {
pluginTrustVerified: '已审核',
pluginTrustDev: '开发',
pluginTrustCommunity: '社区',
pluginStateActive: '已启用',
pluginStateDegraded: '已降级',
pluginStateFailed: '故障',
pluginStatePending: '等待依赖',
pluginStateOff: '已停用',
pluginPermissionsLabel: '权限:{list}',
pluginHighRiskNotice: '包含高危权限,启用前需确认',
pluginViewLog: '查看日志',
@@ -729,11 +736,10 @@ const dict = {
pluginColorSchemes: '配色方案',
pluginColorSchemesHint: '修改种子色派生整套界面色阶',
pluginDeleteScheme: '删除方案',
pluginExternalSection: '第三方与附带插件',
pluginLinkDevBtn: '链接开发目录',
pluginImportBtn: '导入本地包',
pluginExternalEmpty: '尚未安装第三方插件',
pluginBuiltinSection: '内置扩展',
pluginExternalSection: '已安装插件',
pluginLinkDevBtn: '链接插件开发目录',
pluginImportBtn: '导入插件',
pluginBuiltinSection: '内置插件',
pluginPanelsSection: '插件面板',
pluginApproveTitle: '高危权限确认',
pluginApproveL3Warn: '此插件为原生可执行程序(L3 Sidecar),能够以当前 Windows 账户身份执行任意操作',
@@ -750,26 +756,13 @@ const dict = {
pluginAccentSeed: '强调种子色',
pluginSurfaceSeed: '画布种子色(可选)',
pluginSafeModeShort: '安全模式',
pluginTabAll: '全部 ({count})',
pluginTabInstalled: '已安装 ({count})',
pluginTabThemes: '主题 ({count})',
pluginTabBuiltin: '内置 ({count})',
pluginSearchPlaceholder: '筛选插件',
pluginSearchEmpty: '没有匹配的插件',
pluginAlwaysOn: '始终启用',
pluginSchemeDefault: '默认',
pluginThemeEmptyHint: '导入本地主题包(.zip)后可在此切换外观与配色方案',
pluginActiveCount: '已启用 {active} / {total}',
pluginCategoryFilter: '按类别筛选',
pluginCatAll: '全部类别',
pluginCatDriver: '驱动与运行时',
pluginCatTheme: '主题外观',
pluginCatBridge: '输入与协作',
pluginCatCompat: '兼容与工具',
pluginCatOther: '扩展',
pluginPermCount: '{count} 项权限',
pluginExternalEmptyHint: '支持导入签名或本地 .zip 插件包,或链接开发目录实时调试',
pluginInstallBarTitle: '安装本地插件',
pluginInstallBarDesc: '导入 .zip 插件包或链接本地插件开发目录',
themePluginDarkDisabled: '默认主题插件已停用,深色与跟随系统外观不可用',
themePluginLightDisabled: '当前主题仅支持深色外观',
@@ -1108,6 +1101,13 @@ const dict = {
appCheckUpdate: 'Check for updates',
appDownloadUpdate: 'Download',
appUpdateLookupFailed: 'Couldn’t check GitHub for updates',
aboutQQGroup: 'QQ Group',
aboutQQGroupSub: 'Launch QQ directly to join for community support and feedback',
aboutQQNotInstalled: 'QQ not installed',
aboutQQNotInstalledSub: 'Local QQ wasn’t detected — copy the group ID to join manually',
aboutQQLaunchFailed: 'Couldn’t launch QQ — copy the group ID to join manually',
aboutCopyQQGroup: 'Copy group ID',
aboutJoinQQGroup: 'Join group',
whpxTitle: 'WHPX',
whpxReady: 'Ready',
whpxNoHvShort: 'Inactive',
@@ -1435,6 +1435,8 @@ const dict = {
gtStatusWaitingTip: 'Connects once the install command has run in macOS',
gtStatusEnabled: 'Enabled',
gtStatusNone: 'Not installed',
gtStatusOff: 'Off',
gtStatusOffTip: 'Guest Tools Transport is turned off on the Plugins page; clipboard, shared folders and keep-awake are unavailable',
gtStatusUpgrade: 'Update needed',
gtInstall: 'Install…',
gtUpdate: 'Update…',
@@ -1474,11 +1476,9 @@ const dict = {
pluginTrustVerified: 'Verified',
pluginTrustDev: 'Dev',
pluginTrustCommunity: 'Community',
pluginStateActive: 'Active',
pluginStateDegraded: 'Degraded',
pluginStateFailed: 'Failed',
pluginStatePending: 'Pending',
pluginStateOff: 'Off',
pluginPermissionsLabel: 'Permissions: {list}',
pluginHighRiskNotice: 'Contains high-risk permissions; approval required before enabling',
pluginViewLog: 'View log',
@@ -1493,11 +1493,10 @@ const dict = {
pluginColorSchemes: 'Color schemes',
pluginColorSchemesHint: 'Seed colors derive the full surface, text, and accent ramp',
pluginDeleteScheme: 'Delete scheme',
pluginExternalSection: 'External & bundled plugins',
pluginLinkDevBtn: 'Link dev folder',
pluginImportBtn: 'Import package',
pluginExternalEmpty: 'No external plugins installed',
pluginBuiltinSection: 'Built-in extensions',
pluginExternalSection: 'Installed plugins',
pluginLinkDevBtn: 'Link plugin dev folder',
pluginImportBtn: 'Import plugin',
pluginBuiltinSection: 'Built-in plugins',
pluginPanelsSection: 'Plugin panels',
pluginApproveTitle: 'Approve high-risk permissions',
pluginApproveL3Warn: 'This plugin runs native code (L3 Sidecar) and can perform arbitrary actions as your Windows user',
@@ -1514,26 +1513,13 @@ const dict = {
pluginAccentSeed: 'Accent seed',
pluginSurfaceSeed: 'Surface seed (optional)',
pluginSafeModeShort: 'Safe mode',
pluginTabAll: 'All ({count})',
pluginTabInstalled: 'Installed ({count})',
pluginTabThemes: 'Themes ({count})',
pluginTabBuiltin: 'Built-in ({count})',
pluginSearchPlaceholder: 'Filter plugins',
pluginSearchEmpty: 'No matching plugins',
pluginAlwaysOn: 'Always on',
pluginSchemeDefault: 'Default',
pluginThemeEmptyHint: 'Import a local theme package (.zip) to switch visual themes and color schemes',
pluginActiveCount: '{active} / {total} active',
pluginCategoryFilter: 'Filter by category',
pluginCatAll: 'All types',
pluginCatDriver: 'Drivers & runtimes',
pluginCatTheme: 'Themes',
pluginCatBridge: 'Input & bridge',
pluginCatCompat: 'Compatibility',
pluginCatOther: 'Extensions',
pluginPermCount: '{count} permissions',
pluginExternalEmptyHint: 'Import a signed or local .zip package, or link a local dev folder',
pluginInstallBarTitle: 'Install local plugin',
pluginInstallBarDesc: 'Import a .zip plugin archive or link a local development directory',
themePluginDarkDisabled: 'Default theme plugin is disabled; dark and system appearances are unavailable',
themePluginLightDisabled: 'The active theme supports dark appearance only',
+1
View File
@@ -1547,6 +1547,7 @@ button.status-issue + .status-metric { margin-left: 6px; }
}
.plugin-row-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.plugin-row-alert { display: flex; align-items: center; gap: 5px; color: var(--warn-text); }
.plugin-row-fixed { font-size: var(--fs-12); color: var(--text-3); white-space: nowrap; }
.plugin-trust { display: inline-flex; align-items: center; gap: 3px; font-weight: var(--fw-medium); }
.plugin-trust.is-official, .plugin-trust.is-verified { color: var(--ok-text); }
.plugin-trust.is-dev { color: var(--accent-soft-text); }