mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 02:54:15 +00:00
Fix android back action
This commit is contained in:
parent
6a4caaaba8
commit
8a865c41e6
@ -24,6 +24,7 @@
|
||||
"dependencies": {
|
||||
"@ant-design/icons": "4.7.0",
|
||||
"@capacitor/android": "^4.5.0",
|
||||
"@capacitor/app": "^4.1.1",
|
||||
"@capacitor/cli": "^4.5.0",
|
||||
"@capacitor/core": "^4.5.0",
|
||||
"@capacitor/haptics": "1.1.4",
|
||||
|
@ -54,6 +54,7 @@ import { Helmet } from "react-helmet"
|
||||
import * as antd from "antd"
|
||||
import { Toast } from "antd-mobile"
|
||||
import { StatusBar, Style } from "@capacitor/status-bar"
|
||||
import { App as CapacitorApp } from "@capacitor/app"
|
||||
import { Translation } from "react-i18next"
|
||||
|
||||
import { Session, User } from "models"
|
||||
@ -105,6 +106,17 @@ class App extends React.Component {
|
||||
// append var to #root
|
||||
document.getElementById("root").classList.add("electron")
|
||||
}
|
||||
|
||||
if (this.publicMethods.isAppCapacitor()) {
|
||||
// prevent back button to close app
|
||||
CapacitorApp.addListener('backButton', ({ canGoBack }) => {
|
||||
if (!canGoBack) {
|
||||
CapacitorApp.exitApp();
|
||||
} else {
|
||||
window.history.back();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static publicEvents = {
|
||||
@ -316,7 +328,7 @@ class App extends React.Component {
|
||||
escClosable: true,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
return window.app.ModalController.open((props) => <Creator {...props} />)
|
||||
},
|
||||
openSettings: (goTo) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user