1/* 2 * Copyright (c) 2021 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 21import { Callback } from './@ohos.base'; 22import { AsyncCallback } from './@ohos.base'; 23 24/** 25 * @namespace router 26 * @syscap SystemCapability.ArkUI.ArkUI.Full 27 * @since 8 28 */ 29/** 30 * @namespace router 31 * @syscap SystemCapability.ArkUI.ArkUI.Full 32 * @crossplatform 33 * @since 10 34 */ 35/** 36 * @namespace router 37 * @syscap SystemCapability.ArkUI.ArkUI.Full 38 * @crossplatform 39 * @atomicservice 40 * @since 11 41 */ 42declare namespace router { 43 /** 44 * Router Mode 45 * 46 * @enum { number } 47 * @syscap SystemCapability.ArkUI.ArkUI.Full 48 * @since 9 49 */ 50 /** 51 * Router Mode 52 * 53 * @enum { number } 54 * @syscap SystemCapability.ArkUI.ArkUI.Full 55 * @crossplatform 56 * @since 10 57 */ 58 /** 59 * Router Mode 60 * 61 * @enum { number } 62 * @syscap SystemCapability.ArkUI.ArkUI.Full 63 * @crossplatform 64 * @atomicservice 65 * @since 11 66 */ 67 export enum RouterMode { 68 /** 69 * Default route mode. 70 * The page will be added to the top of the page stack. 71 * 72 * @syscap SystemCapability.ArkUI.ArkUI.Full 73 * @since 9 74 */ 75 /** 76 * Default route mode. 77 * The page will be added to the top of the page stack. 78 * 79 * @syscap SystemCapability.ArkUI.ArkUI.Full 80 * @crossplatform 81 * @since 10 82 */ 83 /** 84 * Default route mode. 85 * The page will be added to the top of the page stack. 86 * 87 * @syscap SystemCapability.ArkUI.ArkUI.Full 88 * @crossplatform 89 * @atomicservice 90 * @since 11 91 */ 92 Standard, 93 94 /** 95 * Single route mode. 96 * If the target page already has the same url page in the page stack, 97 * the same url page closest to the top of the stack will be moved to the top of the stack. 98 * If the target page url does not exist in the page stack, route will use default route mode. 99 * 100 * @syscap SystemCapability.ArkUI.ArkUI.Full 101 * @since 9 102 */ 103 /** 104 * Single route mode. 105 * If the target page already has the same url page in the page stack, 106 * the same url page closest to the top of the stack will be moved to the top of the stack. 107 * If the target page url does not exist in the page stack, route will use default route mode. 108 * 109 * @syscap SystemCapability.ArkUI.ArkUI.Full 110 * @crossplatform 111 * @since 10 112 */ 113 /** 114 * Single route mode. 115 * If the target page already has the same url page in the page stack, 116 * the same url page closest to the top of the stack will be moved to the top of the stack. 117 * If the target page url does not exist in the page stack, route will use default route mode. 118 * 119 * @syscap SystemCapability.ArkUI.ArkUI.Full 120 * @crossplatform 121 * @atomicservice 122 * @since 11 123 */ 124 Single, 125 } 126 127 /** 128 * @typedef RouterOptions 129 * @syscap SystemCapability.ArkUI.ArkUI.Lite 130 * @since 8 131 */ 132 /** 133 * @typedef RouterOptions 134 * @syscap SystemCapability.ArkUI.ArkUI.Lite 135 * @atomicservice 136 * @since 11 137 */ 138 interface RouterOptions { 139 /** 140 * URI of the destination page, which supports the following formats: 141 * 1. Absolute path of the page, which is provided by the pages list in the config.json file. 142 * Example: 143 * pages/index/index 144 * pages/detail/detail 145 * 2. Particular path. If the URI is a slash (/), the home page is displayed. 146 * 147 * @type { string } 148 * @syscap SystemCapability.ArkUI.ArkUI.Lite 149 * @since 8 150 */ 151 /** 152 * URI of the destination page, which supports the following formats: 153 * 1. Absolute path of the page, which is provided by the pages list in the config.json file. 154 * Example: 155 * pages/index/index 156 * pages/detail/detail 157 * 2. Particular path. If the URI is a slash (/), the home page is displayed. 158 * 159 * @type { string } 160 * @syscap SystemCapability.ArkUI.ArkUI.Lite 161 * @atomicservice 162 * @since 11 163 */ 164 url: string; 165 166 /** 167 * Data that needs to be passed to the destination page during navigation. 168 * After the destination page is displayed, the parameter can be directly used for the page. 169 * For example, this.data1 (data1 is the key value of the params used for page navigation.) 170 * 171 * @type { ?Object } 172 * @syscap SystemCapability.ArkUI.ArkUI.Lite 173 * @since 8 174 */ 175 /** 176 * Data that needs to be passed to the destination page during navigation. 177 * After the destination page is displayed, the parameter can be directly used for the page. 178 * For example, this.data1 (data1 is the key value of the params used for page navigation.) 179 * 180 * @type { ?Object } 181 * @syscap SystemCapability.ArkUI.ArkUI.Lite 182 * @atomicservice 183 * @since 11 184 */ 185 params?: Object; 186 } 187 188 /** 189 * @typedef RouterState 190 * @syscap SystemCapability.ArkUI.ArkUI.Full 191 * @since 8 192 */ 193 /** 194 * @typedef RouterState 195 * @syscap SystemCapability.ArkUI.ArkUI.Full 196 * @crossplatform 197 * @since 10 198 */ 199 /** 200 * @typedef RouterState 201 * @syscap SystemCapability.ArkUI.ArkUI.Full 202 * @crossplatform 203 * @atomicservice 204 * @since 11 205 */ 206 interface RouterState { 207 /** 208 * Index of the current page in the stack. 209 * NOTE: The index starts from 1 from the bottom to the top of the stack. 210 * 211 * @type { number } 212 * @syscap SystemCapability.ArkUI.ArkUI.Full 213 * @since 8 214 */ 215 /** 216 * Index of the current page in the stack. 217 * NOTE: The index starts from 1 from the bottom to the top of the stack. 218 * 219 * @type { number } 220 * @syscap SystemCapability.ArkUI.ArkUI.Full 221 * @crossplatform 222 * @since 10 223 */ 224 /** 225 * Index of the current page in the stack. 226 * NOTE: The index starts from 1 from the bottom to the top of the stack. 227 * 228 * @type { number } 229 * @syscap SystemCapability.ArkUI.ArkUI.Full 230 * @crossplatform 231 * @atomicservice 232 * @since 11 233 */ 234 index: number; 235 236 /** 237 * Name of the current page, that is, the file name. 238 * 239 * @type { string } 240 * @syscap SystemCapability.ArkUI.ArkUI.Full 241 * @since 8 242 */ 243 /** 244 * Name of the current page, that is, the file name. 245 * 246 * @type { string } 247 * @syscap SystemCapability.ArkUI.ArkUI.Full 248 * @crossplatform 249 * @since 10 250 */ 251 /** 252 * Name of the current page, that is, the file name. 253 * 254 * @type { string } 255 * @syscap SystemCapability.ArkUI.ArkUI.Full 256 * @crossplatform 257 * @atomicservice 258 * @since 11 259 */ 260 name: string; 261 262 /** 263 * Path of the current page. 264 * 265 * @type { string } 266 * @syscap SystemCapability.ArkUI.ArkUI.Full 267 * @since 8 268 */ 269 /** 270 * Path of the current page. 271 * 272 * @type { string } 273 * @syscap SystemCapability.ArkUI.ArkUI.Full 274 * @crossplatform 275 * @since 10 276 */ 277 /** 278 * Path of the current page. 279 * 280 * @type { string } 281 * @syscap SystemCapability.ArkUI.ArkUI.Full 282 * @crossplatform 283 * @atomicservice 284 * @since 11 285 */ 286 path: string; 287 } 288 289 /** 290 * @typedef EnableAlertOptions 291 * @syscap SystemCapability.ArkUI.ArkUI.Full 292 * @since 8 293 */ 294 /** 295 * @typedef EnableAlertOptions 296 * @syscap SystemCapability.ArkUI.ArkUI.Full 297 * @crossplatform 298 * @since 10 299 */ 300 /** 301 * @typedef EnableAlertOptions 302 * @syscap SystemCapability.ArkUI.ArkUI.Full 303 * @crossplatform 304 * @atomicservice 305 * @since 11 306 */ 307 interface EnableAlertOptions { 308 /** 309 * dialog context. 310 * 311 * @type { string } 312 * @syscap SystemCapability.ArkUI.ArkUI.Full 313 * @since 8 314 */ 315 /** 316 * dialog context. 317 * 318 * @type { string } 319 * @syscap SystemCapability.ArkUI.ArkUI.Full 320 * @crossplatform 321 * @since 10 322 */ 323 /** 324 * dialog context. 325 * 326 * @type { string } 327 * @syscap SystemCapability.ArkUI.ArkUI.Full 328 * @crossplatform 329 * @atomicservice 330 * @since 11 331 */ 332 message: string; 333 } 334 335 /** 336 * Navigates to a specified page in the application based on the page URL and parameters. 337 * 338 * @param { RouterOptions } options - Options. 339 * @syscap SystemCapability.ArkUI.ArkUI.Full 340 * @since 8 341 * @deprecated since 9 342 * @useinstead ohos.router.router#pushUrl 343 */ 344 function push(options: RouterOptions): void; 345 346 /** 347 * Navigates to a specified page in the application based on the page URL and parameters. 348 * 349 * @param { RouterOptions } options - Options. 350 * @param { AsyncCallback<void> } callback - the callback of pushUrl. 351 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 352 * @throws { BusinessError } 100001 - if UI execution context not found. 353 * @throws { BusinessError } 100002 - if the uri is not exist. 354 * @throws { BusinessError } 100003 - if the pages are pushed too much. 355 * @syscap SystemCapability.ArkUI.ArkUI.Full 356 * @since 9 357 */ 358 /** 359 * Navigates to a specified page in the application based on the page URL and parameters. 360 * 361 * @param { RouterOptions } options - Options. 362 * @param { AsyncCallback<void> } callback - the callback of pushUrl. 363 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 364 * @throws { BusinessError } 100001 - if UI execution context not found. 365 * @throws { BusinessError } 100002 - if the uri is not exist. 366 * @throws { BusinessError } 100003 - if the pages are pushed too much. 367 * @syscap SystemCapability.ArkUI.ArkUI.Full 368 * @crossplatform 369 * @since 10 370 */ 371 /** 372 * Navigates to a specified page in the application based on the page URL and parameters. 373 * 374 * @param { RouterOptions } options - Options. 375 * @param { AsyncCallback<void> } callback - the callback of pushUrl. 376 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 377 * @throws { BusinessError } 100001 - if UI execution context not found. 378 * @throws { BusinessError } 100002 - if the uri is not exist. 379 * @throws { BusinessError } 100003 - if the pages are pushed too much. 380 * @syscap SystemCapability.ArkUI.ArkUI.Full 381 * @crossplatform 382 * @atomicservice 383 * @since 11 384 */ 385 function pushUrl(options: RouterOptions, callback: AsyncCallback<void>): void; 386 387 /** 388 * Navigates to a specified page in the application based on the page URL and parameters. 389 * 390 * @param { RouterOptions } options - Options. 391 * @returns { Promise<void> } the promise returned by the function. 392 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 393 * @throws { BusinessError } 100001 - if UI execution context not found. 394 * @throws { BusinessError } 100002 - if the uri is not exist. 395 * @throws { BusinessError } 100003 - if the pages are pushed too much. 396 * @syscap SystemCapability.ArkUI.ArkUI.Full 397 * @since 9 398 */ 399 /** 400 * Navigates to a specified page in the application based on the page URL and parameters. 401 * 402 * @param { RouterOptions } options - Options. 403 * @returns { Promise<void> } the promise returned by the function. 404 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 405 * @throws { BusinessError } 100001 - if UI execution context not found. 406 * @throws { BusinessError } 100002 - if the uri is not exist. 407 * @throws { BusinessError } 100003 - if the pages are pushed too much. 408 * @syscap SystemCapability.ArkUI.ArkUI.Full 409 * @crossplatform 410 * @since 10 411 */ 412 /** 413 * Navigates to a specified page in the application based on the page URL and parameters. 414 * 415 * @param { RouterOptions } options - Options. 416 * @returns { Promise<void> } the promise returned by the function. 417 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 418 * @throws { BusinessError } 100001 - if UI execution context not found. 419 * @throws { BusinessError } 100002 - if the uri is not exist. 420 * @throws { BusinessError } 100003 - if the pages are pushed too much. 421 * @syscap SystemCapability.ArkUI.ArkUI.Full 422 * @crossplatform 423 * @atomicservice 424 * @since 11 425 */ 426 function pushUrl(options: RouterOptions): Promise<void>; 427 428 /** 429 * Navigates to a specified page in the application based on the page URL and parameters. 430 * 431 * @param { RouterOptions } options - Options. 432 * @param { RouterMode } mode - RouterMode. 433 * @param { AsyncCallback<void> } callback - the callback of pushUrl. 434 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 435 * @throws { BusinessError } 100001 - if UI execution context not found. 436 * @throws { BusinessError } 100002 - if the uri is not exist. 437 * @throws { BusinessError } 100003 - if the pages are pushed too much. 438 * @syscap SystemCapability.ArkUI.ArkUI.Full 439 * @since 9 440 */ 441 /** 442 * Navigates to a specified page in the application based on the page URL and parameters. 443 * 444 * @param { RouterOptions } options - Options. 445 * @param { RouterMode } mode - RouterMode. 446 * @param { AsyncCallback<void> } callback - the callback of pushUrl. 447 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 448 * @throws { BusinessError } 100001 - if UI execution context not found. 449 * @throws { BusinessError } 100002 - if the uri is not exist. 450 * @throws { BusinessError } 100003 - if the pages are pushed too much. 451 * @syscap SystemCapability.ArkUI.ArkUI.Full 452 * @crossplatform 453 * @since 10 454 */ 455 /** 456 * Navigates to a specified page in the application based on the page URL and parameters. 457 * 458 * @param { RouterOptions } options - Options. 459 * @param { RouterMode } mode - RouterMode. 460 * @param { AsyncCallback<void> } callback - the callback of pushUrl. 461 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 462 * @throws { BusinessError } 100001 - if UI execution context not found. 463 * @throws { BusinessError } 100002 - if the uri is not exist. 464 * @throws { BusinessError } 100003 - if the pages are pushed too much. 465 * @syscap SystemCapability.ArkUI.ArkUI.Full 466 * @crossplatform 467 * @atomicservice 468 * @since 11 469 */ 470 function pushUrl(options: RouterOptions, mode: RouterMode, callback: AsyncCallback<void>): void; 471 472 /** 473 * Navigates to a specified page in the application based on the page URL and parameters. 474 * 475 * @param { RouterOptions } options - Options. 476 * @param { RouterMode } mode - RouterMode. 477 * @returns { Promise<void> } the promise returned by the function. 478 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 479 * @throws { BusinessError } 100001 - if UI execution context not found. 480 * @throws { BusinessError } 100002 - if the uri is not exist. 481 * @throws { BusinessError } 100003 - if the pages are pushed too much. 482 * @syscap SystemCapability.ArkUI.ArkUI.Full 483 * @since 9 484 */ 485 /** 486 * Navigates to a specified page in the application based on the page URL and parameters. 487 * 488 * @param { RouterOptions } options - Options. 489 * @param { RouterMode } mode - RouterMode. 490 * @returns { Promise<void> } the promise returned by the function. 491 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 492 * @throws { BusinessError } 100001 - if UI execution context not found. 493 * @throws { BusinessError } 100002 - if the uri is not exist. 494 * @throws { BusinessError } 100003 - if the pages are pushed too much. 495 * @syscap SystemCapability.ArkUI.ArkUI.Full 496 * @crossplatform 497 * @since 10 498 */ 499 /** 500 * Navigates to a specified page in the application based on the page URL and parameters. 501 * 502 * @param { RouterOptions } options - Options. 503 * @param { RouterMode } mode - RouterMode. 504 * @returns { Promise<void> } the promise returned by the function. 505 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 506 * @throws { BusinessError } 100001 - if UI execution context not found. 507 * @throws { BusinessError } 100002 - if the uri is not exist. 508 * @throws { BusinessError } 100003 - if the pages are pushed too much. 509 * @syscap SystemCapability.ArkUI.ArkUI.Full 510 * @crossplatform 511 * @atomicservice 512 * @since 11 513 */ 514 function pushUrl(options: RouterOptions, mode: RouterMode): Promise<void>; 515 516 /** 517 * Replaces the current page with another one in the application. The current page is destroyed after replacement. 518 * 519 * @param { RouterOptions } options - Options. 520 * @syscap SystemCapability.ArkUI.ArkUI.Lite 521 * @since 8 522 * @deprecated since 9 523 * @useinstead ohos.router.router#replaceUrl 524 */ 525 function replace(options: RouterOptions): void; 526 527 /** 528 * Replaces the current page with another one in the application. The current page is destroyed after replacement. 529 * 530 * @param { RouterOptions } options - Options. 531 * @param { AsyncCallback<void> } callback - the callback of replaceUrl. 532 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 533 * @throws { BusinessError } 100001 - if UI execution context not found, only throw in standard system. 534 * @throws { BusinessError } 200002 - if the uri is not exist. 535 * @syscap SystemCapability.ArkUI.ArkUI.Lite 536 * @since 9 537 */ 538 /** 539 * Replaces the current page with another one in the application. The current page is destroyed after replacement. 540 * 541 * @param { RouterOptions } options - Options. 542 * @param { AsyncCallback<void> } callback - the callback of replaceUrl. 543 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 544 * @throws { BusinessError } 100001 - if UI execution context not found, only throw in standard system. 545 * @throws { BusinessError } 200002 - if the uri is not exist. 546 * @syscap SystemCapability.ArkUI.ArkUI.Lite 547 * @atomicservice 548 * @since 11 549 */ 550 function replaceUrl(options: RouterOptions, callback: AsyncCallback<void>): void; 551 552 /** 553 * Replaces the current page with another one in the application. The current page is destroyed after replacement. 554 * 555 * @param { RouterOptions } options - Options. 556 * @returns { Promise<void> } the promise returned by the function. 557 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 558 * @throws { BusinessError } 100001 - if UI execution context not found, only throw in standard system. 559 * @throws { BusinessError } 200002 - if the uri is not exist. 560 * @syscap SystemCapability.ArkUI.ArkUI.Lite 561 * @since 9 562 */ 563 /** 564 * Replaces the current page with another one in the application. The current page is destroyed after replacement. 565 * 566 * @param { RouterOptions } options - Options. 567 * @returns { Promise<void> } the promise returned by the function. 568 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 569 * @throws { BusinessError } 100001 - if UI execution context not found, only throw in standard system. 570 * @throws { BusinessError } 200002 - if the uri is not exist. 571 * @syscap SystemCapability.ArkUI.ArkUI.Lite 572 * @atomicservice 573 * @since 11 574 */ 575 function replaceUrl(options: RouterOptions): Promise<void>; 576 577 /** 578 * Replaces the current page with another one in the application. The current page is destroyed after replacement. 579 * 580 * @param { RouterOptions } options - Options. 581 * @param { RouterMode } mode - RouterMode. 582 * @param { AsyncCallback<void> } callback - the callback of replaceUrl. 583 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 584 * @throws { BusinessError } 100001 - if UI execution context not found, only throw in standard system. 585 * @throws { BusinessError } 200002 - if the uri is not exist. 586 * @syscap SystemCapability.ArkUI.ArkUI.Lite 587 * @since 9 588 */ 589 /** 590 * Replaces the current page with another one in the application. The current page is destroyed after replacement. 591 * 592 * @param { RouterOptions } options - Options. 593 * @param { RouterMode } mode - RouterMode. 594 * @param { AsyncCallback<void> } callback - the callback of replaceUrl. 595 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 596 * @throws { BusinessError } 100001 - if UI execution context not found, only throw in standard system. 597 * @throws { BusinessError } 200002 - if the uri is not exist. 598 * @syscap SystemCapability.ArkUI.ArkUI.Lite 599 * @atomicservice 600 * @since 11 601 */ 602 function replaceUrl(options: RouterOptions, mode: RouterMode, callback: AsyncCallback<void>): void; 603 604 /** 605 * Replaces the current page with another one in the application. The current page is destroyed after replacement. 606 * 607 * @param { RouterOptions } options - Options. 608 * @param { RouterMode } mode - RouterMode. 609 * @returns { Promise<void> } the promise returned by the function. 610 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 611 * @throws { BusinessError } 100001 - if can not get the delegate, only throw in standard system. 612 * @throws { BusinessError } 200002 - if the uri is not exist. 613 * @syscap SystemCapability.ArkUI.ArkUI.Lite 614 * @since 9 615 */ 616 /** 617 * Replaces the current page with another one in the application. The current page is destroyed after replacement. 618 * 619 * @param { RouterOptions } options - Options. 620 * @param { RouterMode } mode - RouterMode. 621 * @returns { Promise<void> } the promise returned by the function. 622 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 623 * @throws { BusinessError } 100001 - if can not get the delegate, only throw in standard system. 624 * @throws { BusinessError } 200002 - if the uri is not exist. 625 * @syscap SystemCapability.ArkUI.ArkUI.Lite 626 * @atomicservice 627 * @since 11 628 */ 629 function replaceUrl(options: RouterOptions, mode: RouterMode): Promise<void>; 630 631 /** 632 * Returns to the previous page or a specified page. 633 * 634 * @param { RouterOptions } options - Options. 635 * @syscap SystemCapability.ArkUI.ArkUI.Full 636 * @since 8 637 */ 638 /** 639 * Returns to the previous page or a specified page. 640 * 641 * @param { RouterOptions } options - Options. 642 * @syscap SystemCapability.ArkUI.ArkUI.Full 643 * @crossplatform 644 * @since 10 645 */ 646 /** 647 * Returns to the previous page or a specified page. 648 * 649 * @param { RouterOptions } options - Options. 650 * @syscap SystemCapability.ArkUI.ArkUI.Full 651 * @crossplatform 652 * @atomicservice 653 * @since 11 654 */ 655 function back(options?: RouterOptions): void; 656 657 /** 658 * Clears all historical pages and retains only the current page at the top of the stack. 659 * 660 * @syscap SystemCapability.ArkUI.ArkUI.Full 661 * @since 8 662 */ 663 /** 664 * Clears all historical pages and retains only the current page at the top of the stack. 665 * 666 * @syscap SystemCapability.ArkUI.ArkUI.Full 667 * @crossplatform 668 * @since 10 669 */ 670 /** 671 * Clears all historical pages and retains only the current page at the top of the stack. 672 * 673 * @syscap SystemCapability.ArkUI.ArkUI.Full 674 * @crossplatform 675 * @atomicservice 676 * @since 11 677 */ 678 function clear(): void; 679 680 /** 681 * Obtains the number of pages in the current stack. 682 * 683 * @returns { string } Number of pages in the stack. The maximum value is 32. 684 * @syscap SystemCapability.ArkUI.ArkUI.Full 685 * @since 8 686 */ 687 /** 688 * Obtains the number of pages in the current stack. 689 * 690 * @returns { string } Number of pages in the stack. The maximum value is 32. 691 * @syscap SystemCapability.ArkUI.ArkUI.Full 692 * @crossplatform 693 * @since 10 694 */ 695 /** 696 * Obtains the number of pages in the current stack. 697 * 698 * @returns { string } Number of pages in the stack. The maximum value is 32. 699 * @syscap SystemCapability.ArkUI.ArkUI.Full 700 * @crossplatform 701 * @atomicservice 702 * @since 11 703 */ 704 function getLength(): string; 705 706 /** 707 * Obtains information about the current page state. 708 * 709 * @returns { RouterState } Page state. 710 * @syscap SystemCapability.ArkUI.ArkUI.Full 711 * @since 8 712 */ 713 /** 714 * Obtains information about the current page state. 715 * 716 * @returns { RouterState } Page state. 717 * @syscap SystemCapability.ArkUI.ArkUI.Full 718 * @crossplatform 719 * @since 10 720 */ 721 /** 722 * Obtains information about the current page state. 723 * 724 * @returns { RouterState } Page state. 725 * @syscap SystemCapability.ArkUI.ArkUI.Full 726 * @crossplatform 727 * @atomicservice 728 * @since 11 729 */ 730 function getState(): RouterState; 731 732 /** 733 * Pop up dialog to ask whether to back 734 * 735 * @param { EnableAlertOptions } options - Options. 736 * @syscap SystemCapability.ArkUI.ArkUI.Full 737 * @since 8 738 * @deprecated since 9 739 * @useinstead ohos.router.router#showAlertBeforeBackPage 740 */ 741 function enableAlertBeforeBackPage(options: EnableAlertOptions): void; 742 743 /** 744 * Pop up alert dialog to ask whether to back 745 * 746 * @param { EnableAlertOptions } options - Options. 747 * @throws { BusinessError } 401 - if the type of the parameter is not object or the type of the message is not string. 748 * @throws { BusinessError } 100001 - if UI execution context not found. 749 * @syscap SystemCapability.ArkUI.ArkUI.Full 750 * @since 9 751 */ 752 /** 753 * Pop up alert dialog to ask whether to back 754 * 755 * @param { EnableAlertOptions } options - Options. 756 * @throws { BusinessError } 401 - if the type of the parameter is not object or the type of the message is not string. 757 * @throws { BusinessError } 100001 - if UI execution context not found. 758 * @syscap SystemCapability.ArkUI.ArkUI.Full 759 * @crossplatform 760 * @since 10 761 */ 762 /** 763 * Pop up alert dialog to ask whether to back 764 * 765 * @param { EnableAlertOptions } options - Options. 766 * @throws { BusinessError } 401 - if the type of the parameter is not object or the type of the message is not string. 767 * @throws { BusinessError } 100001 - if UI execution context not found. 768 * @syscap SystemCapability.ArkUI.ArkUI.Full 769 * @crossplatform 770 * @atomicservice 771 * @since 11 772 */ 773 function showAlertBeforeBackPage(options: EnableAlertOptions): void; 774 775 /** 776 * Cancel enableAlertBeforeBackPage 777 * 778 * @syscap SystemCapability.ArkUI.ArkUI.Full 779 * @since 8 780 * @deprecated since 9 781 * @useinstead ohos.router.router#hideAlertBeforeBackPage 782 */ 783 function disableAlertBeforeBackPage(): void; 784 785 /** 786 * Hide alert before back page 787 * 788 * @syscap SystemCapability.ArkUI.ArkUI.Full 789 * @since 9 790 */ 791 /** 792 * Hide alert before back page 793 * 794 * @syscap SystemCapability.ArkUI.ArkUI.Full 795 * @crossplatform 796 * @since 10 797 */ 798 /** 799 * Hide alert before back page 800 * 801 * @syscap SystemCapability.ArkUI.ArkUI.Full 802 * @crossplatform 803 * @atomicservice 804 * @since 11 805 */ 806 function hideAlertBeforeBackPage(): void; 807 808 /** 809 * Obtains information about the current page params. 810 * 811 * @returns { Object } Page params. 812 * @syscap SystemCapability.ArkUI.ArkUI.Full 813 * @since 8 814 */ 815 /** 816 * Obtains information about the current page params. 817 * 818 * @returns { Object } Page params. 819 * @syscap SystemCapability.ArkUI.ArkUI.Full 820 * @crossplatform 821 * @since 10 822 */ 823 /** 824 * Obtains information about the current page params. 825 * 826 * @returns { Object } Page params. 827 * @syscap SystemCapability.ArkUI.ArkUI.Full 828 * @crossplatform 829 * @atomicservice 830 * @since 11 831 */ 832 function getParams(): Object; 833 834 /** 835 * @typedef NamedRouterOptions 836 * @syscap SystemCapability.ArkUI.ArkUI.Full 837 * @crossplatform 838 * @since 10 839 */ 840 /** 841 * @typedef NamedRouterOptions 842 * @syscap SystemCapability.ArkUI.ArkUI.Full 843 * @crossplatform 844 * @atomicservice 845 * @since 11 846 */ 847 interface NamedRouterOptions { 848 /** 849 * Name of the destination named route. 850 * 851 * @type { string } 852 * @syscap SystemCapability.ArkUI.ArkUI.Full 853 * @crossplatform 854 * @since 10 855 */ 856 /** 857 * Name of the destination named route. 858 * 859 * @type { string } 860 * @syscap SystemCapability.ArkUI.ArkUI.Full 861 * @crossplatform 862 * @atomicservice 863 * @since 11 864 */ 865 name: string; 866 867 /** 868 * Data that needs to be passed to the destination page during navigation. 869 * 870 * @type { ?Object } 871 * @syscap SystemCapability.ArkUI.ArkUI.Full 872 * @crossplatform 873 * @since 10 874 */ 875 /** 876 * Data that needs to be passed to the destination page during navigation. 877 * 878 * @type { ?Object } 879 * @syscap SystemCapability.ArkUI.ArkUI.Full 880 * @crossplatform 881 * @atomicservice 882 * @since 11 883 */ 884 params?: Object; 885 } 886 887 /** 888 * Navigates to a specified page in the application based on the page URL and parameters. 889 * 890 * @param { NamedRouterOptions } options - Options. 891 * @param { AsyncCallback<void> } callback - the callback of pushNamedRoute. 892 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 893 * @throws { BusinessError } 100001 - if UI execution context not found. 894 * @throws { BusinessError } 100003 - if the pages are pushed too much. 895 * @throws { BusinessError } 100004 - if the named route is not exist. 896 * @syscap SystemCapability.ArkUI.ArkUI.Full 897 * @crossplatform 898 * @since 10 899 */ 900 /** 901 * Navigates to a specified page in the application based on the page URL and parameters. 902 * 903 * @param { NamedRouterOptions } options - Options. 904 * @param { AsyncCallback<void> } callback - the callback of pushNamedRoute. 905 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 906 * @throws { BusinessError } 100001 - if UI execution context not found. 907 * @throws { BusinessError } 100003 - if the pages are pushed too much. 908 * @throws { BusinessError } 100004 - if the named route is not exist. 909 * @syscap SystemCapability.ArkUI.ArkUI.Full 910 * @crossplatform 911 * @atomicservice 912 * @since 11 913 */ 914 function pushNamedRoute(options: NamedRouterOptions, callback: AsyncCallback<void>): void; 915 916 /** 917 * Navigates to a specified page in the application based on the page URL and parameters. 918 * 919 * @param { NamedRouterOptions } options - Options. 920 * @returns { Promise<void> } the promise returned by the function. 921 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 922 * @throws { BusinessError } 100001 - if UI execution context not found. 923 * @throws { BusinessError } 100003 - if the pages are pushed too much. 924 * @throws { BusinessError } 100004 - if the named route is not exist. 925 * @syscap SystemCapability.ArkUI.ArkUI.Full 926 * @crossplatform 927 * @since 10 928 */ 929 /** 930 * Navigates to a specified page in the application based on the page URL and parameters. 931 * 932 * @param { NamedRouterOptions } options - Options. 933 * @returns { Promise<void> } the promise returned by the function. 934 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 935 * @throws { BusinessError } 100001 - if UI execution context not found. 936 * @throws { BusinessError } 100003 - if the pages are pushed too much. 937 * @throws { BusinessError } 100004 - if the named route is not exist. 938 * @syscap SystemCapability.ArkUI.ArkUI.Full 939 * @crossplatform 940 * @atomicservice 941 * @since 11 942 */ 943 function pushNamedRoute(options: NamedRouterOptions): Promise<void>; 944 945 /** 946 * Navigates to a specified page in the application based on the page URL and parameters. 947 * 948 * @param { NamedRouterOptions } options - Options. 949 * @param { RouterMode } mode - RouterMode. 950 * @param { AsyncCallback<void> } callback - the callback of pushNamedRoute. 951 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 952 * @throws { BusinessError } 100001 - if UI execution context not found. 953 * @throws { BusinessError } 100003 - if the pages are pushed too much. 954 * @throws { BusinessError } 100004 - if the named route is not exist. 955 * @syscap SystemCapability.ArkUI.ArkUI.Full 956 * @crossplatform 957 * @since 10 958 */ 959 /** 960 * Navigates to a specified page in the application based on the page URL and parameters. 961 * 962 * @param { NamedRouterOptions } options - Options. 963 * @param { RouterMode } mode - RouterMode. 964 * @param { AsyncCallback<void> } callback - the callback of pushNamedRoute. 965 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 966 * @throws { BusinessError } 100001 - if UI execution context not found. 967 * @throws { BusinessError } 100003 - if the pages are pushed too much. 968 * @throws { BusinessError } 100004 - if the named route is not exist. 969 * @syscap SystemCapability.ArkUI.ArkUI.Full 970 * @crossplatform 971 * @atomicservice 972 * @since 11 973 */ 974 function pushNamedRoute(options: NamedRouterOptions, mode: RouterMode, callback: AsyncCallback<void>): void; 975 976 /** 977 * Navigates to a specified page in the application based on the page URL and parameters. 978 * 979 * @param { NamedRouterOptions } options - Options. 980 * @param { RouterMode } mode - RouterMode. 981 * @returns { Promise<void> } the promise returned by the function. 982 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 983 * @throws { BusinessError } 100001 - if UI execution context not found. 984 * @throws { BusinessError } 100003 - if the pages are pushed too much. 985 * @throws { BusinessError } 100004 - if the named route is not exist. 986 * @syscap SystemCapability.ArkUI.ArkUI.Full 987 * @crossplatform 988 * @since 10 989 */ 990 /** 991 * Navigates to a specified page in the application based on the page URL and parameters. 992 * 993 * @param { NamedRouterOptions } options - Options. 994 * @param { RouterMode } mode - RouterMode. 995 * @returns { Promise<void> } the promise returned by the function. 996 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 997 * @throws { BusinessError } 100001 - if UI execution context not found. 998 * @throws { BusinessError } 100003 - if the pages are pushed too much. 999 * @throws { BusinessError } 100004 - if the named route is not exist. 1000 * @syscap SystemCapability.ArkUI.ArkUI.Full 1001 * @crossplatform 1002 * @atomicservice 1003 * @since 11 1004 */ 1005 function pushNamedRoute(options: NamedRouterOptions, mode: RouterMode): Promise<void>; 1006 1007 /** 1008 * Replaces the current page with another one in the application. The current page is destroyed after replacement. 1009 * 1010 * @param { NamedRouterOptions } options - Options. 1011 * @param { AsyncCallback<void> } callback - the callback of replaceNamedRoute. 1012 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 1013 * @throws { BusinessError } 100001 - if UI execution context not found, only throw in standard system. 1014 * @throws { BusinessError } 100004 - if the named route is not exist. 1015 * @syscap SystemCapability.ArkUI.ArkUI.Full 1016 * @crossplatform 1017 * @since 10 1018 */ 1019 /** 1020 * Replaces the current page with another one in the application. The current page is destroyed after replacement. 1021 * 1022 * @param { NamedRouterOptions } options - Options. 1023 * @param { AsyncCallback<void> } callback - the callback of replaceNamedRoute. 1024 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 1025 * @throws { BusinessError } 100001 - if UI execution context not found, only throw in standard system. 1026 * @throws { BusinessError } 100004 - if the named route is not exist. 1027 * @syscap SystemCapability.ArkUI.ArkUI.Full 1028 * @crossplatform 1029 * @atomicservice 1030 * @since 11 1031 */ 1032 function replaceNamedRoute(options: NamedRouterOptions, callback: AsyncCallback<void>): void; 1033 1034 /** 1035 * Replaces the current page with another one in the application. The current page is destroyed after replacement. 1036 * 1037 * @param { NamedRouterOptions } options - Options. 1038 * @returns { Promise<void> } the promise returned by the function. 1039 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 1040 * @throws { BusinessError } 100001 - if UI execution context not found, only throw in standard system. 1041 * @throws { BusinessError } 100004 - if the named route is not exist. 1042 * @syscap SystemCapability.ArkUI.ArkUI.Full 1043 * @crossplatform 1044 * @since 10 1045 */ 1046 /** 1047 * Replaces the current page with another one in the application. The current page is destroyed after replacement. 1048 * 1049 * @param { NamedRouterOptions } options - Options. 1050 * @returns { Promise<void> } the promise returned by the function. 1051 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 1052 * @throws { BusinessError } 100001 - if UI execution context not found, only throw in standard system. 1053 * @throws { BusinessError } 100004 - if the named route is not exist. 1054 * @syscap SystemCapability.ArkUI.ArkUI.Full 1055 * @crossplatform 1056 * @atomicservice 1057 * @since 11 1058 */ 1059 function replaceNamedRoute(options: NamedRouterOptions): Promise<void>; 1060 1061 /** 1062 * Replaces the current page with another one in the application. The current page is destroyed after replacement. 1063 * 1064 * @param { NamedRouterOptions } options - Options. 1065 * @param { RouterMode } mode - RouterMode. 1066 * @param { AsyncCallback<void> } callback - the callback of replaceNamedRoute. 1067 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 1068 * @throws { BusinessError } 100001 - if UI execution context not found, only throw in standard system. 1069 * @throws { BusinessError } 100004 - if the named route is not exist. 1070 * @syscap SystemCapability.ArkUI.ArkUI.Full 1071 * @crossplatform 1072 * @since 10 1073 */ 1074 /** 1075 * Replaces the current page with another one in the application. The current page is destroyed after replacement. 1076 * 1077 * @param { NamedRouterOptions } options - Options. 1078 * @param { RouterMode } mode - RouterMode. 1079 * @param { AsyncCallback<void> } callback - the callback of replaceNamedRoute. 1080 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 1081 * @throws { BusinessError } 100001 - if UI execution context not found, only throw in standard system. 1082 * @throws { BusinessError } 100004 - if the named route is not exist. 1083 * @syscap SystemCapability.ArkUI.ArkUI.Full 1084 * @crossplatform 1085 * @atomicservice 1086 * @since 11 1087 */ 1088 function replaceNamedRoute(options: NamedRouterOptions, mode: RouterMode, callback: AsyncCallback<void>): void; 1089 1090 /** 1091 * Replaces the current page with another one in the application. The current page is destroyed after replacement. 1092 * 1093 * @param { NamedRouterOptions } options - Options. 1094 * @param { RouterMode } mode - RouterMode. 1095 * @returns { Promise<void> } the promise returned by the function. 1096 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 1097 * @throws { BusinessError } 100001 - if can not get the delegate, only throw in standard system. 1098 * @throws { BusinessError } 100004 - if the named route is not exist. 1099 * @syscap SystemCapability.ArkUI.ArkUI.Full 1100 * @crossplatform 1101 * @since 10 1102 */ 1103 /** 1104 * Replaces the current page with another one in the application. The current page is destroyed after replacement. 1105 * 1106 * @param { NamedRouterOptions } options - Options. 1107 * @param { RouterMode } mode - RouterMode. 1108 * @returns { Promise<void> } the promise returned by the function. 1109 * @throws { BusinessError } 401 - if the number of parameters is less than 1 or the type of the url parameter is not string. 1110 * @throws { BusinessError } 100001 - if can not get the delegate, only throw in standard system. 1111 * @throws { BusinessError } 100004 - if the named route is not exist. 1112 * @syscap SystemCapability.ArkUI.ArkUI.Full 1113 * @crossplatform 1114 * @atomicservice 1115 * @since 11 1116 */ 1117 function replaceNamedRoute(options: NamedRouterOptions, mode: RouterMode): Promise<void>; 1118} 1119 1120export default router; 1121