feat(miniapp): 添加网页右上角菜单功能
- 在 WebMenuView 中添加了刷新、复制、浏览器打开和微信分享等功能- 在 MiniAppManager 中增加了 webController 和相关方法 - 在 Index 页面中添加了 WebMenuView组件 - 修改了 XWebview 和 XWebHelper 以支持新的菜单功能
这个提交包含在:
父节点
3752229689
当前提交
e756dd4319
@ -48,17 +48,16 @@ export struct XWebview {
|
||||
XWebManager.onClose(() => {
|
||||
router.back()
|
||||
})
|
||||
if (this.xController) {
|
||||
this.xController.getUrl = () => {
|
||||
return this.controller.getUrl()
|
||||
}
|
||||
this.xController.getTitle = () => {
|
||||
return this.controller.getTitle()
|
||||
}
|
||||
this.xController.refresh = () => {
|
||||
this.controller.refresh()
|
||||
}
|
||||
XWebManager.onGetUrl = () => {
|
||||
return this.controller.getUrl()
|
||||
}
|
||||
XWebManager.onGetTitle = () => {
|
||||
return this.controller.getTitle()
|
||||
}
|
||||
XWebManager.onRefresh = () => {
|
||||
this.controller.refresh()
|
||||
}
|
||||
|
||||
|
||||
SZYXLocalStorageHelper.storage.setOrCreate('refresh_web_base', -1)
|
||||
SZYXLocalStorageHelper.storage.setOrCreate(SZYXLocalStorageKeys.XWebViewCLose, undefined)
|
||||
@ -135,7 +134,7 @@ export struct XWebview {
|
||||
Button({ buttonStyle: ButtonStyleMode.TEXTUAL }) {
|
||||
if (this.clickMenu?.img) {
|
||||
Image(this.clickMenu?.img)
|
||||
.width(15).height(15)
|
||||
.width(15).height(15).objectFit(ImageFit.Contain)
|
||||
} else if (this.clickMenu?.text) {
|
||||
Text(this.clickMenu.text)
|
||||
.fontColor(this.clickMenu?.color ?? '#17171A')
|
||||
@ -152,7 +151,7 @@ export struct XWebview {
|
||||
}.width(65)
|
||||
.onClick(() => {
|
||||
if (this.clickMenu) {
|
||||
this.clickMenu?.onClick && this.clickMenu?.onClick()
|
||||
XWebManager.menuClick()
|
||||
return
|
||||
}
|
||||
if (this.dialogController != null) {
|
||||
|
||||
@ -64,6 +64,18 @@ export class XWebHelper {
|
||||
params.controller.sendMessage = (msg) => {
|
||||
XWebManager.sendMessageToHtml(msg)
|
||||
}
|
||||
params.controller.getUrl = (): string => {
|
||||
return XWebManager.getUrl();
|
||||
}
|
||||
params.controller.getTitle = (): string => {
|
||||
return XWebManager.getTitle();
|
||||
}
|
||||
params.controller.refresh = () => {
|
||||
XWebManager.refresh()
|
||||
}
|
||||
}
|
||||
if (params.clickMenu){
|
||||
XWebManager.menuClick = params.clickMenu.onClick
|
||||
}
|
||||
|
||||
if (params.jsParams && params.jsParams.obj) {
|
||||
|
||||
@ -2,6 +2,9 @@ import { ToolsHelper } from './ToolsHelper';
|
||||
|
||||
export class XWebManager {
|
||||
private static closeCall?: () => void;
|
||||
static onGetUrl: () => string;
|
||||
static onGetTitle: () => string;
|
||||
static onRefresh: () => void;
|
||||
|
||||
static onClose(call: () => void) {
|
||||
XWebManager.closeCall = call
|
||||
@ -11,6 +14,18 @@ export class XWebManager {
|
||||
XWebManager.closeCall && XWebManager.closeCall()
|
||||
}
|
||||
|
||||
static getUrl() {
|
||||
return XWebManager.onGetUrl()
|
||||
}
|
||||
|
||||
static getTitle() {
|
||||
return XWebManager.onGetTitle()
|
||||
}
|
||||
|
||||
static refresh() {
|
||||
XWebManager.onRefresh()
|
||||
}
|
||||
|
||||
private static MapEventListener = new Map<string, (msg: string) => void>();
|
||||
static objs: Map<string, object> = new Map()
|
||||
|
||||
@ -32,6 +47,7 @@ export class XWebManager {
|
||||
}
|
||||
}
|
||||
|
||||
static menuClick: () => void
|
||||
private static MapEventListenerToHtml = new Map<string, (msg: string) => void>();
|
||||
|
||||
static addOnMessageToHtml(id: string, listener: (msg: string) => void) {
|
||||
|
||||
正在加载...
在新工单中引用
屏蔽一个用户