Skip to content

Commit

Permalink
🎨 Improve backward for HarmonyOS siyuan-note/siyuan#13676
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Jan 1, 2025
1 parent fcf1ab1 commit bb9944b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
8 changes: 7 additions & 1 deletion entry/src/main/ets/pages/JSHarmony.ets
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,16 @@ import { pasteboard } from '@kit.BasicServicesKit';
* JavaScript 接口。
*
* @author <a href="https://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.2, Dec 9, 2024
* @version 1.0.1.0, Jan 1, 2025
* @since 3.1.14
*/
export class JSHarmony {

returnDesktop() {
const context = getContext() as common.UIAbilityContext;
context.moveAbilityToBackground();
}

writeHTMLClipboard(text: string, html: string) {
try {
let pasteData: pasteboard.PasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_HTML, html);
Expand Down
11 changes: 9 additions & 2 deletions entry/src/main/ets/pages/Main.ets
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { Utils } from './Utils';
* 主程序。
*
* @author <a href="https://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.1, Dec 4, 2024
* @version 1.0.1.0, Jan 1, 2025
* @since 3.1.14
*/
@Entry
Expand Down Expand Up @@ -69,7 +69,8 @@ struct Main {
"changeStatusBarColor",
"readClipboard",
"writeClipboard",
"writeHTMLClipboard"
"writeHTMLClipboard",
"returnDesktop",
]
);
})
Expand Down Expand Up @@ -106,4 +107,10 @@ struct Main {
async sleep(mills: number) {
await new Promise<void>(resolve => setTimeout(resolve, mills))
}

onBackPress(): boolean | void {
hilog.debug(0x0000, "siyuan", "on back pressed")
this.controller.runJavaScript("javascript:window.goBack ? window.goBack() : window.history.back()");
return true;
}
}

0 comments on commit bb9944b

Please sign in to comment.