Merge branch 'main' of http://192.168.1.42/developOne/harmonyPool into main
* 'main' of http://192.168.1.42/developOne/harmonyPool: ref |> 修复进入web页面之前存在崩溃问题
Showing
2 changed files
with
13 additions
and
2 deletions
| @@ -43,7 +43,10 @@ export class LaunchPageModel { | @@ -43,7 +43,10 @@ export class LaunchPageModel { | ||
| 43 | static async dealWithLaunchDataModel(model?: LaunchDataModel) { | 43 | static async dealWithLaunchDataModel(model?: LaunchDataModel) { |
| 44 | if (!model) { | 44 | if (!model) { |
| 45 | let dataModelStr = SPHelper.default.getSync(SpConstants.APP_LAUNCH_PAGE_DATA_MODEL, '') as string | 45 | let dataModelStr = SPHelper.default.getSync(SpConstants.APP_LAUNCH_PAGE_DATA_MODEL, '') as string |
| 46 | - model = JSON.parse(dataModelStr ?? "") | 46 | + if (dataModelStr.length == 0) { |
| 47 | + return | ||
| 48 | + } | ||
| 49 | + model = JSON.parse(dataModelStr) | ||
| 47 | if (!model) { return } | 50 | if (!model) { return } |
| 48 | } | 51 | } |
| 49 | 52 |
| 1 | import { FileUtils as imageFileUtils } from '@ohos/imageknife' | 1 | import { FileUtils as imageFileUtils } from '@ohos/imageknife' |
| 2 | import { Action } from 'wdBean' | 2 | import { Action } from 'wdBean' |
| 3 | -import { AppUtils, FileUtils, SPHelper } from 'wdKit' | 3 | +import { AppUtils, FileUtils, Logger, SPHelper } from 'wdKit' |
| 4 | import { JumpInterceptorAction, RouterJumpInterceptor, WDRouterPage } from 'wdRouter' | 4 | import { JumpInterceptorAction, RouterJumpInterceptor, WDRouterPage } from 'wdRouter' |
| 5 | import { JSON, uri } from '@kit.ArkTS' | 5 | import { JSON, uri } from '@kit.ArkTS' |
| 6 | import { SpConstants } from 'wdConstant' | 6 | import { SpConstants } from 'wdConstant' |
| @@ -46,7 +46,12 @@ class DefaultWebJumpHandler implements JumpInterceptorAction { | @@ -46,7 +46,12 @@ class DefaultWebJumpHandler implements JumpInterceptorAction { | ||
| 46 | return list | 46 | return list |
| 47 | } | 47 | } |
| 48 | let filePath = AppUtils.gotApplicationContextFunc().getApplicationContext().filesDir + "/h5_whitelist.txt" | 48 | let filePath = AppUtils.gotApplicationContextFunc().getApplicationContext().filesDir + "/h5_whitelist.txt" |
| 49 | + try { | ||
| 50 | + Logger.debug("读取文件:" + filePath) | ||
| 49 | const jsonStr = FileUtils.readFileAsString(filePath) | 51 | const jsonStr = FileUtils.readFileAsString(filePath) |
| 52 | + if (jsonStr.length == 0) { | ||
| 53 | + return list | ||
| 54 | + } | ||
| 50 | const listObj = JSON.parse(jsonStr) as WhiteListModel | 55 | const listObj = JSON.parse(jsonStr) as WhiteListModel |
| 51 | if (listObj && listObj.whiteurls && listObj.whiteurls.length) { | 56 | if (listObj && listObj.whiteurls && listObj.whiteurls.length) { |
| 52 | 57 | ||
| @@ -59,6 +64,9 @@ class DefaultWebJumpHandler implements JumpInterceptorAction { | @@ -59,6 +64,9 @@ class DefaultWebJumpHandler implements JumpInterceptorAction { | ||
| 59 | 64 | ||
| 60 | list.push(...urls) | 65 | list.push(...urls) |
| 61 | } | 66 | } |
| 67 | + } catch (error) { | ||
| 68 | + Logger.error("读取文件报错:" + JSON.stringify(error)) | ||
| 69 | + } | ||
| 62 | return list | 70 | return list |
| 63 | } | 71 | } |
| 64 | 72 |
-
Please register or login to post a comment