Add runtime restore and temp asset cleanup

This commit is contained in:
2026-06-05 20:28:26 +08:00
parent 644a6f9d17
commit d41d9482c7
22 changed files with 1837 additions and 50 deletions
+46
View File
@@ -84,6 +84,7 @@ import {
pollTaskUntilSettled,
registerLocalAccount,
replacePlatformModels,
restoreModelRuntimeStatus,
setUserWalletBalance,
type HealthResponse,
updateAccessRule,
@@ -635,6 +636,50 @@ export function App() {
}
}
async function restoreRuntimeModel(platformModelId: string) {
setCoreState('loading');
setCoreMessage('');
try {
const restored = await restoreModelRuntimeStatus(token, platformModelId);
setModelRateLimits((current) => current.map((status) => {
if (status.platformId !== restored.platformId) return status;
return {
...status,
platformStatus: 'enabled',
platformCooldownUntil: undefined,
platformDisabledReason: undefined,
...(status.platformModelId === platformModelId
? {
enabled: restored.enabled,
modelCooldownUntil: restored.modelCooldownUntil,
}
: {}),
};
}));
setPlatforms((current) => current.map((platform) => platform.id === restored.platformId
? {
...platform,
status: 'enabled',
cooldownUntil: undefined,
}
: platform));
setModels((current) => current.map((model) => model.id === platformModelId
? {
...model,
enabled: true,
cooldownUntil: undefined,
}
: model));
invalidateDataKeys('modelCatalog', 'modelRateLimits', 'models', 'platforms', 'playgroundModels');
setCoreState('ready');
setCoreMessage('模型运行状态已恢复。');
} catch (err) {
setCoreState('error');
setCoreMessage(err instanceof Error ? err.message : '恢复模型运行状态失败');
throw err;
}
}
async function removePlatform(platformId: string) {
setCoreState('loading');
setCoreMessage('');
@@ -1143,6 +1188,7 @@ export function App() {
onResetBaseModel={resetBaseModelToDefault}
onSavePlatform={savePlatformWithModels}
onSavePlatformDynamicPriority={savePlatformDynamicPriority}
onRestoreRuntimeModel={restoreRuntimeModel}
onTogglePlatformStatus={savePlatformStatus}
onSaveProvider={saveProvider}
onSavePricingRuleSet={savePricingRuleSet}