Fix polyfill

This commit is contained in:
Skyler Lehmkuhl 2025-01-14 20:31:25 -05:00
parent 6617ffa87d
commit 542892cb7b
1 changed files with 18 additions and 3 deletions

View File

@ -52,7 +52,22 @@ if (!window.__TAURI__) {
invoke: () => {} invoke: () => {}
}, },
fs: { fs: {
writeFile: () => {}, writeFile: () => {
// Create a Blob from the contents
const blob = new Blob([contents]);
const link = document.createElement('a');
const url = URL.createObjectURL(blob);
link.href = url;
link.download = path; // Use the file name from the path
document.body.appendChild(link);
link.click();
// Clean up by removing the link and revoking the object URL
document.body.removeChild(link);
URL.revokeObjectURL(url);
},
readFile: () => {}, readFile: () => {},
writeTextFile: async (path, contents) => { writeTextFile: async (path, contents) => {
// Create a Blob from the contents // Create a Blob from the contents
@ -176,9 +191,9 @@ if (!window.__TAURI__) {
confirm: () => {}, confirm: () => {},
}, },
path: { path: {
documentDir: () => {}, documentDir: () => "/Documents",
join: (...segments) => { join: (...segments) => {
return segments.filter(segment => segment.length > 0) // Remove empty strings return segments.filter(segment => (segment && segment.length > 0)) // Remove empty strings
.join('/') .join('/')
}, },
basename: (path) => { basename: (path) => {