desktop: corrigir build (remover uso de @tauri-apps/api/fs e StoreOptions.dir)
- Usa Store.load com caminho absoluto em C:\Raven\data quando possível; fallback para AppData - Remove import de fs (plugin) e opção 'dir' não suportada pelo plugin-store v2
This commit is contained in:
parent
7bc8a1d945
commit
737c737be6
1 changed files with 11 additions and 15 deletions
|
|
@ -4,7 +4,6 @@ import { createRoot } from "react-dom/client"
|
||||||
import { invoke } from "@tauri-apps/api/core"
|
import { invoke } from "@tauri-apps/api/core"
|
||||||
import { Store } from "@tauri-apps/plugin-store"
|
import { Store } from "@tauri-apps/plugin-store"
|
||||||
import { appLocalDataDir, executableDir, join } from "@tauri-apps/api/path"
|
import { appLocalDataDir, executableDir, join } from "@tauri-apps/api/path"
|
||||||
import { createDir, exists } from "@tauri-apps/api/fs"
|
|
||||||
import { ExternalLink, Eye, EyeOff, GalleryVerticalEnd, Loader2, RefreshCw } from "lucide-react"
|
import { ExternalLink, Eye, EyeOff, GalleryVerticalEnd, Loader2, RefreshCw } from "lucide-react"
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "./components/ui/tabs"
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "./components/ui/tabs"
|
||||||
import { cn } from "./lib/utils"
|
import { cn } from "./lib/utils"
|
||||||
|
|
@ -104,21 +103,18 @@ function normalizeUrl(value?: string | null, fallback = DEFAULT_APP_URL) {
|
||||||
const appUrl = normalizeUrl(import.meta.env.VITE_APP_URL, DEFAULT_APP_URL)
|
const appUrl = normalizeUrl(import.meta.env.VITE_APP_URL, DEFAULT_APP_URL)
|
||||||
const apiBaseUrl = normalizeUrl(import.meta.env.VITE_API_BASE_URL, appUrl)
|
const apiBaseUrl = normalizeUrl(import.meta.env.VITE_API_BASE_URL, appUrl)
|
||||||
|
|
||||||
async function resolveDataDir(): Promise<string> {
|
|
||||||
try {
|
|
||||||
const exe = await executableDir()
|
|
||||||
const dir = await join(exe, "data")
|
|
||||||
const ok = await exists(dir).catch(() => false)
|
|
||||||
if (!ok) await createDir(dir, { recursive: true })
|
|
||||||
return dir
|
|
||||||
} catch {
|
|
||||||
return await appLocalDataDir()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadStore(): Promise<Store> {
|
async function loadStore(): Promise<Store> {
|
||||||
const dir = await resolveDataDir()
|
// Tenta usar uma pasta "data" ao lado do executável (ex.: C:\Raven\data)
|
||||||
return await Store.load(STORE_FILENAME, { dir })
|
try {
|
||||||
|
const exeDir = await executableDir()
|
||||||
|
const storePath = await join(exeDir, "data", STORE_FILENAME)
|
||||||
|
return await Store.load(storePath)
|
||||||
|
} catch {
|
||||||
|
// Fallback: AppData local do usuário
|
||||||
|
const appData = await appLocalDataDir()
|
||||||
|
const storePath = await join(appData, STORE_FILENAME)
|
||||||
|
return await Store.load(storePath)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function readToken(store: Store): Promise<string | null> {
|
async function readToken(store: Store): Promise<string | null> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue