protocol-proxy 2.1.1 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/public/app.js +1 -22
- package/public/index.html +0 -1
- package/server.js +1 -1
package/package.json
CHANGED
package/public/app.js
CHANGED
|
@@ -40,7 +40,6 @@ function initProviderDropdown() {
|
|
|
40
40
|
const dropdown = document.getElementById('provider-dropdown');
|
|
41
41
|
const addNameInput = document.getElementById('provider-add-name');
|
|
42
42
|
const addUrlInput = document.getElementById('provider-add-url');
|
|
43
|
-
const addKeyInput = document.getElementById('provider-add-key');
|
|
44
43
|
const addBtn = document.getElementById('provider-add-btn');
|
|
45
44
|
|
|
46
45
|
trigger.addEventListener('click', (e) => {
|
|
@@ -50,7 +49,6 @@ function initProviderDropdown() {
|
|
|
50
49
|
editingProviderId = null;
|
|
51
50
|
addNameInput.value = '';
|
|
52
51
|
addUrlInput.value = '';
|
|
53
|
-
addKeyInput.value = '';
|
|
54
52
|
addUrlInput.disabled = false;
|
|
55
53
|
addBtn.textContent = '添加';
|
|
56
54
|
renderProviderOptions();
|
|
@@ -82,13 +80,10 @@ function initProviderDropdown() {
|
|
|
82
80
|
});
|
|
83
81
|
} else {
|
|
84
82
|
// 新增模式
|
|
85
|
-
const body = { name, url };
|
|
86
|
-
const key = addKeyInput.value.trim();
|
|
87
|
-
if (key) body.apiKey = key;
|
|
88
83
|
res = await fetch('/api/providers', {
|
|
89
84
|
method: 'POST',
|
|
90
85
|
headers: { 'Content-Type': 'application/json' },
|
|
91
|
-
body: JSON.stringify(
|
|
86
|
+
body: JSON.stringify({ name, url }),
|
|
92
87
|
});
|
|
93
88
|
}
|
|
94
89
|
if (!res.ok) {
|
|
@@ -102,7 +97,6 @@ function initProviderDropdown() {
|
|
|
102
97
|
addBtn.textContent = '添加';
|
|
103
98
|
addNameInput.value = '';
|
|
104
99
|
addUrlInput.value = '';
|
|
105
|
-
addKeyInput.value = '';
|
|
106
100
|
await loadProviders();
|
|
107
101
|
selectProvider(provider.id);
|
|
108
102
|
renderProviderOptions();
|
|
@@ -161,7 +155,6 @@ function renderProviderOptions() {
|
|
|
161
155
|
editingProviderId = id;
|
|
162
156
|
document.getElementById('provider-add-name').value = p.name;
|
|
163
157
|
document.getElementById('provider-add-url').value = p.url;
|
|
164
|
-
document.getElementById('provider-add-key').value = p.apiKey || '';
|
|
165
158
|
document.getElementById('provider-add-url').disabled = true;
|
|
166
159
|
document.getElementById('provider-add-btn').textContent = '更新';
|
|
167
160
|
} catch (err) {
|
|
@@ -208,14 +201,6 @@ function selectProvider(id) {
|
|
|
208
201
|
const models = provider?.models || [];
|
|
209
202
|
selectModel(models[0] || '');
|
|
210
203
|
updateModelAddState();
|
|
211
|
-
// 加载供应商的 API Key
|
|
212
|
-
if (id) {
|
|
213
|
-
fetch(`/api/providers/${id}`).then(r => r.json()).then(p => {
|
|
214
|
-
document.getElementById('target-key').value = p.apiKey || '';
|
|
215
|
-
}).catch(() => {});
|
|
216
|
-
} else {
|
|
217
|
-
document.getElementById('target-key').value = '';
|
|
218
|
-
}
|
|
219
204
|
}
|
|
220
205
|
|
|
221
206
|
// ==================== Model 下拉框 ====================
|
|
@@ -505,12 +490,6 @@ function openModal(id = null) {
|
|
|
505
490
|
document.getElementById('auth-token-group').style.display = p.requireAuth ? 'block' : 'none';
|
|
506
491
|
selectProvider(p.providerId || '');
|
|
507
492
|
selectModel(p.defaultModel || '');
|
|
508
|
-
// 加载供应商的 API Key
|
|
509
|
-
if (p.providerId) {
|
|
510
|
-
fetch(`/api/providers/${p.providerId}`).then(r => r.json()).then(provider => {
|
|
511
|
-
document.getElementById('target-key').value = provider.apiKey || '';
|
|
512
|
-
}).catch(() => {});
|
|
513
|
-
}
|
|
514
493
|
} else {
|
|
515
494
|
document.getElementById('proxy-id').value = '';
|
|
516
495
|
document.getElementById('auth-token-group').style.display = 'none';
|
package/public/index.html
CHANGED
|
@@ -85,7 +85,6 @@
|
|
|
85
85
|
<div class="model-add-section">
|
|
86
86
|
<input type="text" class="model-add-input" id="provider-add-name" placeholder="供应商名称">
|
|
87
87
|
<input type="text" class="model-add-input" id="provider-add-url" placeholder="https://api.example.com">
|
|
88
|
-
<input type="password" class="model-add-input" id="provider-add-key" placeholder="API Key (可选)">
|
|
89
88
|
<button type="button" class="btn btn-primary btn-sm" id="provider-add-btn">添加</button>
|
|
90
89
|
</div>
|
|
91
90
|
</div>
|
package/server.js
CHANGED
|
@@ -190,7 +190,7 @@ async function init() {
|
|
|
190
190
|
app.get('/api/providers/:id', (req, res) => {
|
|
191
191
|
const provider = configStore.getProviderById(req.params.id);
|
|
192
192
|
if (!provider) return res.status(404).json({ error: 'Provider not found' });
|
|
193
|
-
res.json(provider);
|
|
193
|
+
res.json({ ...provider, apiKey: provider.apiKey ? '***' : '' });
|
|
194
194
|
});
|
|
195
195
|
|
|
196
196
|
app.post('/api/providers', (req, res) => {
|