@uni-helper/vite-plugin-uni-pages 0.4.6 → 0.4.7
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/README.md +2 -1
- package/dist/index.cjs +10 -3
- package/dist/index.mjs +10 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -253,7 +253,8 @@ export default defineConfig({
|
|
|
253
253
|
本插件默认会:
|
|
254
254
|
|
|
255
255
|
- 通过文件锁串行化对 `pages.json` 的「读取已有内容 → 合并当前平台配置 → 写回」整个流程,避免并发写入互相覆盖;
|
|
256
|
-
- 保留其他平台已经写入的条件编译块(`#ifdef H5` / `#ifndef MP-WEIXIN`
|
|
256
|
+
- 保留其他平台已经写入的条件编译块(`#ifdef H5` / `#ifndef MP-WEIXIN` 等),只更新当前平台对应的条目;
|
|
257
|
+
- 对同一 `path`(或 tabBar 的 `pagePath`)的条目按内容去重:内容相同的条目会合并为一条并叠加平台标识(如 `H5 || MP-WEIXIN`),不会因为先后跑过多个平台而产生重复路由。
|
|
257
258
|
|
|
258
259
|
这样每个终端都能保留各自的平台配置。条件编译注释基于 `comment-json` 写入,最终 `pages.json` 同时包含所有平台的分支。
|
|
259
260
|
|
package/dist/index.cjs
CHANGED
|
@@ -1207,6 +1207,13 @@ function mergePlatformItems(source, currentPlatform, items, uniqueKeyName) {
|
|
|
1207
1207
|
});
|
|
1208
1208
|
tmpMap.set(uniqueKey, existing);
|
|
1209
1209
|
}
|
|
1210
|
+
const stringifyForCompare = (val) => {
|
|
1211
|
+
if (val && typeof val === "object" && "type" in val) {
|
|
1212
|
+
const { type: _type, ...rest } = val;
|
|
1213
|
+
return JSON.stringify(rest);
|
|
1214
|
+
}
|
|
1215
|
+
return JSON.stringify(val);
|
|
1216
|
+
};
|
|
1210
1217
|
for (const item of items) {
|
|
1211
1218
|
const newItem = item;
|
|
1212
1219
|
const uniqueKey = item[uniqueKeyName];
|
|
@@ -1214,14 +1221,14 @@ function mergePlatformItems(source, currentPlatform, items, uniqueKeyName) {
|
|
|
1214
1221
|
if (!tmpMap.has(uniqueKey)) {
|
|
1215
1222
|
tmpMap.set(uniqueKey, [{
|
|
1216
1223
|
item: newItem,
|
|
1217
|
-
itemStr:
|
|
1224
|
+
itemStr: stringifyForCompare(newItem),
|
|
1218
1225
|
platforms: [currentPlatform],
|
|
1219
1226
|
platformStr: currentPlatform
|
|
1220
1227
|
}]);
|
|
1221
1228
|
continue;
|
|
1222
1229
|
}
|
|
1223
1230
|
const existing = tmpMap.get(uniqueKey);
|
|
1224
|
-
const newItemStr =
|
|
1231
|
+
const newItemStr = stringifyForCompare(newItem);
|
|
1225
1232
|
const equalObj = existing.find((val) => val.itemStr === newItemStr);
|
|
1226
1233
|
if (equalObj) {
|
|
1227
1234
|
equalObj.platforms.push(currentPlatform);
|
|
@@ -1229,7 +1236,7 @@ function mergePlatformItems(source, currentPlatform, items, uniqueKeyName) {
|
|
|
1229
1236
|
equalObj.platformStr = equalObj.platforms.join(" || ");
|
|
1230
1237
|
} else existing.push({
|
|
1231
1238
|
item: newItem,
|
|
1232
|
-
itemStr:
|
|
1239
|
+
itemStr: stringifyForCompare(newItem),
|
|
1233
1240
|
platforms: [currentPlatform],
|
|
1234
1241
|
platformStr: currentPlatform
|
|
1235
1242
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1166,6 +1166,13 @@ function mergePlatformItems(source, currentPlatform, items, uniqueKeyName) {
|
|
|
1166
1166
|
});
|
|
1167
1167
|
tmpMap.set(uniqueKey, existing);
|
|
1168
1168
|
}
|
|
1169
|
+
const stringifyForCompare = (val) => {
|
|
1170
|
+
if (val && typeof val === "object" && "type" in val) {
|
|
1171
|
+
const { type: _type, ...rest } = val;
|
|
1172
|
+
return JSON.stringify(rest);
|
|
1173
|
+
}
|
|
1174
|
+
return JSON.stringify(val);
|
|
1175
|
+
};
|
|
1169
1176
|
for (const item of items) {
|
|
1170
1177
|
const newItem = item;
|
|
1171
1178
|
const uniqueKey = item[uniqueKeyName];
|
|
@@ -1173,14 +1180,14 @@ function mergePlatformItems(source, currentPlatform, items, uniqueKeyName) {
|
|
|
1173
1180
|
if (!tmpMap.has(uniqueKey)) {
|
|
1174
1181
|
tmpMap.set(uniqueKey, [{
|
|
1175
1182
|
item: newItem,
|
|
1176
|
-
itemStr:
|
|
1183
|
+
itemStr: stringifyForCompare(newItem),
|
|
1177
1184
|
platforms: [currentPlatform],
|
|
1178
1185
|
platformStr: currentPlatform
|
|
1179
1186
|
}]);
|
|
1180
1187
|
continue;
|
|
1181
1188
|
}
|
|
1182
1189
|
const existing = tmpMap.get(uniqueKey);
|
|
1183
|
-
const newItemStr =
|
|
1190
|
+
const newItemStr = stringifyForCompare(newItem);
|
|
1184
1191
|
const equalObj = existing.find((val) => val.itemStr === newItemStr);
|
|
1185
1192
|
if (equalObj) {
|
|
1186
1193
|
equalObj.platforms.push(currentPlatform);
|
|
@@ -1188,7 +1195,7 @@ function mergePlatformItems(source, currentPlatform, items, uniqueKeyName) {
|
|
|
1188
1195
|
equalObj.platformStr = equalObj.platforms.join(" || ");
|
|
1189
1196
|
} else existing.push({
|
|
1190
1197
|
item: newItem,
|
|
1191
|
-
itemStr:
|
|
1198
|
+
itemStr: stringifyForCompare(newItem),
|
|
1192
1199
|
platforms: [currentPlatform],
|
|
1193
1200
|
platformStr: currentPlatform
|
|
1194
1201
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uni-helper/vite-plugin-uni-pages",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.7",
|
|
5
5
|
"description": "File system based routing for uni-app applications using Vite",
|
|
6
6
|
"author": "KeJun",
|
|
7
7
|
"maintainers": [
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"unconfig": "^7.5.0",
|
|
73
73
|
"write-file-atomic": "^7.0.1",
|
|
74
74
|
"yaml": "^2.9.0",
|
|
75
|
-
"@uni-helper/uni-pages-types": "0.4.
|
|
75
|
+
"@uni-helper/uni-pages-types": "0.4.7"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"@antfu/utils": "^9.3.0",
|