From 7c23a39e7579d8ad0bc40dec33eeb415df1cc865 Mon Sep 17 00:00:00 2001 From: 04041b <65881086+04041b@users.noreply.github.com> Date: Thu, 12 Dec 2024 01:14:10 -0800 Subject: [PATCH] Revert "update api" This reverts commit cdec56e73190341df7b3ce31865057aad48566c6. --- app/components/exporter.tsx | 4 ++-- app/store/update.ts | 10 +++++----- app/utils.ts | 10 +++++----- app/utils/stream.ts | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/components/exporter.tsx b/app/components/exporter.tsx index a8836de21..79ae87be2 100644 --- a/app/components/exporter.tsx +++ b/app/components/exporter.tsx @@ -473,7 +473,7 @@ export function ImagePreviewer(props: { if (isMobile || (isApp && window.__TAURI__)) { if (isApp && window.__TAURI__) { - const result = await window.__TAURI__.core.dialog.save({ + const result = await window.__TAURI__.dialog.save({ defaultPath: `${props.topic}.png`, filters: [ { @@ -491,7 +491,7 @@ export function ImagePreviewer(props: { const response = await fetch(blob); const buffer = await response.arrayBuffer(); const uint8Array = new Uint8Array(buffer); - await window.__TAURI__.core.fs.writeBinaryFile(result, uint8Array); + await window.__TAURI__.fs.writeBinaryFile(result, uint8Array); showToast(Locale.Download.Success); } else { showToast(Locale.Download.Failed); diff --git a/app/store/update.ts b/app/store/update.ts index 38259bdd0..327dc5e88 100644 --- a/app/store/update.ts +++ b/app/store/update.ts @@ -89,22 +89,22 @@ export const useUpdateStore = createPersistStore( set(() => ({ remoteVersion: remoteId, })); - if (window.__TAURI__?.core.notification && isApp) { + if (window.__TAURI__?.notification && isApp) { // Check if notification permission is granted - await window.__TAURI__?.core.notification + await window.__TAURI__?.notification .isPermissionGranted() .then((granted) => { if (!granted) { return; } else { // Request permission to show notifications - window.__TAURI__?.core.notification + window.__TAURI__?.notification .requestPermission() .then((permission) => { if (permission === "granted") { if (version === remoteId) { // Show a notification using Tauri - window.__TAURI__?.core.notification.sendNotification({ + window.__TAURI__?.notification.sendNotification({ title: "NextChat", body: `${Locale.Settings.Update.IsLatest}`, icon: `${ChatGptIcon.src}`, @@ -114,7 +114,7 @@ export const useUpdateStore = createPersistStore( const updateMessage = Locale.Settings.Update.FoundUpdate(`${remoteId}`); // Show a notification for the new version using Tauri - window.__TAURI__?.core.notification.sendNotification({ + window.__TAURI__?.notification.sendNotification({ title: "NextChat", body: updateMessage, icon: `${ChatGptIcon.src}`, diff --git a/app/utils.ts b/app/utils.ts index 7f5fceaf0..b62bc126d 100644 --- a/app/utils.ts +++ b/app/utils.ts @@ -21,7 +21,7 @@ export function trimTopic(topic: string) { export async function copyToClipboard(text: string) { try { if (window.__TAURI__) { - window.__TAURI__.core.writeText(text); + window.__TAURI__.writeText(text); } else { await navigator.clipboard.writeText(text); } @@ -45,7 +45,7 @@ export async function copyToClipboard(text: string) { export async function downloadAs(text: string, filename: string) { if (window.__TAURI__) { - const result = await window.__TAURI__.core.dialog.save({ + const result = await window.__TAURI__.dialog.save({ defaultPath: `${filename}`, filters: [ { @@ -61,7 +61,7 @@ export async function downloadAs(text: string, filename: string) { if (result !== null) { try { - await window.__TAURI__.core.fs.writeTextFile(result, text); + await window.__TAURI__.fs.writeTextFile(result, text); showToast(Locale.Download.Success); } catch (error) { showToast(Locale.Download.Failed); @@ -396,11 +396,11 @@ export function getOperationId(operation: { export function clientUpdate() { // this a wild for updating client app - return window.__TAURI__?.core.updater + return window.__TAURI__?.updater .checkUpdate() .then((updateResult) => { if (updateResult.shouldUpdate) { - window.__TAURI__?.core.updater + window.__TAURI__?.updater .installUpdate() .then((result) => { showToast(Locale.Settings.Update.Success); diff --git a/app/utils/stream.ts b/app/utils/stream.ts index 9fea8c0c9..f15627188 100644 --- a/app/utils/stream.ts +++ b/app/utils/stream.ts @@ -47,7 +47,7 @@ export function fetch(url: string, options?: RequestInit): Promise { signal.addEventListener("abort", () => close()); } // @ts-ignore 2. listen response multi times, and write to Response.body - window.__TAURI__.core.event + window.__TAURI__.event .listen("stream-response", (e: ResponseEvent) => requestIdPromise.then((request_id) => { const { request_id: rid, chunk, status } = e?.payload || {};