@noob-stupid/dsh-plugin-console 0.3.8 → 0.3.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.
Files changed (2) hide show
  1. package/lib/client.js +17 -4
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -1024,12 +1024,25 @@ window.__ModuleLoader__.load({
1024
1024
  (data) => {
1025
1025
  if (data && data.error === null) {
1026
1026
  const current = state.data.compat?.dshVersion ?? "";
1027
- // 版本号比较(防 current 已是 rc.8 时误判 rc.7 为升级目标;rc.N 数字比较)
1028
- const verNum = (v) => { const m = String(v).match(/0\.1\.0-rc\.(\d+)/u); return m ? parseInt(m[1], 10) : -1; };
1027
+ // 通用 semver 比较(支持 0.1.0-rc.8 → 0.1.1-rc.2 跨 minor 升级;0.1.1-rc.N 不再写死 0.1.0)
1028
+ const verNum = (v) => {
1029
+ const m = String(v).match(/^(\d+)\.(\d+)\.(\d+)(?:-(?:[a-z]+\.)?(\d+))?$/iu);
1030
+ if (!m) return -1;
1031
+ const [ , maj, min, pat, rc ] = m;
1032
+ // 正式版(无 rc)视为 rc.∞:0.1.1 > 0.1.1-rc.2
1033
+ return { maj: parseInt(maj, 10), min: parseInt(min, 10), pat: parseInt(pat, 10), rc: rc === undefined ? Number.POSITIVE_INFINITY : parseInt(rc, 10) };
1034
+ };
1035
+ const isNewer = (a, b) => {
1036
+ if (a === -1 || b === -1) return false;
1037
+ if (a.maj !== b.maj) return a.maj > b.maj;
1038
+ if (a.min !== b.min) return a.min > b.min;
1039
+ if (a.pat !== b.pat) return a.pat > b.pat;
1040
+ return a.rc > b.rc;
1041
+ };
1029
1042
  // 稳定版 latest 优先;latest 不高于当前而 next(预发布渠道)更高时,目标取 next
1030
- const target = data.latest && verNum(data.latest) > verNum(current)
1043
+ const target = data.latest && isNewer(verNum(data.latest), verNum(current))
1031
1044
  ? data.latest
1032
- : (data.next && verNum(data.next) > verNum(current) ? data.next : null);
1045
+ : (data.next && isNewer(verNum(data.next), verNum(current)) ? data.next : null);
1033
1046
  if (target) setUpdateMap((prev) => ({ ...prev, [fwItem.fullName]: target }));
1034
1047
  }
1035
1048
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noob-stupid/dsh-plugin-console",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
4
4
  "description": "DSH plugin management panel \u0026 marketplace: one-click enable/disable, multi-source market (GitHub/Gitee/custom), static-index market (500+ plugins / 300 skills), skills, suites, and one-click framework upgrade.",
5
5
  "repository": {
6
6
  "type": "git",