@lynn123411/dsh-a6api 1.0.0 → 1.0.1

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/lib/client.js CHANGED
@@ -156,6 +156,7 @@ var A6ApiStore = class {
156
156
  this.state.models = this.state.models.map(
157
157
  (m) => m.model_name === modelName ? {
158
158
  ...m,
159
+ merchant: void 0,
159
160
  probeStatus: "error",
160
161
  probeError: json.result.error,
161
162
  lastProbedAt: Date.now()
@@ -167,7 +168,7 @@ var A6ApiStore = class {
167
168
  ...m,
168
169
  probeStatus: json?.result?.success ? "success" : "idle",
169
170
  probeLatencyMs: json?.result?.durationMs,
170
- probeError: void 0,
171
+ probeError: json?.result?.success ? "\u63A2\u6D4B\u6210\u529F,\u4F46\u672A\u6355\u83B7\u5546\u6237\u4FE1\u606F(\u9700\u914D\u7F6E\u7CFB\u7EDF\u8BBF\u95EE\u4EE4\u724C)" : void 0,
171
172
  lastProbedAt: Date.now()
172
173
  } : m
173
174
  );
@@ -176,6 +177,7 @@ var A6ApiStore = class {
176
177
  this.state.models = this.state.models.map(
177
178
  (m) => m.model_name === modelName ? {
178
179
  ...m,
180
+ merchant: void 0,
179
181
  probeStatus: "error",
180
182
  probeError: `HTTP ${res.status}`,
181
183
  lastProbedAt: Date.now()
@@ -186,6 +188,7 @@ var A6ApiStore = class {
186
188
  this.state.models = this.state.models.map(
187
189
  (m) => m.model_name === modelName ? {
188
190
  ...m,
191
+ merchant: void 0,
189
192
  probeStatus: "error",
190
193
  probeError: err?.message || String(err),
191
194
  lastProbedAt: Date.now()
@@ -200,8 +203,9 @@ var A6ApiStore = class {
200
203
  }
201
204
  async probeAll() {
202
205
  const allNames = this.state.models.map((m) => m.model_name);
203
- for (const name2 of allNames) {
204
- await this.probeModel(name2);
206
+ const CONCURRENCY = 3;
207
+ for (let i = 0; i < allNames.length; i += CONCURRENCY) {
208
+ await Promise.all(allNames.slice(i, i + CONCURRENCY).map((n) => this.probeModel(n)));
205
209
  }
206
210
  }
207
211
  async toggleDshModel(modelName) {
@@ -338,7 +342,15 @@ var MerchantCard = ({ model }) => {
338
342
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-a6-price-btm", title: "\u7F13\u5B58\u5199 (1M)", children: merchant.cache_write_price_cny })
339
343
  ] }),
340
344
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-a6-ratio-pill", title: "\u5B9E\u65F6\u500D\u7387\u6BD4\u5B98\u65B9\u4EF7", children: ratioText })
341
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-a6-bar-pricing unprobed", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-a6-unprobed-hint", children: isProbing ? "\u5546\u5BB6\u63A2\u6D4B\u4E2D..." : "\u5C1A\u672A\u63A2\u6D4B\u5546\u5BB6" }) }),
345
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-a6-bar-pricing unprobed", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
346
+ "div",
347
+ {
348
+ className: `dsh-a6-unprobed-hint ${model.probeError ? "error" : ""}`,
349
+ "data-tooltip": model.probeError || void 0,
350
+ "data-tooltip-pos": "down",
351
+ children: isProbing ? "\u5546\u5BB6\u63A2\u6D4B\u4E2D..." : model.probeError ? "\u63A2\u6D4B\u5931\u8D25" : "\u5C1A\u672A\u63A2\u6D4B\u5546\u5BB6"
352
+ }
353
+ ) }),
342
354
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-a6-bar-uptime", children: [
343
355
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-a6-uptime-row", children: [
344
356
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-a6-uptime-label", children: "\u5B9E\u65F6" }),
@@ -398,7 +410,7 @@ var MerchantCard = ({ model }) => {
398
410
  className: `dsh-a6-btn dsh-a6-btn-sm ${model.inDsh ? "dsh-a6-btn-in-dsh" : "dsh-a6-btn-primary"}`,
399
411
  onClick: handleToggleDsh,
400
412
  "data-tooltip": model.inDsh ? "\u5DF2\u52A0\u5165 DSH \u6A21\u578B\u9009\u62E9\u5668 (\u70B9\u51FB\u79FB\u9664)" : "\u6DFB\u52A0\u81F3 DSH \u6A21\u578B\u9009\u62E9\u5668",
401
- children: model.inDsh ? "\u5DF2\u5728 DSH" : "\u6DFB\u52A0\u5230 DSH"
413
+ children: model.inDsh ? "\u79FB\u9664\u6A21\u578B" : "\u6DFB\u52A0\u6A21\u578B"
402
414
  }
403
415
  ),
404
416
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -600,11 +612,14 @@ var AccountPanel = ({ balance, config, recentLogs = [], onNavigateToConfig }) =>
600
612
  // src/client/components/ConfigPanel.tsx
601
613
  var import_react3 = require("react");
602
614
  var import_jsx_runtime3 = require("react/jsx-runtime");
615
+ var MASK = "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022";
603
616
  var ConfigPanel = ({ config, dshConfiguredModels }) => {
604
617
  const [apiKey, setApiKey] = (0, import_react3.useState)(config.apiKey || "");
605
618
  const [accessToken, setAccessToken] = (0, import_react3.useState)(
606
619
  config.accessToken || config.sessionCookie || ""
607
620
  );
621
+ const [clearKey, setClearKey] = (0, import_react3.useState)(false);
622
+ const [clearToken, setClearToken] = (0, import_react3.useState)(false);
608
623
  const [selectedNode, setSelectedNode] = (0, import_react3.useState)(
609
624
  config.baseURL || "https://api.a6api.com"
610
625
  );
@@ -617,9 +632,13 @@ var ConfigPanel = ({ config, dshConfiguredModels }) => {
617
632
  const [showHelp, setShowHelp] = (0, import_react3.useState)(false);
618
633
  const [saving, setSaving] = (0, import_react3.useState)(false);
619
634
  const [saveSuccess, setSaveSuccess] = (0, import_react3.useState)(false);
635
+ const apiKeySet = apiKey === MASK;
636
+ const tokenSet = accessToken === MASK;
620
637
  (0, import_react3.useEffect)(() => {
621
638
  setApiKey(config.apiKey || "");
622
639
  setAccessToken(config.accessToken || config.sessionCookie || "");
640
+ setClearKey(false);
641
+ setClearToken(false);
623
642
  setSelectedNode(config.baseURL || "https://api.a6api.com");
624
643
  setCustomNode(config.customBaseURL || "");
625
644
  setIsCustom(
@@ -629,10 +648,11 @@ var ConfigPanel = ({ config, dshConfiguredModels }) => {
629
648
  const handleSave = async () => {
630
649
  setSaving(true);
631
650
  const finalBaseUrl = isCustom ? customNode.trim() || "https://api.a6api.com" : selectedNode;
651
+ const newApiKey = apiKeySet ? clearKey ? "" : void 0 : apiKey.trim();
652
+ const newToken = tokenSet ? clearToken ? "" : void 0 : accessToken.trim();
632
653
  const ok = await store.saveConfig({
633
- apiKey: apiKey.trim(),
634
- accessToken: accessToken.trim(),
635
- sessionCookie: accessToken.trim(),
654
+ ...newApiKey !== void 0 ? { apiKey: newApiKey } : {},
655
+ ...newToken !== void 0 ? { accessToken: newToken, sessionCookie: newToken } : {},
636
656
  baseURL: finalBaseUrl,
637
657
  customBaseURL: customNode.trim()
638
658
  });
@@ -704,53 +724,81 @@ var ConfigPanel = ({ config, dshConfiguredModels }) => {
704
724
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dsh-a6-field", children: [
705
725
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dsh-a6-field-header", children: [
706
726
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("label", { className: "dsh-a6-label", children: "A6API \u4EE4\u724C (API Key)" }),
707
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
708
- "button",
709
- {
710
- type: "button",
711
- className: "dsh-a6-btn-text",
712
- onClick: () => setShowKey(!showKey),
713
- children: showKey ? "\u9690\u85CF" : "\u663E\u793A"
714
- }
715
- )
727
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dsh-a6-field-header-actions", children: [
728
+ apiKeySet && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
729
+ "button",
730
+ {
731
+ type: "button",
732
+ className: "dsh-a6-btn-text",
733
+ onClick: () => {
734
+ setClearKey(true);
735
+ setApiKey("");
736
+ },
737
+ children: "\u6E05\u9664"
738
+ }
739
+ ),
740
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
741
+ "button",
742
+ {
743
+ type: "button",
744
+ className: "dsh-a6-btn-text",
745
+ onClick: () => setShowKey(!showKey),
746
+ children: showKey ? "\u9690\u85CF" : "\u663E\u793A"
747
+ }
748
+ )
749
+ ] })
716
750
  ] }),
717
751
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "dsh-a6-input-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
718
752
  "input",
719
753
  {
720
754
  type: showKey ? "text" : "password",
721
755
  className: "dsh-a6-input",
722
- placeholder: "sk-xxxxxxxxxxxxxxxxxxxxxxxx",
723
- value: apiKey,
756
+ placeholder: apiKeySet ? "\u5DF2\u4FDD\u5B58 \xB7 \u8F93\u5165\u65B0 Key \u53EF\u66FF\u6362" : "sk-xxxxxxxxxxxxxxxxxxxxxxxx",
757
+ value: apiKeySet ? "" : apiKey,
724
758
  onChange: (e) => setApiKey(e.target.value)
725
759
  }
726
760
  ) }),
727
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dsh-a6-field-hint", children: "\u7528\u4E8E\u5411 A6API \u53D1\u8D77\u6A21\u578B\u5BF9\u8BDD\u8BF7\u6C42\u4E0E\u62C9\u53D6\u767D\u540D\u5355\u6A21\u578B\u3002" })
761
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dsh-a6-field-hint", children: apiKeySet ? "\u5DF2\u914D\u7F6E API Key\uFF08\u4EC5\u4FDD\u5B58\u5728\u672C\u673A ~/.dsh/.credentials.yaml\uFF0C\u4E0D\u56DE\u4F20\u754C\u9762\uFF09\u3002" : "\u7528\u4E8E\u5411 A6API \u53D1\u8D77\u6A21\u578B\u5BF9\u8BDD\u8BF7\u6C42\u4E0E\u62C9\u53D6\u767D\u540D\u5355\u6A21\u578B\u3002" })
728
762
  ] }),
729
763
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dsh-a6-field", children: [
730
764
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dsh-a6-field-header", children: [
731
765
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("label", { className: "dsh-a6-label", children: "\u7CFB\u7EDF\u8BBF\u95EE\u4EE4\u724C (Access Token)" }),
732
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
733
- "button",
734
- {
735
- type: "button",
736
- className: "dsh-a6-btn-text",
737
- onClick: () => setShowToken(!showToken),
738
- children: showToken ? "\u9690\u85CF" : "\u663E\u793A"
739
- }
740
- )
766
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dsh-a6-field-header-actions", children: [
767
+ tokenSet && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
768
+ "button",
769
+ {
770
+ type: "button",
771
+ className: "dsh-a6-btn-text",
772
+ onClick: () => {
773
+ setClearToken(true);
774
+ setAccessToken("");
775
+ },
776
+ children: "\u6E05\u9664"
777
+ }
778
+ ),
779
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
780
+ "button",
781
+ {
782
+ type: "button",
783
+ className: "dsh-a6-btn-text",
784
+ onClick: () => setShowToken(!showToken),
785
+ children: showToken ? "\u9690\u85CF" : "\u663E\u793A"
786
+ }
787
+ )
788
+ ] })
741
789
  ] }),
742
790
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "dsh-a6-input-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
743
791
  "input",
744
792
  {
745
793
  type: showToken ? "text" : "password",
746
794
  className: "dsh-a6-input",
747
- placeholder: "\u5728\u63A7\u5236\u53F0\u5B89\u5168\u8BBE\u7F6E\u4E2D\u590D\u5236\uFF0C\u4F8B\u5982 eyJhbGciOi...",
748
- value: accessToken,
795
+ placeholder: tokenSet ? "\u5DF2\u4FDD\u5B58 \xB7 \u8F93\u5165\u65B0\u4EE4\u724C\u53EF\u66FF\u6362" : "\u5728\u63A7\u5236\u53F0\u5B89\u5168\u8BBE\u7F6E\u4E2D\u590D\u5236\uFF0C\u4F8B\u5982 eyJhbGciOi...",
796
+ value: tokenSet ? "" : accessToken,
749
797
  onChange: (e) => setAccessToken(e.target.value)
750
798
  }
751
799
  ) }),
752
800
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dsh-a6-field-footer", children: [
753
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dsh-a6-field-hint", children: "\u7528\u4E8E\u514D\u5931\u6548\u540C\u6B65\u8D26\u6237\u771F\u5B9E\u4F59\u989D\u4E0E\u5546\u6237\u6307\u6807\u3002" }),
801
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dsh-a6-field-hint", children: tokenSet ? "\u5DF2\u914D\u7F6E\u7CFB\u7EDF\u8BBF\u95EE\u4EE4\u724C\uFF08\u4EC5\u4FDD\u5B58\u5728\u672C\u673A\uFF0C\u4E0D\u56DE\u4F20\u754C\u9762\uFF09\u3002" : "\u7528\u4E8E\u514D\u5931\u6548\u540C\u6B65\u8D26\u6237\u771F\u5B9E\u4F59\u989D\u4E0E\u5546\u6237\u6307\u6807\u3002" }),
754
802
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
755
803
  "button",
756
804
  {
@@ -1022,7 +1070,7 @@ var A6ApiSettingsPanel = () => {
1022
1070
  "\u672A\u641C\u7D22\u5230\u5339\u914D\u300C",
1023
1071
  searchQuery,
1024
1072
  "\u300D\u7684\u6A21\u578B"
1025
- ] }) : filterMode === "enabled" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "\u5F53\u524D\u5C1A\u672A\u5728 DSH \u4E2D\u542F\u7528\u4EFB\u4F55 A6API \u6A21\u578B\uFF0C\u70B9\u51FB\u6A21\u578B\u5361\u7247\u53F3\u4FA7\u300C\u6DFB\u52A0\u5230 DSH\u300D\u5373\u53EF\u542F\u7528\u3002" }) : filterMode === "probed" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "\u5C1A\u672A\u63A2\u6D4B\u4EFB\u4F55\u6A21\u578B\u5546\u6237\u7EBF\u8DEF\uFF0C\u70B9\u51FB\u6A21\u578B\u5361\u7247\u4E0A\u7684\u300C\u63A2\u6D4B\u5546\u5BB6\u300D\u6216\u4E0A\u65B9\u300C\u4E00\u952E\u5168\u91CF\u63A2\u6D4B\u300D\u5373\u53EF\u5F00\u59CB\u3002" }) : !state.config.apiKey ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "\u8BF7\u524D\u5F80\u300C\u57FA\u7840\u914D\u7F6E\u300D\u9875\u9762\u586B\u5165\u60A8\u7684 A6API \u4EE4\u724C (API Key) \u5E76\u4FDD\u5B58\uFF0C\u5373\u53EF\u81EA\u52A8\u52A0\u8F7D\u53EF\u7528\u6A21\u578B\u5217\u8868\u3002" }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "\u5F53\u524D\u4EE4\u724C\u6682\u65E0\u53EF\u7528\u6A21\u578B\uFF0C\u8BF7\u68C0\u67E5 A6API \u63A7\u5236\u53F0\u4E2D\u7684\u4EE4\u724C\u9650\u5236\u8BBE\u7F6E\u3002" }) }) })
1073
+ ] }) : filterMode === "enabled" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "\u5F53\u524D\u5C1A\u672A\u5728 DSH \u4E2D\u542F\u7528\u4EFB\u4F55 A6API \u6A21\u578B\uFF0C\u70B9\u51FB\u6A21\u578B\u5361\u7247\u53F3\u4FA7\u300C\u6DFB\u52A0\u5230 DSH\u300D\u5373\u53EF\u542F\u7528\u3002" }) : filterMode === "probed" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "\u5C1A\u672A\u63A2\u6D4B\u4EFB\u4F55\u6A21\u578B\u5546\u6237\u7EBF\u8DEF\uFF0C\u70B9\u51FB\u6A21\u578B\u5361\u7247\u4E0A\u7684\u300C\u63A2\u6D4B\u5546\u5BB6\u300D\u6216\u4E0A\u65B9\u300C\u4E00\u952E\u5168\u91CF\u63A2\u6D4B\u300D\u5373\u53EF\u5F00\u59CB\u3002" }) : !state.config.hasApiKey ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "\u8BF7\u524D\u5F80\u300C\u57FA\u7840\u914D\u7F6E\u300D\u9875\u9762\u586B\u5165\u60A8\u7684 A6API \u4EE4\u724C (API Key) \u5E76\u4FDD\u5B58\uFF0C\u5373\u53EF\u81EA\u52A8\u52A0\u8F7D\u53EF\u7528\u6A21\u578B\u5217\u8868\u3002" }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "\u5F53\u524D\u4EE4\u724C\u6682\u65E0\u53EF\u7528\u6A21\u578B\uFF0C\u8BF7\u68C0\u67E5 A6API \u63A7\u5236\u53F0\u4E2D\u7684\u4EE4\u724C\u9650\u5236\u8BBE\u7F6E\u3002" }) }) })
1026
1074
  ] }),
1027
1075
  activeTab === "account" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "dsh-a6-tab-page account-page", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1028
1076
  AccountPanel,
@@ -1339,6 +1387,19 @@ var main_default = `/* A6API Plugin Styles - Clean Professional DSH Native Theme
1339
1387
  color: var(--dsw-alias-label-secondary, #475569);
1340
1388
  }
1341
1389
 
1390
+ .dsh-a6-probe-fail-chip {
1391
+ margin-left: 8px;
1392
+ font-size: 11px;
1393
+ font-weight: 600;
1394
+ color: #dc2626;
1395
+ background: rgba(220, 38, 38, 0.08);
1396
+ border: 1px solid rgba(220, 38, 38, 0.35);
1397
+ border-radius: 999px;
1398
+ padding: 1px 8px;
1399
+ white-space: nowrap;
1400
+ cursor: help;
1401
+ }
1402
+
1342
1403
  .dsh-a6-sub-desc {
1343
1404
  font-size: 11px;
1344
1405
  color: var(--dsw-alias-label-tertiary, #94a3b8);
@@ -1357,6 +1418,11 @@ var main_default = `/* A6API Plugin Styles - Clean Professional DSH Native Theme
1357
1418
  font-size: 12px;
1358
1419
  }
1359
1420
 
1421
+ .dsh-a6-unprobed-hint.error {
1422
+ color: #dc2626;
1423
+ font-weight: 600;
1424
+ }
1425
+
1360
1426
  .dsh-a6-price-col {
1361
1427
  display: flex;
1362
1428
  flex-direction: column;
@@ -2051,6 +2117,12 @@ var main_default = `/* A6API Plugin Styles - Clean Professional DSH Native Theme
2051
2117
  align-items: center;
2052
2118
  }
2053
2119
 
2120
+ .dsh-a6-field-header-actions {
2121
+ display: flex;
2122
+ align-items: center;
2123
+ gap: 8px;
2124
+ }
2125
+
2054
2126
  .dsh-a6-label {
2055
2127
  font-size: 12px;
2056
2128
  font-weight: 600;