Skip to content

Commit 656acae

Browse files
committed
fix: exports in Desktop builds
The way a Tauri app checks for the running environment has changed between the Tauri versions 1 and 2. In the previous 2.0 builds, this was not updated causing the regression of exports not working. This commit checks the correct value - window.__TAURI_INTERNALS__ to fix that issue. Ref: #129
1 parent 4a4b1f6 commit 656acae

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/components/menubar/utils.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,7 @@ import { invoke } from "@tauri-apps/api/core";
33
import { documentDir } from "@tauri-apps/api/path";
44

55
export const exportFile = async (content, filename) => {
6-
if (typeof window.rpc === "undefined") {
7-
let element = document.createElement("a");
8-
element.setAttribute(
9-
"href",
10-
"data:text/plain;charset=utf-8," + encodeURIComponent(content)
11-
);
12-
element.setAttribute("download", filename);
13-
element.style.display = "none";
14-
document.body.appendChild(element);
15-
element.click();
16-
document.body.removeChild(element);
17-
} else {
6+
if (window.__TAURI_INTERNALS__) {
187
save({
198
defaultPath: await documentDir(),
209
filters: [
@@ -31,5 +20,16 @@ export const exportFile = async (content, filename) => {
3120
.catch((e) => alert(e));
3221
})
3322
.catch(() => {});
23+
} else {
24+
let element = document.createElement("a");
25+
element.setAttribute(
26+
"href",
27+
"data:text/plain;charset=utf-8," + encodeURIComponent(content)
28+
);
29+
element.setAttribute("download", filename);
30+
element.style.display = "none";
31+
document.body.appendChild(element);
32+
element.click();
33+
document.body.removeChild(element);
3434
}
3535
};

0 commit comments

Comments
 (0)