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


TypeScript modals.promisedModal函數代碼示例

本文整理匯總了TypeScript中main/reactors/modals.promisedModal函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript promisedModal函數的具體用法?TypeScript promisedModal怎麽用?TypeScript promisedModal使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


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

示例1: async

  watcher.on(actions.clearBrowsingDataRequest, async (store, action) => {
    const { wind } = action.payload;
    const response = await promisedModal(
      store,
      modals.clearBrowsingData.make({
        wind,
        title: ["preferences.advanced.clear_browsing_data"],
        message: "",
        buttons: [
          {
            label: ["prompt.clear_browsing_data.clear"],
            id: "modal-clear-data",
            action: "widgetResponse",
          },
          "cancel",
        ],
        widgetParams: {},
      })
    );

    if (!response) {
      // modal was closed
      return;
    }

    store.dispatch(
      actions.clearBrowsingData({
        cache: response.cache,
        cookies: response.cookies,
      })
    );
  });
開發者ID:itchio,項目名稱:itch,代碼行數:32,代碼來源:clear-browsing-data.ts

示例2: async

      onError: async (e, log) => {
        const response = await promisedModal(
          store,
          modals.showError.make({
            wind: "root",
            title: ["prompt.uninstall_error.title"],
            message: ["prompt.uninstall_error.message"],
            buttons: [
              {
                label: ["prompt.action.ok"],
                action: actions.modalResponse({}),
              },
              "cancel",
            ],
            widgetParams: { rawError: e, log },
          })
        );

        if (!response) {
          // modal was closed
          return;
        }

        logger.info(`Should remove entry anyway, performing hard uninstall`);
        try {
          await mcall(messages.UninstallPerform, { caveId, hard: true });
          store.dispatch(actions.uninstallEnded({}));
        } catch (e) {
          logger.error(`Well, even hard uninstall didn't work: ${e.stack}`);
        }
      },
開發者ID:itchio,項目名稱:itch,代碼行數:31,代碼來源:queue-cave-uninstall.ts

示例3: pickManifestAction

export async function pickManifestAction(
  store: Store,
  manifestActions: Action[],
  game: Game
): Promise<number> {
  const buttons: ModalButtonSpec[] = [];
  const bigButtons: ModalButtonSpec[] = [];

  for (let index = 0; index < manifestActions.length; index++) {
    const action = manifestActions[index];
    if (!action.name) {
      throw new Error(`in manifest, action ${index} is missing a name`);
    }

    const icon = action.icon || defaultManifestIcons[action.name] || "star";

    bigButtons.push({
      label: [`action.name.${action.name}`, { defaultValue: action.name }],
      action: modals.pickManifestAction.action({ index }),
      icon,
      className: `action-${action.name}`,
    });
  }

  buttons.push("cancel");

  const response = await promisedModal(
    store,
    modals.pickManifestAction.make({
      wind: "root",
      title: game.title,
      stillCoverUrl: game.stillCoverUrl,
      coverUrl: game.coverUrl,
      message: "",
      bigButtons,
      buttons,
      widgetParams: {},
    })
  );

  if (response) {
    return response.index;
  }

  // as per butlerd spec, negative index means abort launch
  return -1;
}
開發者ID:itchio,項目名稱:itch,代碼行數:47,代碼來源:pick-manifest-action.ts

示例4: performInstallQueue

async function performInstallQueue({
  store,
  game,
  uploadId,
}: PerformInstallQueueOpts) {
  await promisedModal(
    store,
    modals.planInstall.make({
      wind: "root",
      title: game.title,
      widgetParams: {
        game,
        uploadId,
      },
      buttons: [],
    })
  );
}
開發者ID:itchio,項目名稱:itch,代碼行數:18,代碼來源:queue-game.ts

示例5: async

              async ({ cave, upload, builds }) => {
                const response = await promisedModal(
                  store,
                  modals.switchVersionCave.make({
                    wind: "root",
                    title: ["prompt.revert.title", { title: cave.game.title }],
                    message: "",
                    widgetParams: { cave, upload, builds },
                    buttons: ["cancel"],
                  })
                );

                if (!response) {
                  // modal was closed
                  return { index: -1 };
                }

                return { index: response.index };
              }
開發者ID:itchio,項目名稱:itch,代碼行數:19,代碼來源:switch-version-cave.ts

示例6: async

            convo.on(messages.PrereqsFailed, async ({ errorStack, error }) => {
              closePrereqsModal();

              const { title } = game;
              let errorMessage = error;
              errorMessage = errorMessage.split("\n")[0];

              let log = logger.getLog();

              const res = await promisedModal(
                store,
                modals.showError.make({
                  wind: "root",
                  title: ["game.install.could_not_launch", { title }],
                  message: [
                    "game.install.could_not_launch.message",
                    { title, errorMessage },
                  ],
                  detail: ["game.install.could_not_launch.detail"],
                  widgetParams: {
                    game,
                    rawError: { stack: errorStack },
                    log,
                  },
                  buttons: [
                    {
                      label: ["prompt.action.continue"],
                      action: actions.modalResponse({
                        continue: true,
                      }),
                    },
                    "cancel",
                  ],
                })
              );

              if (res) {
                return { continue: true };
              }

              return { continue: false };
            });
開發者ID:itchio,項目名稱:itch,代碼行數:42,代碼來源:perform-launch.ts

示例7: async

  watcher.on(actions.quit, async (store, action) => {
    const { tasks } = store.getState().tasks;
    let runningGameIds: number[] = [];
    for (const taskId of Object.keys(tasks)) {
      const task = tasks[taskId];
      if (task.name === "launch") {
        runningGameIds.push(task.gameId);
      }
    }

    if (runningGameIds.length > 0) {
      const res = await promisedModal(
        store,
        modals.confirmQuit.make({
          wind: "root",
          title: ["prompt.confirm_quit.title"],
          message: ["prompt.confirm_quit.message"],
          buttons: [
            {
              label: ["prompt.action.quit_and_close_all"],
              action: actions.modalResponse({}),
            },
            "cancel",
          ],
          widgetParams: {
            gameIds: runningGameIds,
          },
        })
      );

      if (!res) {
        store.dispatch(actions.cancelQuit({}));
        return;
      }
    }

    store.dispatch(actions.performQuit({}));
  });
開發者ID:itchio,項目名稱:itch,代碼行數:38,代碼來源:winds.ts

示例8: async

          client.on(messages.ProfileRequestTOTP, async () => {
            logger.info(`Showing TOTP`);
            const modalRes = await promisedModal(
              store,
              modals.twoFactorInput.make({
                wind: "root",
                title: ["login.two_factor.title"],
                message: "",
                widgetParams: {
                  username,
                },
              })
            );

            if (modalRes) {
              logger.info(`TOTP answered`);
              return { code: modalRes.totpCode };
            } else {
              // abort
              logger.info(`TOTP cancelled`);
              return { code: null };
            }
          });
開發者ID:itchio,項目名稱:itch,代碼行數:23,代碼來源:login.ts


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