feat(app): 添加关闭窗口功能并优化网页管理
- 在 JSSdkCls 中添加 closeWindows 方法,用于关闭窗口 - 在 types 中添加 'closeWindows' 作为 IAppModeName 的一个选项 - 在 XWebview 中添加 onClose事件监听,用于处理窗口关闭事件 - 在 XWebHelper 中添加 close 方法,用于触发窗口关闭- 在 XWebManager 中实现 close 和 onClose 方法,用于管理窗口关闭逻辑
这个提交包含在:
父节点
7fa3204be1
当前提交
e7adec064c
@ -12,7 +12,6 @@ import { SZYXLocalStorageHelper } from '../utils/SZYXLocalStorageHelper';
|
|||||||
import { SZYXLocalStorageKeys } from '../utils/SZYXLocalStorageKeys';
|
import { SZYXLocalStorageKeys } from '../utils/SZYXLocalStorageKeys';
|
||||||
import { XWebManager } from '../utils/XWebManager';
|
import { XWebManager } from '../utils/XWebManager';
|
||||||
import { TitleBarBtn } from '../view/SafeView';
|
import { TitleBarBtn } from '../view/SafeView';
|
||||||
import { HttpHelper } from '../http/HttpHelper';
|
|
||||||
|
|
||||||
@Entry({ routeName: 'XWebview' })
|
@Entry({ routeName: 'XWebview' })
|
||||||
@Component
|
@Component
|
||||||
@ -46,6 +45,10 @@ export struct XWebview {
|
|||||||
}
|
}
|
||||||
|
|
||||||
aboutToAppear(): void {
|
aboutToAppear(): void {
|
||||||
|
XWebManager.onClose(()=>{
|
||||||
|
router.back()
|
||||||
|
})
|
||||||
|
|
||||||
SZYXLocalStorageHelper.storage.setOrCreate('refresh_web_base', -1)
|
SZYXLocalStorageHelper.storage.setOrCreate('refresh_web_base', -1)
|
||||||
SZYXLocalStorageHelper.storage.setOrCreate(SZYXLocalStorageKeys.XWebViewCLose, undefined)
|
SZYXLocalStorageHelper.storage.setOrCreate(SZYXLocalStorageKeys.XWebViewCLose, undefined)
|
||||||
webview.WebviewController.setWebDebuggingAccess(true);
|
webview.WebviewController.setWebDebuggingAccess(true);
|
||||||
|
|||||||
@ -42,6 +42,9 @@ export interface XWebParams {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class XWebHelper {
|
export class XWebHelper {
|
||||||
|
static close() {
|
||||||
|
XWebManager.close()
|
||||||
|
}
|
||||||
private constructor() {
|
private constructor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,16 @@
|
|||||||
import { ToolsHelper } from './ToolsHelper';
|
import { ToolsHelper } from './ToolsHelper';
|
||||||
|
|
||||||
export class XWebManager {
|
export class XWebManager {
|
||||||
|
private static closeCall?: () => void;
|
||||||
|
|
||||||
|
static onClose(call: () => void) {
|
||||||
|
XWebManager.closeCall = call
|
||||||
|
}
|
||||||
|
|
||||||
|
static close() {
|
||||||
|
XWebManager.closeCall && XWebManager.closeCall()
|
||||||
|
}
|
||||||
|
|
||||||
private static MapEventListener = new Map<string, (msg: string) => void>();
|
private static MapEventListener = new Map<string, (msg: string) => void>();
|
||||||
static objs: Map<string, object> = new Map()
|
static objs: Map<string, object> = new Map()
|
||||||
|
|
||||||
|
|||||||
正在加载...
在新工单中引用
屏蔽一个用户