|
|
@@ -7,31 +7,31 @@ interface HTML5 extends Window {
|
|
|
export default new (class {
|
|
|
private h5 = new Promise<HTML5>((resolve) => {
|
|
|
document.addEventListener('plusready', () => {
|
|
|
- resolve(window);
|
|
|
+ resolve(window)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
constructor() {
|
|
|
// 监听返回按钮事件
|
|
|
this.onPlusReady((plus) => {
|
|
|
- let firstBack = true;
|
|
|
- const webview = plus.webview.currentWebview();
|
|
|
+ let firstBack = true
|
|
|
+ const webview = plus.webview.currentWebview()
|
|
|
|
|
|
plus.key.addEventListener('backbutton', () => {
|
|
|
webview.canBack((e: any) => {
|
|
|
// 判断能否继续返回
|
|
|
if (e.canBack) {
|
|
|
- webview.back();
|
|
|
+ webview.back()
|
|
|
} else {
|
|
|
// 1秒内连续两次按返回键退出应用
|
|
|
if (firstBack) {
|
|
|
- firstBack = false;
|
|
|
- plus.nativeUI.toast('再按一次退出应用');
|
|
|
+ firstBack = false
|
|
|
+ plus.nativeUI.toast('再按一次退出应用')
|
|
|
setTimeout(() => {
|
|
|
- firstBack = true;
|
|
|
- }, 1000);
|
|
|
+ firstBack = true
|
|
|
+ }, 1000)
|
|
|
} else {
|
|
|
- plus.runtime.quit();
|
|
|
+ plus.runtime.quit()
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
@@ -50,6 +50,15 @@ export default new (class {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 退出应用程序
|
|
|
+ */
|
|
|
+ quit() {
|
|
|
+ this.onPlusReady((plus) => {
|
|
|
+ plus.runtime.quit()
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 客户端的版本名称
|
|
|
* @returns
|
|
|
*/
|
|
|
@@ -79,8 +88,8 @@ export default new (class {
|
|
|
*/
|
|
|
getStatusBarHeight(callback: (statusbarHeight: number) => void) {
|
|
|
this.onPlusReady((plus) => {
|
|
|
- const height = plus.navigator.getStatusbarHeight();
|
|
|
- callback(height);
|
|
|
+ const height = plus.navigator.getStatusbarHeight()
|
|
|
+ callback(height)
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -90,7 +99,7 @@ export default new (class {
|
|
|
*/
|
|
|
setStatusBarStyle(color: 'dark' | 'light') {
|
|
|
this.onPlusReady((plus) => {
|
|
|
- plus.navigator.setStatusBarStyle(color);
|
|
|
+ plus.navigator.setStatusBarStyle(color)
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -99,7 +108,7 @@ export default new (class {
|
|
|
*/
|
|
|
hideStatusBar() {
|
|
|
this.onPlusReady((plus) => {
|
|
|
- plus.navigator.setFullscreen(true);
|
|
|
+ plus.navigator.setFullscreen(true)
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -108,7 +117,7 @@ export default new (class {
|
|
|
*/
|
|
|
showStatusBar() {
|
|
|
this.onPlusReady((plus) => {
|
|
|
- plus.navigator.setFullscreen(false);
|
|
|
+ plus.navigator.setFullscreen(false)
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -117,8 +126,8 @@ export default new (class {
|
|
|
*/
|
|
|
setFullSreen() {
|
|
|
this.onPlusReady((plus) => {
|
|
|
- this.hideStatusBar();
|
|
|
- plus.navigator.hideSystemNavigation();
|
|
|
+ this.hideStatusBar()
|
|
|
+ plus.navigator.hideSystemNavigation()
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -127,8 +136,8 @@ export default new (class {
|
|
|
*/
|
|
|
exitFullSreen() {
|
|
|
this.onPlusReady((plus) => {
|
|
|
- this.showStatusBar();
|
|
|
- plus.navigator.showSystemNavigation();
|
|
|
+ this.showStatusBar()
|
|
|
+ plus.navigator.showSystemNavigation()
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -209,12 +218,12 @@ export default new (class {
|
|
|
e.target,
|
|
|
() => {
|
|
|
//销毁Bitmap图片
|
|
|
- bitmap.clear();
|
|
|
+ bitmap.clear()
|
|
|
plus.nativeUI.toast('已保存到相册中')
|
|
|
},
|
|
|
() => {
|
|
|
//销毁Bitmap图片
|
|
|
- bitmap.clear();
|
|
|
+ bitmap.clear()
|
|
|
plus.nativeUI.toast('保存失败')
|
|
|
}
|
|
|
)
|