summaryrefslogtreecommitdiff
path: root/packages/frontend/src/components/MkPageWindow.vue
diff options
context:
space:
mode:
Diffstat (limited to 'packages/frontend/src/components/MkPageWindow.vue')
-rw-r--r--packages/frontend/src/components/MkPageWindow.vue17
1 files changed, 11 insertions, 6 deletions
diff --git a/packages/frontend/src/components/MkPageWindow.vue b/packages/frontend/src/components/MkPageWindow.vue
index 709b5a52df..6e35ad4241 100644
--- a/packages/frontend/src/components/MkPageWindow.vue
+++ b/packages/frontend/src/components/MkPageWindow.vue
@@ -17,25 +17,27 @@
</template>
</template>
- <div :class="$style.root" style="container-type: inline-size;">
+ <div ref="contents" :class="$style.root" style="container-type: inline-size;">
<RouterView :key="reloadCount" :router="router"/>
</div>
</MkWindow>
</template>
<script lang="ts" setup>
-import { ComputedRef, onMounted, onUnmounted, provide } from 'vue';
+import { ComputedRef, onMounted, onUnmounted, provide, shallowRef } from 'vue';
import RouterView from '@/components/global/RouterView.vue';
import MkWindow from '@/components/MkWindow.vue';
import { popout as _popout } from '@/scripts/popout';
import copyToClipboard from '@/scripts/copy-to-clipboard';
import { url } from '@/config';
-import { mainRouter, routes } from '@/router';
-import { Router } from '@/nirax';
+import { mainRouter, routes, page } from '@/router';
+import { $i } from '@/account';
+import { Router, useScrollPositionManager } from '@/nirax';
import { i18n } from '@/i18n';
import { PageMetadata, provideMetadataReceiver } from '@/scripts/page-metadata';
import { openingWindowsCount } from '@/os';
import { claimAchievement } from '@/scripts/achievements';
+import { getScrollContainer } from '@/scripts/scroll';
const props = defineProps<{
initialPath: string;
@@ -45,8 +47,9 @@ defineEmits<{
(ev: 'closed'): void;
}>();
-const router = new Router(routes, props.initialPath);
+const router = new Router(routes, props.initialPath, !!$i, page(() => import('@/pages/not-found.vue')));
+const contents = shallowRef<HTMLElement>();
let pageMetadata = $ref<null | ComputedRef<PageMetadata>>();
let windowEl = $shallowRef<InstanceType<typeof MkWindow>>();
const history = $ref<{ path: string; key: any; }[]>([{
@@ -117,7 +120,7 @@ const contextmenu = $computed(() => ([{
function back() {
history.pop();
- router.replace(history[history.length - 1].path, history[history.length - 1].key);
+ router.replace(history.at(-1)!.path, history.at(-1)!.key);
}
function reload() {
@@ -138,6 +141,8 @@ function popout() {
windowEl.close();
}
+useScrollPositionManager(() => getScrollContainer(contents.value), router);
+
onMounted(() => {
openingWindowsCount.value++;
if (openingWindowsCount.value >= 3) {