1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-05-24 09:14:05 +02:00

refactor(frontend): router refactoring

This commit is contained in:
syuilo
2025-03-19 18:06:22 +09:00
parent 2c76018b7f
commit 81ac71f7e5
10 changed files with 115 additions and 168 deletions

View File

@@ -59,7 +59,7 @@ const windowRouter = createRouter(props.initialPath);
const pageMetadata = ref<null | PageMetadata>(null);
const windowEl = shallowRef<InstanceType<typeof MkWindow>>();
const history = ref<{ path: string; }[]>([{
path: windowRouter.getCurrentPath(),
path: windowRouter.getCurrentFullPath(),
}]);
const buttonsLeft = computed(() => {
const buttons: Record<string, unknown>[] = [];
@@ -97,20 +97,20 @@ function getSearchMarker(path: string) {
const searchMarkerId = ref<string | null>(getSearchMarker(props.initialPath));
windowRouter.addListener('push', ctx => {
history.value.push({ path: ctx.path });
history.value.push({ path: ctx.fullPath });
});
windowRouter.addListener('replace', ctx => {
history.value.pop();
history.value.push({ path: ctx.path });
history.value.push({ path: ctx.fullPath });
});
windowRouter.addListener('change', ctx => {
if (_DEV_) console.log('windowRouter: change', ctx.path);
searchMarkerId.value = getSearchMarker(ctx.path);
if (_DEV_) console.log('windowRouter: change', ctx.fullPath);
searchMarkerId.value = getSearchMarker(ctx.fullPath);
analytics.page({
path: ctx.path,
title: ctx.path,
path: ctx.fullPath,
title: ctx.fullPath,
});
});
@@ -139,14 +139,14 @@ const contextmenu = computed(() => ([{
icon: 'ti ti-external-link',
text: i18n.ts.openInNewTab,
action: () => {
window.open(url + windowRouter.getCurrentPath(), '_blank', 'noopener');
window.open(url + windowRouter.getCurrentFullPath(), '_blank', 'noopener');
windowEl.value?.close();
},
}, {
icon: 'ti ti-link',
text: i18n.ts.copyLink,
action: () => {
copyToClipboard(url + windowRouter.getCurrentPath());
copyToClipboard(url + windowRouter.getCurrentFullPath());
},
}]));
@@ -164,12 +164,12 @@ function close() {
}
function expand() {
mainRouter.push(windowRouter.getCurrentPath(), 'forcePage');
mainRouter.push(windowRouter.getCurrentFullPath(), 'forcePage');
windowEl.value?.close();
}
function popout() {
_popout(windowRouter.getCurrentPath(), windowEl.value?.$el);
_popout(windowRouter.getCurrentFullPath(), windowEl.value?.$el);
windowEl.value?.close();
}