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:
@@ -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}`;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user