自动签相关

这个提交包含在:
徐勤民 2024-10-22 12:00:04 +08:00
父节点 79d69e0350
当前提交 b41b8ac20a
共有 4 个文件被更改,包括 23 次插入12 次删除

查看文件

@ -7,6 +7,8 @@ import { BusinessError } from '@kit.BasicServicesKit';
import { ToolsHelper } from '../utils/ToolsHelper'; import { ToolsHelper } from '../utils/ToolsHelper';
import { XWebParams } from '../utils/XWebHelper'; import { XWebParams } from '../utils/XWebHelper';
import { WindowHelper } from '../utils/WindowHelper'; import { WindowHelper } from '../utils/WindowHelper';
import { SZYXLocalStorageHelper } from '../utils/SZYXLocalStorageHelper';
import { SZYXLocalStorageKeys } from '../utils/SZYXLocalStorageKeys';
@Entry({ routeName: 'XWebview' }) @Entry({ routeName: 'XWebview' })
@Preview @Preview
@ -15,6 +17,7 @@ export struct XWebview {
// 手机号 // 手机号
@State url: string = (router.getParams() as XWebParams).url @State url: string = (router.getParams() as XWebParams).url
@State title?: string = (router.getParams() as XWebParams).title @State title?: string = (router.getParams() as XWebParams).title
@State closeTag?: string = (router.getParams() as XWebParams).closeTag
@State showMenu: boolean = (router.getParams() as XWebParams).showMenu ?? false @State showMenu: boolean = (router.getParams() as XWebParams).showMenu ?? false
@State errorInfo: string | null = null @State errorInfo: string | null = null
@State progress: number = 0 @State progress: number = 0
@ -22,9 +25,13 @@ export struct XWebview {
dialogController: XDialogController = {} as XDialogController dialogController: XDialogController = {} as XDialogController
aboutToAppear(): void { aboutToAppear(): void {
SZYXLocalStorageHelper.storage.setOrCreate(SZYXLocalStorageKeys.XWebViewCLose, undefined)
} }
aboutToDisappear(): void { aboutToDisappear(): void {
if (this.closeTag !== undefined) {
SZYXLocalStorageHelper.storage.setOrCreate(SZYXLocalStorageKeys.XWebViewCLose, this.closeTag)
}
} }
onBackPress(): boolean | void { onBackPress(): boolean | void {

查看文件

@ -2,4 +2,5 @@
export class SZYXLocalStorageKeys{ export class SZYXLocalStorageKeys{
public static HttpHandlerList: string = 'httpHandlerList'; public static HttpHandlerList: string = 'httpHandlerList';
public static HttpHandlerListLength: string = 'HttpHandlerListLength'; public static HttpHandlerListLength: string = 'HttpHandlerListLength';
public static XWebViewCLose: string = 'SZYX_XWebViewCLose';
} }

查看文件

@ -37,7 +37,7 @@ interface ListItem {
} }
@Builder @Builder
function customDialogBuilder<T>(option: ListOptions<T>, dialogTag: string) { export function customDialogBuilder<T>(option: ListOptions<T>, dialogTag: string) {
Column() { Column() {
Text(option.title) Text(option.title)

查看文件

@ -9,6 +9,7 @@ export interface XWebParams {
url: string url: string
title?: string title?: string
showMenu?: boolean showMenu?: boolean
closeTag?:string
} }
export class XWebHelper { export class XWebHelper {
@ -16,17 +17,19 @@ export class XWebHelper {
* 打开web页面,加载h5 * 打开web页面,加载h5
* @param params * @param params
*/ */
public static openWeb(params: XWebParams) { public static openWeb(params: XWebParams): Promise<boolean> {
return new Promise((resolve) => {
router.pushNamedRoute({ router.pushNamedRoute({
name: 'XWebview', name: 'XWebview',
params: params params: params
}, router.RouterMode.Single).then(() => { }, router.RouterMode.Single).then(() => {
console.info('Succeeded in jumping to the XWebview page.') console.info('Succeeded in jumping to the XWebview page.')
resolve(true)
}).catch((err: BusinessError) => { }).catch((err: BusinessError) => {
resolve(false)
console.error(`Failed to jump to the second page.Code is ${err.code}, message is ${err.message}`) console.error(`Failed to jump to the second page.Code is ${err.code}, message is ${err.message}`)
ToolsHelper.showMessage(`Failed to jump to the second page.Code is ${err.code}, message is ${err.message}`) ToolsHelper.showMessage(`Failed to jump to the second page.Code is ${err.code}, message is ${err.message}`)
}) })
})
} }
} }