|
1 | 1 | import { |
2 | 2 | Cancel, |
3 | 3 | CheckCircle, |
| 4 | + Dns as DnsIcon, |
4 | 5 | Info as InfoIcon, |
5 | 6 | NorthEast as NorthEastIcon, |
6 | 7 | Settings as SettingsIcon |
@@ -55,6 +56,32 @@ function IndexPopup() { |
55 | 56 | chrome.tabs.create({ url: optionsUrl }) |
56 | 57 | } |
57 | 58 |
|
| 59 | + const handleRemoteServerClick = () => { |
| 60 | + setErrorMessage(null) |
| 61 | + const { servers, selectedServer } = settings.remote |
| 62 | + if (servers.length > 0) { |
| 63 | + // Check if the selected server exists in the server list |
| 64 | + const activeServer = servers.find( |
| 65 | + (s) => `${s.protocol}://${s.url}` === selectedServer |
| 66 | + ) |
| 67 | + |
| 68 | + let targetUrl = "" |
| 69 | + if (activeServer) { |
| 70 | + targetUrl = selectedServer |
| 71 | + } else { |
| 72 | + // Fallback to the first server if no server is selected or the selected server is not found |
| 73 | + const first = servers[0] |
| 74 | + targetUrl = `${first.protocol}://${first.url}` |
| 75 | + } |
| 76 | + |
| 77 | + if (targetUrl) { |
| 78 | + chrome.tabs.create({ url: targetUrl }) |
| 79 | + } |
| 80 | + } else { |
| 81 | + setErrorMessage(chrome.i18n.getMessage("no_server_error")) |
| 82 | + } |
| 83 | + } |
| 84 | + |
58 | 85 | const handleGitHubClick = () => { |
59 | 86 | chrome.tabs.create({ |
60 | 87 | url: "https://github.com/GopeedLab/browser-extension" |
@@ -140,6 +167,16 @@ function IndexPopup() { |
140 | 167 | /> |
141 | 168 | </ListItemButton> |
142 | 169 | </ListItem> |
| 170 | + <ListItem disablePadding> |
| 171 | + <ListItemButton onClick={handleRemoteServerClick}> |
| 172 | + <ListItemIcon> |
| 173 | + <DnsIcon /> |
| 174 | + </ListItemIcon> |
| 175 | + <ListItemText |
| 176 | + primary={chrome.i18n.getMessage("remote_server")} |
| 177 | + /> |
| 178 | + </ListItemButton> |
| 179 | + </ListItem> |
143 | 180 | <ListItem disablePadding> |
144 | 181 | <ListItemButton onClick={handleSettingsClick}> |
145 | 182 | <ListItemIcon> |
|
0 commit comments