跳至主要内容

函数: register()

register(routeId, commandId): Disposable

允许为扩展定义自定义路由。

参数

routeId: string

navigation.navigate 中可以使用的唯一字符串值

commandId: string

导航时将执行的命令

返回值

Disposable

备注

使用的 commandId 必须通过 commands.registerCommand 注册

示例

import { navigation, commands } from '@podman-desktop/api';

commands.registerCommand('redirect-download-command', (trackingId: string) => {
// todo: do something with the trackingId
});

// register the route
navigation.register('download-page', 'redirect-download-command');

// when needed call the navigate with the route id registered to
// trigger the command
navigation.navigate('download-page', 'dummy-tracking-id');

定义在

packages/extension-api/src/extension-api.d.ts:4831