!287 修复备忘录jscrash

Merge pull request !287 from 张宏/0909
This commit is contained in:
openharmony_ci 2024-09-09 13:20:54 +00:00 committed by Gitee
commit 5b5e59ac40
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
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
}