• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 */
233export type ParamsInterface = Record<string,Object>
234
235/**
236 * Defines the Router interface.
237 *
238 * @syscap SystemCapability.ArkUI.ArkUI.Lite
239 * @since 3
240 * @deprecated since 8
241 * @useinstead ohos.router#router
242 */
243declare class Router {
244  /**
245   * Navigates to a specified page in the application based on the page URL and parameters.
246   *
247   * @param { RouterOptions } options Options.
248   * @syscap SystemCapability.ArkUI.ArkUI.Full
249   * @since 3
250   * @deprecated since 8
251   */
252  static push(options: RouterOptions): void;
253
254  /**
255   * Replaces the current page with another one in the application. The current page is destroyed after replacement.
256   *
257   * @param { RouterOptions } options Options.
258   * @syscap SystemCapability.ArkUI.ArkUI.Lite
259   * @since 3
260   * @deprecated since 8
261   */
262  static replace(options: RouterOptions): void;
263
264  /**
265   * Returns to the previous page or a specified page.
266   *
267   * @param { BackRouterOptions } options Options.
268   * @syscap SystemCapability.ArkUI.ArkUI.Full
269   * @since 3
270   * @deprecated since 8
271   */
272  static back(options?: BackRouterOptions): void;
273
274  /**
275   * Obtains information about the current page params.
276   *
277   * @returns { ParamsInterface } Page params.
278   * @syscap SystemCapability.ArkUI.ArkUI.Full
279   * @since 7
280   * @deprecated since 8
281   */
282  static getParams(): ParamsInterface;
283
284  /**
285   * Clears all historical pages and retains only the current page at the top of the stack.
286   *
287   * @syscap SystemCapability.ArkUI.ArkUI.Full
288   * @since 3
289   * @deprecated since 8
290   */
291  static clear(): void;
292
293  /**
294   * Obtains the number of pages in the current stack.
295   *
296   * @returns { string } Number of pages in the stack. The maximum value is 32.
297   * @syscap SystemCapability.ArkUI.ArkUI.Full
298   * @since 3
299   * @deprecated since 8
300   */
301  static getLength(): string;
302
303  /**
304   * Obtains information about the current page state.
305   *
306   * @returns { RouterState } Page state.
307   * @syscap SystemCapability.ArkUI.ArkUI.Full
308   * @since 3
309   * @deprecated since 8
310   */
311  static getState(): RouterState;
312
313  /**
314   * Pop up dialog to ask whether to back
315   *
316   * @param { EnableAlertBeforeBackPageOptions } options Options.
317   * @syscap SystemCapability.ArkUI.ArkUI.Full
318   * @since 6
319   * @deprecated since 8
320   */
321  static enableAlertBeforeBackPage(options: EnableAlertBeforeBackPageOptions): void;
322
323  /**
324   * cancel enableAlertBeforeBackPage
325   *
326   * @param { DisableAlertBeforeBackPageOptions } options Options.
327   * @syscap SystemCapability.ArkUI.ArkUI.Full
328   * @since 6
329   * @deprecated since 8
330   */
331  static disableAlertBeforeBackPage(options?: DisableAlertBeforeBackPageOptions): void;
332}
333export default Router;