MCPcopy Create free account
hub / github.com/Tron521/codex-console-temp / handleSaveSub2ApiService

Function handleSaveSub2ApiService

static/js/settings.js:1553–1583  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

1551}
1552
1553async function handleSaveSub2ApiService(e) {
1554 e.preventDefault();
1555 const id = document.getElementById('sub2api-service-id').value;
1556 const data = {
1557 name: document.getElementById('sub2api-service-name').value,
1558 api_url: document.getElementById('sub2api-service-url').value,
1559 api_key: document.getElementById('sub2api-service-key').value || undefined,
1560 target_type: document.getElementById('sub2api-service-target-type').value || 'sub2api',
1561 priority: parseInt(document.getElementById('sub2api-service-priority').value) || 0,
1562 enabled: document.getElementById('sub2api-service-enabled').checked,
1563 };
1564 if (!id && !data.api_key) {
1565 toast.error('请填写 API Key');
1566 return;
1567 }
1568 if (!data.api_key) delete data.api_key;
1569
1570 try {
1571 if (id) {
1572 await api.patch(`/sub2api-services/${id}`, data);
1573 toast.success('服务已更新');
1574 } else {
1575 await api.post('/sub2api-services', data);
1576 toast.success('服务已添加');
1577 }
1578 closeSub2ApiServiceModal();
1579 loadSub2ApiServices();
1580 } catch (e) {
1581 toast.error('保存失败: ' + e.message);
1582 }
1583}
1584
1585async function testSub2ApiServiceById(id) {
1586 try {

Callers

nothing calls this directly

Calls 6

closeSub2ApiServiceModalFunction · 0.85
loadSub2ApiServicesFunction · 0.85
errorMethod · 0.80
successMethod · 0.80
patchMethod · 0.45
postMethod · 0.45

Tested by

no test coverage detected