From 1ad0b04bf96725beab65fdd1fd9bd6c38628a103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E5=8B=A4=E6=B0=91?= Date: Tue, 18 Feb 2025 15:11:40 +0800 Subject: [PATCH] =?UTF-8?q?feat(miniapp):=20=E5=AE=9E=E7=8E=B0=20H5=20?= =?UTF-8?q?=E9=87=91=E6=B2=99=E6=A1=86=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 JSSdkClsManager 类,实现 H5 金沙框架的功能 - 添加 RecordData 类,用于记录用户行为数据 - 更新 MiniAppManager,支持选择厂商弹窗的取消事件 - 修改 Index 页面,添加选择厂商弹窗的取消回调- 更新 XWebview 页面,支持自动刷新功能 - 修改 XWebHelper,添加刷新 WebView 的方法- 更新 CaManager,优化存在证书的判断逻辑 --- src/main/ets/pages/XWebview.ets | 11 ++++++++++- src/main/ets/utils/XWebHelper.ets | 6 +++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/ets/pages/XWebview.ets b/src/main/ets/pages/XWebview.ets index 8c7c079..1b2a010 100644 --- a/src/main/ets/pages/XWebview.ets +++ b/src/main/ets/pages/XWebview.ets @@ -15,6 +15,7 @@ import { XWebManager } from '../utils/XWebManager'; @Entry({ routeName: 'XWebview' }) @Component export struct XWebview { + @LocalStorageLink('refresh_web_base') @Watch('onRefresh') refresh_web_base: number = -1 // 手机号 @State headers?: Array = (router.getParams() as XWebParams).headers @State url?: string = (router.getParams() as XWebParams).url @@ -34,7 +35,15 @@ export struct XWebview { dialogController: XDialogController = {} as XDialogController ports: webview.WebMessagePort[] = []; + onRefresh() { + if (this.refresh_web_base !== -1) { + this.controller.refresh() + } + + } + aboutToAppear(): void { + SZYXLocalStorageHelper.storage.setOrCreate('refresh_web_base', -1) SZYXLocalStorageHelper.storage.setOrCreate(SZYXLocalStorageKeys.XWebViewCLose, undefined) webview.WebviewController.setWebDebuggingAccess(true); if (this._uuidToHtml) { @@ -205,7 +214,7 @@ export struct XWebview { this.ports = this.controller.createWebMessagePorts(); this.ports[1].onMessageEvent((result: webview.WebMessage) => { if (typeof (result) === 'string') { - ToolsHelper.log(result, typeof (result)) + // ToolsHelper.log(result, typeof (result)) XWebManager.sendMessage(result) } }) diff --git a/src/main/ets/utils/XWebHelper.ets b/src/main/ets/utils/XWebHelper.ets index e7dde0c..75af43d 100644 --- a/src/main/ets/utils/XWebHelper.ets +++ b/src/main/ets/utils/XWebHelper.ets @@ -1,6 +1,6 @@ import { router, WebHeader } from '@kit.ArkUI'; import { BusinessError } from '@kit.BasicServicesKit'; -import { LogHelper } from '../../../../Index'; +import { LogHelper, SZYXLocalStorageHelper } from '../../../../Index'; import { baseEncode } from '../util/base64Util'; import { ToolsHelper } from './ToolsHelper'; import { XWebManager } from './XWebManager'; @@ -86,6 +86,10 @@ export class XWebHelper { }) } + public static refreshWeb() { + SZYXLocalStorageHelper.storage.setOrCreate('refresh_web_base', new Date().getTime()) + } + public static openPreview(params: XWebParams): Promise { params.url = `https://mdtdemo.51trust.com/preview/onlinePreview?url=${baseEncode(params.url)}&watermarkTxt=${encodeURI(params.watermarkTxt ??