xugenyuan

ref |> 添加页面跳转拦截类,用于拦截登录页跳转,增加一键登录判断

Signed-off-by: xugenyuan <xugenyuan@wondertek.com.cn>
... ... @@ -5,3 +5,5 @@ export { WDRouterPage } from './src/main/ets/router/WDRouterPage'
export { registerRouter } from './src/main/ets/router/Action2Page'
export { ProcessUtils } from './src/main/ets/utils/ProcessUtils'
export { RouterJumpInterceptor, JumpInterceptorAction } from './src/main/ets/router/RouterJumpInterceptor'
\ No newline at end of file
... ...
import { WDRouterPage } from './WDRouterPage';
export interface JumpInterceptorAction {
on(params?: object, singleMode?: boolean): boolean
}
// TODO:待优化
// 临时解决跳转页面之前方法拦截,比如登录先走一键登录,直播请求接口等
//
export class RouterJumpInterceptor {
private static actions: Record<string, JumpInterceptorAction> = {}
static getInterceptorAction(jumpPage: WDRouterPage): JumpInterceptorAction | undefined {
return RouterJumpInterceptor.actions[jumpPage.url()]
}
static register(jumpPage: WDRouterPage, interceptorAction: JumpInterceptorAction) {
RouterJumpInterceptor.actions[jumpPage.url()] = interceptorAction
}
}
... ...
... ... @@ -66,6 +66,7 @@ export class WDRouterPage {
// 动态详情页
static dynamicDetailPage = new WDRouterPage("phone", "ets/pages/detail/DynamicDetailPage");
static loginPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginPage");
static oneKeyLoginPage = new WDRouterPage("wdLogin", "ets/pages/login/OneKeyLoginPage");
static forgetPasswordPage = new WDRouterPage("wdLogin", "ets/pages/login/ForgetPasswordPage");
//我的 预约
static appointmentListPage = new WDRouterPage("wdComponent", "ets/components/page/AppointmentListPage");
... ...
... ... @@ -3,6 +3,7 @@ import { Action } from 'wdBean'
import { ToastUtils } from 'wdKit'
import { Action2Page } from './Action2Page'
import { WDRouterPage } from './WDRouterPage'
import { RouterJumpInterceptor } from './RouterJumpInterceptor'
export class WDRouterRule {
static jumpWithAction(action?: Action) {
... ... @@ -16,6 +17,11 @@ export class WDRouterRule {
static jumpWithPage(page?: WDRouterPage, params?: object, singleMode?: boolean) {
if (page) {
let action = RouterJumpInterceptor.getInterceptorAction(page)
if (action && action.on(params, singleMode)) {
return
}
let mode = router.RouterMode.Standard
if (singleMode) {
mode = router.RouterMode.Single
... ... @@ -36,6 +42,10 @@ export class WDRouterRule {
static jumpWithReplacePage(page?: WDRouterPage, params?: object) {
if (page) {
let action = RouterJumpInterceptor.getInterceptorAction(page)
if (action && action.on(params)) {
return
}
if (params) {
// router.pushUrl({ url: 'pages/routerpage2', , params: params })
router.replaceUrl({ url: page.url(), params: params })
... ...