This commit is contained in:
syuilo
2025-03-19 15:17:41 +09:00
parent 11378b17c5
commit bdc72e5817
6 changed files with 21 additions and 69 deletions

View File

@@ -47,14 +47,14 @@ function resolveNested(current: Resolved, d = 0): Resolved | null {
const current = resolveNested(router.current)!;
const currentPageComponent = shallowRef('component' in current.route ? current.route.component : MkLoadingPage);
const currentPageProps = ref(current.props);
const key = ref(router.getCurrentKey() + JSON.stringify(Object.fromEntries(current.props)));
const key = ref(router.getCurrentPath());
function onChange({ resolved, key: newKey }) {
function onChange({ resolved }) {
const current = resolveNested(resolved);
if (current == null || 'redirect' in current.route) return;
currentPageComponent.value = current.route.component;
currentPageProps.value = current.props;
key.value = newKey + JSON.stringify(Object.fromEntries(current.props));
key.value = router.getCurrentPath();
}
router.addListener('change', onChange);

View File

@@ -44,13 +44,13 @@ provide(DI.routerCurrentDepth, currentDepth + 1);
const current = router.current!;
const currentPageComponent = shallowRef('component' in current.route ? current.route.component : MkLoadingPage);
const currentPageProps = ref(current.props);
const key = ref(router.getCurrentKey() + JSON.stringify(Object.fromEntries(current.props)));
const key = ref(router.getCurrentPath());
function onChange({ resolved, key: newKey }) {
function onChange({ resolved }) {
if (resolved == null || 'redirect' in resolved.route) return;
currentPageComponent.value = resolved.route.component;
currentPageProps.value = resolved.props;
key.value = newKey + JSON.stringify(Object.fromEntries(resolved.props));
key.value = router.getCurrentPath();
nextTick(() => {
// ページ遷移完了後に再びキャッシュを有効化

View File

@@ -123,7 +123,7 @@ function mount() {
function back() {
const prev = tabs.value[tabs.value.length - 2];
tabs.value = [...tabs.value.slice(0, tabs.value.length - 1)];
router.replace(prev.path, prev.key);
router.replace(prev.path);
}
router.addListener('replace', onReplace);