大幅优化同步

This commit is contained in:
JiangYingjin
2025-03-03 13:06:43 +08:00
parent 88f8ca822f
commit 3bc977cebd
6 changed files with 102 additions and 22 deletions

View File

@@ -1167,6 +1167,7 @@ function _Chat() {
const onDelete = (msgId: string) => {
deleteMessage(msgId);
syncStore.upload();
};
const onResend = (message: ChatMessage) => {

View File

@@ -28,6 +28,7 @@ import { AuthPage } from "./auth";
import { getClientConfig } from "../config/client";
import { type ClientApi, getClientApi } from "../client/api";
import { useAccessStore } from "../store";
import { useSyncStore } from "../store/sync";
import clsx from "clsx";
export function Loading(props: { noLogo?: boolean }) {
@@ -239,6 +240,8 @@ export function Home() {
return <Loading />;
}
useSyncStore.getState().download();
return (
<ErrorBoundary>
<Router>

View File

@@ -534,7 +534,22 @@ function SyncItems() {
text={Locale.UI.Overwrite}
onClick={async () => {
try {
await syncStore.overwrite();
await syncStore.upload();
showToast(Locale.Settings.Sync.Success);
} catch (e) {
showToast(Locale.Settings.Sync.Fail);
console.error("[Sync]", e);
}
}}
/>
)}
{couldSync && (
<IconButton
icon={<DownloadIcon />}
text={Locale.UI.Overwrite}
onClick={async () => {
try {
await syncStore.download();
showToast(Locale.Settings.Sync.Success);
} catch (e) {
showToast(Locale.Settings.Sync.Fail);
@@ -1408,7 +1423,10 @@ export function Settings() {
<IconButton
aria={Locale.UI.Close}
icon={<CloseIcon />}
onClick={() => navigate(Path.Home)}
onClick={() => {
navigate(Path.Home);
useSyncStore.getState().sync();
}}
bordered
/>
</div>