实现快传,完善快传和网盘的功能,实现文件的互传等一系列功能
This commit is contained in:
24
front/src/lib/transfer-links.ts
Normal file
24
front/src/lib/transfer-links.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
export type TransferRouterMode = 'browser' | 'hash';
|
||||
|
||||
export const APP_TRANSFER_ROUTE = '/transfer';
|
||||
export const PUBLIC_TRANSFER_ROUTE = '/transfer';
|
||||
export const LEGACY_PUBLIC_TRANSFER_ROUTE = '/t';
|
||||
|
||||
export function getTransferRouterMode(mode: string | undefined = import.meta.env?.VITE_ROUTER_MODE): TransferRouterMode {
|
||||
return mode === 'hash' ? 'hash' : 'browser';
|
||||
}
|
||||
|
||||
export function buildTransferShareUrl(
|
||||
origin: string,
|
||||
sessionId: string,
|
||||
routerMode: TransferRouterMode = 'browser',
|
||||
) {
|
||||
const normalizedOrigin = origin.replace(/\/+$/, '');
|
||||
const encodedSessionId = encodeURIComponent(sessionId);
|
||||
|
||||
if (routerMode === 'hash') {
|
||||
return `${normalizedOrigin}/#${PUBLIC_TRANSFER_ROUTE}?session=${encodedSessionId}`;
|
||||
}
|
||||
|
||||
return `${normalizedOrigin}${PUBLIC_TRANSFER_ROUTE}?session=${encodedSessionId}`;
|
||||
}
|
||||
Reference in New Issue
Block a user