fix window controls and ui zoom - stop externalizing tauri api modules
This commit is contained in:
+4
-35
@@ -1,11 +1,11 @@
|
|||||||
import { useDownloads } from '../stores/downloads-store'
|
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).
|
* Note: persistent disk storage in the Tauri build would require the
|
||||||
* Tauri: writes the bytes to the app's AppLocalData directory and stores the path.
|
* 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: {
|
export async function startDownload(args: {
|
||||||
itemId: string
|
itemId: string
|
||||||
@@ -27,36 +27,6 @@ export async function startDownload(args: {
|
|||||||
try {
|
try {
|
||||||
store.update(dl.id, { status: 'downloading', progress: 0 })
|
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)
|
const response = await fetch(streamUrl)
|
||||||
if (!response.ok || !response.body) {
|
if (!response.ok || !response.body) {
|
||||||
throw new Error(`Download failed: ${response.status}`)
|
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 blob = new Blob(chunks as any)
|
||||||
const objectUrl = URL.createObjectURL(blob)
|
const objectUrl = URL.createObjectURL(blob)
|
||||||
store.update(dl.id, {
|
store.update(dl.id, {
|
||||||
|
|||||||
+1
-3
@@ -6,8 +6,6 @@ export default defineConfig({
|
|||||||
plugins: [react(), tailwindcss()],
|
plugins: [react(), tailwindcss()],
|
||||||
build: {
|
build: {
|
||||||
chunkSizeWarningLimit: 900,
|
chunkSizeWarningLimit: 900,
|
||||||
rollupOptions: {
|
|
||||||
external: [/^@tauri-apps\/.*/],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user