dsh-free-search 0.9.48 → 0.9.50

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/lib/client.js +294 -372
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -301,13 +301,13 @@ window.__ModuleLoader__.load({
301
301
  }
302
302
  //#endregion
303
303
 
304
- const BRIDGE_PATH = "api/dsh-free-search-settings";
305
- const bridgeUrl = (endpoint) => {
306
- try {
307
- return new URL(`${BRIDGE_PATH}/${endpoint}`, document.baseURI).toString();
308
- } catch {
309
- return `/${BRIDGE_PATH}/${endpoint}`;
310
- }
304
+ const BRIDGE_PATH = "api/dsh-free-search-settings";
305
+ const bridgeUrl = (endpoint) => {
306
+ try {
307
+ return new URL(`${BRIDGE_PATH}/${endpoint}`, document.baseURI).toString();
308
+ } catch {
309
+ return `/${BRIDGE_PATH}/${endpoint}`;
310
+ }
311
311
  };
312
312
  // rc.1: the settings namespace is the profile composition entry id (the
313
313
  // `web-search-free` row declared by cordis.patch.yml), not the old `free-search`
@@ -361,6 +361,9 @@ window.__ModuleLoader__.load({
361
361
  allowlistMode: "只使用勾选的引擎",
362
362
  allowlistHint: "开启后只有勾选的引擎可用,新版本新增的引擎默认不启用。",
363
363
  fallbackPriority: "全局回退优先级",
364
+ engineSettings: "设置",
365
+ explicitEnginesLabel: "仅手动选择",
366
+ explicitEnginesHint: "这些引擎不会进入自动回退,只在明确选择时运行。",
364
367
  fallbackPriorityHint: "从上到下为回退顺序。首选引擎仍先尝试;Auto 保留语言/时间路由,但自定义后同一分组内及后续回退按此顺序。禁用引擎不会执行,但会保留当前位置。",
365
368
  fallbackPriorityReset: "恢复默认顺序",
366
369
  zhPoolLabel: "中文查询池",
@@ -474,10 +477,10 @@ window.__ModuleLoader__.load({
474
477
  yuanbaoModeHybrid: "混合结果",
475
478
  yuanbaoModeHint: "自然结果最通用;权威/多模态适合天气、股价、汇率等时效信息。",
476
479
  yuanbaoSiteLabel: "限定站点(可选)",
477
- yuanbaoSiteHint: "只搜某个域名时填写,例如 qq.com;留空搜索全网。",
478
- deepseekToolsKeyLabel: "DeepSeek 搜索 API key(可选)",
479
- deepseekToolsKeyHint: "留空复用现有 DeepSeek API key;自定义网关可以单独填。",
480
- deepseekToolsUrlLabel: "DeepSeek 搜索端点(可选)",
480
+ yuanbaoSiteHint: "只搜某个域名时填写,例如 qq.com;留空搜索全网。",
481
+ deepseekToolsKeyLabel: "DeepSeek 搜索 API key(可选)",
482
+ deepseekToolsKeyHint: "留空复用现有 DeepSeek API key;自定义网关可以单独填。",
483
+ deepseekToolsUrlLabel: "DeepSeek 搜索端点(可选)",
481
484
  deepseekToolsUrlHint: "留空使用 https://api.deepseek.com/v1/tools/search;可填完整 URL 或 base。自定义网关若走 /v1/search(如 wkbd2api),直接填完整地址。",
482
485
  restoreOfficial: "恢复官方搜索",
483
486
  restoreOfficialHint: "把 web.searchProvider 改回 deepseek-official、web.fetchProvider 改回 http。停用或卸载本插件前建议先点一次,避免宿主报 configured web provider \"ddg\" is not registered。",
@@ -560,6 +563,9 @@ window.__ModuleLoader__.load({
560
563
  allowlistMode: "Use only the checked engines",
561
564
  allowlistHint: "When on, only the checked engines are usable; engines added in later versions stay off.",
562
565
  fallbackPriority: "Global fallback priority",
566
+ engineSettings: "Settings",
567
+ explicitEnginesLabel: "Explicit only",
568
+ explicitEnginesHint: "These engines never join automatic fallback; they run only when selected explicitly.",
563
569
  fallbackPriorityHint: "Top to bottom is the fallback order. The preferred engine is still tried first. Auto keeps language/time routing, while customized priority orders engines within a route group and the remaining fallback chain. Disabled engines keep their position but are skipped.",
564
570
  fallbackPriorityReset: "Reset default order",
565
571
  zhPoolLabel: "Chinese query pool",
@@ -673,10 +679,10 @@ window.__ModuleLoader__.load({
673
679
  yuanbaoModeHybrid: "Hybrid results",
674
680
  yuanbaoModeHint: "Natural is the general default; authoritative/multimodal suits weather, stocks, FX and other timely facts.",
675
681
  yuanbaoSiteLabel: "Restrict to site (optional)",
676
- yuanbaoSiteHint: "Only search one domain, e.g. qq.com; leave empty for the whole web.",
677
- deepseekToolsKeyLabel: "DeepSeek search API key (optional)",
678
- deepseekToolsKeyHint: "Leave empty to reuse the existing DeepSeek API key; set a separate key for custom gateways.",
679
- deepseekToolsUrlLabel: "DeepSeek search endpoint (optional)",
682
+ yuanbaoSiteHint: "Only search one domain, e.g. qq.com; leave empty for the whole web.",
683
+ deepseekToolsKeyLabel: "DeepSeek search API key (optional)",
684
+ deepseekToolsKeyHint: "Leave empty to reuse the existing DeepSeek API key; set a separate key for custom gateways.",
685
+ deepseekToolsUrlLabel: "DeepSeek search endpoint (optional)",
680
686
  deepseekToolsUrlHint: "Leave empty for https://api.deepseek.com/v1/tools/search; a full URL or base works. For a custom gateway using /v1/search (e.g. wkbd2api), enter the full URL.",
681
687
  restoreOfficial: "Restore official search",
682
688
  restoreOfficialHint: "Sets web.searchProvider back to deepseek-official and web.fetchProvider back to http. Run this before disabling or uninstalling the plugin, otherwise the host reports configured web provider \"ddg\" is not registered.",
@@ -727,7 +733,7 @@ window.__ModuleLoader__.load({
727
733
  "cache_search",
728
734
  "domain_search",
729
735
  ];
730
- const PLUGIN_VERSION = "0.9.48";
736
+ const PLUGIN_VERSION = "0.9.50";
731
737
  const PLUGIN_REPO_URL = "https://github.com/DDDMUC/dsh-free-search";
732
738
  // 右侧浮动目录(#85):条目顺序即页面顺序,anchor 是页面里对应 field 的 id。
733
739
  const NAV_ITEMS = [
@@ -739,6 +745,14 @@ window.__ModuleLoader__.load({
739
745
  { id: "performance", anchor: "dshfs-anchor-performance" },
740
746
  { id: "prompt", anchor: "dshfs-anchor-prompt" },
741
747
  ];
748
+ const sectionIdFromHash = () => {
749
+ const hash = String((typeof window !== "undefined" && window.location && window.location.hash) || "");
750
+ const parts = decodeURIComponent(hash.replace(/^#\/?/, "")).split("/").filter(Boolean);
751
+ const index = parts.lastIndexOf("plugins");
752
+ if (index >= 0) return parts[index + 2] || "";
753
+ if (parts[0] === "panel" && parts[1] === "dsh-free-search") return parts[2] || "";
754
+ return parts.length === 1 ? parts[0] : "";
755
+ };
742
756
  // 目录跟着真正滚动的祖先走:DSH 页面通常不是 window 在滚。
743
757
  const findScrollParent = (element) => {
744
758
  let node = element && element.parentElement ? element.parentElement : null;
@@ -864,6 +878,22 @@ window.__ModuleLoader__.load({
864
878
  return { domains, stats };
865
879
  };
866
880
 
881
+ async function bridgeRead(endpoint, body = "{}") {
882
+ const request = () =>
883
+ fetch(bridgeUrl(endpoint), {
884
+ method: "POST",
885
+ headers: { "content-type": "application/json" },
886
+ body,
887
+ signal: AbortSignal.timeout(15000),
888
+ });
889
+ try {
890
+ return await request();
891
+ } catch (error) {
892
+ await new Promise((resolve) => setTimeout(resolve, 800));
893
+ return request();
894
+ }
895
+ }
896
+
867
897
  async function bridgeRestoreProvider() {
868
898
  const response = await fetch(bridgeUrl("restore-provider"), {
869
899
  method: "POST",
@@ -893,11 +923,7 @@ window.__ModuleLoader__.load({
893
923
  }
894
924
 
895
925
  async function bridgeDescribe() {
896
- const response = await fetch(bridgeUrl("describe"), {
897
- method: "POST",
898
- headers: { "content-type": "application/json" },
899
- body: "{}",
900
- });
926
+ const response = await bridgeRead("describe");
901
927
  return response.json();
902
928
  }
903
929
 
@@ -920,11 +946,7 @@ window.__ModuleLoader__.load({
920
946
  }
921
947
 
922
948
  async function bridgeCredentialsStatus() {
923
- const response = await fetch(bridgeUrl("credentials-status"), {
924
- method: "POST",
925
- headers: { "content-type": "application/json" },
926
- body: "{}",
927
- });
949
+ const response = await bridgeRead("credentials-status");
928
950
  return response.json();
929
951
  }
930
952
 
@@ -946,7 +968,47 @@ window.__ModuleLoader__.load({
946
968
  return response.json();
947
969
  }
948
970
 
949
- // 插件页行配置的摘要文案(bundle 页每行显示;不触发 bridge 读取)
971
+ // 侧栏入口跟随 DSH 的界面语言,而不是浏览器语言。
972
+ const PANEL_LABELS = {
973
+ zh: "免费搜索",
974
+ en: "Free Search",
975
+ ja: "無料検索",
976
+ es: "Búsqueda gratis",
977
+ fr: "Recherche gratuite",
978
+ de: "Kostenlose Suche",
979
+ ru: "Бесплатный поиск",
980
+ pt: "Pesquisa grátis",
981
+ };
982
+ let localeFace = null;
983
+ function panelLabel(active) {
984
+ const current = active ?? localeFace?.getLocale?.().active ?? "";
985
+ const id = String(current || "").trim().toLowerCase().split(/[-_]/)[0];
986
+ if (id) return PANEL_LABELS[id] || "Free Search";
987
+ const primary = typeof navigator === "undefined" ? "" : String((navigator.languages && navigator.languages[0]) || navigator.language || "").toLowerCase();
988
+ return PANEL_LABELS[primary.split(/[-_]/)[0]] || "Free Search";
989
+ }
990
+
991
+ function FreeSearchPage() {
992
+ return react_jsx_runtime.jsx("div", {
993
+ style: { height: "100%", minHeight: 0, overflowY: "auto", boxSizing: "border-box", padding: "16px 150px 24px 24px" },
994
+ children: react_jsx_runtime.jsx(FreeSearchCard, { page: true }),
995
+ });
996
+ }
997
+
998
+ function FreeSearchPanelIcon() {
999
+ return react_jsx_runtime.jsx("svg", {
1000
+ width: 18,
1001
+ height: 18,
1002
+ viewBox: "0 0 24 24",
1003
+ fill: "none",
1004
+ "aria-hidden": "true",
1005
+ children: [
1006
+ react_jsx_runtime.jsx("circle", { cx: "11", cy: "11", r: "6.5", stroke: "currentColor", strokeWidth: "1.8" }),
1007
+ react_jsx_runtime.jsx("path", { d: "m16 16 4.2 4.2", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round" }),
1008
+ ],
1009
+ });
1010
+ }
1011
+
950
1012
  function summaryText() {
951
1013
  const primary = typeof navigator === "undefined" ? "zh" : String((navigator.languages && navigator.languages[0]) || navigator.language || "zh").toLowerCase();
952
1014
  return primary.startsWith("en")
@@ -989,6 +1051,7 @@ window.__ModuleLoader__.load({
989
1051
  const [allowedEngines, setAllowedEngines] = react.useState([]);
990
1052
  const [fallbackOrder, setFallbackOrder] = react.useState(DEFAULT_FALLBACK_ORDER);
991
1053
  const [dragIndex, setDragIndex] = react.useState(null);
1054
+ const [expandedEngine, setExpandedEngine] = react.useState("");
992
1055
  const [poolDrag, setPoolDrag] = react.useState(null);
993
1056
  const [zhPool, setZhPool] = react.useState(DEFAULT_ZH_POOL);
994
1057
  const [enPool, setEnPool] = react.useState(DEFAULT_EN_POOL);
@@ -1108,6 +1171,9 @@ window.__ModuleLoader__.load({
1108
1171
  serply: [serplyKey, setSerplyKey],
1109
1172
  outcrawl: [outcrawlKey, setOutcrawlKey],
1110
1173
  google: [googleKey, setGoogleKey],
1174
+ metaso: [metasoKey, setMetasoKey],
1175
+ yandex: [yandexKey, setYandexKey],
1176
+ yuanbao: [yuanbaoKey, setYuanbaoKey],
1111
1177
  you: [youcomKey, setYoucomKey],
1112
1178
  baidu: [baiduKey, setBaiduKey],
1113
1179
  kimi: [kimiKey, setKimiKey],
@@ -1144,6 +1210,137 @@ window.__ModuleLoader__.load({
1144
1210
  });
1145
1211
  };
1146
1212
 
1213
+ const ENGINE_SETTINGS_IDS = ["google", "deepseek-tools", "metaso", "yandex", "yuanbao"];
1214
+ const engineHasSettings = (id) => ENGINE_SETTINGS_IDS.includes(id);
1215
+ const markEngineDirty = () => {
1216
+ setDirty(true);
1217
+ setFailed(false);
1218
+ setSaveError("");
1219
+ };
1220
+ const renderEngineKeyInput = (id) => {
1221
+ const k = KEY_INPUTS[id];
1222
+ if (!k) return null;
1223
+ return react_jsx_runtime.jsx("input", {
1224
+ className: "dshfs-priorityKey",
1225
+ type: "password",
1226
+ placeholder: "API key",
1227
+ value: k[0],
1228
+ disabled: !ready || saving,
1229
+ onDragStart: (e) => { e.preventDefault(); e.stopPropagation(); },
1230
+ onChange: (e) => { k[1](e.target.value); markEngineDirty(); },
1231
+ });
1232
+ };
1233
+ const engineSettingField = (label, value, setter, options = {}) =>
1234
+ react_jsx_runtime.jsx("div", {
1235
+ className: "dshfs-engineSetting",
1236
+ children: [
1237
+ react_jsx_runtime.jsx("div", { className: "dshfs-label", children: label }),
1238
+ react_jsx_runtime.jsx("input", {
1239
+ className: "dshfs-input",
1240
+ type: options.type ?? "text",
1241
+ value,
1242
+ spellCheck: false,
1243
+ placeholder: options.placeholder ?? "",
1244
+ disabled: !ready || saving,
1245
+ onChange: (e) => { setter(e.target.value); markEngineDirty(); },
1246
+ }),
1247
+ options.hint
1248
+ ? react_jsx_runtime.jsx("p", { className: "dshfs-hint", children: options.hint })
1249
+ : null,
1250
+ ],
1251
+ });
1252
+ const engineSettingSelect = (label, value, setter, choices, hint) =>
1253
+ react_jsx_runtime.jsx("div", {
1254
+ className: "dshfs-engineSetting",
1255
+ children: [
1256
+ react_jsx_runtime.jsx("div", { className: "dshfs-label", children: label }),
1257
+ react_jsx_runtime.jsx("select", {
1258
+ className: "dshfs-select",
1259
+ value,
1260
+ style: { colorScheme: selectColorScheme },
1261
+ disabled: !ready || saving,
1262
+ onChange: (e) => { setter(e.target.value); markEngineDirty(); },
1263
+ children: choices.map((choice) =>
1264
+ react_jsx_runtime.jsx("option", { value: choice[0], children: choice[1] }, choice[0])
1265
+ ),
1266
+ }),
1267
+ hint ? react_jsx_runtime.jsx("p", { className: "dshfs-hint", children: hint }) : null,
1268
+ ],
1269
+ });
1270
+ const renderEngineSettings = (id) => {
1271
+ let fields = [];
1272
+ if (id === "google") {
1273
+ fields = [engineSettingField(t.googleCseIdLabel, googleCx, setGoogleCx, {
1274
+ placeholder: "0123456789:abcdef",
1275
+ hint: t.googleCseIdHint,
1276
+ })];
1277
+ } else if (id === "deepseek-tools") {
1278
+ fields = [
1279
+ engineSettingField(t.deepseekToolsKeyLabel, deepseekToolsKey, setDeepseekToolsKey, {
1280
+ type: "password",
1281
+ placeholder: "API key",
1282
+ hint: t.deepseekToolsKeyHint,
1283
+ }),
1284
+ engineSettingField(t.deepseekToolsUrlLabel, deepseekToolsUrl, setDeepseekToolsUrl, {
1285
+ placeholder: "https://api.deepseek.com/v1/tools/search",
1286
+ hint: t.deepseekToolsUrlHint,
1287
+ }),
1288
+ ];
1289
+ } else if (id === "metaso") {
1290
+ fields = [engineSettingSelect(t.metasoScopeLabel, metasoScope, setMetasoScope, [
1291
+ ["webpage", t.metasoScopeWebpage],
1292
+ ["document", t.metasoScopeDocument],
1293
+ ["scholar", t.metasoScopeScholar],
1294
+ ], t.metasoScopeHint)];
1295
+ } else if (id === "yandex") {
1296
+ fields = [
1297
+ engineSettingField(t.yandexFolderLabel, yandexFolder, setYandexFolder, {
1298
+ placeholder: "b1g...",
1299
+ hint: t.yandexFolderHint,
1300
+ }),
1301
+ engineSettingSelect(t.yandexSearchTypeLabel, yandexType, setYandexType, [
1302
+ ["auto", t.yandexSearchTypeAuto],
1303
+ ["ru", t.yandexSearchTypeRu],
1304
+ ["tr", t.yandexSearchTypeTr],
1305
+ ["com", t.yandexSearchTypeCom],
1306
+ ["kk", t.yandexSearchTypeKk],
1307
+ ["be", t.yandexSearchTypeBe],
1308
+ ["uz", t.yandexSearchTypeUz],
1309
+ ], t.yandexSearchTypeHint),
1310
+ ];
1311
+ } else if (id === "yuanbao") {
1312
+ fields = [
1313
+ engineSettingSelect(t.yuanbaoModeLabel, yuanbaoMode, setYuanbaoMode, [
1314
+ ["0", t.yuanbaoModeNatural],
1315
+ ["1", t.yuanbaoModeVr],
1316
+ ["2", t.yuanbaoModeHybrid],
1317
+ ], t.yuanbaoModeHint),
1318
+ engineSettingField(t.yuanbaoSiteLabel, yuanbaoSite, setYuanbaoSite, {
1319
+ placeholder: "qq.com",
1320
+ hint: t.yuanbaoSiteHint,
1321
+ }),
1322
+ ];
1323
+ }
1324
+ return fields.length === 0
1325
+ ? null
1326
+ : react_jsx_runtime.jsx("div", {
1327
+ className: "dshfs-engineSettings",
1328
+ style: { flexBasis: "100%", display: "grid", gap: "8px", paddingTop: "8px" },
1329
+ children: fields,
1330
+ });
1331
+ };
1332
+ const renderEngineSettingsButton = (id) => {
1333
+ if (!engineHasSettings(id)) return null;
1334
+ return react_jsx_runtime.jsx("button", {
1335
+ type: "button",
1336
+ className: "dshfs-btn dshfs-engineSettingsBtn",
1337
+ disabled: !ready || saving,
1338
+ onMouseDown: (e) => e.stopPropagation(),
1339
+ onDragStart: (e) => { e.preventDefault(); e.stopPropagation(); },
1340
+ onClick: () => setExpandedEngine((prev) => (prev === id ? "" : id)),
1341
+ children: expandedEngine === id ? t.engineSettings + " ▴" : t.engineSettings,
1342
+ });
1343
+ };
1147
1344
  const load = react.useCallback(async () => {
1148
1345
  try {
1149
1346
  const result = await bridgeDescribe();
@@ -1258,7 +1455,7 @@ window.__ModuleLoader__.load({
1258
1455
  if (path === "googleCseApiKey") configured.google = true;
1259
1456
  if (path === "metasoApiKey") configured.metaso = true;
1260
1457
  if (path === "yandexApiKey") configured.yandex = true;
1261
- if (path === "yuanbaoApiKey") configured.yuanbao = true;
1458
+ if (path === "yuanbaoApiKey") configured.yuanbao = true;
1262
1459
  if (path === "deepseekToolsApiKey") configured.deepseek = true;
1263
1460
  }
1264
1461
  }
@@ -1315,7 +1512,7 @@ window.__ModuleLoader__.load({
1315
1512
  ["firecrawlApiKey", firecrawlKey],
1316
1513
  ["parallelApiKey", parallelKey],
1317
1514
  ["perplexityApiKey", perplexityKey],
1318
- ["deepseekApiKey", deepseekKey],
1515
+ ["deepseekApiKey", deepseekKey],
1319
1516
  ["deepseekToolsApiKey", deepseekToolsKey],
1320
1517
  ["serpbaseApiKey", serpbaseKey],
1321
1518
  ["serplyApiKey", serplyKey],
@@ -1374,7 +1571,7 @@ window.__ModuleLoader__.load({
1374
1571
  ops.push({ op: "set", path: ["yandexFolderId"], value: yandexFolder.trim() });
1375
1572
  ops.push({ op: "set", path: ["yandexSearchType"], value: ["ru", "tr", "com", "kk", "be", "uz"].includes(yandexType) ? yandexType : "auto" });
1376
1573
  ops.push({ op: "set", path: ["yuanbaoMode"], value: yuanbaoMode === "1" || yuanbaoMode === "2" ? Number(yuanbaoMode) : 0 });
1377
- ops.push({ op: "set", path: ["yuanbaoSite"], value: yuanbaoSite.trim() });
1574
+ ops.push({ op: "set", path: ["yuanbaoSite"], value: yuanbaoSite.trim() });
1378
1575
  ops.push({ op: "set", path: ["deepseekToolsBaseUrl"], value: deepseekToolsUrl.trim() });
1379
1576
  ops.push({ op: "set", path: ["browserFetch"], value: browserFetch });
1380
1577
  ops.push({
@@ -1553,19 +1750,12 @@ window.__ModuleLoader__.load({
1553
1750
  return () => window.removeEventListener("resize", place);
1554
1751
  }, [open, state.status]);
1555
1752
 
1556
- // 分区链接:地址栏里出现 #/panel/plugins/dsh-free-search/<分区>(或任意 …/<分区>)就滚过去。
1753
+ // 分区链接:地址栏里出现 #/panel/dsh-free-search/<分区>(或旧插件页 …/plugins/dsh-free-search/<分区>)就滚过去。
1557
1754
  // 本插件**只读不写** URL —— 地址栏的唯一写者是 dsh-url-router,写这里会跟它抢。
1558
1755
  react.useEffect(() => {
1559
1756
  if (!pageMode) return undefined;
1560
- const sectionOfHash = () => {
1561
- const hash = String((typeof window !== "undefined" && window.location && window.location.hash) || "");
1562
- const parts = decodeURIComponent(hash.replace(/^#\/?/, "")).split("/").filter(Boolean);
1563
- const index = parts.lastIndexOf("plugins");
1564
- if (index >= 0) return parts[index + 2] || "";
1565
- return parts.length === 1 ? parts[0] : "";
1566
- };
1567
1757
  const apply = () => {
1568
- const id = sectionOfHash();
1758
+ const id = sectionIdFromHash();
1569
1759
  if (!id || !NAV_ITEMS.some((entry) => entry.id === id)) return;
1570
1760
  const node = document.querySelector(`[data-dsh-section="${id}"]`)
1571
1761
  || (NAV_ITEMS.find((entry) => entry.id === id) ? document.getElementById(NAV_ITEMS.find((entry) => entry.id === id).anchor) : null);
@@ -1772,7 +1962,7 @@ window.__ModuleLoader__.load({
1772
1962
  ],
1773
1963
  }, segment.key);
1774
1964
  };
1775
- const title = "Free Search";
1965
+ const title = panelLabel();
1776
1966
  const description = t.description;
1777
1967
  const allowlistMode = allowedEngines.length > 0;
1778
1968
  const engineDisabled = (id) => (allowlistMode ? !allowedEngines.includes(id) : disabledEngines.includes(id));
@@ -2000,12 +2190,11 @@ window.__ModuleLoader__.load({
2000
2190
  ref: railRef,
2001
2191
  "aria-label": t.navLabel,
2002
2192
  children: NAV_ITEMS.map((item) =>
2003
- // 真链接:右键能"复制链接"、能开新标签、地址栏里就是分区。
2004
- // 本插件不写 URL(地址栏的唯一写者是 dsh-url-router);href 只是给出
2005
- // 这条分区的地址,点击时浏览器自己改 hash,滚动仍由 goToSection 立即完成。
2193
+ // 分区链接挂在独立页自己的 #/panel/dsh-free-search/<id> 下,
2194
+ // 不再指到 #/panel/plugins/... 的插件行页。
2006
2195
  react_jsx_runtime.jsx("a", {
2007
2196
  className: "dshfs-railItem" + (railActive === item.id ? " dshfs-railItemActive" : ""),
2008
- href: `#/panel/plugins/dsh-free-search/${item.id}`,
2197
+ href: `#/panel/dsh-free-search/${item.id}`,
2009
2198
  "data-dsh-fs-section": item.id,
2010
2199
  "data-dsh-section": item.id,
2011
2200
  onClick: () => goToSection(item.id),
@@ -2128,316 +2317,6 @@ react_jsx_runtime.jsx("div", {
2128
2317
  }),
2129
2318
  ],
2130
2319
  }),
2131
- react_jsx_runtime.jsx("div", {
2132
- className: "dshfs-field",
2133
- children: [
2134
- react_jsx_runtime.jsx("div", {
2135
- className: "dshfs-label",
2136
- children: t.googleCseIdLabel,
2137
- }),
2138
- react_jsx_runtime.jsx("input", {
2139
- className: "dshfs-input",
2140
- type: "text",
2141
- value: googleCx,
2142
- spellCheck: false,
2143
- placeholder: "0123456789:abcdef",
2144
- disabled: !ready || saving,
2145
- onChange: (e) => {
2146
- setGoogleCx(e.target.value);
2147
- setDirty(true);
2148
- setFailed(false);
2149
- setSaveError("");
2150
- },
2151
- }),
2152
- react_jsx_runtime.jsx("p", {
2153
- className: "dshfs-hint",
2154
- children: t.googleCseIdHint,
2155
- }),
2156
- ],
2157
- }),
2158
- react_jsx_runtime.jsx("div", {
2159
- className: "dshfs-field",
2160
- children: [
2161
- react_jsx_runtime.jsx("div", {
2162
- className: "dshfs-label",
2163
- children: t.metasoKeyLabel,
2164
- }),
2165
- react_jsx_runtime.jsx("input", {
2166
- className: "dshfs-input",
2167
- type: "password",
2168
- value: metasoKey,
2169
- spellCheck: false,
2170
- placeholder: "API key",
2171
- disabled: !ready || saving,
2172
- onChange: (e) => {
2173
- setMetasoKey(e.target.value);
2174
- setDirty(true);
2175
- setFailed(false);
2176
- setSaveError("");
2177
- },
2178
- }),
2179
- react_jsx_runtime.jsx("p", {
2180
- className: "dshfs-hint",
2181
- children: t.metasoKeyHint,
2182
- }),
2183
- ],
2184
- }),
2185
- react_jsx_runtime.jsx("div", {
2186
- className: "dshfs-field",
2187
- children: [
2188
- react_jsx_runtime.jsx("div", {
2189
- className: "dshfs-label",
2190
- children: t.metasoScopeLabel,
2191
- }),
2192
- react_jsx_runtime.jsx("select", {
2193
- className: "dshfs-select",
2194
- value: metasoScope,
2195
- style: { colorScheme: selectColorScheme },
2196
- disabled: !ready || saving,
2197
- onChange: (e) => {
2198
- setMetasoScope(e.target.value === "document" || e.target.value === "scholar" ? e.target.value : "webpage");
2199
- setDirty(true);
2200
- setFailed(false);
2201
- setSaveError("");
2202
- },
2203
- children: [
2204
- react_jsx_runtime.jsx("option", { value: "webpage", children: t.metasoScopeWebpage }),
2205
- react_jsx_runtime.jsx("option", { value: "document", children: t.metasoScopeDocument }),
2206
- react_jsx_runtime.jsx("option", { value: "scholar", children: t.metasoScopeScholar }),
2207
- ],
2208
- }),
2209
- react_jsx_runtime.jsx("p", {
2210
- className: "dshfs-hint",
2211
- children: t.metasoScopeHint,
2212
- }),
2213
- ],
2214
- }),
2215
- react_jsx_runtime.jsx("div", {
2216
- className: "dshfs-field",
2217
- children: [
2218
- react_jsx_runtime.jsx("div", {
2219
- className: "dshfs-label",
2220
- children: t.yandexKeyLabel,
2221
- }),
2222
- react_jsx_runtime.jsx("input", {
2223
- className: "dshfs-input",
2224
- type: "password",
2225
- value: yandexKey,
2226
- spellCheck: false,
2227
- placeholder: "API key",
2228
- disabled: !ready || saving,
2229
- onChange: (e) => {
2230
- setYandexKey(e.target.value);
2231
- setDirty(true);
2232
- setFailed(false);
2233
- setSaveError("");
2234
- },
2235
- }),
2236
- react_jsx_runtime.jsx("p", {
2237
- className: "dshfs-hint",
2238
- children: t.yandexKeyHint,
2239
- }),
2240
- ],
2241
- }),
2242
- react_jsx_runtime.jsx("div", {
2243
- className: "dshfs-field",
2244
- children: [
2245
- react_jsx_runtime.jsx("div", {
2246
- className: "dshfs-label",
2247
- children: t.yandexFolderLabel,
2248
- }),
2249
- react_jsx_runtime.jsx("input", {
2250
- className: "dshfs-input",
2251
- type: "text",
2252
- value: yandexFolder,
2253
- spellCheck: false,
2254
- placeholder: "b1g...",
2255
- disabled: !ready || saving,
2256
- onChange: (e) => {
2257
- setYandexFolder(e.target.value);
2258
- setDirty(true);
2259
- setFailed(false);
2260
- setSaveError("");
2261
- },
2262
- }),
2263
- react_jsx_runtime.jsx("p", {
2264
- className: "dshfs-hint",
2265
- children: t.yandexFolderHint,
2266
- }),
2267
- ],
2268
- }),
2269
- react_jsx_runtime.jsx("div", {
2270
- className: "dshfs-field",
2271
- children: [
2272
- react_jsx_runtime.jsx("div", {
2273
- className: "dshfs-label",
2274
- children: t.yandexSearchTypeLabel,
2275
- }),
2276
- react_jsx_runtime.jsx("select", {
2277
- className: "dshfs-select",
2278
- value: yandexType,
2279
- style: { colorScheme: selectColorScheme },
2280
- disabled: !ready || saving,
2281
- onChange: (e) => {
2282
- setYandexType(["ru", "tr", "com", "kk", "be", "uz"].includes(e.target.value) ? e.target.value : "auto");
2283
- setDirty(true);
2284
- setFailed(false);
2285
- setSaveError("");
2286
- },
2287
- children: [
2288
- react_jsx_runtime.jsx("option", { value: "auto", children: t.yandexSearchTypeAuto }),
2289
- react_jsx_runtime.jsx("option", { value: "ru", children: t.yandexSearchTypeRu }),
2290
- react_jsx_runtime.jsx("option", { value: "tr", children: t.yandexSearchTypeTr }),
2291
- react_jsx_runtime.jsx("option", { value: "com", children: t.yandexSearchTypeCom }),
2292
- react_jsx_runtime.jsx("option", { value: "kk", children: t.yandexSearchTypeKk }),
2293
- react_jsx_runtime.jsx("option", { value: "be", children: t.yandexSearchTypeBe }),
2294
- react_jsx_runtime.jsx("option", { value: "uz", children: t.yandexSearchTypeUz }),
2295
- ],
2296
- }),
2297
- react_jsx_runtime.jsx("p", {
2298
- className: "dshfs-hint",
2299
- children: t.yandexSearchTypeHint,
2300
- }),
2301
- ],
2302
- }),
2303
- react_jsx_runtime.jsx("div", {
2304
- className: "dshfs-field",
2305
- children: [
2306
- react_jsx_runtime.jsx("div", {
2307
- className: "dshfs-label",
2308
- children: t.yuanbaoKeyLabel,
2309
- }),
2310
- react_jsx_runtime.jsx("input", {
2311
- className: "dshfs-input",
2312
- type: "password",
2313
- value: yuanbaoKey,
2314
- spellCheck: false,
2315
- placeholder: "API key",
2316
- disabled: !ready || saving,
2317
- onChange: (e) => {
2318
- setYuanbaoKey(e.target.value);
2319
- setDirty(true);
2320
- setFailed(false);
2321
- setSaveError("");
2322
- },
2323
- }),
2324
- react_jsx_runtime.jsx("p", {
2325
- className: "dshfs-hint",
2326
- children: t.yuanbaoKeyHint,
2327
- }),
2328
- ],
2329
- }),
2330
- react_jsx_runtime.jsx("div", {
2331
- className: "dshfs-field",
2332
- children: [
2333
- react_jsx_runtime.jsx("div", {
2334
- className: "dshfs-label",
2335
- children: t.yuanbaoModeLabel,
2336
- }),
2337
- react_jsx_runtime.jsx("select", {
2338
- className: "dshfs-select",
2339
- value: yuanbaoMode,
2340
- style: { colorScheme: selectColorScheme },
2341
- disabled: !ready || saving,
2342
- onChange: (e) => {
2343
- setYuanbaoMode(e.target.value === "1" || e.target.value === "2" ? e.target.value : "0");
2344
- setDirty(true);
2345
- setFailed(false);
2346
- setSaveError("");
2347
- },
2348
- children: [
2349
- react_jsx_runtime.jsx("option", { value: "0", children: t.yuanbaoModeNatural }),
2350
- react_jsx_runtime.jsx("option", { value: "1", children: t.yuanbaoModeVr }),
2351
- react_jsx_runtime.jsx("option", { value: "2", children: t.yuanbaoModeHybrid }),
2352
- ],
2353
- }),
2354
- react_jsx_runtime.jsx("p", {
2355
- className: "dshfs-hint",
2356
- children: t.yuanbaoModeHint,
2357
- }),
2358
- ],
2359
- }),
2360
- react_jsx_runtime.jsx("div", {
2361
- className: "dshfs-field",
2362
- children: [
2363
- react_jsx_runtime.jsx("div", {
2364
- className: "dshfs-label",
2365
- children: t.yuanbaoSiteLabel,
2366
- }),
2367
- react_jsx_runtime.jsx("input", {
2368
- className: "dshfs-input",
2369
- type: "text",
2370
- value: yuanbaoSite,
2371
- spellCheck: false,
2372
- placeholder: "qq.com",
2373
- disabled: !ready || saving,
2374
- onChange: (e) => {
2375
- setYuanbaoSite(e.target.value);
2376
- setDirty(true);
2377
- setFailed(false);
2378
- setSaveError("");
2379
- },
2380
- }),
2381
- react_jsx_runtime.jsx("p", {
2382
- className: "dshfs-hint",
2383
- children: t.yuanbaoSiteHint,
2384
- }),
2385
- ],
2386
- }),
2387
- react_jsx_runtime.jsx("div", {
2388
- className: "dshfs-field",
2389
- children: [
2390
- react_jsx_runtime.jsx("div", {
2391
- className: "dshfs-label",
2392
- children: t.deepseekToolsKeyLabel,
2393
- }),
2394
- react_jsx_runtime.jsx("input", {
2395
- className: "dshfs-input",
2396
- type: "password",
2397
- value: deepseekToolsKey,
2398
- spellCheck: false,
2399
- placeholder: "API key",
2400
- disabled: !ready || saving,
2401
- onChange: (e) => {
2402
- setDeepseekToolsKey(e.target.value);
2403
- setDirty(true);
2404
- setFailed(false);
2405
- setSaveError("");
2406
- },
2407
- }),
2408
- react_jsx_runtime.jsx("p", {
2409
- className: "dshfs-hint",
2410
- children: t.deepseekToolsKeyHint,
2411
- }),
2412
- ],
2413
- }),
2414
- react_jsx_runtime.jsx("div", {
2415
- className: "dshfs-field",
2416
- children: [
2417
- react_jsx_runtime.jsx("div", {
2418
- className: "dshfs-label",
2419
- children: t.deepseekToolsUrlLabel,
2420
- }),
2421
- react_jsx_runtime.jsx("input", {
2422
- className: "dshfs-input",
2423
- type: "text",
2424
- value: deepseekToolsUrl,
2425
- spellCheck: false,
2426
- placeholder: "https://api.deepseek.com/v1/tools/search",
2427
- disabled: !ready || saving,
2428
- onChange: (e) => {
2429
- setDeepseekToolsUrl(e.target.value);
2430
- setDirty(true);
2431
- setFailed(false);
2432
- setSaveError("");
2433
- },
2434
- }),
2435
- react_jsx_runtime.jsx("p", {
2436
- className: "dshfs-hint",
2437
- children: t.deepseekToolsUrlHint,
2438
- }),
2439
- ],
2440
- }),
2441
2320
  react_jsx_runtime.jsx("div", {
2442
2321
  className: "dshfs-field",
2443
2322
  id: "dshfs-anchor-fallback",
@@ -2455,6 +2334,7 @@ react_jsx_runtime.jsx("div", {
2455
2334
  const isDisabled = engineDisabled(engineId);
2456
2335
  return react_jsx_runtime.jsx("div", {
2457
2336
  className: "dshfs-priorityRow" + (isDisabled ? " dshfs-priorityRowDisabled" : "") + (dragIndex === index ? " dshfs-priorityRowDragging" : ""),
2337
+ style: { flexWrap: "wrap" },
2458
2338
  draggable: ready && !saving,
2459
2339
  onDragStart: (e) => {
2460
2340
  setDragIndex(index);
@@ -2480,24 +2360,8 @@ react_jsx_runtime.jsx("div", {
2480
2360
  children: `${engine.label} (${engine.badge})${isDisabled ? " · " + t.priorityDisabled : ""}`,
2481
2361
  }),
2482
2362
  renderKeyStatus(engineId),
2483
- (() => {
2484
- const k = KEY_INPUTS[engineId];
2485
- if (!k) return null;
2486
- return react_jsx_runtime.jsx("input", {
2487
- className: "dshfs-priorityKey",
2488
- type: "password",
2489
- placeholder: "API key",
2490
- value: k[0],
2491
- disabled: !ready || saving,
2492
- onDragStart: (e) => { e.preventDefault(); e.stopPropagation(); },
2493
- onChange: (e) => {
2494
- k[1](e.target.value);
2495
- setDirty(true);
2496
- setFailed(false);
2497
- setSaveError("");
2498
- },
2499
- });
2500
- })(),
2363
+ renderEngineKeyInput(engineId),
2364
+ renderEngineSettingsButton(engineId),
2501
2365
  react_jsx_runtime.jsx("span", {
2502
2366
  className: "dshfs-priorityActions",
2503
2367
  children: [
@@ -2509,6 +2373,7 @@ react_jsx_runtime.jsx("div", {
2509
2373
  }, "handle"),
2510
2374
  ],
2511
2375
  }),
2376
+ expandedEngine === engineId ? renderEngineSettings(engineId) : null,
2512
2377
  ],
2513
2378
  }, engineId);
2514
2379
  }),
@@ -2533,6 +2398,40 @@ react_jsx_runtime.jsx("div", {
2533
2398
  }),
2534
2399
  ],
2535
2400
  }),
2401
+ react_jsx_runtime.jsx("div", {
2402
+ className: "dshfs-field",
2403
+ children: [
2404
+ react_jsx_runtime.jsx("div", {
2405
+ className: "dshfs-label",
2406
+ children: t.explicitEnginesLabel,
2407
+ }),
2408
+ react_jsx_runtime.jsx("p", {
2409
+ className: "dshfs-hint",
2410
+ children: t.explicitEnginesHint,
2411
+ }),
2412
+ react_jsx_runtime.jsx("div", {
2413
+ className: "dshfs-priorityList",
2414
+ children: ["metaso", "yandex", "yuanbao"].map((engineId) => {
2415
+ const engine = ENGINES.find((item) => item.id === engineId);
2416
+ if (!engine) return null;
2417
+ return react_jsx_runtime.jsx("div", {
2418
+ className: "dshfs-priorityRow",
2419
+ style: { flexWrap: "wrap" },
2420
+ children: [
2421
+ react_jsx_runtime.jsx("span", {
2422
+ className: "dshfs-priorityName",
2423
+ children: `${engine.label} (${engine.badge})`,
2424
+ }),
2425
+ renderKeyStatus(engineId),
2426
+ renderEngineKeyInput(engineId),
2427
+ renderEngineSettingsButton(engineId),
2428
+ expandedEngine === engineId ? renderEngineSettings(engineId) : null,
2429
+ ],
2430
+ }, engineId);
2431
+ }),
2432
+ }),
2433
+ ],
2434
+ }),
2536
2435
  react_jsx_runtime.jsx("div", {
2537
2436
  className: "dshfs-field",
2538
2437
  children: [
@@ -3287,10 +3186,33 @@ react_jsx_runtime.jsx("div", {
3287
3186
  const inject = ["slots", "commandUi"];
3288
3187
 
3289
3188
  function apply(ctx) {
3189
+ ctx.inject(["locale"], (sctx) => {
3190
+ localeFace = sctx.get("locale") || null;
3191
+ });
3290
3192
  // 挂插件页 slot:侧栏 插件 → 已安装 → free-search → 行配置页。
3291
3193
  // rc.1 废弃了旧版设置页的插件配置 slot,只保留 plugins.row.config;
3292
3194
  // key 规则见 ui-plugin-manager 的 rowConfigKey:<包名>#<patch 里声明的行 id>。
3293
3195
  // 配置读写走自建 bridge(按页面 base 解析 api/dsh-free-search-settings),不依赖 dsh-web-ui。
3196
+ ctx.slots.inject("sidebar.panellist", () =>
3197
+ ctx.slots.register(
3198
+ {
3199
+ name: "sidebar.panellist",
3200
+ id: "dsh-free-search",
3201
+ order: 30,
3202
+ label: () => panelLabel(),
3203
+ },
3204
+ FreeSearchPanelIcon
3205
+ )
3206
+ );
3207
+ ctx.slots.inject("main", () =>
3208
+ ctx.slots.register(
3209
+ {
3210
+ name: "main",
3211
+ key: "dsh-free-search",
3212
+ },
3213
+ FreeSearchPage
3214
+ )
3215
+ );
3294
3216
  ctx.slots.inject("plugins.row.config", () =>
3295
3217
  ctx.slots.register(
3296
3218
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-free-search",
3
- "version": "0.9.48",
3
+ "version": "0.9.50",
4
4
  "description": "Free web search for DeepSeek Harness: 39 engines (Bing/DuckDuckGo/AnySearch/SearXNG/Exa/Tavily/Keenable/Firecrawl/Parallel/You.com keyless; Zhihu global/site via MCP and Perplexity/SerpBase/DeepSeek (official + native tools/search)/Baidu/Kimi/Aliyun/Doubao/Google CSE/Metaso/Yandex/Yuanbao with key; OpenAI/Gemini/Claude model built-in search, explicit-only) + auto smart routing + global engine enable/disable & fallback priority + editable zh/en language pools + multi mode (parallel full language-pool merge) + multi_search cross-source tool + failure-aware fallback (quota/auth cooldown, transient retry, fallbackOn) + time filtering + platform search + domain blocklist (blockedDomains) + web_fetch, with web settings UI, plus a standalone stdio MCP server.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",