wwt-platform 1.1.7 → 1.1.9

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wwt-platform",
3
- "version": "1.1.7",
3
+ "version": "1.1.9",
4
4
  "description": "WWT 工作平台 - 平台本体与工具清单分发",
5
5
  "files": [
6
6
  "platform.html",
package/platform.html CHANGED
@@ -1357,7 +1357,7 @@ function doAddMod(){
1357
1357
  // ═══════════════════════════════════════════════════════════
1358
1358
  // 平台更新(方案B:平台 + 内置工具统一检查)
1359
1359
  // ═══════════════════════════════════════════════════════════
1360
- const PLATFORM_VER = '1.1.7';
1360
+ const PLATFORM_VER = '1.1.9';
1361
1361
  const NPM_PKG = 'wwt-platform'; // NPM 包名(主力分发源)
1362
1362
  const GITEE_TOKEN_KEY = 'wwt_gitee_token';
1363
1363
  const GITEE_TOKEN_DEF = 'e45883b9c89b8d9689746ce42bbc2b0b';
@@ -1382,7 +1382,7 @@ const SOURCES = [
1382
1382
  // 更新清单:每个条目 = 一个可更新对象(平台或工具)
1383
1383
  // 这是「离线兜底种子」——联网时会与远程 tools.json 合并,远程为准
1384
1384
  const UPD_REG_DEF = [
1385
- {key:'platform', name:'WWT 工作平台', cur:'1.1.7', repo:GITEE_PLATFORM_REPO, verFile:'version.js', appFile:'app.js', pat:'__WWT_PLATFORM_VER', kind:'platform'},
1385
+ {key:'platform', name:'WWT 工作平台', cur:'1.1.9', repo:GITEE_PLATFORM_REPO, verFile:'version.js', appFile:'app.js', pat:'__WWT_PLATFORM_VER', kind:'platform'},
1386
1386
  {key:'erp-recon', name:'ERP 对账工具', cur:'V1.0.2',repo:'wwtmrhu/erp-recon', verFile:'version.js', appFile:'app.js', pat:'__ERP_LATEST_VER'},
1387
1387
  {key:'erp-tool', name:'ERP 对账单生成匹配', cur:'1.0.0', repo:'wwtmrhu/erp-tool', verFile:'version.js', appFile:'app.js', pat:'__ERP_LATEST_VER'},
1388
1388
  {key:'voucher', name:'WWT 凭证工具', cur:'P1.2.12',repo:'wwtmrhu/certificate-generation', verFile:'dist/version.json', appFile:'', pat:'ver', appUrl:true}
@@ -1450,6 +1450,31 @@ async function fetchText(url, timeoutMs) {
1450
1450
  } finally { clearTimeout(timer); }
1451
1451
  }
1452
1452
 
1453
+ // 版本号比较:a 返回 a-b 的差值(>0 表示 a 更新)
1454
+ function verCmp(a, b) {
1455
+ const pa = verNum(a), pb = verNum(b);
1456
+ for (let i = 0; i < 3; i++) { if (pa[i] !== pb[i]) return pa[i] - pb[i]; }
1457
+ return 0;
1458
+ }
1459
+
1460
+ // 并行查询所有源,取其中最高的版本号
1461
+ // 原因:npmmirror 有同步延迟,刚发布的版本可能短时间读不到;
1462
+ // 若只用单一源会漏报更新,所以取各源最大值最稳妥
1463
+ async function bestVersion() {
1464
+ const rs = await Promise.all(SOURCES.map(async (s) => {
1465
+ try {
1466
+ const v = await sourceVersion(s);
1467
+ return v ? { src:s.id, label:s.label, ver:v } : null;
1468
+ } catch(e) { return null; }
1469
+ }));
1470
+ const list = rs.filter(Boolean);
1471
+ if (!list.length) throw new Error('所有分发源均不可用');
1472
+ list.sort((x, y) => verCmp(y.ver, x.ver));
1473
+ const best = list[0];
1474
+ best.all = list;
1475
+ return best;
1476
+ }
1477
+
1453
1478
  // 查询任意 NPM 包的最新版本号(兼容 npmmirror → npmjs)
1454
1479
  async function npmLatestVer(pkg) {
1455
1480
  for (const urls of [
@@ -1528,18 +1553,29 @@ let _manifestSrc = null; // 来源标签
1528
1553
  let _newTools = []; // 清单里有、本平台还没装的工具
1529
1554
 
1530
1555
  async function fetchManifest() {
1531
- const r = await trySources(async (s) => {
1532
- const ver = await sourceVersion(s);
1533
- const txt = await sourceFile(s, ver, 'tools.json');
1534
- const m = JSON.parse(txt);
1535
- if (!m || !Array.isArray(m.tools)) throw new Error('清单格式错误');
1536
- m.__ver = ver;
1537
- return m;
1538
- });
1539
- _manifest = r.val;
1540
- _manifestSrc = r.label;
1541
- mergeManifest(_manifest);
1542
- return _manifest;
1556
+ // 优先从版本最新的源取清单(镜像可能滞后,导致拉到旧清单)
1557
+ let order = SOURCES.slice(), vers = {};
1558
+ try {
1559
+ const best = await bestVersion();
1560
+ (best.all || []).forEach(x => { vers[x.src] = x.ver; });
1561
+ order = SOURCES.slice().sort((a, b) => verCmp(vers[b.id] || '0', vers[a.id] || '0'));
1562
+ } catch(e) { /* 取不到版本就按默认顺序试 */ }
1563
+
1564
+ const errs = [];
1565
+ for (const s of order) {
1566
+ try {
1567
+ const ver = vers[s.id] || (await sourceVersion(s));
1568
+ const txt = await sourceFile(s, ver, 'tools.json');
1569
+ const m = JSON.parse(txt);
1570
+ if (!m || !Array.isArray(m.tools)) throw new Error('清单格式错误');
1571
+ m.__ver = ver;
1572
+ _manifest = m;
1573
+ _manifestSrc = s.label;
1574
+ mergeManifest(m);
1575
+ return m;
1576
+ } catch(e) { errs.push(s.label + ':' + e.message); }
1577
+ }
1578
+ throw new Error(errs.join(' | '));
1543
1579
  }
1544
1580
 
1545
1581
  // 把远程清单合并进本地注册表(远程为准,本地保留已安装状态)
@@ -1680,15 +1716,13 @@ async function checkOneUpd(it, token) {
1680
1716
  const r = {key:it.key, name:it.name, cur:it.cur, latest:null, hasNew:false, error:null,
1681
1717
  noSrc:!!it.noSrc, removed:!!it.removed, module:it.module};
1682
1718
 
1683
- // 平台自身:走多源(NPM镜像 → NPM官方 → Gitee)
1719
+ // 平台自身:并行查询所有源,取最高版本(规避镜像同步延迟导致的漏报)
1684
1720
  if (it.key === 'platform') {
1685
1721
  try {
1686
- const res = await trySources(async (s) => {
1687
- const v = await sourceVersion(s);
1688
- if (!v) throw new Error('未取到版本号');
1689
- return v;
1690
- });
1691
- r.latest = res.val; r.srcLabel = res.label;
1722
+ const best = await bestVersion();
1723
+ r.latest = best.ver;
1724
+ r.srcLabel = best.label;
1725
+ r.allVers = (best.all || []).map(x => x.label + ' ' + x.ver).join(' / ');
1692
1726
  r.hasNew = verGt(r.latest, r.cur);
1693
1727
  } catch(e) { r.error = e.message; }
1694
1728
  return r;
@@ -1697,10 +1731,20 @@ async function checkOneUpd(it, token) {
1697
1731
  // 没有远程更新源的工具:不做版本比对
1698
1732
  if (it.noSrc) { r.latest = it.cur; r.note = '本地工具(无远程更新源)'; return r; }
1699
1733
 
1734
+ // ① 优先用 NPM 清单里声明的版本号——版本检查不再频繁请求 Gitee,避免被限流
1735
+ if (it.manifestVer) {
1736
+ r.latest = it.manifestVer;
1737
+ r.srcLabel = 'NPM清单';
1738
+ r.hasNew = verGt(r.latest, r.cur);
1739
+ return r;
1740
+ }
1741
+
1742
+ // ② 清单未声明版本时,才回退去读工具自身仓库
1700
1743
  try {
1701
1744
  const vc = await fetchGiteeFile(it.repo, it.verFile, token);
1702
1745
  r.latest = parseVer(vc, it.pat);
1703
1746
  if (!r.latest) { r.error = '版本文件中未找到版本号'; return r; }
1747
+ r.srcLabel = 'Gitee';
1704
1748
  r.hasNew = verGt(r.latest, r.cur);
1705
1749
  } catch(e) { r.error = e.message; }
1706
1750
  return r;
@@ -1774,7 +1818,9 @@ function renderUpdList() {
1774
1818
 
1775
1819
  const sub = r.noSrc
1776
1820
  ? '本地工具,无远程更新源'
1777
- : '当前 ' + esc(r.cur) + ' → 最新 ' + esc(r.latest || '—') + (r.srcLabel ? ' <span style="color:var(--green)">来源:' + esc(r.srcLabel) + '</span>' : '');
1821
+ : '当前 ' + esc(r.cur) + ' → 最新 ' + esc(r.latest || '—')
1822
+ + (r.srcLabel ? ' <span style="color:var(--green)">来源:' + esc(r.srcLabel) + '</span>' : '')
1823
+ + (r.allVers ? '<div style="font-size:11px;color:var(--text-3);margin-top:1px">各源:' + esc(r.allVers) + '</div>' : '');
1778
1824
 
1779
1825
  return `<div style="display:flex;align-items:center;justify-content:space-between;padding:10px 14px;border:1px solid var(--border);border-radius:10px;margin-bottom:8px">
1780
1826
  <div>
package/tools.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schema": 1,
3
- "platform": "1.1.7",
3
+ "platform": "1.1.9",
4
4
  "updatedAt": "2026-09-10",
5
5
  "note": "WWT 工作平台工具清单。新增/修改工具只需改这个文件并发布新版本,用户端自动同步,无需重新分发平台。",
6
6
  "tools": [