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
23 additions
and
12 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,18 +46,26 @@ class DefaultWebJumpHandler implements JumpInterceptorAction { | @@ -46,18 +46,26 @@ 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 | - const jsonStr = FileUtils.readFileAsString(filePath) | ||
| 50 | - const listObj = JSON.parse(jsonStr) as WhiteListModel | ||
| 51 | - if (listObj && listObj.whiteurls && listObj.whiteurls.length) { | 49 | + try { |
| 50 | + Logger.debug("读取文件:" + filePath) | ||
| 51 | + const jsonStr = FileUtils.readFileAsString(filePath) | ||
| 52 | + if (jsonStr.length == 0) { | ||
| 53 | + return list | ||
| 54 | + } | ||
| 55 | + const listObj = JSON.parse(jsonStr) as WhiteListModel | ||
| 56 | + if (listObj && listObj.whiteurls && listObj.whiteurls.length) { | ||
| 52 | 57 | ||
| 53 | - const urls = listObj.whiteurls.map((obj) => { | ||
| 54 | - if (obj.startsWith("http")) { | ||
| 55 | - return new uri.URI(obj).host | ||
| 56 | - } | ||
| 57 | - return new uri.URI("https://" + obj).host | ||
| 58 | - }) | 58 | + const urls = listObj.whiteurls.map((obj) => { |
| 59 | + if (obj.startsWith("http")) { | ||
| 60 | + return new uri.URI(obj).host | ||
| 61 | + } | ||
| 62 | + return new uri.URI("https://" + obj).host | ||
| 63 | + }) | ||
| 59 | 64 | ||
| 60 | - list.push(...urls) | 65 | + list.push(...urls) |
| 66 | + } | ||
| 67 | + } catch (error) { | ||
| 68 | + Logger.error("读取文件报错:" + JSON.stringify(error)) | ||
| 61 | } | 69 | } |
| 62 | return list | 70 | return list |
| 63 | } | 71 | } |
-
Please register or login to post a comment