From 3ce6c04d665c65333b229ebafa965940bfce5e89 Mon Sep 17 00:00:00 2001 From: estel <690930@qq.com> Date: Mon, 18 Aug 2025 10:40:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dwindows?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/pages/index.vue | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/app/pages/index.vue b/app/pages/index.vue index 425c6c6..1e65608 100644 --- a/app/pages/index.vue +++ b/app/pages/index.vue @@ -114,20 +114,30 @@ async function updateVideoSrc() { return } - // Always use HTTP protocol for both Tauri and development - // This works reliably in both environments - const filename = raw.split('/').pop() || 'video.mp4' + // Handle Windows paths with backslashes and drive letters + const isWindowsPath = /^[a-zA-Z]:[\\/]|^\\/.test(raw) - // Use relative HTTP URL - this works in both Tauri and development - if (filename === 'video.mp4') { - videoSrc.value = '/video.mp4' + if (isWindowsPath) { + // Windows: Use Tauri's asset protocol for absolute paths + // Convert backslashes to forward slashes and use asset:// protocol + const normalizedPath = raw.replace(/\\/g, '/') + videoSrc.value = `asset://localhost/${normalizedPath}` } else { - videoSrc.value = `/${filename}` + // Unix-like: Use HTTP protocol for both Tauri and development + const filename = raw.split(/[/\\]/).pop() || "video.mp4"; + + // Use relative HTTP URL for bundled resources + if (filename === 'video.mp4') { + videoSrc.value = '/video.mp4' + } else { + videoSrc.value = `/${filename}` + } } - console.log('🎥 Using HTTP URL for video:') + console.log('🎥 Using URL for video:') console.log(' - Original path:', raw) - console.log(' - HTTP URL:', videoSrc.value) + console.log(' - Platform:', isWindowsPath ? 'Windows' : 'Unix') + console.log(' - Final URL:', videoSrc.value) } // Watch for changes in currentVideo and update videoSrc