Bump release version and snapshot startup state
This commit is contained in:
@@ -43,6 +43,15 @@ export interface SavedStateResponse {
|
||||
generatedConfigPath: string;
|
||||
}
|
||||
|
||||
export interface StartupSnapshotResponse {
|
||||
adminStatus: AdminStatusResponse;
|
||||
savedState: SavedStateResponse;
|
||||
components: ComponentStatus[];
|
||||
proxifyreSetupStatus: ProxiFyreSetupStatus;
|
||||
singboxStatus: LocalSingBoxStatusResponse;
|
||||
singboxSetupStatus: SingBoxSetupStatus;
|
||||
}
|
||||
|
||||
export interface ProxiFyreSetupItem {
|
||||
id: string;
|
||||
name: string;
|
||||
@@ -150,6 +159,10 @@ export function restartAsAdmin(): Promise<void> {
|
||||
return invoke<void>('restart_as_admin');
|
||||
}
|
||||
|
||||
export function getStartupSnapshot(): Promise<StartupSnapshotResponse> {
|
||||
return invoke<StartupSnapshotResponse>('get_startup_snapshot');
|
||||
}
|
||||
|
||||
export function getSavedState(): Promise<SavedStateResponse> {
|
||||
return invoke<SavedStateResponse>('get_saved_state');
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@ import {
|
||||
fetchSingBoxSubscription,
|
||||
forgetSingBoxSubscription,
|
||||
generateSingBoxConfig,
|
||||
getAdminStatus,
|
||||
getComponents,
|
||||
getProxiFyreSetupStatus,
|
||||
getSavedState,
|
||||
getSingBoxSetupStatus,
|
||||
getSingBoxStatus,
|
||||
getStartupSnapshot,
|
||||
installProxiFyre,
|
||||
installSingBox,
|
||||
pingAllSingBoxServers,
|
||||
@@ -268,11 +268,21 @@ export function App() {
|
||||
}, [activeLogId]);
|
||||
|
||||
async function refresh() {
|
||||
void refreshAdminStatus();
|
||||
setIsLoading(true);
|
||||
setIsDetectingComponents(true);
|
||||
try {
|
||||
const saved = await getSavedState();
|
||||
applySavedState(saved.profiles, saved.targets, saved.generatedConfigPath);
|
||||
const snapshot = await getStartupSnapshot();
|
||||
setAdminStatus(snapshot.adminStatus);
|
||||
setComponents(snapshot.components);
|
||||
setSetupStatus(snapshot.proxifyreSetupStatus);
|
||||
setSingBoxStatus(snapshot.singboxStatus);
|
||||
setSingBoxSetupStatus(snapshot.singboxSetupStatus);
|
||||
applySavedState(
|
||||
snapshot.savedState.profiles,
|
||||
snapshot.savedState.targets,
|
||||
snapshot.savedState.generatedConfigPath,
|
||||
snapshot.singboxStatus,
|
||||
);
|
||||
} catch {
|
||||
showNotice({
|
||||
kind: 'info',
|
||||
@@ -281,17 +291,7 @@ export function App() {
|
||||
});
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
|
||||
void refreshComponents();
|
||||
}
|
||||
|
||||
async function refreshAdminStatus() {
|
||||
try {
|
||||
const status = await getAdminStatus();
|
||||
setAdminStatus(status);
|
||||
} catch {
|
||||
setAdminStatus(null);
|
||||
setIsDetectingComponents(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,37 +310,6 @@ export function App() {
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshComponents() {
|
||||
setIsDetectingComponents(true);
|
||||
try {
|
||||
const [detectedComponents, detectedSetupStatus, detectedSingBoxStatus, detectedSingBoxSetupStatus] = await Promise.all([
|
||||
getComponents(),
|
||||
getProxiFyreSetupStatus(),
|
||||
getSingBoxStatus(),
|
||||
getSingBoxSetupStatus(),
|
||||
]);
|
||||
setComponents(detectedComponents);
|
||||
setSetupStatus(detectedSetupStatus);
|
||||
setSingBoxStatus(detectedSingBoxStatus);
|
||||
setSingBoxSetupStatus(detectedSingBoxSetupStatus);
|
||||
setAppliedSnapshot((current) => {
|
||||
if (!current || current.routeMode !== 'local-singbox' || current.selectedServerTag) return current;
|
||||
return {
|
||||
...current,
|
||||
selectedServerTag: normalizeServerTag(detectedSingBoxStatus.config.selectedServerTag),
|
||||
};
|
||||
});
|
||||
} catch (error) {
|
||||
showNotice({
|
||||
kind: 'error',
|
||||
title: 'Компоненты не проверены',
|
||||
text: errorMessage(error),
|
||||
});
|
||||
} finally {
|
||||
setIsDetectingComponents(false);
|
||||
}
|
||||
}
|
||||
|
||||
function applySavedState(
|
||||
profiles: Profile[],
|
||||
targets: Target[],
|
||||
|
||||
Reference in New Issue
Block a user