fix: persisted available models ard not be update after source code have been updated

This commit is contained in:
skymkmk 2024-09-16 02:06:17 +08:00
parent 027e5adf67
commit 9e1e0a7252
No known key found for this signature in database
GPG Key ID: 6F4CA5A97C68BD71
1 changed files with 15 additions and 0 deletions

View File

@ -143,6 +143,21 @@ export const useAppConfig = createPersistStore(
{
name: StoreKey.Config,
version: 4,
merge(persistedState, currentState) {
const state = persistedState as ChatConfig | undefined;
if (!state) return { ...currentState };
const models = currentState.models.slice();
state.models.forEach((pModel) => {
const idx = models.findIndex(
(v) => v.name === pModel.name && v.provider === pModel.provider,
);
if (idx !== -1) models[idx] = pModel;
else models.push(pModel);
});
return { ...currentState, ...state, models: models };
},
migrate(persistedState, version) {
const state = persistedState as ChatConfig;