From 363a10a702efba6a5bfa0d3afc61c4cd19ead5c5 Mon Sep 17 00:00:00 2001 From: zhuhaokun Date: Mon, 30 Dec 2024 14:11:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=87=E5=BF=98=E5=BD=95jscrash=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhuhaokun --- .gitignore | 5 +- common/resources/.gitignore | 1 + common/utils/.gitignore | 1 + features/.gitignore | 1 + .../main/ets/components/NoteContentComp.ets | 62 ++++++++++--------- .../components/NoteContentCompPortrait.ets | 4 +- .../src/main/ets/components/NoteListComp.ets | 17 +++-- product/default/.gitignore | 1 + 8 files changed, 54 insertions(+), 38 deletions(-) diff --git a/.gitignore b/.gitignore index fd58715..5fc64b7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,10 @@ /node_modules +/oh_modules /local.properties /.idea **/build /signature /.hvigor -/package.json \ No newline at end of file +/package.json +/.clang-format +**/oh-package-lock.json5 \ No newline at end of file diff --git a/common/resources/.gitignore b/common/resources/.gitignore index a5c564a..725ae70 100644 --- a/common/resources/.gitignore +++ b/common/resources/.gitignore @@ -1,4 +1,5 @@ /node_modules +/oh_modules /.preview /build /package.json \ No newline at end of file diff --git a/common/utils/.gitignore b/common/utils/.gitignore index a5c564a..725ae70 100644 --- a/common/utils/.gitignore +++ b/common/utils/.gitignore @@ -1,4 +1,5 @@ /node_modules +/oh_modules /.preview /build /package.json \ No newline at end of file diff --git a/features/.gitignore b/features/.gitignore index 9924c4f..fd0ce92 100644 --- a/features/.gitignore +++ b/features/.gitignore @@ -1,4 +1,5 @@ /node_modules +/oh_modules /.preview /build /.cxx diff --git a/features/src/main/ets/components/NoteContentComp.ets b/features/src/main/ets/components/NoteContentComp.ets index c2be924..6bc06a6 100644 --- a/features/src/main/ets/components/NoteContentComp.ets +++ b/features/src/main/ets/components/NoteContentComp.ets @@ -29,7 +29,7 @@ import StyleConstants from '@ohos/utils/src/main/ets/default/constants/StyleCons import { EditContentDialog, DeleteDialog, EditTitleDialog } from './CusDialogComp' import FolderUtil from '@ohos/utils/src/main/ets/default/baseUtil/FolderUtil' import NoteUtil from '@ohos/utils/src/main/ets/default/baseUtil/NoteUtil' -import prompt from '@system.prompt' +import { promptAction } from '@kit.ArkUI'; import util from '@ohos.util' import { LogUtil } from '@ohos/utils/src/main/ets/default/baseUtil/LogUtil' import OperationUtils from '@ohos/utils/src/main/ets/default/baseUtil/OperationUtils' @@ -256,33 +256,37 @@ export struct NoteContentComp { }) .enabled(this.sectionStatus !== 1 ? false : true) .onPageEnd((e) => { - if (this.dpi <= 240) { - this.controllerShow.runJavaScript("changeSizeToRk()") - } else if (this.dpi <= 320 && this.dpi > 240) { - this.controllerShow.runJavaScript("changeSizeToPhone()") - } else { - this.controllerShow.runJavaScript("changeSizeToTablet()") - } - if (AppStorage.Get('breakPoint') !== 'sm') { - this.controllerShow.runJavaScript("hiddenButton()") - } - LogUtil.info(TAG, "finish loadurl") - if (this.selectedNoteData) { - let self = this - this.controllerShow.runJavaScript( - "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')", - () => { - // wait for the image in the note to load - setTimeout(() => { - self.restoreScrollTop() - self.restoreFocus() - }, 100) - } - ) - } - // 初次加载为为小屏预览模式 - if (this.sectionStatus != 1) { - this.controllerShow.runJavaScript("RICH_EDITOR.setInputEnabled(false)") + try { + if (this.dpi <= 240) { + this.controllerShow.runJavaScript("changeSizeToRk()") + } else if (this.dpi <= 320 && this.dpi > 240) { + this.controllerShow.runJavaScript("changeSizeToPhone()") + } else { + this.controllerShow.runJavaScript("changeSizeToTablet()") + } + if (AppStorage.Get('breakPoint') !== 'sm') { + this.controllerShow.runJavaScript("hiddenButton()") + } + LogUtil.info(TAG, "finish loadurl") + if (this.selectedNoteData) { + let self = this + this.controllerShow.runJavaScript( + "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')", + () => { + // wait for the image in the note to load + setTimeout(() => { + self.restoreScrollTop() + self.restoreFocus() + }, 100) + } + ) + } + // 初次加载为为小屏预览模式 + if (this.sectionStatus != 1) { + this.controllerShow.runJavaScript("RICH_EDITOR.setInputEnabled(false)") + } + } catch (error) { + LogUtil.info(TAG, `runJavaScript onPageEnd error. code:${JSON.stringify(error.code)},message:${error.message}`); } }) .imageAccess(true) @@ -636,7 +640,7 @@ export struct ToolBarComp { if (error != null) { LogUtil.error(TAG, "error is " + error); } else { - prompt.showToast({ message: value, duration: 2000 }); + promptAction.showToast({ message: value, duration: 2000 }); } }); this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0) diff --git a/features/src/main/ets/components/NoteContentCompPortrait.ets b/features/src/main/ets/components/NoteContentCompPortrait.ets index 1f1e874..1eb3eb7 100644 --- a/features/src/main/ets/components/NoteContentCompPortrait.ets +++ b/features/src/main/ets/components/NoteContentCompPortrait.ets @@ -30,7 +30,7 @@ import StyleConstants from '@ohos/utils/src/main/ets/default/constants/StyleCons import { EditContentDialogPortrait, DeleteDialog, EditTitleDialog } from './CusDialogComp' import FolderUtil from '@ohos/utils/src/main/ets/default/baseUtil/FolderUtil' import NoteUtil from '@ohos/utils/src/main/ets/default/baseUtil/NoteUtil' -import prompt from '@system.prompt' +import { promptAction } from '@kit.ArkUI'; import { LogUtil } from '@ohos/utils/src/main/ets/default/baseUtil/LogUtil' import OperationUtils from '@ohos/utils/src/main/ets/default/baseUtil/OperationUtils' import router from '@system.router' @@ -792,7 +792,7 @@ export struct DeleteNoteComp { if (error != null) { LogUtil.error(TAG, 'error is' + error); } else { - prompt.showToast({ message: value, duration: 2000 }); + promptAction.showToast({ message: value, duration: 2000 }); } }); this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0) diff --git a/features/src/main/ets/components/NoteListComp.ets b/features/src/main/ets/components/NoteListComp.ets index 1bedca4..8621e93 100644 --- a/features/src/main/ets/components/NoteListComp.ets +++ b/features/src/main/ets/components/NoteListComp.ets @@ -28,7 +28,7 @@ import { } from '@ohos/utils/src/main/ets/default/model/databaseModel/EnumData'; import { NoteDataMoveDialog, DeleteDialog } from './CusDialogComp' import RdbStoreUtil from '@ohos/utils/src/main/ets/default/baseUtil/RdbStoreUtil' -import prompt from '@system.prompt' +import { promptAction } from '@kit.ArkUI'; import NoteUtil from '@ohos/utils/src/main/ets/default/baseUtil/NoteUtil' import FolderUtil from '@ohos/utils/src/main/ets/default/baseUtil/FolderUtil' import SearchModel from '@ohos/utils/src/main/ets/default/model/searchModel/SearchModel' @@ -812,7 +812,7 @@ export struct OperateNoteComp { if (error != null) { LogUtil.error(TAG, "error is " + error); } else { - prompt.showToast({ message: value, duration: 2000 }); + promptAction.showToast({ message: value, duration: 2000 }); } }); // update note to db @@ -881,9 +881,14 @@ export struct AddNoteComp { this.selectedNoteData = noteData AppStorage.SetOrCreate('NewNote', noteData) if (this.portraitModel == false) { - this.controllerShow.runJavaScript( - "RICH_EDITOR.setHtml('" + this.selectedNoteData?.content_text + "')" - ) + try { + this.controllerShow.runJavaScript( + "RICH_EDITOR.setHtml('" + this.selectedNoteData?.content_text + "')" + ) + } catch (error) { + LogUtil.error(TAG, `runJavaScript setHtml content_text failed. + code:${JSON.stringify(error.code)},message:${JSON.stringify(error.message)}`); + } } if (this.portraitModel == true) { this.editModel = true @@ -1176,7 +1181,7 @@ export struct OperateNoteCompForPortrait { if (error != null) { LogUtil.error(TAG, "error is " + error); } else { - prompt.showToast({ message: value, duration: 2000 }); + promptAction.showToast({ message: value, duration: 2000 }); } }); // update note to db diff --git a/product/default/.gitignore b/product/default/.gitignore index a5c564a..725ae70 100644 --- a/product/default/.gitignore +++ b/product/default/.gitignore @@ -1,4 +1,5 @@ /node_modules +/oh_modules /.preview /build /package.json \ No newline at end of file -- Gitee