Skip to content

Commit 571920a

Browse files
committed
update __TAURI__ api
1 parent 7c23a39 commit 571920a

3 files changed

Lines changed: 12 additions & 12 deletions

File tree

app/components/exporter.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ export function ImagePreviewer(props: {
473473

474474
if (isMobile || (isApp && window.__TAURI__)) {
475475
if (isApp && window.__TAURI__) {
476-
const result = await window.__TAURI__.dialog.save({
476+
const result = await window.__TAURI__.core.dialog.save({
477477
defaultPath: `${props.topic}.png`,
478478
filters: [
479479
{
@@ -491,7 +491,7 @@ export function ImagePreviewer(props: {
491491
const response = await fetch(blob);
492492
const buffer = await response.arrayBuffer();
493493
const uint8Array = new Uint8Array(buffer);
494-
await window.__TAURI__.fs.writeBinaryFile(result, uint8Array);
494+
await window.__TAURI__.core.fs.writeBinaryFile(result, uint8Array);
495495
showToast(Locale.Download.Success);
496496
} else {
497497
showToast(Locale.Download.Failed);

app/store/update.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,22 +89,22 @@ export const useUpdateStore = createPersistStore(
8989
set(() => ({
9090
remoteVersion: remoteId,
9191
}));
92-
if (window.__TAURI__?.notification && isApp) {
92+
if (window.__TAURI__?.core.notification && isApp) {
9393
// Check if notification permission is granted
94-
await window.__TAURI__?.notification
94+
await window.__TAURI__?.core.notification
9595
.isPermissionGranted()
9696
.then((granted) => {
9797
if (!granted) {
9898
return;
9999
} else {
100100
// Request permission to show notifications
101-
window.__TAURI__?.notification
101+
window.__TAURI__?.core.notification
102102
.requestPermission()
103103
.then((permission) => {
104104
if (permission === "granted") {
105105
if (version === remoteId) {
106106
// Show a notification using Tauri
107-
window.__TAURI__?.notification.sendNotification({
107+
window.__TAURI__?.core.notification.sendNotification({
108108
title: "NextChat",
109109
body: `${Locale.Settings.Update.IsLatest}`,
110110
icon: `${ChatGptIcon.src}`,
@@ -114,7 +114,7 @@ export const useUpdateStore = createPersistStore(
114114
const updateMessage =
115115
Locale.Settings.Update.FoundUpdate(`${remoteId}`);
116116
// Show a notification for the new version using Tauri
117-
window.__TAURI__?.notification.sendNotification({
117+
window.__TAURI__?.core.notification.sendNotification({
118118
title: "NextChat",
119119
body: updateMessage,
120120
icon: `${ChatGptIcon.src}`,

app/utils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function trimTopic(topic: string) {
2121
export async function copyToClipboard(text: string) {
2222
try {
2323
if (window.__TAURI__) {
24-
window.__TAURI__.writeText(text);
24+
window.__TAURI__.core.writeText(text);
2525
} else {
2626
await navigator.clipboard.writeText(text);
2727
}
@@ -45,7 +45,7 @@ export async function copyToClipboard(text: string) {
4545

4646
export async function downloadAs(text: string, filename: string) {
4747
if (window.__TAURI__) {
48-
const result = await window.__TAURI__.dialog.save({
48+
const result = await window.__TAURI__.core.dialog.save({
4949
defaultPath: `${filename}`,
5050
filters: [
5151
{
@@ -61,7 +61,7 @@ export async function downloadAs(text: string, filename: string) {
6161

6262
if (result !== null) {
6363
try {
64-
await window.__TAURI__.fs.writeTextFile(result, text);
64+
await window.__TAURI__.core.fs.writeTextFile(result, text);
6565
showToast(Locale.Download.Success);
6666
} catch (error) {
6767
showToast(Locale.Download.Failed);
@@ -396,11 +396,11 @@ export function getOperationId(operation: {
396396

397397
export function clientUpdate() {
398398
// this a wild for updating client app
399-
return window.__TAURI__?.updater
399+
return window.__TAURI__?.core.updater
400400
.checkUpdate()
401401
.then((updateResult) => {
402402
if (updateResult.shouldUpdate) {
403-
window.__TAURI__?.updater
403+
window.__TAURI__?.core.updater
404404
.installUpdate()
405405
.then((result) => {
406406
showToast(Locale.Settings.Update.Success);

0 commit comments

Comments
 (0)