ref |> 补充推送内链跳转与设置别名问题解决
Signed-off-by: xugenyuan <xugenyuan@wondertek.com.cn>
Showing
3 changed files
with
111 additions
and
7 deletions
| 1 | import { url } from '@kit.ArkTS' | 1 | import { url } from '@kit.ArkTS' |
| 2 | import App from '@system.app' | 2 | import App from '@system.app' |
| 3 | +import { Action, Params } from 'wdBean/Index' | ||
| 4 | +import { ExtraDTO } from 'wdBean/src/main/ets/bean/component/extra/ExtraDTO' | ||
| 3 | import { Logger } from 'wdKit/Index' | 5 | import { Logger } from 'wdKit/Index' |
| 6 | +import { WDRouterRule } from '../router/WDRouterRule' | ||
| 7 | +import { ProcessUtils } from './ProcessUtils' | ||
| 4 | 8 | ||
| 5 | const TAG = "AppInnerLink" | 9 | const TAG = "AppInnerLink" |
| 6 | 10 | ||
| @@ -8,7 +12,7 @@ export class AppInnerLink { | @@ -8,7 +12,7 @@ export class AppInnerLink { | ||
| 8 | 12 | ||
| 9 | static readonly INNER_LINK_PROTCOL = "rmrbapp:" | 13 | static readonly INNER_LINK_PROTCOL = "rmrbapp:" |
| 10 | static readonly INNER_LINK_HOSTNAME = "rmrb.app" | 14 | static readonly INNER_LINK_HOSTNAME = "rmrb.app" |
| 11 | - static readonly INNER_LINK_PATHNAME = "openwith" | 15 | + static readonly INNER_LINK_PATHNAME = "/openwith" |
| 12 | 16 | ||
| 13 | // 内链跳转 | 17 | // 内链跳转 |
| 14 | // 内链地址例如:rmrbapp://rmrb.app/openwith?type=article&subType=h5_template_article&contentId=30000762651&relId=500000038702&skipType=1&relType=1 | 18 | // 内链地址例如:rmrbapp://rmrb.app/openwith?type=article&subType=h5_template_article&contentId=30000762651&relId=500000038702&skipType=1&relType=1 |
| @@ -48,19 +52,110 @@ export class AppInnerLink { | @@ -48,19 +52,110 @@ export class AppInnerLink { | ||
| 48 | } | 52 | } |
| 49 | 53 | ||
| 50 | private static jumpParams(params: InnerLinkParam) { | 54 | private static jumpParams(params: InnerLinkParam) { |
| 55 | + if (!AppInnerLink.validTypes(params.type)) { | ||
| 56 | + return | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + const contentType = AppInnerLink.contentTypeWithType(params.type) | ||
| 60 | + | ||
| 61 | + if (params.type == "article") { | ||
| 62 | + let taskAction: Action = { | ||
| 63 | + type: 'JUMP_INNER_NEW_PAGE', | ||
| 64 | + params: { | ||
| 65 | + contentID: params.contentId, | ||
| 66 | + pageID: 'IMAGE_TEXT_DETAIL', | ||
| 67 | + extra: { | ||
| 68 | + relType: params.relType, | ||
| 69 | + relId: params.relId, | ||
| 70 | + sourcePage: '5', // ??? | ||
| 71 | + } as ExtraDTO | ||
| 72 | + } as Params, | ||
| 73 | + }; | ||
| 74 | + WDRouterRule.jumpWithAction(taskAction) | ||
| 75 | + return | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + if (params.type == "video" | ||
| 79 | + || params.type == "dynamic" | ||
| 80 | + || params.type == "live" | ||
| 81 | + || params.type == "audio" | ||
| 82 | + || params.type == "picture") { | ||
| 83 | + let taskAction: Action = { | ||
| 84 | + type: 'JUMP_DETAIL_PAGE', | ||
| 85 | + params: { | ||
| 86 | + detailPageType: contentType, | ||
| 87 | + contentID: params.contentId, | ||
| 88 | + extra: { | ||
| 89 | + relType: params.relType, | ||
| 90 | + relId: params.relId, | ||
| 91 | + } as ExtraDTO | ||
| 92 | + } as Params, | ||
| 93 | + }; | ||
| 94 | + WDRouterRule.jumpWithAction(taskAction) | ||
| 95 | + return | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + if (params.type == "owner_page" && params.creatorId) { | ||
| 99 | + ProcessUtils.gotoPeopleShipHomePage(params.creatorId) | ||
| 100 | + return | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + if (params.type == "topic") { | ||
| 104 | + | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + if (params.type == "channel") { | ||
| 108 | + | ||
| 109 | + } | ||
| 51 | 110 | ||
| 52 | } | 111 | } |
| 112 | + private static contentTypeWithType(type?: string) : number | undefined { | ||
| 113 | + switch (type) { | ||
| 114 | + case "video": return 1 | ||
| 115 | + case "dynamic": return 14 | ||
| 116 | + case "live": return 2 | ||
| 117 | + case "audio": return 13 | ||
| 118 | + case "picture": return 9 | ||
| 119 | + case "article": return 8 | ||
| 120 | + case "ask": return 16 | ||
| 121 | + } | ||
| 122 | + return | ||
| 123 | + } | ||
| 124 | + private static validTypes(type?: string) : boolean { | ||
| 125 | + if (!type) { | ||
| 126 | + return false | ||
| 127 | + } | ||
| 128 | + let typeArray = ["article", "dynamic", "live", "video", "topic", "audio", "ask", "picture", "owner_page", "topic", "channel"] | ||
| 129 | + return typeArray.indexOf(type) != -1 | ||
| 130 | + } | ||
| 131 | + | ||
| 53 | private static jumpNoParams(params: InnerLinkParam) { | 132 | private static jumpNoParams(params: InnerLinkParam) { |
| 133 | + if (!params.type || params.type != "app" || !params.subType) { | ||
| 134 | + return | ||
| 135 | + } | ||
| 136 | + if (params.subType == "login") { | ||
| 137 | + ProcessUtils.gotoLoginPage(); | ||
| 138 | + } else if (params.subType == "search") { | ||
| 139 | + | ||
| 140 | + } else if (params.subType == "home") { | ||
| 141 | + | ||
| 142 | + } else if (params.subType == "mine") { | ||
| 54 | 143 | ||
| 55 | } | 144 | } |
| 56 | - private static jumpAppH5(params: InnerLinkParam) { | 145 | + } |
| 57 | 146 | ||
| 147 | + private static jumpAppH5(params: InnerLinkParam) { | ||
| 148 | + if (params.type && params.type == "h5" && params.url) { | ||
| 149 | + ProcessUtils.gotoDefaultWebPage(params.url); | ||
| 150 | + } | ||
| 58 | } | 151 | } |
| 59 | private static jumpOutH5(params: InnerLinkParam) { | 152 | private static jumpOutH5(params: InnerLinkParam) { |
| 60 | - | 153 | + if (params.type && params.type == "h5" && params.url) { |
| 154 | + ProcessUtils.jumpExternalWebPage(params.url); | ||
| 155 | + } | ||
| 61 | } | 156 | } |
| 62 | private static jumpThirdApp(params: InnerLinkParam) { | 157 | private static jumpThirdApp(params: InnerLinkParam) { |
| 63 | - | 158 | + //TODO: |
| 64 | } | 159 | } |
| 65 | 160 | ||
| 66 | static parseParams(link: string) : InnerLinkParam | undefined { | 161 | static parseParams(link: string) : InnerLinkParam | undefined { |
| @@ -149,6 +149,9 @@ export class GetuiPush { | @@ -149,6 +149,9 @@ export class GetuiPush { | ||
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | setAlias(bind: boolean, alias: string, sn: string = this.ALIAS_SN_USERID) { | 151 | setAlias(bind: boolean, alias: string, sn: string = this.ALIAS_SN_USERID) { |
| 152 | + if (typeof alias == "number") { | ||
| 153 | + alias = `${alias}` | ||
| 154 | + } | ||
| 152 | if (!this.initialed) { return } | 155 | if (!this.initialed) { return } |
| 153 | if (bind) { | 156 | if (bind) { |
| 154 | Logger.debug(TAG, "推送 绑定别名 " + alias) | 157 | Logger.debug(TAG, "推送 绑定别名 " + alias) |
| @@ -56,9 +56,15 @@ export class PushContentParser { | @@ -56,9 +56,15 @@ export class PushContentParser { | ||
| 56 | },*/ | 56 | },*/ |
| 57 | let gtData = want.parameters[PushContentParser.LAUNCH_PARAM_GETUI_DATA] as Record<string, string | number | object> | 57 | let gtData = want.parameters[PushContentParser.LAUNCH_PARAM_GETUI_DATA] as Record<string, string | number | object> |
| 58 | if (gtData[PushContentParser.LAUNCH_PARAM_GETUI_TASKID] != undefined) { | 58 | if (gtData[PushContentParser.LAUNCH_PARAM_GETUI_TASKID] != undefined) { |
| 59 | - let json = JSON.parse(gtData["wantUri"] as string) as Record<string, string | number> | ||
| 60 | - if (json && json[PushContentParser.PUSH_PARAM_PUSH_LINK] != null) { | ||
| 61 | - const pushLink = json[PushContentParser.PUSH_PARAM_PUSH_LINK] as string | 59 | + // let json = JSON.parse(gtData["wantUri"] as string) as Record<string, string | number> |
| 60 | + // if (json && json[PushContentParser.PUSH_PARAM_PUSH_LINK] != null) { | ||
| 61 | + // const pushLink = json[PushContentParser.PUSH_PARAM_PUSH_LINK] as string | ||
| 62 | + // return { | ||
| 63 | + // isPush: true, online: true, pushLink: pushLink, want: want | ||
| 64 | + // } | ||
| 65 | + // } | ||
| 66 | + if (want.parameters[PushContentParser.PUSH_PARAM_PUSH_LINK]) { | ||
| 67 | + let pushLink = want.parameters[PushContentParser.PUSH_PARAM_PUSH_LINK] as string | ||
| 62 | return { | 68 | return { |
| 63 | isPush: true, online: true, pushLink: pushLink, want: want | 69 | isPush: true, online: true, pushLink: pushLink, want: want |
| 64 | } | 70 | } |
-
Please register or login to post a comment