protocol-proxy 1.1.0 → 1.1.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/public/app.js +22 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "protocol-proxy",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "OpenAI / Anthropic 协议转换透明代理",
5
5
  "main": "server.js",
6
6
  "bin": {
package/public/app.js CHANGED
@@ -162,6 +162,7 @@ function renderProviderOptions() {
162
162
  if (!ok) return;
163
163
  const providers = loadProviders().filter(pr => pr.url !== url);
164
164
  saveProviders(providers);
165
+ localStorage.removeItem(getModelKey(url));
165
166
  if (getSelectedProviderUrl() === url) {
166
167
  selectProvider('');
167
168
  }
@@ -481,6 +482,27 @@ function openModal(id = null) {
481
482
  if (t.providerUrl && !findProviderByUrl(t.providerUrl)) {
482
483
  addProvider(getProviderDisplayName(t.providerUrl), t.providerUrl);
483
484
  }
485
+
486
+ // 迁移旧模型数据:从按代理ID存储 → 按供应商URL存储
487
+ if (t.providerUrl) {
488
+ const existingByProvider = loadModelsByProvider(t.providerUrl);
489
+ if (existingByProvider.length === 0) {
490
+ // 优先用服务端的模型列表
491
+ let modelsToMigrate = Array.isArray(t.models) ? t.models.filter(Boolean) : [];
492
+ // 兼容旧版 localStorage(按代理ID存储)
493
+ if (modelsToMigrate.length === 0) {
494
+ const legacyKey = `protocol-proxy-models-${id}`;
495
+ try {
496
+ const legacy = JSON.parse(localStorage.getItem(legacyKey));
497
+ if (Array.isArray(legacy)) modelsToMigrate = legacy;
498
+ } catch {}
499
+ }
500
+ if (modelsToMigrate.length > 0) {
501
+ saveModelsByProvider(t.providerUrl, modelsToMigrate);
502
+ }
503
+ }
504
+ }
505
+
484
506
  selectProvider(t.providerUrl || '');
485
507
  selectModel(t.defaultModel || '');
486
508
  } else {