當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。