mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-28 07:14:40 +08:00
feat(backup): restore starts automatically with loading overlay without closing dialog
This commit is contained in:
@@ -66,5 +66,6 @@
|
||||
- 保存 TUN 设置时优化执行流程,避免界面卡顿
|
||||
- 补充 `deb` / `rpm` 依赖 `libayatana-appindicator`
|
||||
- 「连接」表格标题的排序点击区域扩展到整列宽度
|
||||
- 备份恢复时显示加载覆盖层,恢复过程无需再手动关闭对话框
|
||||
|
||||
</details>
|
||||
|
||||
@@ -79,6 +79,7 @@ export const BackupHistoryViewer = ({
|
||||
const { verge } = useVerge();
|
||||
const [rows, setRows] = useState<BackupRow[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [isRestoring, setIsRestoring] = useState(false);
|
||||
const [isRestarting, setIsRestarting] = useState(false);
|
||||
const isLocal = source === "local";
|
||||
const isWebDavConfigured = Boolean(
|
||||
@@ -86,7 +87,7 @@ export const BackupHistoryViewer = ({
|
||||
);
|
||||
const shouldSkipWebDav = !isLocal && !isWebDavConfigured;
|
||||
const pageSize = 8;
|
||||
const isBusy = loading || isRestarting;
|
||||
const isBusy = loading || isRestoring || isRestarting;
|
||||
|
||||
const buildRow = useCallback(
|
||||
(item: ILocalBackupFile | IWebDavFile): BackupRow | null => {
|
||||
@@ -195,24 +196,32 @@ export const BackupHistoryViewer = ({
|
||||
});
|
||||
|
||||
const handleRestore = useLockFn(async (filename: string) => {
|
||||
if (isRestarting) return;
|
||||
if (isRestoring || isRestarting) return;
|
||||
if (
|
||||
!(await confirmAsync(t("settings.modals.backup.messages.confirmRestore")))
|
||||
)
|
||||
return;
|
||||
if (isLocal) {
|
||||
await restoreLocalBackup(filename);
|
||||
} else {
|
||||
await restoreWebDavBackup(filename);
|
||||
setIsRestoring(true);
|
||||
try {
|
||||
if (isLocal) {
|
||||
await restoreLocalBackup(filename);
|
||||
} else {
|
||||
await restoreWebDavBackup(filename);
|
||||
}
|
||||
showNotice.success("settings.modals.backup.messages.restoreSuccess");
|
||||
setIsRestarting(true);
|
||||
window.setTimeout(() => {
|
||||
void restartApp().catch((err: unknown) => {
|
||||
setIsRestarting(false);
|
||||
showNotice.error(err);
|
||||
});
|
||||
}, 1000);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
showNotice.error(error);
|
||||
} finally {
|
||||
setIsRestoring(false);
|
||||
}
|
||||
showNotice.success("settings.modals.backup.messages.restoreSuccess");
|
||||
setIsRestarting(true);
|
||||
window.setTimeout(() => {
|
||||
void restartApp().catch((err: unknown) => {
|
||||
setIsRestarting(false);
|
||||
showNotice.error(err);
|
||||
});
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
const handleExport = useLockFn(async (filename: string) => {
|
||||
|
||||
Reference in New Issue
Block a user