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


TypeScript Space.fromStore方法代码示例

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


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

示例1: async

  watcher.on(actions.tabParamsChanged, async (store, action) => {
    let { tab, params, window } = action.payload;
    const sp = Space.fromStore(store, window, tab);

    const newParams = {
      ...sp.query(),
      ...params,
    };

    const previousURL = sp.url();
    const parsed = nodeURL.parse(previousURL);
    const { host, protocol, pathname } = parsed;
    const newURL = nodeURL.format({
      host,
      protocol,
      pathname,
      slashes: true,
      search: `?${querystring.stringify(newParams)}`,
    });

    store.dispatch(
      actions.evolveTab({
        window,
        tab,
        url: newURL,
        replace: true,
        onlyParamsChange: true,
      })
    );
  });
开发者ID:HorrerGames,项目名称:itch,代码行数:30,代码来源:navigation.ts

示例2: async

  watcher.on(actions.openTabForwardHistory, async (store, action) => {
    const { wind, tab, clientX, clientY } = action.payload;
    const space = Space.fromStore(store, wind, tab);
    if (!space.canGoForward()) {
      return;
    }

    let startIndex = space.currentIndex() + 1;
    let endIndex = space.history().length;
    if (endIndex - startIndex > shownHistoryItems) {
      endIndex = startIndex + shownHistoryItems;
    }

    const template = makeHistoryTemplate({
      i18n: store.getState().i18n,
      wind,
      space,
      startIndex,
      endIndex,
      dir: 1,
    });
    store.dispatch(
      actions.popupContextMenu({ wind, clientX, clientY, template })
    );
  });
开发者ID:itchio,项目名称:itch,代码行数:25,代码来源:navigation.ts

示例3:

 let printStateHistory = () => {
   const space = Space.fromStore(store, wind, tab);
   logger.debug(`---------------------------------`);
   for (let i = 0; i < space.history().length; i++) {
     const page = space.history()[i];
     logger.debug(`S| ${i === space.currentIndex() ? ">" : " "} ${page.url}`);
   }
 };
开发者ID:itchio,项目名称:itch,代码行数:8,代码来源:web-contents.ts

示例4: async

  watcher.on(actions.commandMain, async (store, action) => {
    const { window } = action.payload;
    const { tab } = store.getState().windows[window].navigation;
    const sp = Space.fromStore(store, window, tab);

    if (sp.prefix === "games") {
      const game = sp.game();
      if (game) {
        // FIXME: queueGame doesn't always do the right thing.
        // it'll try installing even if there's no chance you'll be able
        // to download it (for example, if you need to purchase it first)
        store.dispatch(actions.queueGame({ game }));
      }
    }
  });
开发者ID:HorrerGames,项目名称:itch,代码行数:15,代码来源:triggers.ts

示例5: async

  watcher.on(actions.openTabContextMenu, async (store, action) => {
    const { window, tab } = action.payload;

    let template: IMenuTemplate;
    template = concatTemplates(template, newTabControls(store, window, tab));

    const sp = Space.fromStore(store, window, tab);
    if (sp.prefix === "games") {
      const game = sp.game();
      if (game && game.id) {
        template = concatTemplates(template, gameControls(store, game));
      }
    }

    template = concatTemplates(template, closeTabControls(store, window, tab));
    const { clientX, clientY } = action.payload;
    openMenu(store, template, { window, clientX, clientY });
  });
开发者ID:HorrerGames,项目名称:itch,代码行数:18,代码来源:context-menu.ts

示例6: cb

function withWebContents<T>(
  store: IStore,
  window: string,
  tab: string,
  cb: WebContentsCallback<T>
): T | null {
  const sp = Space.fromStore(store, window, tab);

  const { webContentsId } = sp.web();
  if (!webContentsId) {
    return null;
  }

  const wc = webContents.fromId(webContentsId);
  if (!wc || wc.isDestroyed()) {
    return null;
  }

  return cb(wc as ExtendedWebContents);
}
开发者ID:HorrerGames,项目名称:itch,代码行数:20,代码来源:web-contents.ts

示例7: getFetcherClass

function getFetcherClass(
  store: IStore,
  window: string,
  tab: string
): typeof Fetcher {
  const sp = Space.fromStore(store, window, tab);

  switch (sp.internalPage()) {
    case "dashboard":
      return DashboardFetcher;
    case "collections": {
      if (sp.firstPathElement()) {
        return CollectionFetcher;
      } else {
        return CollectionsFetcher;
      }
    }
    case "dashboard":
      return DashboardFetcher;
    case "library":
      return LibraryFetcher;
    case "games":
      return GameFetcher;
    case "collections":
      return CollectionFetcher;
    case "locations":
      return LocationFetcher;
    case "applog":
      return AppLogFetcher;
  }

  switch (sp.prefix) {
    case "games":
      return GameFetcher;
  }
  return null;
}
开发者ID:HorrerGames,项目名称:itch,代码行数:37,代码来源:fetchers.ts

示例8: navigation

  const commit = (
    event: any,
    url: string, // latest URL
    inPage: boolean, // in-page navigation (HTML5 pushState/popState/replaceState)
    replaceEntry: boolean // previous history entry was replaced
  ) => {
    if (wc.currentIndex < 0) {
      // We get those spurious events after a "clear history & loadURL()"
      // at this point `wc.history.length` is 0 anyway, so it's not like we
      // can figure out much. They're followed by a meaningful event shortly after.
      logger.debug(
        `Ignoring navigation-entry-committed with negative currentIndex`
      );
      return;
    }

    let { previousIndex, previousHistorySize } = previousState;
    previousState = {
      previousIndex: wc.currentIndex,
      previousHistorySize: wc.history.length,
    };

    const space = Space.fromStore(store, wind, tab);
    const stateHistory = space.history();
    const getStateURL = (index: number) => {
      if (index >= 0 && index < stateHistory.length) {
        return stateHistory[index].url;
      }
      // The index passed to this function is sometimes computed
      // from the current index + an offset, so it might be out
      // of bounds.
      // We always use it to find equal URLs,
      // so it's okay to just return undefined in these cases
      return undefined;
    };
    const stateIndex = space.currentIndex();
    const stateURL = getStateURL(stateIndex);

    logger.debug("\n");
    logger.debug(`=================================`);
    logger.debug(`navigation-entry-committed ${url}`);
    logger.debug(
      `currentIndex ${wc.currentIndex} pendingIndex ${
        wc.pendingIndex
      } inPageIndex ${wc.inPageIndex} inPage ${inPage}`
    );

    printWebContentsHistory(previousIndex);
    printStateHistory();

    const wcTitle = wc.getTitle();
    if (
      wcTitle !== url &&
      space.label() !== wc.getTitle() &&
      !/^itch:/i.test(url)
    ) {
      // page-title-updated does not always fire, so a navigation (in-page or not)
      // is a good place to check.
      // we also check that the webContents' title is not its URL, which happens
      // while it's currently loading a page.
      logger.debug(`pushing webContents title ${wcTitle}`);
      pushPageUpdate({
        url,
        label: wcTitle,
      });
    }

    // The logic that follows may not make sense to the casual observer.
    // Let's recap our assumptions:
    //   - The Redux state (ie. Space.history(), Space.currentIndex(), etc.)
    //     should always mirror Electron's navigation controller history.
    //   - Navigation can occur in-page (in which case it's important to
    //     call webContents.{goBack,goForward,goToOffset}), or it can be http-level
    //     navigation (in which case Electron's navigation controller restarts the
    //     renderer process anyway - because "just using Chrome's navigation controller"
    //     apparently broke nodeIntegration (which we don't use for web tabs anyway...))
    //   - Navigation can be triggered by the itch app (actions.tabGoBack is dispatched, etc.)
    //     or by the webContents (window.history.go(-1), pushState, clicking on a link, etc.)
    //   - We choose not to rely on events like `did-start-navigation` (Electron 3.x+),
    //     `did-navigate`, `did-navigate-in-page` etc. to avoid race conditions

    let offset = wc.currentIndex - previousIndex;
    let sizeOffset = wc.history.length - previousHistorySize;

    if (sizeOffset === 1) {
      logger.debug(`History grew one, offset is ${offset}`);

      if (stateURL === url) {
        logger.debug(`web and state point to same URL, doing nothing`);
      }

      if (offset === 0) {
        logger.debug(`Replacing because offset is 0`);
        didNavigate(url, NavMode.Replace);
        printStateHistory();
        return;
      }

      let currentURL = space.url();
      let previousWebURL = wc.history[wc.currentIndex - 1];
//.........这里部分代码省略.........
开发者ID:itchio,项目名称:itch,代码行数:101,代码来源:web-contents.ts


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