161847f8eSopenharmony_ci/* 261847f8eSopenharmony_ci * Copyright (c) 2020 Huawei Device Co., Ltd. 361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 461847f8eSopenharmony_ci * you may not use this file except in compliance with the License. 561847f8eSopenharmony_ci * You may obtain a copy of the License at 661847f8eSopenharmony_ci * 761847f8eSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 861847f8eSopenharmony_ci * 961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and 1361847f8eSopenharmony_ci * limitations under the License. 1461847f8eSopenharmony_ci */ 1561847f8eSopenharmony_ci 1661847f8eSopenharmony_ci/** 1761847f8eSopenharmony_ci * @file 1861847f8eSopenharmony_ci * @kit ArkUI 1961847f8eSopenharmony_ci */ 2061847f8eSopenharmony_ci 2161847f8eSopenharmony_ci/** 2261847f8eSopenharmony_ci * Defines the option of router. 2361847f8eSopenharmony_ci * 2461847f8eSopenharmony_ci * @interface RouterOptions 2561847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Lite 2661847f8eSopenharmony_ci * @since 3 2761847f8eSopenharmony_ci * @deprecated since 8 2861847f8eSopenharmony_ci * @useinstead ohos.router#RouterOptions 2961847f8eSopenharmony_ci */ 3061847f8eSopenharmony_ciexport interface RouterOptions { 3161847f8eSopenharmony_ci /** 3261847f8eSopenharmony_ci * URI of the destination page, which supports the following formats: 3361847f8eSopenharmony_ci * 1. Absolute path of the page, which is provided by the pages list in the config.json file. 3461847f8eSopenharmony_ci * Example: 3561847f8eSopenharmony_ci * pages/index/index 3661847f8eSopenharmony_ci * pages/detail/detail 3761847f8eSopenharmony_ci * 2. Particular path. If the URI is a slash (/), the home page is displayed. 3861847f8eSopenharmony_ci * 3961847f8eSopenharmony_ci * @type { string } 4061847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Lite 4161847f8eSopenharmony_ci * @since 3 4261847f8eSopenharmony_ci * @deprecated since 8 4361847f8eSopenharmony_ci */ 4461847f8eSopenharmony_ci uri: string; 4561847f8eSopenharmony_ci 4661847f8eSopenharmony_ci /** 4761847f8eSopenharmony_ci * Data that needs to be passed to the destination page during navigation. 4861847f8eSopenharmony_ci * After the destination page is displayed, the parameter can be directly used for the page. 4961847f8eSopenharmony_ci * For example, this.data1 (data1 is the key value of the params used for page navigation.) 5061847f8eSopenharmony_ci * 5161847f8eSopenharmony_ci * @type { ?Object } 5261847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Lite 5361847f8eSopenharmony_ci * @since 3 5461847f8eSopenharmony_ci * @deprecated since 8 5561847f8eSopenharmony_ci */ 5661847f8eSopenharmony_ci params?: Object; 5761847f8eSopenharmony_ci} 5861847f8eSopenharmony_ci 5961847f8eSopenharmony_ci/** 6061847f8eSopenharmony_ci * Defines the option of router back. 6161847f8eSopenharmony_ci * 6261847f8eSopenharmony_ci * @interface BackRouterOptions 6361847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 6461847f8eSopenharmony_ci * @since 7 6561847f8eSopenharmony_ci * @deprecated since 8 6661847f8eSopenharmony_ci * @useinstead ohos.router#RouterOptions 6761847f8eSopenharmony_ci */ 6861847f8eSopenharmony_ciexport interface BackRouterOptions { 6961847f8eSopenharmony_ci /** 7061847f8eSopenharmony_ci * Returns to the page of the specified path. 7161847f8eSopenharmony_ci * If the page with the specified path does not exist in the page stack, router.back() is called by default. 7261847f8eSopenharmony_ci * 7361847f8eSopenharmony_ci * @type { ?string } 7461847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 7561847f8eSopenharmony_ci * @since 7 7661847f8eSopenharmony_ci * @deprecated since 8 7761847f8eSopenharmony_ci */ 7861847f8eSopenharmony_ci uri?: string; 7961847f8eSopenharmony_ci 8061847f8eSopenharmony_ci /** 8161847f8eSopenharmony_ci * Data that needs to be passed to the destination page during navigation. 8261847f8eSopenharmony_ci * 8361847f8eSopenharmony_ci * @type { ?Object } 8461847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Lite 8561847f8eSopenharmony_ci * @since 7 8661847f8eSopenharmony_ci * @deprecated since 8 8761847f8eSopenharmony_ci */ 8861847f8eSopenharmony_ci params?: Object; 8961847f8eSopenharmony_ci} 9061847f8eSopenharmony_ci 9161847f8eSopenharmony_ci/** 9261847f8eSopenharmony_ci * Defines the state of router. 9361847f8eSopenharmony_ci * 9461847f8eSopenharmony_ci * @interface RouterState 9561847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 9661847f8eSopenharmony_ci * @since 3 9761847f8eSopenharmony_ci * @deprecated since 8 9861847f8eSopenharmony_ci * @useinstead ohos.router#RouterState 9961847f8eSopenharmony_ci */ 10061847f8eSopenharmony_ciexport interface RouterState { 10161847f8eSopenharmony_ci /** 10261847f8eSopenharmony_ci * Index of the current page in the stack. 10361847f8eSopenharmony_ci * NOTE: The index starts from 1 from the bottom to the top of the stack. 10461847f8eSopenharmony_ci * 10561847f8eSopenharmony_ci * @type { number } 10661847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 10761847f8eSopenharmony_ci * @since 3 10861847f8eSopenharmony_ci * @deprecated since 8 10961847f8eSopenharmony_ci */ 11061847f8eSopenharmony_ci index: number; 11161847f8eSopenharmony_ci 11261847f8eSopenharmony_ci /** 11361847f8eSopenharmony_ci * Name of the current page, that is, the file name. 11461847f8eSopenharmony_ci * 11561847f8eSopenharmony_ci * @type { string } 11661847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 11761847f8eSopenharmony_ci * @since 3 11861847f8eSopenharmony_ci * @deprecated since 8 11961847f8eSopenharmony_ci */ 12061847f8eSopenharmony_ci name: string; 12161847f8eSopenharmony_ci 12261847f8eSopenharmony_ci /** 12361847f8eSopenharmony_ci * Path of the current page. 12461847f8eSopenharmony_ci * 12561847f8eSopenharmony_ci * @type { string } 12661847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 12761847f8eSopenharmony_ci * @since 3 12861847f8eSopenharmony_ci * @deprecated since 8 12961847f8eSopenharmony_ci */ 13061847f8eSopenharmony_ci path: string; 13161847f8eSopenharmony_ci} 13261847f8eSopenharmony_ci 13361847f8eSopenharmony_ci/** 13461847f8eSopenharmony_ci * Defines the option of EnableAlertBeforeBackPage. 13561847f8eSopenharmony_ci * 13661847f8eSopenharmony_ci * @interface EnableAlertBeforeBackPageOptions 13761847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 13861847f8eSopenharmony_ci * @since 6 13961847f8eSopenharmony_ci * @deprecated since 8 14061847f8eSopenharmony_ci * @useinstead ohos.router#RouterState 14161847f8eSopenharmony_ci */ 14261847f8eSopenharmony_ciexport interface EnableAlertBeforeBackPageOptions { 14361847f8eSopenharmony_ci /** 14461847f8eSopenharmony_ci * dialog context. 14561847f8eSopenharmony_ci * 14661847f8eSopenharmony_ci * @type { string } 14761847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 14861847f8eSopenharmony_ci * @since 6 14961847f8eSopenharmony_ci * @deprecated since 8 15061847f8eSopenharmony_ci */ 15161847f8eSopenharmony_ci message: string; 15261847f8eSopenharmony_ci 15361847f8eSopenharmony_ci /** 15461847f8eSopenharmony_ci * Called when the dialog box is displayed. 15561847f8eSopenharmony_ci * 15661847f8eSopenharmony_ci * @type { ?function } 15761847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 15861847f8eSopenharmony_ci * @since 6 15961847f8eSopenharmony_ci * @deprecated since 8 16061847f8eSopenharmony_ci */ 16161847f8eSopenharmony_ci success?: (errMsg: string) => void; 16261847f8eSopenharmony_ci 16361847f8eSopenharmony_ci /** 16461847f8eSopenharmony_ci * Called when the operation is cancelled. 16561847f8eSopenharmony_ci * 16661847f8eSopenharmony_ci * @type { ?function } 16761847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 16861847f8eSopenharmony_ci * @since 6 16961847f8eSopenharmony_ci * @deprecated since 8 17061847f8eSopenharmony_ci */ 17161847f8eSopenharmony_ci cancel?: (errMsg: string) => void; 17261847f8eSopenharmony_ci 17361847f8eSopenharmony_ci /** 17461847f8eSopenharmony_ci * Called when the dialog box is closed. 17561847f8eSopenharmony_ci * 17661847f8eSopenharmony_ci * @type { ?function } 17761847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 17861847f8eSopenharmony_ci * @since 6 17961847f8eSopenharmony_ci * @deprecated since 8 18061847f8eSopenharmony_ci */ 18161847f8eSopenharmony_ci complete?: () => void; 18261847f8eSopenharmony_ci} 18361847f8eSopenharmony_ci 18461847f8eSopenharmony_ci/** 18561847f8eSopenharmony_ci * Defines the option of DisableAlertBeforeBackPage. 18661847f8eSopenharmony_ci * 18761847f8eSopenharmony_ci * @interface DisableAlertBeforeBackPageOptions 18861847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 18961847f8eSopenharmony_ci * @since 6 19061847f8eSopenharmony_ci * @deprecated since 8 19161847f8eSopenharmony_ci * @useinstead ohos.router#RouterOptions 19261847f8eSopenharmony_ci */ 19361847f8eSopenharmony_ciexport interface DisableAlertBeforeBackPageOptions { 19461847f8eSopenharmony_ci /** 19561847f8eSopenharmony_ci * Called when the dialog box is displayed. 19661847f8eSopenharmony_ci * 19761847f8eSopenharmony_ci * @type { ?function } 19861847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 19961847f8eSopenharmony_ci * @since 6 20061847f8eSopenharmony_ci * @deprecated since 8 20161847f8eSopenharmony_ci */ 20261847f8eSopenharmony_ci success?: (errMsg: string) => void; 20361847f8eSopenharmony_ci 20461847f8eSopenharmony_ci /** 20561847f8eSopenharmony_ci * Called when the operation is cancelled. 20661847f8eSopenharmony_ci * 20761847f8eSopenharmony_ci * @type { ?function } 20861847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 20961847f8eSopenharmony_ci * @since 6 21061847f8eSopenharmony_ci * @deprecated since 8 21161847f8eSopenharmony_ci */ 21261847f8eSopenharmony_ci cancel?: (errMsg: string) => void; 21361847f8eSopenharmony_ci 21461847f8eSopenharmony_ci /** 21561847f8eSopenharmony_ci * Called when the dialog box is closed. 21661847f8eSopenharmony_ci * 21761847f8eSopenharmony_ci * @type { ?function } 21861847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 21961847f8eSopenharmony_ci * @since 6 22061847f8eSopenharmony_ci * @deprecated since 8 22161847f8eSopenharmony_ci */ 22261847f8eSopenharmony_ci complete?: () => void; 22361847f8eSopenharmony_ci} 22461847f8eSopenharmony_ci 22561847f8eSopenharmony_ci/** 22661847f8eSopenharmony_ci * Define ParamsInterface. 22761847f8eSopenharmony_ci * 22861847f8eSopenharmony_ci * @typedef { object } ParamsInterface 22961847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 23061847f8eSopenharmony_ci * @since 7 23161847f8eSopenharmony_ci * @deprecated since 8 23261847f8eSopenharmony_ci */ 23361847f8eSopenharmony_citype ParamsInterface = { 23461847f8eSopenharmony_ci [key: string]: Object; 23561847f8eSopenharmony_ci}; 23661847f8eSopenharmony_ci 23761847f8eSopenharmony_ci/** 23861847f8eSopenharmony_ci * Defines the Router interface. 23961847f8eSopenharmony_ci * 24061847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Lite 24161847f8eSopenharmony_ci * @since 3 24261847f8eSopenharmony_ci * @deprecated since 8 24361847f8eSopenharmony_ci * @useinstead ohos.router#router 24461847f8eSopenharmony_ci */ 24561847f8eSopenharmony_ciexport default class Router { 24661847f8eSopenharmony_ci /** 24761847f8eSopenharmony_ci * Navigates to a specified page in the application based on the page URL and parameters. 24861847f8eSopenharmony_ci * 24961847f8eSopenharmony_ci * @param { RouterOptions } options Options. 25061847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 25161847f8eSopenharmony_ci * @since 3 25261847f8eSopenharmony_ci * @deprecated since 8 25361847f8eSopenharmony_ci */ 25461847f8eSopenharmony_ci static push(options: RouterOptions): void; 25561847f8eSopenharmony_ci 25661847f8eSopenharmony_ci /** 25761847f8eSopenharmony_ci * Replaces the current page with another one in the application. The current page is destroyed after replacement. 25861847f8eSopenharmony_ci * 25961847f8eSopenharmony_ci * @param { RouterOptions } options Options. 26061847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Lite 26161847f8eSopenharmony_ci * @since 3 26261847f8eSopenharmony_ci * @deprecated since 8 26361847f8eSopenharmony_ci */ 26461847f8eSopenharmony_ci static replace(options: RouterOptions): void; 26561847f8eSopenharmony_ci 26661847f8eSopenharmony_ci /** 26761847f8eSopenharmony_ci * Returns to the previous page or a specified page. 26861847f8eSopenharmony_ci * 26961847f8eSopenharmony_ci * @param { BackRouterOptions } options Options. 27061847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 27161847f8eSopenharmony_ci * @since 3 27261847f8eSopenharmony_ci * @deprecated since 8 27361847f8eSopenharmony_ci */ 27461847f8eSopenharmony_ci static back(options?: BackRouterOptions): void; 27561847f8eSopenharmony_ci 27661847f8eSopenharmony_ci /** 27761847f8eSopenharmony_ci * Obtains information about the current page params. 27861847f8eSopenharmony_ci * 27961847f8eSopenharmony_ci * @returns { ParamsInterface } Page params. 28061847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 28161847f8eSopenharmony_ci * @since 7 28261847f8eSopenharmony_ci * @deprecated since 8 28361847f8eSopenharmony_ci */ 28461847f8eSopenharmony_ci static getParams(): ParamsInterface; 28561847f8eSopenharmony_ci 28661847f8eSopenharmony_ci /** 28761847f8eSopenharmony_ci * Clears all historical pages and retains only the current page at the top of the stack. 28861847f8eSopenharmony_ci * 28961847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 29061847f8eSopenharmony_ci * @since 3 29161847f8eSopenharmony_ci * @deprecated since 8 29261847f8eSopenharmony_ci */ 29361847f8eSopenharmony_ci static clear(): void; 29461847f8eSopenharmony_ci 29561847f8eSopenharmony_ci /** 29661847f8eSopenharmony_ci * Obtains the number of pages in the current stack. 29761847f8eSopenharmony_ci * 29861847f8eSopenharmony_ci * @returns { string } Number of pages in the stack. The maximum value is 32. 29961847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 30061847f8eSopenharmony_ci * @since 3 30161847f8eSopenharmony_ci * @deprecated since 8 30261847f8eSopenharmony_ci */ 30361847f8eSopenharmony_ci static getLength(): string; 30461847f8eSopenharmony_ci 30561847f8eSopenharmony_ci /** 30661847f8eSopenharmony_ci * Obtains information about the current page state. 30761847f8eSopenharmony_ci * 30861847f8eSopenharmony_ci * @returns { RouterState } Page state. 30961847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 31061847f8eSopenharmony_ci * @since 3 31161847f8eSopenharmony_ci * @deprecated since 8 31261847f8eSopenharmony_ci */ 31361847f8eSopenharmony_ci static getState(): RouterState; 31461847f8eSopenharmony_ci 31561847f8eSopenharmony_ci /** 31661847f8eSopenharmony_ci * Pop up dialog to ask whether to back 31761847f8eSopenharmony_ci * 31861847f8eSopenharmony_ci * @param { EnableAlertBeforeBackPageOptions } options Options. 31961847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 32061847f8eSopenharmony_ci * @since 6 32161847f8eSopenharmony_ci * @deprecated since 8 32261847f8eSopenharmony_ci */ 32361847f8eSopenharmony_ci static enableAlertBeforeBackPage(options: EnableAlertBeforeBackPageOptions): void; 32461847f8eSopenharmony_ci 32561847f8eSopenharmony_ci /** 32661847f8eSopenharmony_ci * cancel enableAlertBeforeBackPage 32761847f8eSopenharmony_ci * 32861847f8eSopenharmony_ci * @param { DisableAlertBeforeBackPageOptions } options Options. 32961847f8eSopenharmony_ci * @syscap SystemCapability.ArkUI.ArkUI.Full 33061847f8eSopenharmony_ci * @since 6 33161847f8eSopenharmony_ci * @deprecated since 8 33261847f8eSopenharmony_ci */ 33361847f8eSopenharmony_ci static disableAlertBeforeBackPage(options?: DisableAlertBeforeBackPageOptions): void; 33461847f8eSopenharmony_ci} 335