Demo

FileSystem

Mobile တွင် @capacitor/filesystem၊ desktop တွင် Electron bridge၊ web တွင် localStorage fallback ဖြင့် disk ကို ဝင်ရောက်အသုံးပြုနိုင်ပါသည်။

FileSystem

Mobile တွင် @capacitor/filesystem၊ desktop တွင် Electron bridge၊ web တွင် localStorage fallback ဖြင့် disk ကို ဝင်ရောက်အသုံးပြုနိုင်ပါသည်။

  • Methods: write(path, data), read(path), delete(path), exists(path), getUri(), stat()
  • Path နှင့် စွမ်းရည်များသည် platform အလိုက် ကွဲပြားပါသည် — ပစ်မှတ် runtime တွင် စမ်းသပ်ရပါသည်
TSXFileSystem — CRUD helper
1import { FileSystem, toast } from "@quan-erp/shared-frontend-core"; 2 3const DRAFT = "notes/draft.txt"; 4 5export async function saveDraft(text: string) { 6 const fs = FileSystem.instance; 7 try { 8 await fs.write(DRAFT, text); 9 } catch (e) { 10 toast.error((e as Error).message ?? "Write failed"); 11 } 12} 13 14export async function loadDraft() { 15 const fs = FileSystem.instance; 16 try { 17 if (!(await fs.exists(DRAFT))) return ""; 18 return await fs.read(DRAFT); 19 } catch (e) { 20 toast.error((e as Error).message ?? "Read failed"); 21 return ""; 22 } 23} 24 25export async function clearDraft() { 26 const fs = FileSystem.instance; 27 if (await fs.exists(DRAFT)) await fs.delete(DRAFT); 28} 29 30export async function draftMeta() { 31 const fs = FileSystem.instance; 32 const uri = await fs.getUri(); 33 const stat = await fs.stat(); 34 return { uri, stat }; 35}