本文整理汇总了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,
})
);
});
示例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;
};