1/* 2 * Copyright (c) 2020 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit ArkUI 19 */ 20 21/** 22 * Defines the option of router. 23 * 24 * @interface RouterOptions 25 * @syscap SystemCapability.ArkUI.ArkUI.Lite 26 * @since 3 27 * @deprecated since 8 28 * @useinstead ohos.router#RouterOptions 29 */ 30export interface RouterOptions { 31 /** 32 * URI of the destination page, which supports the following formats: 33 * 1. Absolute path of the page, which is provided by the pages list in the config.json file. 34 * Example: 35 * pages/index/index 36 * pages/detail/detail 37 * 2. Particular path. If the URI is a slash (/), the home page is displayed. 38 * 39 * @type { string } 40 * @syscap SystemCapability.ArkUI.ArkUI.Lite 41 * @since 3 42 * @deprecated since 8 43 */ 44 uri: string; 45 46 /** 47 * Data that needs to be passed to the destination page during navigation. 48 * After the destination page is displayed, the parameter can be directly used for the page. 49 * For example, this.data1 (data1 is the key value of the params used for page navigation.) 50 * 51 * @type { ?Object } 52 * @syscap SystemCapability.ArkUI.ArkUI.Lite 53 * @since 3 54 * @deprecated since 8 55 */ 56 params?: Object; 57} 58 59/** 60 * Defines the option of router back. 61 * 62 * @interface BackRouterOptions 63 * @syscap SystemCapability.ArkUI.ArkUI.Full 64 * @since 7 65 * @deprecated since 8 66 * @useinstead ohos.router#RouterOptions 67 */ 68export interface BackRouterOptions { 69 /** 70 * Returns to the page of the specified path. 71 * If the page with the specified path does not exist in the page stack, router.back() is called by default. 72 * 73 * @type { ?string } 74 * @syscap SystemCapability.ArkUI.ArkUI.Full 75 * @since 7 76 * @deprecated since 8 77 */ 78 uri?: string; 79 80 /** 81 * Data that needs to be passed to the destination page during navigation. 82 * 83 * @type { ?Object } 84 * @syscap SystemCapability.ArkUI.ArkUI.Lite 85 * @since 7 86 * @deprecated since 8 87 */ 88 params?: Object; 89} 90 91/** 92 * Defines the state of router. 93 * 94 * @interface RouterState 95 * @syscap SystemCapability.ArkUI.ArkUI.Full 96 * @since 3 97 * @deprecated since 8 98 * @useinstead ohos.router#RouterState 99 */ 100export interface RouterState { 101 /** 102 * Index of the current page in the stack. 103 * NOTE: The index starts from 1 from the bottom to the top of the stack. 104 * 105 * @type { number } 106 * @syscap SystemCapability.ArkUI.ArkUI.Full 107 * @since 3 108 * @deprecated since 8 109 */ 110 index: number; 111 112 /** 113 * Name of the current page, that is, the file name. 114 * 115 * @type { string } 116 * @syscap SystemCapability.ArkUI.ArkUI.Full 117 * @since 3 118 * @deprecated since 8 119 */ 120 name: string; 121 122 /** 123 * Path of the current page. 124 * 125 * @type { string } 126 * @syscap SystemCapability.ArkUI.ArkUI.Full 127 * @since 3 128 * @deprecated since 8 129 */ 130 path: string; 131} 132 133/** 134 * Defines the option of EnableAlertBeforeBackPage. 135 * 136 * @interface EnableAlertBeforeBackPageOptions 137 * @syscap SystemCapability.ArkUI.ArkUI.Full 138 * @since 6 139 * @deprecated since 8 140 * @useinstead ohos.router#RouterState 141 */ 142export interface EnableAlertBeforeBackPageOptions { 143 /** 144 * dialog context. 145 * 146 * @type { string } 147 * @syscap SystemCapability.ArkUI.ArkUI.Full 148 * @since 6 149 * @deprecated since 8 150 */ 151 message: string; 152 153 /** 154 * Called when the dialog box is displayed. 155 * 156 * @type { ?function } 157 * @syscap SystemCapability.ArkUI.ArkUI.Full 158 * @since 6 159 * @deprecated since 8 160 */ 161 success?: (errMsg: string) => void; 162 163 /** 164 * Called when the operation is cancelled. 165 * 166 * @type { ?function } 167 * @syscap SystemCapability.ArkUI.ArkUI.Full 168 * @since 6 169 * @deprecated since 8 170 */ 171 cancel?: (errMsg: string) => void; 172 173 /** 174 * Called when the dialog box is closed. 175 * 176 * @type { ?function } 177 * @syscap SystemCapability.ArkUI.ArkUI.Full 178 * @since 6 179 * @deprecated since 8 180 */ 181 complete?: () => void; 182} 183 184/** 185 * Defines the option of DisableAlertBeforeBackPage. 186 * 187 * @interface DisableAlertBeforeBackPageOptions 188 * @syscap SystemCapability.ArkUI.ArkUI.Full 189 * @since 6 190 * @deprecated since 8 191 * @useinstead ohos.router#RouterOptions 192 */ 193export interface DisableAlertBeforeBackPageOptions { 194 /** 195 * Called when the dialog box is displayed. 196 * 197 * @type { ?function } 198 * @syscap SystemCapability.ArkUI.ArkUI.Full 199 * @since 6 200 * @deprecated since 8 201 */ 202 success?: (errMsg: string) => void; 203 204 /** 205 * Called when the operation is cancelled. 206 * 207 * @type { ?function } 208 * @syscap SystemCapability.ArkUI.ArkUI.Full 209 * @since 6 210 * @deprecated since 8 211 */ 212 cancel?: (errMsg: string) => void; 213 214 /** 215 * Called when the dialog box is closed. 216 * 217 * @type { ?function } 218 * @syscap SystemCapability.ArkUI.ArkUI.Full 219 * @since 6 220 * @deprecated since 8 221 */ 222 complete?: () => void; 223} 224 225/** 226 * Define ParamsInterface. 227 * 228 * @typedef { object } ParamsInterface 229 * @syscap SystemCapability.ArkUI.ArkUI.Full 230 * @since 7 231 * @deprecated since 8 232 */ 233type ParamsInterface = { 234 [key: string]: Object; 235}; 236 237/** 238 * Defines the Router interface. 239 * 240 * @syscap SystemCapability.ArkUI.ArkUI.Lite 241 * @since 3 242 * @deprecated since 8 243 * @useinstead ohos.router#router 244 */ 245export default class Router { 246 /** 247 * Navigates to a specified page in the application based on the page URL and parameters. 248 * 249 * @param { RouterOptions } options Options. 250 * @syscap SystemCapability.ArkUI.ArkUI.Full 251 * @since 3 252 * @deprecated since 8 253 */ 254 static push(options: RouterOptions): void; 255 256 /** 257 * Replaces the current page with another one in the application. The current page is destroyed after replacement. 258 * 259 * @param { RouterOptions } options Options. 260 * @syscap SystemCapability.ArkUI.ArkUI.Lite 261 * @since 3 262 * @deprecated since 8 263 */ 264 static replace(options: RouterOptions): void; 265 266 /** 267 * Returns to the previous page or a specified page. 268 * 269 * @param { BackRouterOptions } options Options. 270 * @syscap SystemCapability.ArkUI.ArkUI.Full 271 * @since 3 272 * @deprecated since 8 273 */ 274 static back(options?: BackRouterOptions): void; 275 276 /** 277 * Obtains information about the current page params. 278 * 279 * @returns { ParamsInterface } Page params. 280 * @syscap SystemCapability.ArkUI.ArkUI.Full 281 * @since 7 282 * @deprecated since 8 283 */ 284 static getParams(): ParamsInterface; 285 286 /** 287 * Clears all historical pages and retains only the current page at the top of the stack. 288 * 289 * @syscap SystemCapability.ArkUI.ArkUI.Full 290 * @since 3 291 * @deprecated since 8 292 */ 293 static clear(): void; 294 295 /** 296 * Obtains the number of pages in the current stack. 297 * 298 * @returns { string } Number of pages in the stack. The maximum value is 32. 299 * @syscap SystemCapability.ArkUI.ArkUI.Full 300 * @since 3 301 * @deprecated since 8 302 */ 303 static getLength(): string; 304 305 /** 306 * Obtains information about the current page state. 307 * 308 * @returns { RouterState } Page state. 309 * @syscap SystemCapability.ArkUI.ArkUI.Full 310 * @since 3 311 * @deprecated since 8 312 */ 313 static getState(): RouterState; 314 315 /** 316 * Pop up dialog to ask whether to back 317 * 318 * @param { EnableAlertBeforeBackPageOptions } options Options. 319 * @syscap SystemCapability.ArkUI.ArkUI.Full 320 * @since 6 321 * @deprecated since 8 322 */ 323 static enableAlertBeforeBackPage(options: EnableAlertBeforeBackPageOptions): void; 324 325 /** 326 * cancel enableAlertBeforeBackPage 327 * 328 * @param { DisableAlertBeforeBackPageOptions } options Options. 329 * @syscap SystemCapability.ArkUI.ArkUI.Full 330 * @since 6 331 * @deprecated since 8 332 */ 333 static disableAlertBeforeBackPage(options?: DisableAlertBeforeBackPageOptions): void; 334} 335