Fix: Stub Capacitor, Fix Tauri-Build, Fix Static-Build

This commit is contained in:
Youwes09
2026-05-25 10:21:12 -05:00
parent d9a9427e3b
commit cbdf9e8be1
10 changed files with 213 additions and 89 deletions
+21 -19
View File
@@ -4,8 +4,6 @@ import { open } from '@tauri-apps/plugin-dialog'
import { readFile, writeFile } from '@tauri-apps/plugin-fs'
import { open as openUrl } from '@tauri-apps/plugin-shell'
import { getVersion } from '@tauri-apps/api/app'
import { check } from '@tauri-apps/plugin-updater'
import { relaunch } from '@tauri-apps/plugin-process'
import type {
PlatformAdapter,
PlatformFeature,
@@ -69,19 +67,20 @@ export class TauriAdapter implements PlatformAdapter {
}
async setTitle(title: string) {
await invoke('set_window_title', { title })
await getCurrentWindow().setTitle(title)
}
async minimize() {
await invoke('minimize_window')
await getCurrentWindow().minimize()
}
async maximize() {
await invoke('maximize_window')
const win = getCurrentWindow()
await (await win.isMaximized() ? win.unmaximize() : win.maximize())
}
async close() {
await invoke('close_window')
await getCurrentWindow().close()
}
async toggleFullscreen() {
@@ -106,20 +105,23 @@ export class TauriAdapter implements PlatformAdapter {
}
async checkForAppUpdate(): Promise<AppUpdateInfo | null> {
const update = await check()
if (!update?.available) return null
return {
version: update.version,
url: update.body ?? '',
notes: update.body,
}
const releases = await invoke<Array<{ tag_name: string; html_url: string; body: string }>>('list_releases')
const current = await getVersion()
const valid = releases.filter(r => r.tag_name?.trim())
if (!valid.length) return null
const parse = (v: string) => v.replace(/^v/, '').split('.').map(Number)
const latest = valid.map(r => r.tag_name).sort((a, b) => {
const pa = parse(a), pb = parse(b)
for (let i = 0; i < 3; i++) if ((pb[i] ?? 0) !== (pa[i] ?? 0)) return (pb[i] ?? 0) - (pa[i] ?? 0)
return 0
})[0]
const pa = parse(latest), pb = parse(current)
if (!pa.some((n, i) => n > (pb[i] ?? 0))) return null
const rel = valid.find(r => r.tag_name === latest)!
return { version: latest.replace(/^v/, ''), url: rel.html_url, notes: rel.body }
}
async installAppUpdate() {
const update = await check()
if (update?.available) {
await update.downloadAndInstall()
await relaunch()
}
async installAppUpdate(tag: string) {
await invoke('download_and_install_update', { tag })
}
}
+2 -1
View File
@@ -86,7 +86,7 @@ import {
mapDownloadItem,
mapCategory,
} from './types'
import { clearPageCache as _clearPageCache } from './pageCache'
import { initPageCache, clearPageCache as _clearPageCache } from './pageCache'
const SET_SOCKS_PROXY = `
mutation SetSocksProxy(
@@ -142,6 +142,7 @@ export class SuwayomiAdapter implements ServerAdapter {
const { username, password } = config.credentials
this.authHeader = 'Basic ' + btoa(`${username}:${password}`)
}
initPageCache(this.gql.bind(this), this.getServerUrl.bind(this))
}
getServerUrl(): string {
+15 -6
View File
@@ -1,7 +1,16 @@
import { gql, getServerUrl } from "$lib/server-adapters/suwayomi";
import { getBlobUrl, preloadBlobUrls } from "$lib/core/cache/imageCache";
import { dedupeRequest } from "$lib/core/async/batchRequests";
import { FETCH_CHAPTER_PAGES } from "$lib/server-adapters/suwayomi/chapters";
import { getBlobUrl, preloadBlobUrls } from "$lib/core/cache/imageCache";
import { dedupeRequest } from "$lib/core/async/batchRequests";
import { FETCH_CHAPTER_PAGES } from "$lib/server-adapters/suwayomi/chapters";
type GqlFn = <T>(query: string, vars?: Record<string, unknown>, signal?: AbortSignal) => Promise<T>;
let _gql: GqlFn;
let _getServerUrl: () => string;
export function initPageCache(gql: GqlFn, getServerUrl: () => string): void {
_gql = gql;
_getServerUrl = getServerUrl;
}
const pageCache = new Map<number, string[]>();
const inflight = new Map<number, Promise<string[]>>();
@@ -32,9 +41,9 @@ export function fetchPages(
if (!inflight.has(chapterId)) {
const p = dedupeRequest(`chapter-pages:${chapterId}`, () =>
gql<{ fetchChapterPages: { pages: string[] } }>(FETCH_CHAPTER_PAGES, { chapterId })
_gql<{ fetchChapterPages: { pages: string[] } }>(FETCH_CHAPTER_PAGES, { chapterId })
.then(d => {
const urls = d.fetchChapterPages.pages.map(p => p.startsWith("http") ? p : `${getServerUrl()}${p}`);
const urls = d.fetchChapterPages.pages.map(p => p.startsWith("http") ? p : `${_getServerUrl()}${p}`);
if (useBlob && urls[priorityPage]) getBlobUrl(urls[priorityPage], 999);
pageCache.set(chapterId, urls);
return urls;