chore: Remove console logs and clean up code

This commit removes unnecessary console.log statements and makes minor code cleanup in several files:
- PlantUML component
- WebSearchSettings
- WebSearchService
- Store settings

Additionally, it updates the store migration to handle LM Studio provider addition and reverts the store version
This commit is contained in:
kangfenmao 2025-02-25 13:25:22 +08:00
parent c7071a98f0
commit 68df5cd211
6 changed files with 24 additions and 11 deletions

View File

@ -136,9 +136,10 @@ const PlantUMLPopupCantaier: React.FC<PlantUMLPopupProps> = ({ resolve, diagram
png: false,
svg: false
})
const [activeTab, setActiveTab] = useState('preview')
const { t } = useTranslation()
console.log(`plantuml diagram: ${diagram}`)
const encodedDiagram = encodeDiagram(diagram)
const onOk = () => {
setOpen(false)

View File

@ -33,7 +33,6 @@ const WebSearchSettings: FC = () => {
useEffect(() => {
return () => {
console.log('apiKey', apiKey, provider.apiKey)
if (apiKey && apiKey !== provider.apiKey) {
updateProvider({ ...provider, apiKey })
}

View File

@ -25,14 +25,15 @@ class WebSearchService {
public async search(query: string) {
const searchWithTime = store.getState().websearch.searchWithTime
console.log('searchWithTime', searchWithTime)
let formatted_query = query
if (searchWithTime) {
formatted_query = `today is ${dayjs().format('YYYY-MM-DD')} \r\n ${query}`
}
console.log('formatted_query', formatted_query)
const provider = this.getWebSearchProvider()
const tvly = tavily({ apiKey: provider.apiKey })
return await tvly.search(formatted_query, {
maxResults: 5
})

View File

@ -32,7 +32,7 @@ const persistedReducer = persistReducer(
{
key: 'cherry-studio',
storage,
version: 73,
version: 72,
blacklist: ['runtime'],
migrate
},

View File

@ -1093,12 +1093,11 @@ const migrateConfig = {
state.minapps.enabled.push(app)
}
})
// remove zhihu-zhiada
state.minapps.enabled = state.minapps.enabled.filter((app) => app.id !== 'zhihu-zhiada')
state.minapps.disabled = state.minapps.disabled.filter((app) => app.id !== 'zhihu-zhiada')
}
// remove zhihu-zhiada
state.minapps.enabled = state.minapps.enabled.filter((app) => app.id !== 'zhihu-zhiada')
state.minapps.disabled = state.minapps.disabled.filter((app) => app.id !== 'zhihu-zhiada')
state.settings.thoughtAutoCollapse = true
return state
@ -1123,7 +1122,21 @@ const migrateConfig = {
return state
},
'73': (state: RootState) => {
state.websearch.searchWithTime = true
if (state.websearch) {
state.websearch.searchWithTime = true
}
if (!state.llm.providers.find((provider) => provider.id === 'lmstudio')) {
state.llm.providers.push({
id: 'lmstudio',
name: 'LM Studio',
type: 'openai',
apiKey: '',
apiHost: 'http://localhost:1234',
models: SYSTEM_MODELS.lmstudio,
isSystem: true,
enabled: false
})
}
return state
}
}

View File

@ -189,7 +189,6 @@ const settingsSlice = createSlice({
},
setWindowStyle: (state, action: PayloadAction<'transparent' | 'opaque'>) => {
state.windowStyle = action.payload
console.log(state.windowStyle)
},
setTopicPosition: (state, action: PayloadAction<'left' | 'right'>) => {
state.topicPosition = action.payload