修复备忘录jscrash

Signed-off-by: zwx1126739 <zhanghong121@huawei.com>
This commit is contained in:
zwx1126739 2024-09-09 16:57:49 +08:00
parent 9f43b46130
commit 962ba4cbe3
3 changed files with 41 additions and 10 deletions

View File

@ -442,9 +442,15 @@ struct FolderItemComp {
}
// 刷新web界面
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 + "')"
);
LogUtil.info(this.TAG, `onClick runJavaScript setHtml success.`);
} catch (error) {
LogUtil.error(this.TAG, `onClick runJavaScript setHtml failed,code:${JSON.stringify(error.code)},
message:${JSON.stringify(error.message)}.`);
}
}
// save continue data
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())
@ -501,9 +507,15 @@ struct FolderItemComp {
}
// 刷新web界面
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 + "')"
);
LogUtil.info(this.TAG, `else runJavaScript setHtml success.`);
} catch (error) {
LogUtil.info(this.TAG, `else runJavaScript setHtml failed.code:${JSON.stringify(error.code)},
message:${JSON.stringify(error.message)}`);
}
}
// save continue data
let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject())

View File

@ -232,7 +232,13 @@ export struct NoteContent {
clearInterval(timeID)
}
timeID = setInterval(() => {
this.controllerShow.runJavaScript("scheduledSaveContent()")
try {
this.controllerShow.runJavaScript("scheduledSaveContent()");
LogUtil.info(TAG, `runJavaScript scheduledSaveContent success.`);
} catch (error) {
LogUtil.info(TAG, `runJavaScript scheduledSaveContent failed.code:${JSON.stringify(error.code)},
message:${JSON.stringify(error.message)}`);
}
}, 3000)
LogUtil.info(TAG, "setInterval timeID : " + timeID)
this.issave = 0
@ -288,8 +294,15 @@ export struct ToolBarComp {
.height(24)
.width(24)
.onClick(() => {
this.controllerShow.runJavaScript("RICH_EDITOR.setInputEnabled(false)")
this.controllerShow.runJavaScript("getHtmlContent()")
try {
this.controllerShow.runJavaScript("RICH_EDITOR.setInputEnabled(false)");
this.controllerShow.runJavaScript("getHtmlContent()");
LogUtil.info(TAG, `runJavaScript setInputEnabled and getHtmlContent success.`);
} catch (error) {
LogUtil.info(TAG, `runJavaScript setInputEnabled and getHtmlContent fail.code:${JSON.stringify(error.code)},
message:${JSON.stringify(error.message)}`);
}
// 清除定时器
if (timeID != undefined) {
LogUtil.info(TAG, "zoom, clearInterval timeID : " + timeID)

View File

@ -69,7 +69,13 @@ export struct NoteContentComp {
if (!this.refreshCurrentNote) {
return
}
this.controllerShow.runJavaScript("RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')")
try {
this.controllerShow.runJavaScript("RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')");
LogUtil.info(TAG, `runJavaScript setHtml success.`);
} catch (error) {
LogUtil.error(TAG, `runJavaScript setHtml failed.code:${JSON.stringify(error.code)},
message:${JSON.stringify(error.message)}`);
}
this.refreshCurrentNote = false
}