@lynn123411/dsh-a6api 1.5.4 → 1.5.5

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/index.js CHANGED
@@ -1796,10 +1796,12 @@ function overlayPinsOnModels(models, pins, tokenId) {
1796
1796
  if (list) list.push(p);
1797
1797
  else byModel.set(key, [p]);
1798
1798
  }
1799
+ const latestFirst = (list) => [...list].sort((a, b) => (Number(b.created_at) || 0) - (Number(a.created_at) || 0));
1799
1800
  return models.map((m) => {
1800
1801
  const list = byModel.get(m.model_name.toLowerCase());
1801
1802
  if (!list || list.length === 0) return m;
1802
- const pick = (tokenId ? list.find((p) => Number(p.token_id) === tokenId) : void 0) || list[0];
1803
+ const sorted = latestFirst(list);
1804
+ const pick = (tokenId ? sorted.find((p) => Number(p.token_id) === tokenId) : void 0) || sorted[0];
1803
1805
  const cardChannel = m.merchant?.channel_id;
1804
1806
  const pinChannel = pick.channel_id;
1805
1807
  return {
@@ -1809,7 +1811,8 @@ function overlayPinsOnModels(models, pins, tokenId) {
1809
1811
  pinnedChannelId: pinChannel,
1810
1812
  pinnedSupplierName: pick.supplier_nickname || pick.supplier_name,
1811
1813
  pinnedFallback: pick.fallback_to_smart_routing,
1812
- pinTokenMatched: Boolean(tokenId && Number(pick.token_id) === tokenId)
1814
+ // 三态:true=属于当前令牌,false=属于其他令牌,undefined=当前令牌未解析(未知)
1815
+ pinTokenMatched: tokenId ? Number(pick.token_id) === tokenId : void 0
1813
1816
  };
1814
1817
  });
1815
1818
  }
@@ -2183,7 +2186,7 @@ function apply(ctx) {
2183
2186
  }
2184
2187
  const tokenId = await resolveTokenId(config);
2185
2188
  if (!tokenId) {
2186
- return sendJson(res, 400, { ok: false, error: "\u65E0\u6CD5\u89E3\u6790 API Key \u5BF9\u5E94\u7684\u4EE4\u724C ID\uFF0C\u8BF7\u68C0\u67E5\u7CFB\u7EDF\u8BBF\u95EE\u4EE4\u724C\u662F\u5426\u6709\u6548" });
2189
+ return sendJson(res, 400, { ok: false, error: "\u65E0\u6CD5\u89E3\u6790 API Key \u5BF9\u5E94\u7684\u4EE4\u724C ID\uFF08\u591A\u4EE4\u724C\u8D26\u53F7\u9700\u4FDD\u8BC1\u4EE4\u724C\u5217\u8868\u53EF\u8BFB\uFF09\uFF1B\u53EF\u5148\u300C\u63A2\u6D4B\u5546\u5BB6\u300D\u4E00\u6B21\u540E\u91CD\u8BD5\uFF0C\u6216\u5230\u5B98\u7F51\u624B\u52A8\u53D6\u6D88" });
2187
2190
  }
2188
2191
  const unpinResult = await marketplaceUnpin(userId, token, { token_id: tokenId, model_name: modelName });
2189
2192
  if (!unpinResult.ok) {