feat: update migration logic and increment version for store

- Incremented version in the store configuration from 161 to 162.
- Updated migration logic to handle new provider integration and state adjustments.
- Removed deprecated migration logic for version 161.
This commit is contained in:
kangfenmao 2025-10-11 16:16:09 +08:00
parent a000ff2a1a
commit ee4c310725
2 changed files with 19 additions and 20 deletions

View File

@ -65,7 +65,7 @@ const persistedReducer = persistReducer(
{ {
key: 'cherry-studio', key: 'cherry-studio',
storage, storage,
version: 161, version: 162,
blacklist: ['runtime', 'messages', 'messageBlocks', 'tabs'], blacklist: ['runtime', 'messages', 'messageBlocks', 'tabs'],
migrate migrate
}, },

View File

@ -2597,16 +2597,30 @@ const migrateConfig = {
return state return state
} }
}, },
'160': (state: RootState) => { '161': (state: RootState) => {
try {
removeMiniAppFromState(state, 'nm-search')
removeMiniAppFromState(state, 'hika')
removeMiniAppFromState(state, 'hugging-chat')
addProvider(state, 'cherryin')
state.llm.providers = moveProvider(state.llm.providers, 'cherryin', 1)
return state
} catch (error) {
logger.error('migrate 161 error', error as Error)
return state
}
},
'162': (state: RootState) => {
try { try {
// @ts-ignore // @ts-ignore
if (state?.agents?.agents) { if (state?.agents?.agents) {
// @ts-ignore // @ts-ignore
state.assistants.presets = [...state.agents.agents] state.assistants.presets = [...state.agents.agents]
// @ts-ignore // @ts-ignore
delete state.agents.agents delete state.agents.agents
}
if (state.settings.sidebarIcons) {
state.settings.sidebarIcons.visible = state.settings.sidebarIcons.visible.map((icon) => { state.settings.sidebarIcons.visible = state.settings.sidebarIcons.visible.map((icon) => {
// @ts-ignore // @ts-ignore
return icon === 'agents' ? 'store' : icon return icon === 'agents' ? 'store' : icon
@ -2616,6 +2630,7 @@ const migrateConfig = {
return icon === 'agents' ? 'store' : icon return icon === 'agents' ? 'store' : icon
}) })
} }
state.llm.providers.forEach((provider) => { state.llm.providers.forEach((provider) => {
if (provider.anthropicApiHost) { if (provider.anthropicApiHost) {
return return
@ -2643,29 +2658,13 @@ const migrateConfig = {
case 'new-api': case 'new-api':
provider.anthropicApiHost = 'http://localhost:3000' provider.anthropicApiHost = 'http://localhost:3000'
break break
case 'cherryai':
provider.anthropicApiHost = 'https://api.cherry-ai.com'
break
case 'grok': case 'grok':
provider.anthropicApiHost = 'https://api.x.ai' provider.anthropicApiHost = 'https://api.x.ai'
} }
}) })
return state return state
} catch (error) { } catch (error) {
logger.error('migrate 160 error', error as Error) logger.error('migrate 162 error', error as Error)
return state
}
},
'161': (state: RootState) => {
try {
removeMiniAppFromState(state, 'nm-search')
removeMiniAppFromState(state, 'hika')
removeMiniAppFromState(state, 'hugging-chat')
addProvider(state, 'cherryin')
state.llm.providers = moveProvider(state.llm.providers, 'cherryin', 1)
return state
} catch (error) {
logger.error('migrate 161 error', error as Error)
return state return state
} }
} }