ohos-router 1.2.1 → 1.2.3

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 +13 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ohos-router",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "鸿蒙路由管理插件",
5
5
  "main": "main.js",
6
6
  "scripts": {
package/router.ts CHANGED
@@ -158,12 +158,17 @@ export function pluginStart(node: HvigorNode, isExecute: boolean) {
158
158
  endHsp = "getARouter()"
159
159
  }
160
160
 
161
- if(appFileDataString.indexOf("new "+name+"RouterConfig(") == -1){
162
- isHaveConfig=true;
161
+ if (appFileDataString.indexOf("new " + name + "RouterConfig(") == -1) {
162
+ isHaveConfig = true;
163
163
  initHaveConfig = initHaveConfig + (" new " + name + "RouterConfig(" + endHsp + "),\n")
164
164
  }
165
- if(appFileDataString.indexOf("import { "+name+"RouterConfig }") == -1){
166
- isHaveConfig=true;
165
+
166
+ //这个必须要带
167
+ let exportClassIndex = appFileDataString.indexOf("export class");
168
+ let exportContent = appFileDataString.substring(0, exportClassIndex);
169
+
170
+ if (exportContent.indexOf(name + "RouterConfig") == -1) {
171
+ isHaveConfig = true;
167
172
  importHaveConfig = importHaveConfig + "\nimport { " + name + "RouterConfig } from '" + name.toLowerCase() + "';\n"
168
173
  }
169
174
  })
@@ -219,7 +224,7 @@ function moduleJson5JSONParse(json: string) {
219
224
  let module = moduleJsonBean.module
220
225
  moduleSrcEntry = module.srcEntry
221
226
  } catch (error) {
222
- console.log("moduleJson5JSONParse:"+error)
227
+ console.log("moduleJson5JSONParse:" + error)
223
228
  }
224
229
  }
225
230
 
@@ -257,7 +262,7 @@ function getRouterConfig(upperCaseName: string, nodeName: string, isHsp: boolean
257
262
  " * INTRODUCE:动态配置组件\n" +
258
263
  " * */\n" +
259
264
  "@Builder\n" +
260
- "export function viewBuilder() {\n" +
265
+ "export function viewBuilder(params?:Object) {\n" +
261
266
  " NavDestinationView() {\n" +
262
267
  "\n" +
263
268
  " }\n" +
@@ -333,7 +338,7 @@ function dependenciesJSONParse(json: string) {
333
338
  }
334
339
  }
335
340
  } catch (error) {
336
- console.log("dependenciesJSONParse:"+error)
341
+ console.log("dependenciesJSONParse:" + error)
337
342
  }
338
343
  }
339
344
 
@@ -361,7 +366,7 @@ function buildProfileJSONParse(json: string) {
361
366
  }
362
367
  }
363
368
  } catch (error) {
364
- console.log("buildProfileJSONParse:"+error)
369
+ console.log("buildProfileJSONParse:" + error)
365
370
  }
366
371
  }
367
372