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


TypeScript space.Space类代码示例

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


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

示例1: 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

示例2: 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

示例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: map

  items = map(openTabs, id => {
    const ti = tabInstances[id];
    if (!ti) {
      return null;
    }

    const sp = Space.fromInstance(ti);
    const { history, currentIndex } = ti;
    const savedLabel = sp.label();
    return { id, history, currentIndex, savedLabel };
  });
开发者ID:HorrerGames,项目名称:itch,代码行数:11,代码来源:tab-save.ts

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: withWebContents

    withWebContents(store, wind, tab, wc => {
      let offset = index - oldIndex;
      const url = rs.winds[wind].tabInstances[tab].history[index].url;
      if (
        wc.canGoToOffset(offset) &&
        wc.history[wc.currentIndex + offset] === url
      ) {
        logger.debug(`\n`);
        logger.debug(`~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`);
        logger.debug(
          `For index ${oldIndex} => ${index}, applying offset ${offset}`
        );
        logger.debug(`~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n`);
        wc.goToOffset(offset);
      } else {
        const url = Space.fromState(rs, wind, tab).url();
        logger.debug(`\n`);
        logger.debug(`~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`);
        logger.debug(
          `For index ${oldIndex} => ${index}, clearing history and loading ${url}`
        );
        logger.debug(`(could go to offset? ${wc.canGoToOffset(offset)})`);
        logger.debug(`(wcl = ${wc.history[wc.currentIndex + offset]})`);
        logger.debug(`(url = ${url})`);

        if (offset == 1) {
          logger.debug(
            `Wait, no, we're just going forward one, we don't need to clear history`
          );
        } else {
          wc.clearHistory();
        }
        logger.debug(`~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n`);
        loadURL(wc, url);
      }
    });
开发者ID:itchio,项目名称:itch,代码行数:36,代码来源:web-contents.ts


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