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


TypeScript actions.tabWentToIndex方法代码示例

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


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

示例1: async

  watcher.on(actions.tabGoToIndex, async (store, action) => {
    const { wind, tab, index } = action.payload;
    const rs = store.getState();
    const ti = rs.winds[wind].tabInstances[tab];
    if (!ti) {
      return;
    }

    if (index < 0 || index >= ti.history.length) {
      return;
    }

    store.dispatch(
      actions.tabWentToIndex({
        wind,
        tab,
        index,
        oldIndex: ti.currentIndex,
      })
    );
  });
开发者ID:itchio,项目名称:itch,代码行数:21,代码来源:web-contents.ts

示例2: navigation


//.........这里部分代码省略.........
      if (currentURL && previousWebURL !== currentURL) {
        logger.debug(
          `Replacing because previous web url \n${previousWebURL}\n is not current state url \n${currentURL}`
        );
        didNavigate(url, NavMode.Replace);
        printStateHistory();
        return;
      }

      logger.debug(`Assuming regular navigation happened`);
      didNavigate(url, NavMode.Append);
      printStateHistory();
      return;
    }

    if (sizeOffset === 0) {
      logger.debug(`History stayed the same size, offset is ${1}`);
      if (offset === 1) {
        if (stateURL === url) {
          logger.debug(`web and state point to same URL, doing nothing`);
          return;
        }

        if (getStateURL(stateIndex + offset) === url) {
          logger.debug(`If we apply the history offset, the URLs match!`);
          // fallthrough to in-history navigation
        } else {
          logger.debug(`Assuming normal navigation happened`);
          didNavigate(url, NavMode.Append);
          printStateHistory();
          return;
        }
      } else if (offset === 0) {
        if (replaceEntry) {
          const index = space.currentIndex();
          if (inPage) {
            if (getStateURL(index - 1) === url) {
              logger.debug(
                `replaceEntry is true, but inPage & previous is a dupe, ignoring`
              );
              return;
            }

            if (getStateURL(index + 1) === url) {
              logger.debug(
                `replaceEntry is true, but inPage & next is a dupe, ignoring`
              );
              return;
            }
          }

          logger.debug(`Handling it like a replace`);
          didNavigate(url, NavMode.Replace);
          printStateHistory();
          return;
        } else {
          logger.debug(`Not a replace, doing nothing.`);
          return;
        }
      }

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

      let oldIndex = stateIndex;
      let index = oldIndex + offset;
      if (getStateURL(index) === url) {
        logger.debug(
          `Assuming in-history navigation (${oldIndex} => ${index})`
        );
        store.dispatch(
          actions.tabWentToIndex({
            wind,
            tab,
            oldIndex,
            index,
            fromWebContents: true,
          })
        );
        printStateHistory();
        return;
      } else {
        logger.debug(`We're not sure what happened, doing nothing`);
        return;
      }
    }

    logger.debug(`History shrunk ; usually means normal navigation.`);

    if (stateURL === url) {
      logger.debug(`Except the url is already good, nvm!`);
    } else {
      logger.debug(`Assuming normal navigation happened`);
      didNavigate(url, NavMode.Append);
      printStateHistory();
    }
    return;
  };
开发者ID:itchio,项目名称:itch,代码行数:101,代码来源:web-contents.ts


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