From 08c12c2959696c0ac40809b820fc9c24c29e40b1 Mon Sep 17 00:00:00 2001 From: go0p Date: Tue, 15 Apr 2025 13:37:14 +0800 Subject: [PATCH] fix popup ui --- src/entrypoints/options/App.css | 36 ++++++++++++--- src/entrypoints/options/App.tsx | 79 +++++++++++++++++++++++++++------ src/types/proxy.ts | 2 + 3 files changed, 99 insertions(+), 18 deletions(-) diff --git a/src/entrypoints/options/App.css b/src/entrypoints/options/App.css index 35a92f9..089f81e 100644 --- a/src/entrypoints/options/App.css +++ b/src/entrypoints/options/App.css @@ -8,21 +8,46 @@ align-items: center; justify-content: center; padding: 0 24px; + height: 64px; } .options-content { - padding: 24px; - max-width: 800px; + padding: 32px; + min-width: 600px; margin: 0 auto; background-color: #f5f5f5; } .proxy-list-card { - margin-bottom: 24px; + margin-bottom: 32px; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); +} + +.proxy-list-card .ant-card-head { + padding: 0 16px; + min-height: 48px; +} + +.proxy-list-card .ant-card-head-title { + padding: 14px 0; + font-size: 16px; +} + +.proxy-list-card .ant-card-head-wrapper { + display: flex; + align-items: center; +} + +.proxy-list-card .ant-card-extra { + padding: 8px 0; +} + +.proxy-list-card .ant-card-body { + padding: 24px; } .proxy-list-card .ant-list-item { - padding: 12px 24px; + padding: 16px 24px; transition: all 0.3s; } @@ -31,7 +56,8 @@ } .add-proxy-card { - margin-bottom: 24px; + margin-bottom: 32px; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); } .ant-space { diff --git a/src/entrypoints/options/App.tsx b/src/entrypoints/options/App.tsx index 508df8b..504ccb2 100644 --- a/src/entrypoints/options/App.tsx +++ b/src/entrypoints/options/App.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect } from 'react'; -import { ConfigProvider, Layout, Typography, List, Button, Form, Input, Select, Space, Card, Divider } from 'antd'; +import { ConfigProvider, Layout, Typography, List, Button, Form, Input, Select, Space, Card, Divider, Modal } from 'antd'; import { PlusOutlined, DeleteOutlined } from '@ant-design/icons'; import { v4 as uuidv4 } from 'uuid'; import { browser } from 'wxt/browser'; @@ -16,6 +16,7 @@ export default function App() { const [proxies, setProxies] = useState([]); const [form] = Form.useForm(); const [loading, setLoading] = useState(false); + const [isModalOpen, setIsModalOpen] = useState(false); useEffect(() => { loadProxies(); @@ -23,7 +24,7 @@ export default function App() { // 监听添加代理请求 const handleMessage = (message: any) => { if (message.action === ContentActionType.TRIGGER_ADD_PROXY) { - document.getElementById('add-proxy-form')?.scrollIntoView({ behavior: 'smooth' }); + setIsModalOpen(true); } }; @@ -36,7 +37,7 @@ export default function App() { const loadProxies = async () => { try { const configs = await getAllProxyConfigs(); - setProxies(configs.filter(config => config.proxyType !== 'direct' && config.proxyType !== 'system')); + setProxies(configs.filter(config => config.proxyType === "fixed_servers")); } catch (error) { console.error('Error loading proxies:', error); } @@ -49,14 +50,15 @@ export default function App() { const newProxy: ProxyConfig = { id: uuidv4(), name: values.name, - proxyType: values.proxyType, + proxyType: "fixed_servers", + scheme: values.proxyType, host: values.host, port: Number(values.port), enabled: false }; - // if (values.username) newProxy.username = values.username; - // if (values.password) newProxy.password = values.password; + if (values.username) newProxy.username = values.username; + if (values.password) newProxy.password = values.password; await saveProxyConfig(newProxy); @@ -66,6 +68,9 @@ export default function App() { // 重置表单 form.resetFields(); + // 关闭模态框 + setIsModalOpen(false); + // 通知后台脚本 browser.runtime.sendMessage({ action: ContentActionType.PROXY_CONFIGS_UPDATED, @@ -111,6 +116,15 @@ export default function App() { } }; + const showModal = () => { + form.resetFields(); + setIsModalOpen(true); + }; + + const handleCancel = () => { + setIsModalOpen(false); + }; + return ( Yaklang 代理管理设置 - + } + onClick={showModal} + size="small" + style={{ + backgroundColor: "#F28B44", + borderColor: "#F28B44", + borderRadius: "4px", + fontSize: "13px" + }} + > + 添加代理 + + } + > +
+ No data +
+

还没有添加任何代理

+ + ) + }} renderItem={(proxy) => ( )} />
- - - - + {/* */} + +
-
+
diff --git a/src/types/proxy.ts b/src/types/proxy.ts index e59abb3..08647d2 100644 --- a/src/types/proxy.ts +++ b/src/types/proxy.ts @@ -16,6 +16,8 @@ export interface ProxyConfig { pacScript?: PacScript; bypassList?: string[]; matchList?: string[]; + username?: string; + password?: string; } export interface ProxyLog {