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


TypeScript actions.installLocationsChanged方法代码示例

本文整理汇总了TypeScript中common/actions.actions.installLocationsChanged方法的典型用法代码示例。如果您正苦于以下问题:TypeScript actions.installLocationsChanged方法的具体用法?TypeScript actions.installLocationsChanged怎么用?TypeScript actions.installLocationsChanged使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common/actions.actions的用法示例。


在下文中一共展示了actions.installLocationsChanged方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: async

  watcher.on(actions.addInstallLocation, async (store, action) => {
    const { window } = action.payload;
    const i18n = store.getState().i18n;
    const nativeWindow = getNativeWindow(store.getState(), window);
    if (!nativeWindow) {
      return;
    }

    const dialogOpts = {
      title: t(i18n, ["prompt.install_location_add.title"]),
      // crazy typescript workaround, avert your eyes
      properties: ["openDirectory", "createDirectory"] as (
        | "openDirectory"
        | "createDirectory")[],
    };

    const promise = new ItchPromise<string>((resolve, reject) => {
      const callback = (response: string[]) => {
        if (!response) {
          return resolve();
        }

        return resolve(response[0]);
      };
      dialog.showOpenDialog(nativeWindow, dialogOpts, callback);
    });

    const path = await promise;
    if (path) {
      await call(messages.InstallLocationsAdd, { path });
      store.dispatch(actions.installLocationsChanged({}));
    }
  });
开发者ID:HorrerGames,项目名称:itch,代码行数:33,代码来源:install-locations.ts

示例2: async

  watcher.on(actions.removeInstallLocation, async (store, action) => {
    const { id } = action.payload;

    const { installLocations } = await mcall(messages.InstallLocationsList, {});
    if (installLocations.length <= 1) {
      // refuse to remove the last one
      return;
    }

    const { installLocation } = await mcall(messages.InstallLocationsGetByID, {
      id,
    });
    if (!installLocation) {
      return;
    }

    {
      const res = await promisedModal(
        store,
        modals.naked.make({
          wind: "root",
          title: ["prompt.install_location_remove.title"],
          message: ["prompt.install_location_remove.message"],
          detail: [
            "prompt.install_location_remove.detail",
            {
              location: installLocation.path,
            },
          ],
          buttons: [
            {
              label: ["prompt.action.confirm_removal"],
              action: actions.modalResponse({}),
            },
            "cancel",
          ],
          widgetParams: null,
        })
      );

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

      const logger = recordingLogger(mainLogger);
      try {
        await mcall(messages.InstallLocationsRemove, { id }, convo => {
          hookLogging(convo, logger);
        });
        store.dispatch(actions.installLocationsChanged({}));
      } catch (e) {
        store.dispatch(
          actions.openModal(
            modals.showError.make({
              wind: "root",
              title: _("prompt.show_error.generic_message"),
              message: t(store.getState().i18n, formatError(e)),
              widgetParams: {
                rawError: e,
                log: logger.getLog(),
                forceDetails: true,
              },
              buttons: ["ok"],
            })
          )
        );
      }
    }
  });
开发者ID:itchio,项目名称:itch,代码行数:70,代码来源:install-locations.ts


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