当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript actions.navigate方法代码示例

本文整理汇总了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;
  }
}
开发者ID:HorrerGames,项目名称:itch,代码行数:56,代码来源:flesh-out-template.ts

示例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 }));
  });
开发者ID:itchio,项目名称:itch,代码行数:7,代码来源:purchases.ts

示例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 }));
 }
开发者ID:itchio,项目名称:itch,代码行数:8,代码来源:winds.ts

示例4: async

 watcher.on(actions.navigateToGame, async (store, action) => {
   const { game, background } = action.payload;
   store.dispatch(
     actions.navigate({
       ...gameEvolvePayload(game),
       background,
     })
   );
 });
开发者ID:HorrerGames,项目名称:itch,代码行数:9,代码来源:navigation.ts

示例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),
            }),
          })
        );
      }
    }
  });
开发者ID:itchio,项目名称:itch,代码行数:54,代码来源:download-ended.ts

示例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}`,
     })
   );
 });
开发者ID:itchio,项目名称:itch,代码行数:11,代码来源:url.ts


注:本文中的common/actions.actions.navigate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。