mirror of
https://gh-proxy.org/https://github.com/tiajinsha/JKVideo
synced 2026-07-07 23:18:38 +08:00
feat:下载管理页面,集成分享功能
This commit is contained in:
26
utils/lanServer.ts
Normal file
26
utils/lanServer.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import StaticServer from '@dr.pogodin/react-native-static-server';
|
||||
import * as FileSystem from 'expo-file-system/legacy';
|
||||
import * as Network from 'expo-network';
|
||||
|
||||
const PORT = 18080;
|
||||
let server: StaticServer | null = null;
|
||||
|
||||
export async function startLanServer(): Promise<string> {
|
||||
if (server) await server.stop();
|
||||
const root = FileSystem.documentDirectory!.replace('file://', '');
|
||||
server = new StaticServer({ fileDir: root, port: PORT, nonLocal: true });
|
||||
await server.start();
|
||||
const ip = await Network.getIpAddressAsync();
|
||||
return `http://${ip}:${PORT}`;
|
||||
}
|
||||
|
||||
export async function stopLanServer(): Promise<void> {
|
||||
if (server) {
|
||||
await server.stop();
|
||||
server = null;
|
||||
}
|
||||
}
|
||||
|
||||
export function buildVideoUrl(baseUrl: string, bvid: string, qn: number): string {
|
||||
return `${baseUrl}/${bvid}_${qn}.mp4`;
|
||||
}
|
||||
Reference in New Issue
Block a user