函数:register()
register(
routeId
,commandId
):Disposable
定义于: packages/extension-api/src/extension-api.d.ts:4991
允许为扩展定义自定义路由。
参数
routeId
string
一个唯一的字符串值,可在 navigation.navigate 中使用。
commandId
string
导航时将执行的命令。
返回
备注
使用的 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');