Emit single-segment hotlink share and viewer URLs.

Legacy /i and /h two-segment routes remain supported in the router and viewer.
This commit is contained in:
2026-11-02 14:20:12 +01:00
parent 2396c5d16d
commit 0d8d682990
9 changed files with 67 additions and 26 deletions
+21 -6
View File
@@ -28,7 +28,12 @@ import { onBeforeMount, ref } from 'vue';
import { useRoute } from 'vue-router';
import { config } from '@/config';
import type { HotlinkViewerViewState } from '@/types/view/HotlinkViewerViewState';
import { buildHotlinkImagePath } from '@/utils/share/buildHotlinkImagePath';
import {
buildHotlinkImagePath,
buildLegacyHotlinkImagePath
} from '@/utils/share/buildHotlinkImagePath';
const { baseUrlRoot } = config.api;
const route = useRoute();
@@ -36,19 +41,29 @@ const state = ref<HotlinkViewerViewState>('loading');
const imageSrc = ref<string | null>(null);
onBeforeMount(() => {
const accessToken = route.params.accessToken;
const uploadId = route.params.id;
const secret = route.params.secret;
if (typeof uploadId !== 'string' || typeof secret !== 'string' || !uploadId || !secret) {
let path: string | null = null;
if (typeof accessToken === 'string' && accessToken) {
path = buildHotlinkImagePath(accessToken);
} else if (
typeof uploadId === 'string' &&
typeof secret === 'string' &&
uploadId &&
secret
) {
path = buildLegacyHotlinkImagePath(uploadId, secret);
}
if (!path) {
state.value = 'invalidLink';
return;
}
const { baseUrlRoot } = config.api;
const path = buildHotlinkImagePath(uploadId, secret);
imageSrc.value = `${baseUrlRoot}${path}`;
});