openprototype 1.7.1 → 1.8.1
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/bin/cli.js +46 -0
- package/package.json +1 -1
- package/product/demo/pc/index.html +3 -12
- package/templates/product-shell/index.html +3 -12
package/bin/cli.js
CHANGED
|
@@ -135,6 +135,27 @@ const LAN_ADDRESS_CLICK = ` document.getElementById('copyAddressBtn').addEventL
|
|
|
135
135
|
showToast(err.message || '局域网地址读取失败');
|
|
136
136
|
}
|
|
137
137
|
});`;
|
|
138
|
+
const FUZZY_VERSION_MATCH_CALL = 'fuzzyVersionMatch(prdVer, currentVer)';
|
|
139
|
+
const EXACT_VERSION_MATCH_CALL = 'versionSearchMatch(prdVer, currentVer)';
|
|
140
|
+
const FUZZY_VERSION_MATCH_HELPER = `function fuzzyVersionMatch(version, keyword) {
|
|
141
|
+
const source = normalizeVersionSearchText(version);
|
|
142
|
+
const target = normalizeVersionSearchText(keyword);
|
|
143
|
+
if (!target) return true;
|
|
144
|
+
if (source.indexOf(target) !== -1) return true;
|
|
145
|
+
|
|
146
|
+
let index = 0;
|
|
147
|
+
for (const char of target) {
|
|
148
|
+
index = source.indexOf(char, index);
|
|
149
|
+
if (index === -1) return false;
|
|
150
|
+
index++;
|
|
151
|
+
}
|
|
152
|
+
return true;
|
|
153
|
+
}`;
|
|
154
|
+
const EXACT_VERSION_MATCH_HELPER = `function versionSearchMatch(version, keyword) {
|
|
155
|
+
const source = normalizeVersionSearchText(version);
|
|
156
|
+
const target = normalizeVersionSearchText(keyword);
|
|
157
|
+
return !!target && source === target;
|
|
158
|
+
}`;
|
|
138
159
|
const LEGACY_LAN_ADDRESS_MARK = 'openprototype:lan-address:start';
|
|
139
160
|
const LEGACY_LAN_ADDRESS_BLOCK = `<!-- openprototype:lan-address:start -->
|
|
140
161
|
<script>
|
|
@@ -298,6 +319,30 @@ function patchShellLanAddress(projectRoot) {
|
|
|
298
319
|
return patched;
|
|
299
320
|
}
|
|
300
321
|
|
|
322
|
+
/** 把旧产品壳的版本模糊匹配迁移为忽略格式差异后的完整匹配。 */
|
|
323
|
+
function patchShellVersionSearch(projectRoot) {
|
|
324
|
+
let patched = 0;
|
|
325
|
+
for (const shell of listProductShells(projectRoot)) {
|
|
326
|
+
const rel = path.relative(projectRoot, shell);
|
|
327
|
+
let html = fs.readFileSync(shell, 'utf8');
|
|
328
|
+
if (html.includes(EXACT_VERSION_MATCH_CALL) && html.includes(EXACT_VERSION_MATCH_HELPER)) {
|
|
329
|
+
info(C.dim(' 跳过(版本搜索已是精确匹配): ') + rel);
|
|
330
|
+
continue;
|
|
331
|
+
}
|
|
332
|
+
if (!html.includes(FUZZY_VERSION_MATCH_CALL) || !html.includes(FUZZY_VERSION_MATCH_HELPER)) {
|
|
333
|
+
info(C.dim(' 跳过(版本搜索逻辑不是已知旧版本): ') + rel);
|
|
334
|
+
continue;
|
|
335
|
+
}
|
|
336
|
+
html = html
|
|
337
|
+
.replace(FUZZY_VERSION_MATCH_CALL, EXACT_VERSION_MATCH_CALL)
|
|
338
|
+
.replace(FUZZY_VERSION_MATCH_HELPER, EXACT_VERSION_MATCH_HELPER);
|
|
339
|
+
fs.writeFileSync(shell, html);
|
|
340
|
+
ok('已迁移版本精确搜索 ' + rel);
|
|
341
|
+
patched++;
|
|
342
|
+
}
|
|
343
|
+
return patched;
|
|
344
|
+
}
|
|
345
|
+
|
|
301
346
|
/** 新项目 package.json 里本框架的依赖版本(已发布 npm,语义化版本管理) */
|
|
302
347
|
function kitDependencySpec() {
|
|
303
348
|
const pkg = readJson(path.join(PKG_ROOT, 'package.json'), {});
|
|
@@ -381,6 +426,7 @@ async function cmdInit() {
|
|
|
381
426
|
|
|
382
427
|
patchShellOnboarding(root);
|
|
383
428
|
patchShellLanAddress(root);
|
|
429
|
+
patchShellVersionSearch(root);
|
|
384
430
|
|
|
385
431
|
// 合并 package.json 脚本(不覆盖用户已有脚本)
|
|
386
432
|
const pkgPath = path.join(root, 'package.json');
|
package/package.json
CHANGED
|
@@ -807,7 +807,7 @@ function applyVersionBadge(path, ver) {
|
|
|
807
807
|
function refreshVersionMatch(row) {
|
|
808
808
|
const currentVer = (document.getElementById('versionInput').value || '').trim();
|
|
809
809
|
const prdVer = row.dataset.prdVersion || '';
|
|
810
|
-
const isMatch = currentVer && prdVer &&
|
|
810
|
+
const isMatch = currentVer && prdVer && versionSearchMatch(prdVer, currentVer);
|
|
811
811
|
row.classList.toggle('version-match', isMatch);
|
|
812
812
|
const badge = row.querySelector('.version-badge');
|
|
813
813
|
if (badge) badge.classList.toggle('match', isMatch);
|
|
@@ -969,19 +969,10 @@ function normalizeVersionSearchText(text) {
|
|
|
969
969
|
return normalizeSearchText(text).replace(/[._-]/g, '');
|
|
970
970
|
}
|
|
971
971
|
|
|
972
|
-
function
|
|
972
|
+
function versionSearchMatch(version, keyword) {
|
|
973
973
|
const source = normalizeVersionSearchText(version);
|
|
974
974
|
const target = normalizeVersionSearchText(keyword);
|
|
975
|
-
|
|
976
|
-
if (source.indexOf(target) !== -1) return true;
|
|
977
|
-
|
|
978
|
-
let index = 0;
|
|
979
|
-
for (const char of target) {
|
|
980
|
-
index = source.indexOf(char, index);
|
|
981
|
-
if (index === -1) return false;
|
|
982
|
-
index++;
|
|
983
|
-
}
|
|
984
|
-
return true;
|
|
975
|
+
return !!target && source === target;
|
|
985
976
|
}
|
|
986
977
|
|
|
987
978
|
function renderVersionHistory() {
|
|
@@ -807,7 +807,7 @@ function applyVersionBadge(path, ver) {
|
|
|
807
807
|
function refreshVersionMatch(row) {
|
|
808
808
|
const currentVer = (document.getElementById('versionInput').value || '').trim();
|
|
809
809
|
const prdVer = row.dataset.prdVersion || '';
|
|
810
|
-
const isMatch = currentVer && prdVer &&
|
|
810
|
+
const isMatch = currentVer && prdVer && versionSearchMatch(prdVer, currentVer);
|
|
811
811
|
row.classList.toggle('version-match', isMatch);
|
|
812
812
|
const badge = row.querySelector('.version-badge');
|
|
813
813
|
if (badge) badge.classList.toggle('match', isMatch);
|
|
@@ -969,19 +969,10 @@ function normalizeVersionSearchText(text) {
|
|
|
969
969
|
return normalizeSearchText(text).replace(/[._-]/g, '');
|
|
970
970
|
}
|
|
971
971
|
|
|
972
|
-
function
|
|
972
|
+
function versionSearchMatch(version, keyword) {
|
|
973
973
|
const source = normalizeVersionSearchText(version);
|
|
974
974
|
const target = normalizeVersionSearchText(keyword);
|
|
975
|
-
|
|
976
|
-
if (source.indexOf(target) !== -1) return true;
|
|
977
|
-
|
|
978
|
-
let index = 0;
|
|
979
|
-
for (const char of target) {
|
|
980
|
-
index = source.indexOf(char, index);
|
|
981
|
-
if (index === -1) return false;
|
|
982
|
-
index++;
|
|
983
|
-
}
|
|
984
|
-
return true;
|
|
975
|
+
return !!target && source === target;
|
|
985
976
|
}
|
|
986
977
|
|
|
987
978
|
function renderVersionHistory() {
|