File size: 663 Bytes
50fe3c9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | import { revealItemInDir } from "@tauri-apps/plugin-opener";
export async function copyToClipboard(text: string): Promise<void> {
try {
await navigator.clipboard.writeText(text);
} catch {
// Best-effort; ignore in environments without clipboard permission.
}
}
export function relativePath(rootPath: string, path: string): string {
if (path === rootPath) return ".";
if (path.startsWith(`${rootPath}/`)) return path.slice(rootPath.length + 1);
return path;
}
export async function revealInFinder(path: string): Promise<void> {
try {
await revealItemInDir(path);
} catch (e) {
console.error("revealItemInDir failed:", e);
}
}
|