diff --git a/packages/ui/src/product/converter/advanced-mode/sections/proxy-group-advanced-panel.test.ts b/packages/ui/src/product/converter/advanced-mode/sections/proxy-group-advanced-panel.test.ts index 7a31443..8c31f28 100644 --- a/packages/ui/src/product/converter/advanced-mode/sections/proxy-group-advanced-panel.test.ts +++ b/packages/ui/src/product/converter/advanced-mode/sections/proxy-group-advanced-panel.test.ts @@ -122,6 +122,7 @@ describe("ProxyGroupAdvancedPanel", () => { expect(html).toContain("DIRECT"); expect(html).toContain("rules-content"); expect(html).toContain("还没有分流规则"); + expect(html).toContain("max-h-52 space-y-1.5 overflow-y-auto pr-1 custom-scrollbar"); expect(mocks.inputs.map((input) => input.value)).toEqual(["Source", "Japan"]); mocks.inputs[0].onChange({ target: { value: "IEPL" } }); @@ -198,6 +199,55 @@ describe("ProxyGroupAdvancedPanel", () => { expect(html).toContain("暂无已启用的节点或代理组"); }); + it("previews enabled members for a disabled built-in proxy group", () => { + mocks.store = { + ...mocks.store, + enabledProxyGroups: [], + customProxyGroups: [], + proxyGroupAdvanced: {}, + }; + + const html = renderToStaticMarkup( + React.createElement(ProxyGroupAdvancedPanel, { + target: { kind: "module", id: "auto", name: "⚡ Auto" }, + advanced: {}, + onChange: vi.fn(), + rulesCount: 0, + rulesContent: null, + }), + ); + + expect(html).toContain("US Source"); + expect(html).toContain("Japan Source"); + expect(html).toContain("max-h-52 overflow-y-auto pr-1 custom-scrollbar flex flex-wrap gap-1.5"); + expect(html).not.toContain("暂无已启用的节点或代理组"); + }); + + it("previews enabled members for a disabled custom proxy group", () => { + mocks.store = { + ...mocks.store, + enabledProxyGroups: [], + customProxyGroups: [ + { id: "media", name: "Media", emoji: "", groupType: "select", enabled: false }, + ], + proxyGroupAdvanced: {}, + }; + + const html = renderToStaticMarkup( + React.createElement(ProxyGroupAdvancedPanel, { + target: { kind: "custom", id: "media", name: "Media" }, + advanced: {}, + onChange: vi.fn(), + rulesCount: 0, + rulesContent: null, + }), + ); + + expect(html).toContain("US Source"); + expect(html).toContain("Japan Source"); + expect(html).not.toContain("暂无已启用的节点或代理组"); + }); + it("normalizes advanced member helpers without rendering the panel", () => { const nodes = [node("US Source")]; const moduleNames = { auto: "Auto", select: "Select" }; diff --git a/packages/ui/src/product/converter/advanced-mode/sections/proxy-group-advanced-panel.tsx b/packages/ui/src/product/converter/advanced-mode/sections/proxy-group-advanced-panel.tsx index 16dbb10..a635214 100644 --- a/packages/ui/src/product/converter/advanced-mode/sections/proxy-group-advanced-panel.tsx +++ b/packages/ui/src/product/converter/advanced-mode/sections/proxy-group-advanced-panel.tsx @@ -182,6 +182,16 @@ export function ProxyGroupAdvancedPanel({ () => customProxyGroups.filter((group) => group.enabled !== false), [customProxyGroups], ); + const previewEnabledProxyGroups = React.useMemo(() => { + if (target.kind !== "module" || enabledProxyGroups.includes(target.id)) return enabledProxyGroups; + return [...enabledProxyGroups, target.id]; + }, [enabledProxyGroups, target.id, target.kind]); + const previewCustomProxyGroups = React.useMemo(() => { + if (target.kind !== "custom") return customProxyGroups; + return customProxyGroups.map((group) => + group.id === target.id && group.enabled === false ? { ...group, enabled: true } : group, + ); + }, [customProxyGroups, target.id, target.kind]); const activeNodes = React.useMemo( () => nodes.filter((node) => !isSubscriptionInfoNodeName(node.name)), @@ -202,11 +212,11 @@ export function ProxyGroupAdvancedPanel({ if (nodes.length === 0) return []; const generated = generateProxyGroups({ nodes, - enabledModules: enabledProxyGroups, + enabledModules: previewEnabledProxyGroups, ruleProviderBaseUrl, testUrl, testInterval, - customProxyGroups: activeCustomProxyGroups, + customProxyGroups: previewCustomProxyGroups, customRuleSets, proxyGroupAdvanced, builtinRuleEdits, @@ -215,11 +225,11 @@ export function ProxyGroupAdvancedPanel({ return generated.find((group) => group.name === target.name)?.proxies ?? []; }, [ nodes, - enabledProxyGroups, + previewEnabledProxyGroups, ruleProviderBaseUrl, testUrl, testInterval, - activeCustomProxyGroups, + previewCustomProxyGroups, customRuleSets, proxyGroupAdvanced, builtinRuleEdits, @@ -325,7 +335,7 @@ export function ProxyGroupAdvancedPanel({