本文整理汇总了TypeScript中common/actions.actions.navigate方法的典型用法代码示例。如果您正苦于以下问题:TypeScript actions.navigate方法的具体用法?TypeScript actions.navigate怎么用?TypeScript actions.navigate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common/actions.actions
的用法示例。
在下文中一共展示了actions.navigate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: convertMenuAction
function convertMenuAction(
window: string,
payload: IMenuItem,
runtime: IRuntime
) {
const { role, localizedLabel } = payload;
switch (role) {
case "about":
return actions.openInExternalBrowser({ url: urls.appHomepage });
default: // muffin
}
const labelString = localizedLabel ? localizedLabel[0] : null;
switch (labelString) {
case "sidebar.new_tab":
return actions.newTab({ window });
case "menu.file.close_tab":
return runtime.platform === "osx"
? actions.closeTabOrAuxWindow({ window })
: actions.closeCurrentTab({ window });
case "menu.file.close_all_tabs":
return actions.closeAllTabs({ window });
case "menu.file.close_window":
return actions.hideWindow({ window });
case "menu.file.quit":
return actions.quitWhenMain({ window });
case "menu.file.preferences":
return actions.navigate({ window, url: "itch://preferences" });
case "menu.view.downloads":
return actions.navigate({ window, url: "itch://downloads" });
case "menu.account.change_user":
return actions.changeUser({});
case "menu.help.view_terms":
return actions.openInExternalBrowser({ url: urls.termsOfService });
case "menu.help.view_license":
return actions.openInExternalBrowser({
url: `${urls.itchRepo}/blob/master/LICENSE`,
});
case "menu.help.report_issue":
return actions.openInExternalBrowser({
url: `${urls.itchRepo}/issues/new`,
});
case "menu.help.search_issue":
return actions.openInExternalBrowser({
url: `${urls.itchRepo}/search?type=Issues`,
});
case "menu.help.release_notes":
return actions.openInExternalBrowser({
url: `${urls.itchRepo}/releases`,
});
default:
return null;
}
}
示例2: async
watcher.on(actions.initiatePurchase, async (store, action) => {
const { game } = action.payload;
const purchaseUrl = game.url + "/purchase";
const loginPurchaseUrl = buildLoginAndReturnUrl(purchaseUrl);
store.dispatch(actions.navigate({ wind: "root", url: loginPurchaseUrl }));
});
示例3: instead
(ev, url, frameName, disposition, options, additionalFeatures) => {
ev.preventDefault();
logger.debug(
`new-window fired for ${url}, navigating instead (in wind ${wind})`
);
const background = disposition === "background-tab";
store.dispatch(actions.navigate({ url, wind, background }));
}
示例4: async
watcher.on(actions.navigateToGame, async (store, action) => {
const { game, background } = action.payload;
store.dispatch(
actions.navigate({
...gameEvolvePayload(game),
background,
})
);
});
示例5: async
watcher.on(actions.downloadEnded, async (store, action) => {
const { download } = action.payload;
if (download.error) {
// don't show notifications for these
return;
}
const prefs = store.getState().preferences || { readyNotification: true };
const { readyNotification } = prefs;
if (readyNotification) {
let notificationMessage: string = null;
let notificationOptions: any = {
title: download.game.title,
};
switch (download.reason) {
case "install":
notificationMessage = "notification.download_installed";
break;
case "reinstall":
notificationMessage = "notification.download_healed";
break;
case "update":
notificationMessage = "notification.download_updated";
break;
case "version-switch":
notificationMessage = "notification.download_reverted";
notificationOptions.version = `?`;
const { build } = download;
if (build) {
notificationOptions.version = `#${build.userVersion ||
build.version}`;
}
break;
default:
// make the typescript compiler happy
}
if (notificationMessage) {
const { i18n } = store.getState();
const message = t(i18n, [notificationMessage, notificationOptions]);
store.dispatch(
actions.notify({
body: message,
onClick: actions.navigate({
wind: "root",
url: urlForGame(download.game.id),
}),
})
);
}
}
});
示例6: async
watcher.on(actions.viewCommunityProfile, async (store, action) => {
const url = store.getState().profile.profile.user.url;
const host = urlParser.parse(url).hostname;
const slug = /^[^.]+/.exec(host);
store.dispatch(
actions.navigate({
wind: "root",
url: `${urls.itchio}/profile/${slug}`,
})
);
});