fix window controls and ui zoom - stop externalizing tauri api modules

This commit is contained in:
2026-04-03 23:34:15 +03:00
parent a77b2d491c
commit 42fa705037
2 changed files with 5 additions and 38 deletions
+4 -35
View File
@@ -1,11 +1,11 @@
import { useDownloads } from '../stores/downloads-store'
import { isTauri } from './tauri'
/**
* Download a Jellyfin stream to local storage.
* Download a Jellyfin stream to local storage as a Blob URL.
*
* Browser: caches the response as a Blob URL (session-only, lost on reload).
* Tauri: writes the bytes to the app's AppLocalData directory and stores the path.
* Note: persistent disk storage in the Tauri build would require the
* tauri-plugin-fs plugin, which is not currently included. For now both
* browser and Tauri builds cache downloads as in-memory Blob URLs.
*/
export async function startDownload(args: {
itemId: string
@@ -27,36 +27,6 @@ export async function startDownload(args: {
try {
store.update(dl.id, { status: 'downloading', progress: 0 })
if (isTauri) {
// Tauri path: fetch via the Rust-backed HTTP client so we avoid
// CORS + we can stream large files without the browser's memory
// pressure.
// @ts-ignore
const { fetch } = await import('@tauri-apps/api/http') as any
// @ts-ignore
const { appLocalDataDir } = await import('@tauri-apps/api/path') as any
// @ts-ignore
const { writeBinaryFile, BaseDirectory } = await import('@tauri-apps/api/fs') as any
const res = await (fetch as any)(streamUrl, {
method: 'GET',
responseType: 3, // ResponseType.Binary
})
const bytes: Uint8Array = res.data
const dir = await appLocalDataDir()
const fileName = `download_${itemId}_${Date.now()}.mp4`
await writeBinaryFile(fileName, bytes, { dir: BaseDirectory.AppLocalData })
const localPath = `${dir}/${fileName}`
store.update(dl.id, {
status: 'done',
progress: 100,
sizeBytes: bytes.length,
localPath,
})
return
}
// Browser path: fetch with progress tracking via a ReadableStream reader
const response = await fetch(streamUrl)
if (!response.ok || !response.body) {
throw new Error(`Download failed: ${response.status}`)
@@ -79,7 +49,6 @@ export async function startDownload(args: {
}
}
// Assemble the full blob
const blob = new Blob(chunks as any)
const objectUrl = URL.createObjectURL(blob)
store.update(dl.id, {
+1 -3
View File
@@ -6,8 +6,6 @@ export default defineConfig({
plugins: [react(), tailwindcss()],
build: {
chunkSizeWarningLimit: 900,
rollupOptions: {
external: [/^@tauri-apps\/.*/],
},
},
})