wwt-platform 1.1.6 → 1.1.8

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 (3) hide show
  1. package/package.json +18 -18
  2. package/platform.html +67 -9
  3. package/tools.json +82 -82
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
- {
2
- "name": "wwt-platform",
3
- "version": "1.1.6",
4
- "description": "WWT 工作平台 - 平台本体与工具清单分发",
5
- "files": [
6
- "platform.html",
7
- "tools.json",
8
- "README.md"
9
- ],
10
- "keywords": [
11
- "wwt",
12
- "platform",
13
- "tools"
14
- ],
15
- "author": "mrhu1988",
16
- "license": "UNLICENSED",
17
- "private": false
18
- }
1
+ {
2
+ "name": "wwt-platform",
3
+ "version": "1.1.8",
4
+ "description": "WWT 工作平台 - 平台本体与工具清单分发",
5
+ "files": [
6
+ "platform.html",
7
+ "tools.json",
8
+ "README.md"
9
+ ],
10
+ "keywords": [
11
+ "wwt",
12
+ "platform",
13
+ "tools"
14
+ ],
15
+ "author": "mrhu1988",
16
+ "license": "UNLICENSED",
17
+ "private": false
18
+ }
package/platform.html CHANGED
@@ -1357,7 +1357,7 @@ function doAddMod(){
1357
1357
  // ═══════════════════════════════════════════════════════════
1358
1358
  // 平台更新(方案B:平台 + 内置工具统一检查)
1359
1359
  // ═══════════════════════════════════════════════════════════
1360
- const PLATFORM_VER = '1.1.6';
1360
+ const PLATFORM_VER = '1.1.8';
1361
1361
  const NPM_PKG = 'wwt-platform'; // NPM 包名(主力分发源)
1362
1362
  const GITEE_TOKEN_KEY = 'wwt_gitee_token';
1363
1363
  const GITEE_TOKEN_DEF = 'e45883b9c89b8d9689746ce42bbc2b0b';
@@ -1366,20 +1366,23 @@ const GITEE_PLATFORM_REPO = 'wwtmrhu/wwt-platform';
1366
1366
 
1367
1367
  // ── 分发源:按优先级依次尝试,任一成功即用 ────────────────────────────
1368
1368
  // npmmirror 国内最快;npmjs 官方源兜底;Gitee 作为最终备用
1369
+ // 注:npmmirror 的 /files/ 接口有白名单限制,新包取不到;
1370
+ // 改用 tarball 接口 + 浏览器原生解压(DecompressionStream),国内速度最快
1369
1371
  const SOURCES = [
1370
1372
  { id:'npmmirror', label:'NPM镜像',
1371
1373
  verUrl : () => `https://registry.npmmirror.com/${NPM_PKG}/latest`,
1372
- fileUrl: (v,f) => `https://registry.npmmirror.com/${NPM_PKG}/${v}/files/${f}` },
1374
+ file : async (v,f) => await tarFile(
1375
+ `https://registry.npmmirror.com/${NPM_PKG}/-/${NPM_PKG}-${v}.tgz`, f) },
1373
1376
  { id:'npmjs', label:'NPM官方',
1374
1377
  verUrl : () => `https://registry.npmjs.org/${NPM_PKG}/latest`,
1375
- fileUrl: (v,f) => `https://cdn.jsdelivr.net/npm/${NPM_PKG}@${v}/${f}` },
1376
- { id:'gitee', label:'Gitee', verUrl:null, fileUrl:null } // 走 API,单独处理
1378
+ file : async (v,f) => await fetchText(`https://cdn.jsdelivr.net/npm/${NPM_PKG}@${v}/${f}`) },
1379
+ { id:'gitee', label:'Gitee', verUrl:null, file:null } // 走 API,单独处理
1377
1380
  ];
1378
1381
 
1379
1382
  // 更新清单:每个条目 = 一个可更新对象(平台或工具)
1380
1383
  // 这是「离线兜底种子」——联网时会与远程 tools.json 合并,远程为准
1381
1384
  const UPD_REG_DEF = [
1382
- {key:'platform', name:'WWT 工作平台', cur:'1.1.6', repo:GITEE_PLATFORM_REPO, verFile:'version.js', appFile:'app.js', pat:'__WWT_PLATFORM_VER', kind:'platform'},
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'},
1383
1386
  {key:'erp-recon', name:'ERP 对账工具', cur:'V1.0.2',repo:'wwtmrhu/erp-recon', verFile:'version.js', appFile:'app.js', pat:'__ERP_LATEST_VER'},
1384
1387
  {key:'erp-tool', name:'ERP 对账单生成匹配', cur:'1.0.0', repo:'wwtmrhu/erp-tool', verFile:'version.js', appFile:'app.js', pat:'__ERP_LATEST_VER'},
1385
1388
  {key:'voucher', name:'WWT 凭证工具', cur:'P1.2.12',repo:'wwtmrhu/certificate-generation', verFile:'dist/version.json', appFile:'', pat:'ver', appUrl:true}
@@ -1447,6 +1450,21 @@ async function fetchText(url, timeoutMs) {
1447
1450
  } finally { clearTimeout(timer); }
1448
1451
  }
1449
1452
 
1453
+ // 查询任意 NPM 包的最新版本号(兼容 npmmirror → npmjs)
1454
+ async function npmLatestVer(pkg) {
1455
+ for (const urls of [
1456
+ `https://registry.npmmirror.com/${pkg}/latest`,
1457
+ `https://registry.npmjs.org/${pkg}/latest`
1458
+ ]) {
1459
+ try {
1460
+ const j = await fetchText(urls);
1461
+ const v = (JSON.parse(j) || {}).version;
1462
+ if (v) return v;
1463
+ } catch(e) {}
1464
+ }
1465
+ throw new Error('未取到 ' + pkg + ' 的版本号');
1466
+ }
1467
+
1450
1468
  // 某个源上的平台版本号
1451
1469
  async function sourceVersion(s) {
1452
1470
  if (s.id === 'gitee') {
@@ -1457,10 +1475,36 @@ async function sourceVersion(s) {
1457
1475
  return (JSON.parse(j) || {}).version || null;
1458
1476
  }
1459
1477
 
1478
+ // 从 NPM tarball(.tgz)中解出指定文件:gzip 解压 + tar 解析
1479
+ // 浏览器原生 DecompressionStream,无需任何第三方库
1480
+ async function tarFile(tgzUrl, wantName) {
1481
+ const resp = await fetch(tgzUrl, { cache:'no-store' });
1482
+ if (!resp.ok) throw new Error('HTTP ' + resp.status);
1483
+ const stream = resp.body.pipeThrough(new DecompressionStream('gzip'));
1484
+ const buf = new Uint8Array(await new Response(stream).arrayBuffer());
1485
+ const dec = new TextDecoder('utf-8');
1486
+ let off = 0;
1487
+ while (off + 512 <= buf.length) {
1488
+ const header = buf.subarray(off, off + 512);
1489
+ // 全零块 = 归档结束
1490
+ let zero = true;
1491
+ for (let i = 0; i < 512; i++) { if (header[i] !== 0) { zero = false; break; } }
1492
+ if (zero) break;
1493
+ const name = dec.decode(header.subarray(0, 100)).replace(/\0[\s\S]*$/, '');
1494
+ const size = parseInt(dec.decode(header.subarray(124, 136)).replace(/\0[\s\S]*$/, '').trim(), 8) || 0;
1495
+ const start = off + 512;
1496
+ if (name.replace(/^package\//, '') === wantName) {
1497
+ return dec.decode(buf.subarray(start, start + size));
1498
+ }
1499
+ off = start + Math.ceil(size / 512) * 512;
1500
+ }
1501
+ throw new Error('压缩包中未找到 ' + wantName);
1502
+ }
1503
+
1460
1504
  // 某个源上的文件内容
1461
1505
  async function sourceFile(s, ver, name) {
1462
1506
  if (s.id === 'gitee') return await fetchGiteeFile(GITEE_PLATFORM_REPO, name);
1463
- return await fetchText(s.fileUrl(ver, name));
1507
+ return await s.file(ver, name);
1464
1508
  }
1465
1509
 
1466
1510
  // 依次尝试所有源
@@ -1552,9 +1596,13 @@ async function downloadToolContent(it) {
1552
1596
  const src = SOURCES.find(s => s.id === 'npmmirror');
1553
1597
  let b64;
1554
1598
  if (it.npmPkg && it.npmFile) {
1555
- // NPM 托管的工具:直接取文件
1556
- const ver = await sourceVersion(src);
1557
- return await fetchText(`https://registry.npmmirror.com/${it.npmPkg}/${ver}/files/${it.npmFile}`);
1599
+ // NPM 托管的工具:从 tarball 里取文件(npmmirror 的 /files/ 有白名单限制)
1600
+ const ver = it.npmVer || (await npmLatestVer(it.npmPkg));
1601
+ try {
1602
+ return await tarFile(`https://registry.npmmirror.com/${it.npmPkg}/-/${it.npmPkg}-${ver}.tgz`, it.npmFile);
1603
+ } catch(e) {
1604
+ return await fetchText(`https://cdn.jsdelivr.net/npm/${it.npmPkg}@${ver}/${it.npmFile}`);
1605
+ }
1558
1606
  }
1559
1607
  if (it.appUrl) {
1560
1608
  const vc = await fetchGiteeFile(it.repo, it.verFile);
@@ -1649,10 +1697,20 @@ async function checkOneUpd(it, token) {
1649
1697
  // 没有远程更新源的工具:不做版本比对
1650
1698
  if (it.noSrc) { r.latest = it.cur; r.note = '本地工具(无远程更新源)'; return r; }
1651
1699
 
1700
+ // ① 优先用 NPM 清单里声明的版本号——版本检查不再频繁请求 Gitee,避免被限流
1701
+ if (it.manifestVer) {
1702
+ r.latest = it.manifestVer;
1703
+ r.srcLabel = 'NPM清单';
1704
+ r.hasNew = verGt(r.latest, r.cur);
1705
+ return r;
1706
+ }
1707
+
1708
+ // ② 清单未声明版本时,才回退去读工具自身仓库
1652
1709
  try {
1653
1710
  const vc = await fetchGiteeFile(it.repo, it.verFile, token);
1654
1711
  r.latest = parseVer(vc, it.pat);
1655
1712
  if (!r.latest) { r.error = '版本文件中未找到版本号'; return r; }
1713
+ r.srcLabel = 'Gitee';
1656
1714
  r.hasNew = verGt(r.latest, r.cur);
1657
1715
  } catch(e) { r.error = e.message; }
1658
1716
  return r;
package/tools.json CHANGED
@@ -1,82 +1,82 @@
1
- {
2
- "schema": 1,
3
- "platform": "1.1.6",
4
- "updatedAt": "2026-09-10",
5
- "note": "WWT 工作平台工具清单。新增/修改工具只需改这个文件并发布新版本,用户端自动同步,无需重新分发平台。",
6
- "tools": [
7
- {
8
- "key": "ledger-clear",
9
- "name": "往来款项两清工具",
10
- "module": "fin",
11
- "desc": "自动对账核销,支持 Excel 导入",
12
- "ver": "1.0.0",
13
- "type": "html",
14
- "tag": "HTML",
15
- "path": "C:/Users/Administrator/Desktop/往来款项两清工具.html",
16
- "src": null
17
- },
18
- {
19
- "key": "erp-recon",
20
- "name": "ERP对账工具",
21
- "module": "fin",
22
- "desc": "ERP 系统多模块对账比对",
23
- "ver": "1.1.10",
24
- "type": "html",
25
- "tag": "HTML",
26
- "path": "C:/Users/Administrator/Desktop/ERP对账工具更新版.html",
27
- "src": {
28
- "type": "gitee",
29
- "repo": "wwtmrhu/erp-recon",
30
- "verFile": "version.js",
31
- "appFile": "app.js",
32
- "pat": "__ERP_LATEST_VER"
33
- }
34
- },
35
- {
36
- "key": "erp-tool",
37
- "name": "ERP对账单生成匹配",
38
- "module": "fin",
39
- "desc": "对账单自动生成与匹配",
40
- "ver": "2.0.45",
41
- "type": "html",
42
- "tag": "HTML",
43
- "path": "C:/Users/Administrator/Desktop/ERP对账单生成匹配工具更新版.html",
44
- "src": {
45
- "type": "gitee",
46
- "repo": "wwtmrhu/erp-tool",
47
- "verFile": "version.js",
48
- "appFile": "app.js",
49
- "pat": "__ERP_LATEST_VER"
50
- }
51
- },
52
- {
53
- "key": "kkd",
54
- "name": "WWT快快对",
55
- "module": "fin",
56
- "desc": "往来账双向自动对账",
57
- "ver": "1.0.0",
58
- "type": "html",
59
- "tag": "HTML",
60
- "path": "C:/Users/Administrator/WorkBuddy/2026-08-12-10-53-10/WWT快快对.html",
61
- "src": null
62
- },
63
- {
64
- "key": "voucher",
65
- "name": "WWT凭证工具",
66
- "module": "fin",
67
- "desc": "自动生成记账凭证,支持规则配置、凭证审核、导出金蝶",
68
- "ver": "P1.2.36",
69
- "type": "html",
70
- "tag": "HTML",
71
- "path": "C:/Users/Administrator/Desktop/WWT凭证工具_P1.2.36.html",
72
- "src": {
73
- "type": "gitee",
74
- "repo": "wwtmrhu/certificate-generation",
75
- "verFile": "dist/version.json",
76
- "appFile": "",
77
- "pat": "ver",
78
- "appUrl": true
79
- }
80
- }
81
- ]
82
- }
1
+ {
2
+ "schema": 1,
3
+ "platform": "1.1.8",
4
+ "updatedAt": "2026-09-10",
5
+ "note": "WWT 工作平台工具清单。新增/修改工具只需改这个文件并发布新版本,用户端自动同步,无需重新分发平台。",
6
+ "tools": [
7
+ {
8
+ "key": "ledger-clear",
9
+ "name": "往来款项两清工具",
10
+ "module": "fin",
11
+ "desc": "自动对账核销,支持 Excel 导入",
12
+ "ver": "1.0.0",
13
+ "type": "html",
14
+ "tag": "HTML",
15
+ "path": "C:/Users/Administrator/Desktop/往来款项两清工具.html",
16
+ "src": null
17
+ },
18
+ {
19
+ "key": "erp-recon",
20
+ "name": "ERP对账工具",
21
+ "module": "fin",
22
+ "desc": "ERP 系统多模块对账比对",
23
+ "ver": "1.1.10",
24
+ "type": "html",
25
+ "tag": "HTML",
26
+ "path": "C:/Users/Administrator/Desktop/ERP对账工具更新版.html",
27
+ "src": {
28
+ "type": "gitee",
29
+ "repo": "wwtmrhu/erp-recon",
30
+ "verFile": "version.js",
31
+ "appFile": "app.js",
32
+ "pat": "__ERP_LATEST_VER"
33
+ }
34
+ },
35
+ {
36
+ "key": "erp-tool",
37
+ "name": "ERP对账单生成匹配",
38
+ "module": "fin",
39
+ "desc": "对账单自动生成与匹配",
40
+ "ver": "2.0.45",
41
+ "type": "html",
42
+ "tag": "HTML",
43
+ "path": "C:/Users/Administrator/Desktop/ERP对账单生成匹配工具更新版.html",
44
+ "src": {
45
+ "type": "gitee",
46
+ "repo": "wwtmrhu/erp-tool",
47
+ "verFile": "version.js",
48
+ "appFile": "app.js",
49
+ "pat": "__ERP_LATEST_VER"
50
+ }
51
+ },
52
+ {
53
+ "key": "kkd",
54
+ "name": "WWT快快对",
55
+ "module": "fin",
56
+ "desc": "往来账双向自动对账",
57
+ "ver": "1.0.0",
58
+ "type": "html",
59
+ "tag": "HTML",
60
+ "path": "C:/Users/Administrator/WorkBuddy/2026-08-12-10-53-10/WWT快快对.html",
61
+ "src": null
62
+ },
63
+ {
64
+ "key": "voucher",
65
+ "name": "WWT凭证工具",
66
+ "module": "fin",
67
+ "desc": "自动生成记账凭证,支持规则配置、凭证审核、导出金蝶",
68
+ "ver": "P1.2.36",
69
+ "type": "html",
70
+ "tag": "HTML",
71
+ "path": "C:/Users/Administrator/Desktop/WWT凭证工具_P1.2.36.html",
72
+ "src": {
73
+ "type": "gitee",
74
+ "repo": "wwtmrhu/certificate-generation",
75
+ "verFile": "dist/version.json",
76
+ "appFile": "",
77
+ "pat": "ver",
78
+ "appUrl": true
79
+ }
80
+ }
81
+ ]
82
+ }