ohos-router 1.2.5 → 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/router.ts +7 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ohos-router",
3
- "version": "1.2.5",
3
+ "version": "1.2.6",
4
4
  "description": "鸿蒙路由管理插件",
5
5
  "main": "main.js",
6
6
  "scripts": {
package/router.ts CHANGED
@@ -168,6 +168,10 @@ export function pluginStart(node: HvigorNode, isExecute: boolean, filterModule:
168
168
 
169
169
  //这个必须要带
170
170
  let exportClassIndex = appFileDataString.indexOf("export class");
171
+
172
+ if(exportClassIndex == -1){
173
+ exportClassIndex = appFileDataString.indexOf("export default");
174
+ }
171
175
  let exportContent = appFileDataString.substring(0, exportClassIndex);
172
176
 
173
177
  if (exportContent.indexOf(name + "RouterConfig") == -1) {
@@ -196,7 +200,8 @@ export function pluginStart(node: HvigorNode, isExecute: boolean, filterModule:
196
200
  initNewConfig = initNewConfig + (" new " + name + "RouterConfig(" + endHsp + "),\n")
197
201
  importNewConfig = importNewConfig + "\nimport { " + name + "RouterConfig } from '" + name.toLowerCase() + "';\n"
198
202
  })
199
-
203
+ const moduleSrcEntryCount = moduleSrcEntry.split("/").length;
204
+ const endSrcEntryString = "../".repeat(moduleSrcEntryCount);
200
205
  let routerInitTag = "onCreate(): void {"
201
206
  let routerInitPosition = appFileDataString.indexOf(routerInitTag) + routerInitTag.length
202
207
  let routerJson = "\n routerInitConfig([\n" +
@@ -205,7 +210,7 @@ export function pluginStart(node: HvigorNode, isExecute: boolean, filterModule:
205
210
  " ])\n"
206
211
  let routerInitContent = insertString(appFileDataString, routerInitPosition, routerJson)
207
212
  routerInitContent = "import { getARouter,routerInitConfig } from '@abner/router';\n" +
208
- "import { EntryRouterConfig } from '../../../EntryRouterConfig';\n"
213
+ "import { EntryRouterConfig } from '"+endSrcEntryString+"EntryRouterConfig';\n"
209
214
  + importNewConfig
210
215
  + routerInitContent
211
216
  FileUtil.writeFileSync(endAppPath, routerInitContent);