ohos-router 1.2.4 → 1.2.6
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/package.json +1 -1
- package/router.ts +11 -5
package/package.json
CHANGED
package/router.ts
CHANGED
|
@@ -19,13 +19,14 @@ export function pluginStart(node: HvigorNode, isExecute: boolean, filterModule:
|
|
|
19
19
|
let nodeName = childNode.getNodeName()
|
|
20
20
|
let upperCaseName = nodeName.substring(0, 1).toUpperCase() + nodeName.substring(1, nodeName.length)
|
|
21
21
|
//默认Entry不追加
|
|
22
|
-
|
|
22
|
+
let isFilter = filterModule.includes(nodeName)//是否包含
|
|
23
|
+
|
|
24
|
+
if ("Entry" != upperCaseName && !isFilter) {
|
|
23
25
|
entryUpperCaseNameArray.push(upperCaseName)
|
|
24
26
|
entryIsHsp.push(isHsp)
|
|
25
27
|
}
|
|
26
|
-
let configPath = FileUtil.pathResolve(childNode.getNodePath(), upperCaseName + "RouterConfig.ets")
|
|
27
28
|
|
|
28
|
-
let
|
|
29
|
+
let configPath = FileUtil.pathResolve(childNode.getNodePath(), upperCaseName + "RouterConfig.ets")
|
|
29
30
|
|
|
30
31
|
if (!FileUtil.exist(configPath) && !isFilter) {
|
|
31
32
|
FileUtil.ensureFileSync(configPath)
|
|
@@ -167,6 +168,10 @@ export function pluginStart(node: HvigorNode, isExecute: boolean, filterModule:
|
|
|
167
168
|
|
|
168
169
|
//这个必须要带
|
|
169
170
|
let exportClassIndex = appFileDataString.indexOf("export class");
|
|
171
|
+
|
|
172
|
+
if(exportClassIndex == -1){
|
|
173
|
+
exportClassIndex = appFileDataString.indexOf("export default");
|
|
174
|
+
}
|
|
170
175
|
let exportContent = appFileDataString.substring(0, exportClassIndex);
|
|
171
176
|
|
|
172
177
|
if (exportContent.indexOf(name + "RouterConfig") == -1) {
|
|
@@ -195,7 +200,8 @@ export function pluginStart(node: HvigorNode, isExecute: boolean, filterModule:
|
|
|
195
200
|
initNewConfig = initNewConfig + (" new " + name + "RouterConfig(" + endHsp + "),\n")
|
|
196
201
|
importNewConfig = importNewConfig + "\nimport { " + name + "RouterConfig } from '" + name.toLowerCase() + "';\n"
|
|
197
202
|
})
|
|
198
|
-
|
|
203
|
+
const moduleSrcEntryCount = moduleSrcEntry.split("/").length;
|
|
204
|
+
const endSrcEntryString = "../".repeat(moduleSrcEntryCount);
|
|
199
205
|
let routerInitTag = "onCreate(): void {"
|
|
200
206
|
let routerInitPosition = appFileDataString.indexOf(routerInitTag) + routerInitTag.length
|
|
201
207
|
let routerJson = "\n routerInitConfig([\n" +
|
|
@@ -204,7 +210,7 @@ export function pluginStart(node: HvigorNode, isExecute: boolean, filterModule:
|
|
|
204
210
|
" ])\n"
|
|
205
211
|
let routerInitContent = insertString(appFileDataString, routerInitPosition, routerJson)
|
|
206
212
|
routerInitContent = "import { getARouter,routerInitConfig } from '@abner/router';\n" +
|
|
207
|
-
"import { EntryRouterConfig } from '
|
|
213
|
+
"import { EntryRouterConfig } from '"+endSrcEntryString+"EntryRouterConfig';\n"
|
|
208
214
|
+ importNewConfig
|
|
209
215
|
+ routerInitContent
|
|
210
216
|
FileUtil.writeFileSync(endAppPath, routerInitContent);
|