(e)
| 1132 | |
| 1133 | // 保存代理 |
| 1134 | async function handleSaveProxyItem(e) { |
| 1135 | e.preventDefault(); |
| 1136 | |
| 1137 | const proxyId = document.getElementById('proxy-item-id').value; |
| 1138 | const data = { |
| 1139 | name: document.getElementById('proxy-item-name').value, |
| 1140 | type: document.getElementById('proxy-item-type').value, |
| 1141 | host: document.getElementById('proxy-item-host').value, |
| 1142 | port: parseInt(document.getElementById('proxy-item-port').value), |
| 1143 | username: document.getElementById('proxy-item-username').value || null, |
| 1144 | password: document.getElementById('proxy-item-password').value || null, |
| 1145 | enabled: true |
| 1146 | }; |
| 1147 | |
| 1148 | try { |
| 1149 | if (proxyId) { |
| 1150 | await api.patch(`/settings/proxies/${proxyId}`, data); |
| 1151 | toast.success('代理已更新'); |
| 1152 | } else { |
| 1153 | await api.post('/settings/proxies', data); |
| 1154 | toast.success('代理已添加'); |
| 1155 | } |
| 1156 | closeProxyModal(); |
| 1157 | loadProxies(); |
| 1158 | } catch (error) { |
| 1159 | toast.error('保存失败: ' + error.message); |
| 1160 | } |
| 1161 | } |
| 1162 | |
| 1163 | // 编辑代理 |
| 1164 | async function editProxyItem(id) { |
nothing calls this directly
no test coverage detected