From f399277047b175ed304517b9bf9386316d417c55 Mon Sep 17 00:00:00 2001 From: QLHazyCoder <2825305047@qq.com> Date: Tue, 28 Apr 2026 19:48:07 +0800 Subject: [PATCH] =?UTF-8?q?feat(ip-proxy):=20=E6=B7=BB=E5=8A=A0=20IP=20?= =?UTF-8?q?=E4=BB=A3=E7=90=86=E9=9D=A2=E6=9D=BF=E7=9A=84=E5=B1=95=E5=BC=80?= =?UTF-8?q?/=E6=94=B6=E8=B5=B7=E5=8A=9F=E8=83=BD=E5=8F=8A=E6=8C=81?= =?UTF-8?q?=E4=B9=85=E5=8C=96=E7=8A=B6=E6=80=81=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sidepanel/ip-proxy-panel.js | 88 +++++++++++++++---- sidepanel/sidepanel.css | 5 ++ sidepanel/sidepanel.html | 2 + sidepanel/sidepanel.js | 10 +++ ...epanel-phone-verification-settings.test.js | 14 +++ 5 files changed, 100 insertions(+), 19 deletions(-) diff --git a/sidepanel/ip-proxy-panel.js b/sidepanel/ip-proxy-panel.js index 6ae4002..947a9de 100644 --- a/sidepanel/ip-proxy-panel.js +++ b/sidepanel/ip-proxy-panel.js @@ -14,6 +14,47 @@ const ipProxyActionState = { busy: false, action: '', }; +const IP_PROXY_SECTION_EXPANDED_STORAGE_KEY = 'multipage-ip-proxy-section-expanded'; +let ipProxySectionExpanded = false; + +function readIpProxySectionExpanded() { + try { + return globalThis.localStorage?.getItem(IP_PROXY_SECTION_EXPANDED_STORAGE_KEY) === '1'; + } catch (err) { + return false; + } +} + +function persistIpProxySectionExpanded(expanded) { + try { + if (expanded) { + globalThis.localStorage?.setItem(IP_PROXY_SECTION_EXPANDED_STORAGE_KEY, '1'); + } else { + globalThis.localStorage?.removeItem(IP_PROXY_SECTION_EXPANDED_STORAGE_KEY); + } + } catch (err) { + // Ignore storage errors; the in-memory collapsed state is still enough for this session. + } +} + +function setIpProxySectionExpanded(expanded) { + ipProxySectionExpanded = Boolean(expanded); + persistIpProxySectionExpanded(ipProxySectionExpanded); + if (typeof updateIpProxyUI === 'function') { + updateIpProxyUI(latestState); + } +} + +function toggleIpProxySectionExpanded() { + setIpProxySectionExpanded(!ipProxySectionExpanded); +} + +function initIpProxySectionExpandedState() { + ipProxySectionExpanded = readIpProxySectionExpanded(); + if (typeof updateIpProxyUI === 'function') { + updateIpProxyUI(latestState); + } +} function normalizeIpProxyActionType(value = '') { const normalized = String(value || '').trim().toLowerCase(); @@ -1158,6 +1199,7 @@ function setIpProxyEnabledInlineStatus(state = {}, enabled = getSelectedIpProxyE function updateIpProxyUI(state = latestState) { const enabled = getSelectedIpProxyEnabled(); + const showSettings = enabled && ipProxySectionExpanded; const mode = getSelectedIpProxyMode(); const service = normalizeIpProxyService(selectIpProxyService?.value || state?.ipProxyService || DEFAULT_IP_PROXY_SERVICE); const apiModeAvailable = isIpProxyApiModeAvailable(); @@ -1175,59 +1217,67 @@ function updateIpProxyUI(state = latestState) { if (rowIpProxyEnabled) { rowIpProxyEnabled.style.display = ''; } + if (btnToggleIpProxySection) { + btnToggleIpProxySection.disabled = !enabled; + btnToggleIpProxySection.textContent = showSettings ? '收起设置' : '展开设置'; + btnToggleIpProxySection.title = enabled + ? (showSettings ? '收起 IP 代理设置' : '展开 IP 代理设置') + : '开启 IP 代理后可展开设置'; + btnToggleIpProxySection.setAttribute('aria-expanded', String(showSettings)); + } if (rowIpProxyFold) { - rowIpProxyFold.style.display = enabled ? '' : 'none'; + rowIpProxyFold.style.display = showSettings ? '' : 'none'; } if (rowIpProxyService) { - rowIpProxyService.style.display = enabled ? '' : 'none'; + rowIpProxyService.style.display = showSettings ? '' : 'none'; } if (rowIpProxyMode) { - rowIpProxyMode.style.display = enabled ? '' : 'none'; + rowIpProxyMode.style.display = showSettings ? '' : 'none'; } if (rowIpProxyLayout) { - rowIpProxyLayout.style.display = enabled ? '' : 'none'; + rowIpProxyLayout.style.display = showSettings ? '' : 'none'; } if (rowIpProxyApiUrl) { - rowIpProxyApiUrl.style.display = enabled && apiModeAvailable && isApiMode ? '' : 'none'; + rowIpProxyApiUrl.style.display = showSettings && apiModeAvailable && isApiMode ? '' : 'none'; } if (rowIpProxyAccountList) { - rowIpProxyAccountList.style.display = enabled && isAccountMode && accountListAvailable ? '' : 'none'; + rowIpProxyAccountList.style.display = showSettings && isAccountMode && accountListAvailable ? '' : 'none'; } if (rowIpProxyAccountSessionPrefix) { - rowIpProxyAccountSessionPrefix.style.display = enabled && showSessionOptions ? '' : 'none'; + rowIpProxyAccountSessionPrefix.style.display = showSettings && showSessionOptions ? '' : 'none'; } if (rowIpProxyAccountLifeMinutes) { - rowIpProxyAccountLifeMinutes.style.display = enabled && showSessionOptions ? '' : 'none'; + rowIpProxyAccountLifeMinutes.style.display = showSettings && showSessionOptions ? '' : 'none'; } if (rowIpProxyPoolTargetCount) { - rowIpProxyPoolTargetCount.style.display = enabled ? '' : 'none'; + rowIpProxyPoolTargetCount.style.display = showSettings ? '' : 'none'; } if (rowIpProxyHost) { - rowIpProxyHost.style.display = enabled && isAccountMode ? '' : 'none'; + rowIpProxyHost.style.display = showSettings && isAccountMode ? '' : 'none'; } if (rowIpProxyPort) { - rowIpProxyPort.style.display = enabled && isAccountMode ? '' : 'none'; + rowIpProxyPort.style.display = showSettings && isAccountMode ? '' : 'none'; } if (rowIpProxyProtocol) { - rowIpProxyProtocol.style.display = enabled ? '' : 'none'; + rowIpProxyProtocol.style.display = showSettings ? '' : 'none'; } if (rowIpProxyUsername) { - rowIpProxyUsername.style.display = enabled && isAccountMode ? '' : 'none'; + rowIpProxyUsername.style.display = showSettings && isAccountMode ? '' : 'none'; } if (rowIpProxyPassword) { - rowIpProxyPassword.style.display = enabled && isAccountMode ? '' : 'none'; + rowIpProxyPassword.style.display = showSettings && isAccountMode ? '' : 'none'; } if (rowIpProxyRegion) { - rowIpProxyRegion.style.display = enabled && isAccountMode ? '' : 'none'; + rowIpProxyRegion.style.display = showSettings && isAccountMode ? '' : 'none'; } if (rowIpProxyActions) { - rowIpProxyActions.style.display = enabled ? '' : 'none'; + rowIpProxyActions.style.display = showSettings ? '' : 'none'; } if (ipProxyActionButtons) { - ipProxyActionButtons.style.display = enabled ? '' : 'none'; + ipProxyActionButtons.style.display = showSettings ? '' : 'none'; } if (rowIpProxyRuntimeStatus) { - rowIpProxyRuntimeStatus.style.display = enabled ? '' : 'none'; + rowIpProxyRuntimeStatus.style.display = showSettings ? '' : 'none'; } if (ipProxyLayout) { ipProxyLayout.classList.toggle('is-account-only', !apiModeAvailable); @@ -1254,7 +1304,7 @@ function updateIpProxyUI(state = latestState) { ipProxyApiPanel.classList.toggle('is-disabled', !apiModeAvailable); ipProxyApiPanel.setAttribute('aria-disabled', String(!apiModeAvailable)); ipProxyApiPanel.hidden = !apiModeAvailable; - ipProxyApiPanel.style.display = enabled && apiModeAvailable ? '' : 'none'; + ipProxyApiPanel.style.display = showSettings && apiModeAvailable ? '' : 'none'; } if (inputIpProxyApiUrl) { inputIpProxyApiUrl.disabled = !enabled || !apiModeAvailable; diff --git a/sidepanel/sidepanel.css b/sidepanel/sidepanel.css index 404c144..b91977d 100644 --- a/sidepanel/sidepanel.css +++ b/sidepanel/sidepanel.css @@ -791,6 +791,11 @@ header { .ip-proxy-header-actions { flex: 0 0 auto; + align-items: center; +} + +#btn-toggle-ip-proxy-section { + white-space: nowrap; } .ip-proxy-fold { diff --git a/sidepanel/sidepanel.html b/sidepanel/sidepanel.html index b9a7cb3..ad23478 100644 --- a/sidepanel/sidepanel.html +++ b/sidepanel/sidepanel.html @@ -454,6 +454,8 @@ 用于浏览器代理接管与出口切换
+