wwt-platform 1.1.8 → 1.1.10

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.8",
3
+ "version": "1.1.10",
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.8';
1360
+ const PLATFORM_VER = '1.1.10';
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.8', repo:GITEE_PLATFORM_REPO, verFile:'version.js', appFile:'app.js', pat:'__WWT_PLATFORM_VER', kind:'platform'},
1385
+ {key:'platform', name:'WWT 工作平台', cur:'1.1.10', 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,27 @@ 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
+ // 镜像的 /latest 常滞后,但它按版本号取文件是准的——所以不能用各源自己的版本号,
1558
+ // 否则会从镜像拉到旧清单。
1559
+ let target = null;
1560
+ try { target = (await bestVersion()).ver; } catch(e) { /* 取不到就逐源自查 */ }
1561
+
1562
+ const errs = [];
1563
+ for (const s of SOURCES) {
1564
+ try {
1565
+ const ver = target || (await sourceVersion(s));
1566
+ const txt = await sourceFile(s, ver, 'tools.json');
1567
+ const m = JSON.parse(txt);
1568
+ if (!m || !Array.isArray(m.tools)) throw new Error('清单格式错误');
1569
+ m.__ver = ver;
1570
+ _manifest = m;
1571
+ _manifestSrc = s.label;
1572
+ mergeManifest(m);
1573
+ return m;
1574
+ } catch(e) { errs.push(s.label + ':' + e.message); }
1575
+ }
1576
+ throw new Error(errs.join(' | '));
1543
1577
  }
1544
1578
 
1545
1579
  // 把远程清单合并进本地注册表(远程为准,本地保留已安装状态)
@@ -1680,15 +1714,13 @@ async function checkOneUpd(it, token) {
1680
1714
  const r = {key:it.key, name:it.name, cur:it.cur, latest:null, hasNew:false, error:null,
1681
1715
  noSrc:!!it.noSrc, removed:!!it.removed, module:it.module};
1682
1716
 
1683
- // 平台自身:走多源(NPM镜像 → NPM官方 → Gitee)
1717
+ // 平台自身:并行查询所有源,取最高版本(规避镜像同步延迟导致的漏报)
1684
1718
  if (it.key === 'platform') {
1685
1719
  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;
1720
+ const best = await bestVersion();
1721
+ r.latest = best.ver;
1722
+ r.srcLabel = best.label;
1723
+ r.allVers = (best.all || []).map(x => x.label + ' ' + x.ver).join(' / ');
1692
1724
  r.hasNew = verGt(r.latest, r.cur);
1693
1725
  } catch(e) { r.error = e.message; }
1694
1726
  return r;
@@ -1784,7 +1816,9 @@ function renderUpdList() {
1784
1816
 
1785
1817
  const sub = r.noSrc
1786
1818
  ? '本地工具,无远程更新源'
1787
- : '当前 ' + esc(r.cur) + ' → 最新 ' + esc(r.latest || '—') + (r.srcLabel ? ' <span style="color:var(--green)">来源:' + esc(r.srcLabel) + '</span>' : '');
1819
+ : '当前 ' + esc(r.cur) + ' → 最新 ' + esc(r.latest || '—')
1820
+ + (r.srcLabel ? ' <span style="color:var(--green)">来源:' + esc(r.srcLabel) + '</span>' : '')
1821
+ + (r.allVers ? '<div style="font-size:11px;color:var(--text-3);margin-top:1px">各源:' + esc(r.allVers) + '</div>' : '');
1788
1822
 
1789
1823
  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">
1790
1824
  <div>
@@ -1959,17 +1993,20 @@ async function doUpdateOne(key) {
1959
1993
  let bytes, srcLabel = '';
1960
1994
  if (it.key === 'platform') {
1961
1995
  // 平台本体:NPM 上直接是 platform.html(明文),Gitee 上是 base64 的 app.js
1996
+ // 用「各源中的最高版本」下载,避免镜像滞后导致下到旧版
1997
+ let target = null;
1998
+ try { target = (await bestVersion()).ver; } catch(e) {}
1962
1999
  const res = await trySources(async (s) => {
1963
2000
  if (s.id === 'gitee') {
1964
2001
  const appJs = await fetchGiteeFile(GITEE_PLATFORM_REPO, 'app.js');
1965
2002
  return { bytes: b64ToBytes(b64FromApiJson(appJs)) };
1966
2003
  }
1967
- const ver = await sourceVersion(s);
2004
+ const ver = target || (await sourceVersion(s));
1968
2005
  const html = await sourceFile(s, ver, 'platform.html');
1969
2006
  return { bytes: new TextEncoder().encode(html) };
1970
2007
  });
1971
2008
  bytes = res.val.bytes;
1972
- srcLabel = res.label;
2009
+ srcLabel = res.label + (target ? ' v' + target : '');
1973
2010
  } else if (it.appUrl) {
1974
2011
  // version.json 里直接带最新版文件 API 地址,按 url 字段下载
1975
2012
  const vc = await fetchGiteeFile(it.repo, it.verFile);
package/tools.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schema": 1,
3
- "platform": "1.1.8",
3
+ "platform": "1.1.10",
4
4
  "updatedAt": "2026-09-10",
5
5
  "note": "WWT 工作平台工具清单。新增/修改工具只需改这个文件并发布新版本,用户端自动同步,无需重新分发平台。",
6
6
  "tools": [