Skip to content

Commit 6cba5a2

Browse files
authored
feat: 마우스 뒤로가기/앞으로가기 버튼으로 히스토리 네비게이션 (#95)
1 parent 1de9c2b commit 6cba5a2

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/window.ts

+22
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,28 @@ export class BoxHeroWindow extends ViteWindow {
229229

230230
if (!this.webviewContents) return;
231231

232+
this.removeAllListeners("app-command").on("app-command", (e, cmd) => {
233+
if (cmd === "browser-backward" && this.webviewContents?.canGoBack()) {
234+
this.webviewContents.goBack();
235+
} else if (
236+
cmd === "browser-forward" &&
237+
this.webviewContents?.canGoForward()
238+
) {
239+
this.webviewContents.goForward();
240+
}
241+
});
242+
243+
this.removeAllListeners("swipe").on("swipe", (e, direction) => {
244+
if (direction === "left" && this.webviewContents?.canGoBack()) {
245+
this.webviewContents.goBack();
246+
} else if (
247+
direction === "right" &&
248+
this.webviewContents?.canGoForward()
249+
) {
250+
this.webviewContents.goForward();
251+
}
252+
});
253+
232254
this.webviewContents
233255
.removeAllListeners("did-create-window")
234256
.on("did-create-window", (window, detail) => {

0 commit comments

Comments
 (0)