當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript actions.notify方法代碼示例

本文整理匯總了TypeScript中common/actions.actions.notify方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript actions.notify方法的具體用法?TypeScript actions.notify怎麽用?TypeScript actions.notify使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在common/actions.actions的用法示例。


在下文中一共展示了actions.notify方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: 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.navigateToGame({
              window: "root",
              game: download.game,
            }),
          })
        );
      }
    }
  });
開發者ID:HorrerGames,項目名稱:itch,代碼行數:54,代碼來源:download-ended.ts

示例2: t

  nativeWindow.on("close", (e: any) => {
    const rs = store.getState();
    if (wind === "root") {
      const prefs =
        rs.preferences || ({ closeToTray: true } as PreferencesState);

      let { closeToTray } = prefs;
      if (rs.system.macos) {
        closeToTray = true;
      }
      if (env.integrationTests) {
        // always let app close in testing
        closeToTray = false;
      }

      if (store.getState().system.quitting) {
        logger.debug("On window.close: quitting, letting it close");
        return;
      }
      if (closeToTray) {
        logger.debug("On window.close: close to tray enabled");
      } else {
        logger.debug("On window.close: close to tray disabled, quitting!");
        process.nextTick(() => {
          store.dispatch(actions.quit({}));
        });
        return;
      }

      // hide, never destroy
      e.preventDefault();
      nativeWindow.hide();

      if (!prefs.gotMinimizeNotification && !store.getState().system.macos) {
        store.dispatch(
          actions.updatePreferences({
            gotMinimizeNotification: true,
          })
        );

        const i18n = store.getState().i18n;
        store.dispatch(
          actions.notify({
            title: t(i18n, ["notification.see_you_soon.title"]),
            body: t(i18n, ["notification.see_you_soon.message"]),
          })
        );
      }
    } else {
      store.dispatch(actions.windClosed({ wind }));
    }
  });
開發者ID:itchio,項目名稱:itch,代碼行數:52,代碼來源:winds.ts

示例3: t

  nativeWindow.on("close", (e: any) => {
    const prefs = store.getState().preferences || { closeToTray: true };

    let { closeToTray } = prefs;
    if (env.integrationTests) {
      // always let app close in testing
      closeToTray = false;
    }

    if (closeToTray) {
      logger.debug("Close to tray enabled");
    } else {
      logger.debug("Close to tray disabled, quitting!");
      process.nextTick(() => {
        store.dispatch(actions.quit({}));
      });
      return;
    }

    if (!nativeWindow.isVisible()) {
      logger.info("Main window hidden, letting it close");
      return;
    }

    if (!prefs.gotMinimizeNotification) {
      store.dispatch(
        actions.updatePreferences({
          gotMinimizeNotification: true,
        })
      );

      const i18n = store.getState().i18n;
      store.dispatch(
        actions.notify({
          title: t(i18n, ["notification.see_you_soon.title"]),
          body: t(i18n, ["notification.see_you_soon.message"]),
        })
      );
    }

    // hide, never destroy
    e.preventDefault();
    logger.info("Hiding main window");
    nativeWindow.hide();
  });
開發者ID:HorrerGames,項目名稱:itch,代碼行數:45,代碼來源:main-window.ts


注:本文中的common/actions.actions.notify方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。