提交 0b1219f1 编写于 作者: lizhongyi_'s avatar lizhongyi_

实现iOS平台 uts-get-native-view插件逻辑

上级 3ef6bc07
......@@ -119,6 +119,8 @@
},
load(event : UniWebViewLoadEvent) {
console.log(JSON.stringify(event.detail));
this.canGoBack = canWebViewGoBack('web-view');
this.canGoForward = canWebViewGoForward('web-view');
if (this.autoTest) {
this.eventLoad = {
"tagName": event.target?.tagName,
......
//
// DCUni.swift
// DCGetElementByID
//
// Created by DCloud-iOS-XHY on 2024/7/8.
//
import DCloudUniappRuntime
public class DCGetElementByID {
/// 返回一个匹配特定 ID 的元素, 如果不存在,返回 null 规则同 https://doc.dcloud.net.cn/uni-app-x/api/get-element.html#getelementbyid
public static func dcGetElementById(_ id: String) -> UniElement? {
let appManager = UniSDKEngine.self.getAppManager()
if let app = appManager.getCurretApp(),
let pageManager = app.pageManager as? UniPageManagerImpl,
let page = pageManager.getTopPage(),
let domManager = page.document as? UniDomManager {
return domManager.getElementById(id)
}
return nil
}
}
import { CanWebViewGoBack, CanWebViewGoForward } from "../interface";
import { WKWebView } from 'WebKit';
export const canWebViewGoBack : CanWebViewGoBack = function (elementId : string) : boolean {
// const element = uni.getElementById(elementId)
const element = DCGetElementByID.dcGetElementById(elementId)
const view = element?.getIOSView();
if (view != null && view instanceof WKWebView) {
return (view! as WKWebView).canGoBack;
}
return false;
}
export const canWebViewGoForward : CanWebViewGoForward = function (elementId : string) : boolean {
// const element = uni.getElementById(elementId)
const element = DCGetElementByID.dcGetElementById(elementId)
const view = element?.getIOSView();
if (view != null && view instanceof WKWebView) {
return (view! as WKWebView).canGoForward;
}
return false;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册