update api
This commit is contained in:
parent
be9c6e5c26
commit
cdec56e731
|
@ -473,7 +473,7 @@ export function ImagePreviewer(props: {
|
|||
|
||||
if (isMobile || (isApp && window.__TAURI__)) {
|
||||
if (isApp && window.__TAURI__) {
|
||||
const result = await window.__TAURI__.dialog.save({
|
||||
const result = await window.__TAURI__.core.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__.fs.writeBinaryFile(result, uint8Array);
|
||||
await window.__TAURI__.core.fs.writeBinaryFile(result, uint8Array);
|
||||
showToast(Locale.Download.Success);
|
||||
} else {
|
||||
showToast(Locale.Download.Failed);
|
||||
|
|
|
@ -89,22 +89,22 @@ export const useUpdateStore = createPersistStore(
|
|||
set(() => ({
|
||||
remoteVersion: remoteId,
|
||||
}));
|
||||
if (window.__TAURI__?.notification && isApp) {
|
||||
if (window.__TAURI__?.core.notification && isApp) {
|
||||
// Check if notification permission is granted
|
||||
await window.__TAURI__?.notification
|
||||
await window.__TAURI__?.core.notification
|
||||
.isPermissionGranted()
|
||||
.then((granted) => {
|
||||
if (!granted) {
|
||||
return;
|
||||
} else {
|
||||
// Request permission to show notifications
|
||||
window.__TAURI__?.notification
|
||||
window.__TAURI__?.core.notification
|
||||
.requestPermission()
|
||||
.then((permission) => {
|
||||
if (permission === "granted") {
|
||||
if (version === remoteId) {
|
||||
// Show a notification using Tauri
|
||||
window.__TAURI__?.notification.sendNotification({
|
||||
window.__TAURI__?.core.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__?.notification.sendNotification({
|
||||
window.__TAURI__?.core.notification.sendNotification({
|
||||
title: "NextChat",
|
||||
body: updateMessage,
|
||||
icon: `${ChatGptIcon.src}`,
|
||||
|
|
10
app/utils.ts
10
app/utils.ts
|
@ -21,7 +21,7 @@ export function trimTopic(topic: string) {
|
|||
export async function copyToClipboard(text: string) {
|
||||
try {
|
||||
if (window.__TAURI__) {
|
||||
window.__TAURI__.writeText(text);
|
||||
window.__TAURI__.core.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__.dialog.save({
|
||||
const result = await window.__TAURI__.core.dialog.save({
|
||||
defaultPath: `${filename}`,
|
||||
filters: [
|
||||
{
|
||||
|
@ -61,7 +61,7 @@ export async function downloadAs(text: string, filename: string) {
|
|||
|
||||
if (result !== null) {
|
||||
try {
|
||||
await window.__TAURI__.fs.writeTextFile(result, text);
|
||||
await window.__TAURI__.core.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__?.updater
|
||||
return window.__TAURI__?.core.updater
|
||||
.checkUpdate()
|
||||
.then((updateResult) => {
|
||||
if (updateResult.shouldUpdate) {
|
||||
window.__TAURI__?.updater
|
||||
window.__TAURI__?.core.updater
|
||||
.installUpdate()
|
||||
.then((result) => {
|
||||
showToast(Locale.Settings.Update.Success);
|
||||
|
|
|
@ -47,7 +47,7 @@ export function fetch(url: string, options?: RequestInit): Promise<Response> {
|
|||
signal.addEventListener("abort", () => close());
|
||||
}
|
||||
// @ts-ignore 2. listen response multi times, and write to Response.body
|
||||
window.__TAURI__.event
|
||||
window.__TAURI__.core.event
|
||||
.listen("stream-response", (e: ResponseEvent) =>
|
||||
requestIdPromise.then((request_id) => {
|
||||
const { request_id: rid, chunk, status } = e?.payload || {};
|
||||
|
|
Loading…
Reference in New Issue