@ray-js/build-plugin-router 1.6.24 → 1.6.26
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/lib/index.js +30 -10
- package/package.json +4 -4
package/lib/index.js
CHANGED
@@ -81,7 +81,7 @@ function normalizeTabBarConfig(config, routes, fields) {
|
|
81
81
|
let { list } = config, rest = __rest(config, ["list"]);
|
82
82
|
let cfg;
|
83
83
|
if (!lodash_1.default.isArray(list)) {
|
84
|
-
printError(
|
84
|
+
printError(shared_1.i18n.__('tabBarInvalidStructure').red);
|
85
85
|
return cfg;
|
86
86
|
}
|
87
87
|
list = list.map((tab) => {
|
@@ -107,13 +107,17 @@ function normalizeTabBarConfig(config, routes, fields) {
|
|
107
107
|
var _a;
|
108
108
|
const m = routes.find((i) => tab.pagePath === i.path);
|
109
109
|
if (!m) {
|
110
|
-
printError(
|
110
|
+
printError(shared_1.i18n.__('tabBarPagePathNotInRoutes', {
|
111
|
+
index,
|
112
|
+
pagePath: tab.pagePath,
|
113
|
+
routes: JSON.stringify(routes, null, 2),
|
114
|
+
}).red);
|
111
115
|
return;
|
112
116
|
}
|
113
117
|
let pagePath = tab.pagePath.replace(/^\//, '');
|
114
118
|
const urlObj = url_1.default.parse(pagePath);
|
115
119
|
if (urlObj.hash || urlObj.search) {
|
116
|
-
printError(
|
120
|
+
printError(shared_1.i18n.__('tabBarNoParams', { index, pagePath: tab.pagePath }).red);
|
117
121
|
return;
|
118
122
|
}
|
119
123
|
pagePath = urlObj.pathname;
|
@@ -124,7 +128,12 @@ function normalizeTabBarConfig(config, routes, fields) {
|
|
124
128
|
// 判断是否能被路由命中
|
125
129
|
const matched = (0, path_to_regexp_1.match)((_a = m.route) !== null && _a !== void 0 ? _a : m.path)(tab.route);
|
126
130
|
if (!matched) {
|
127
|
-
printError(
|
131
|
+
printError(shared_1.i18n.__('tabBarRouteNotMatched', {
|
132
|
+
index,
|
133
|
+
route: tab.route,
|
134
|
+
pagePath: tab.pagePath,
|
135
|
+
routeInfo: JSON.stringify(m, null, 2),
|
136
|
+
}).red);
|
128
137
|
return;
|
129
138
|
}
|
130
139
|
// 判断是否还被其他路由命中
|
@@ -133,12 +142,23 @@ function normalizeTabBarConfig(config, routes, fields) {
|
|
133
142
|
.filter((r) => { var _a; return (0, path_to_regexp_1.match)((_a = r.route) !== null && _a !== void 0 ? _a : r.path)(tab.route); });
|
134
143
|
const unusable = otherMatched.filter((r) => r.path !== tab.pagePath);
|
135
144
|
if (unusable.length) {
|
136
|
-
printError(
|
145
|
+
printError(shared_1.i18n.__('tabBarRouteMatchedMultiple', {
|
146
|
+
index,
|
147
|
+
route: tab.route,
|
148
|
+
pagePath: tab.pagePath,
|
149
|
+
matchedRoute: JSON.stringify(m, null, 2),
|
150
|
+
otherRoutes: JSON.stringify(unusable, null, 2),
|
151
|
+
}).red);
|
137
152
|
return;
|
138
153
|
}
|
139
154
|
// tab中配置的页面.route 匹配的页面为模式匹配,需给出告警
|
140
155
|
if (!lodash_1.default.isEmpty(matched.params)) {
|
141
|
-
console.warn(LOG_PREFIX,
|
156
|
+
console.warn(LOG_PREFIX, shared_1.i18n.__('tabBarPatternMatchWarning', {
|
157
|
+
index,
|
158
|
+
route: tab.route,
|
159
|
+
routeInfo: JSON.stringify(m, null, 2),
|
160
|
+
mRoute: m.route,
|
161
|
+
}).yellow);
|
142
162
|
}
|
143
163
|
return {
|
144
164
|
pagePath,
|
@@ -149,14 +169,14 @@ function normalizeTabBarConfig(config, routes, fields) {
|
|
149
169
|
})
|
150
170
|
.filter((tab) => !!tab);
|
151
171
|
if (tabs.length < 2 || tabs.length > 5) {
|
152
|
-
printError(
|
172
|
+
printError(shared_1.i18n.__('tabBarCountLimit').red);
|
153
173
|
return cfg;
|
154
174
|
}
|
155
175
|
_cfg.list = tabs;
|
156
176
|
// 找出 tabBar.list[number].pagePath 重复的配置
|
157
177
|
const _list = duplicates(tabs, (a, b) => (a.pagePath > b.pagePath ? 1 : a.pagePath == b.pagePath ? 0 : -1), 'pagePath');
|
158
178
|
if (_list.length) {
|
159
|
-
console.error(LOG_PREFIX,
|
179
|
+
console.error(LOG_PREFIX, shared_1.i18n.__('tabBarDuplicatePages', { duplicates: JSON.stringify(_list, null, 2) }).red);
|
160
180
|
}
|
161
181
|
cfg = fields.reduce((o, next) => {
|
162
182
|
const [src, t] = typeof next === 'string' ? [next] : next;
|
@@ -194,7 +214,7 @@ function PluginRouter(api) {
|
|
194
214
|
readConfigFromConfigFile() {
|
195
215
|
const routesConfigFile = api.searchJSFile(`${source}/routes.config`);
|
196
216
|
if (!routesConfigFile) {
|
197
|
-
throw new Error(
|
217
|
+
throw new Error(shared_1.i18n.__('missingConfigFile'));
|
198
218
|
}
|
199
219
|
const globalConfigFile = api.searchJSFile(`${source}/global.config`);
|
200
220
|
const routesConfig = api.requireJSFile(routesConfigFile);
|
@@ -285,7 +305,7 @@ function PluginRouter(api) {
|
|
285
305
|
const templateFile = path_1.default.join(__dirname, '../templates/app.config.ejs');
|
286
306
|
const context = ejsRender(templateFile, { appConfig: { [target]: data } });
|
287
307
|
api.writeFile(`${source}/app.config.ts`, context);
|
288
|
-
shared_1.log.verbose(LOG_PREFIX, `generate`, `${source}/app.config.ts`.underline.green,
|
308
|
+
shared_1.log.verbose(LOG_PREFIX, `generate`, `${source}/app.config.ts`.underline.green, shared_1.i18n.__('forWechatPlatform'));
|
289
309
|
},
|
290
310
|
};
|
291
311
|
// todo theme 逻辑不应该在这个文件
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ray-js/build-plugin-router",
|
3
|
-
"version": "1.6.
|
3
|
+
"version": "1.6.26",
|
4
4
|
"description": "Ray build plugin for router",
|
5
5
|
"keywords": [
|
6
6
|
"ray"
|
@@ -24,7 +24,7 @@
|
|
24
24
|
"watch": "tsc -p ./tsconfig.build.json --watch"
|
25
25
|
},
|
26
26
|
"dependencies": {
|
27
|
-
"@ray-js/shared": "1.6.
|
27
|
+
"@ray-js/shared": "1.6.26",
|
28
28
|
"chokidar": "^3.6.0",
|
29
29
|
"colors": "1.4.0",
|
30
30
|
"ejs": "^3.1.10",
|
@@ -33,11 +33,11 @@
|
|
33
33
|
"url": "^0.11.4"
|
34
34
|
},
|
35
35
|
"devDependencies": {
|
36
|
-
"@ray-js/types": "1.6.
|
36
|
+
"@ray-js/types": "1.6.26"
|
37
37
|
},
|
38
38
|
"publishConfig": {
|
39
39
|
"access": "public",
|
40
40
|
"registry": "https://registry.npmjs.com"
|
41
41
|
},
|
42
|
-
"gitHead": "
|
42
|
+
"gitHead": "d842231dd15303495069483a809a71dbc640ebaf"
|
43
43
|
}
|