ref |> 添加页面跳转拦截类,用于拦截登录页跳转,增加一键登录判断
Signed-off-by: xugenyuan <xugenyuan@wondertek.com.cn>
Showing
4 changed files
with
36 additions
and
0 deletions
| @@ -5,3 +5,5 @@ export { WDRouterPage } from './src/main/ets/router/WDRouterPage' | @@ -5,3 +5,5 @@ export { WDRouterPage } from './src/main/ets/router/WDRouterPage' | ||
| 5 | export { registerRouter } from './src/main/ets/router/Action2Page' | 5 | export { registerRouter } from './src/main/ets/router/Action2Page' |
| 6 | 6 | ||
| 7 | export { ProcessUtils } from './src/main/ets/utils/ProcessUtils' | 7 | export { ProcessUtils } from './src/main/ets/utils/ProcessUtils' |
| 8 | + | ||
| 9 | +export { RouterJumpInterceptor, JumpInterceptorAction } from './src/main/ets/router/RouterJumpInterceptor' |
| 1 | +import { WDRouterPage } from './WDRouterPage'; | ||
| 2 | + | ||
| 3 | +export interface JumpInterceptorAction { | ||
| 4 | + on(params?: object, singleMode?: boolean): boolean | ||
| 5 | +} | ||
| 6 | + | ||
| 7 | +// TODO:待优化 | ||
| 8 | +// 临时解决跳转页面之前方法拦截,比如登录先走一键登录,直播请求接口等 | ||
| 9 | +// | ||
| 10 | +export class RouterJumpInterceptor { | ||
| 11 | + | ||
| 12 | + private static actions: Record<string, JumpInterceptorAction> = {} | ||
| 13 | + | ||
| 14 | + static getInterceptorAction(jumpPage: WDRouterPage): JumpInterceptorAction | undefined { | ||
| 15 | + return RouterJumpInterceptor.actions[jumpPage.url()] | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + static register(jumpPage: WDRouterPage, interceptorAction: JumpInterceptorAction) { | ||
| 19 | + RouterJumpInterceptor.actions[jumpPage.url()] = interceptorAction | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + | ||
| 23 | +} |
| @@ -66,6 +66,7 @@ export class WDRouterPage { | @@ -66,6 +66,7 @@ export class WDRouterPage { | ||
| 66 | // 动态详情页 | 66 | // 动态详情页 |
| 67 | static dynamicDetailPage = new WDRouterPage("phone", "ets/pages/detail/DynamicDetailPage"); | 67 | static dynamicDetailPage = new WDRouterPage("phone", "ets/pages/detail/DynamicDetailPage"); |
| 68 | static loginPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginPage"); | 68 | static loginPage = new WDRouterPage("wdLogin", "ets/pages/login/LoginPage"); |
| 69 | + static oneKeyLoginPage = new WDRouterPage("wdLogin", "ets/pages/login/OneKeyLoginPage"); | ||
| 69 | static forgetPasswordPage = new WDRouterPage("wdLogin", "ets/pages/login/ForgetPasswordPage"); | 70 | static forgetPasswordPage = new WDRouterPage("wdLogin", "ets/pages/login/ForgetPasswordPage"); |
| 70 | //我的 预约 | 71 | //我的 预约 |
| 71 | static appointmentListPage = new WDRouterPage("wdComponent", "ets/components/page/AppointmentListPage"); | 72 | static appointmentListPage = new WDRouterPage("wdComponent", "ets/components/page/AppointmentListPage"); |
| @@ -3,6 +3,7 @@ import { Action } from 'wdBean' | @@ -3,6 +3,7 @@ import { Action } from 'wdBean' | ||
| 3 | import { ToastUtils } from 'wdKit' | 3 | import { ToastUtils } from 'wdKit' |
| 4 | import { Action2Page } from './Action2Page' | 4 | import { Action2Page } from './Action2Page' |
| 5 | import { WDRouterPage } from './WDRouterPage' | 5 | import { WDRouterPage } from './WDRouterPage' |
| 6 | +import { RouterJumpInterceptor } from './RouterJumpInterceptor' | ||
| 6 | 7 | ||
| 7 | export class WDRouterRule { | 8 | export class WDRouterRule { |
| 8 | static jumpWithAction(action?: Action) { | 9 | static jumpWithAction(action?: Action) { |
| @@ -16,6 +17,11 @@ export class WDRouterRule { | @@ -16,6 +17,11 @@ export class WDRouterRule { | ||
| 16 | 17 | ||
| 17 | static jumpWithPage(page?: WDRouterPage, params?: object, singleMode?: boolean) { | 18 | static jumpWithPage(page?: WDRouterPage, params?: object, singleMode?: boolean) { |
| 18 | if (page) { | 19 | if (page) { |
| 20 | + let action = RouterJumpInterceptor.getInterceptorAction(page) | ||
| 21 | + if (action && action.on(params, singleMode)) { | ||
| 22 | + return | ||
| 23 | + } | ||
| 24 | + | ||
| 19 | let mode = router.RouterMode.Standard | 25 | let mode = router.RouterMode.Standard |
| 20 | if (singleMode) { | 26 | if (singleMode) { |
| 21 | mode = router.RouterMode.Single | 27 | mode = router.RouterMode.Single |
| @@ -36,6 +42,10 @@ export class WDRouterRule { | @@ -36,6 +42,10 @@ export class WDRouterRule { | ||
| 36 | 42 | ||
| 37 | static jumpWithReplacePage(page?: WDRouterPage, params?: object) { | 43 | static jumpWithReplacePage(page?: WDRouterPage, params?: object) { |
| 38 | if (page) { | 44 | if (page) { |
| 45 | + let action = RouterJumpInterceptor.getInterceptorAction(page) | ||
| 46 | + if (action && action.on(params)) { | ||
| 47 | + return | ||
| 48 | + } | ||
| 39 | if (params) { | 49 | if (params) { |
| 40 | // router.pushUrl({ url: 'pages/routerpage2', , params: params }) | 50 | // router.pushUrl({ url: 'pages/routerpage2', , params: params }) |
| 41 | router.replaceUrl({ url: page.url(), params: params }) | 51 | router.replaceUrl({ url: page.url(), params: params }) |
-
Please register or login to post a comment