mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-27 12:51:26 +08:00
feat: add default painting provider support and update routing
- Introduced defaultPaintingProvider in settings to manage selected painting provider. - Updated Sidebar component to reflect the selected painting provider in the route. - Enhanced PaintingsRoutePage to dispatch the default painting provider based on URL parameters. - Added PaintingProvider type to define available options for painting providers.
This commit is contained in:
parent
4eaf6fdf15
commit
2642b8f693
@ -137,7 +137,7 @@ const MainMenus: FC = () => {
|
||||
const { hideMinappPopup } = useMinappPopup()
|
||||
const { t } = useTranslation()
|
||||
const { pathname } = useLocation()
|
||||
const { sidebarIcons } = useSettings()
|
||||
const { sidebarIcons, defaultPaintingProvider } = useSettings()
|
||||
const { minappShow } = useRuntime()
|
||||
const navigate = useNavigate()
|
||||
const { theme } = useTheme()
|
||||
@ -158,7 +158,7 @@ const MainMenus: FC = () => {
|
||||
const pathMap = {
|
||||
assistants: '/',
|
||||
agents: '/agents',
|
||||
paintings: '/paintings',
|
||||
paintings: `/paintings/${defaultPaintingProvider}`,
|
||||
translate: '/translate',
|
||||
minapp: '/apps',
|
||||
knowledge: '/knowledge',
|
||||
|
||||
@ -6,13 +6,13 @@ import {
|
||||
setAutoCheckUpdate as _setAutoCheckUpdate,
|
||||
setLaunchOnBoot,
|
||||
setLaunchToTray,
|
||||
setPinTopicsToTop,
|
||||
setSendMessageShortcut as _setSendMessageShortcut,
|
||||
setSidebarIcons,
|
||||
setTargetLanguage,
|
||||
setTheme,
|
||||
SettingsState,
|
||||
setTopicPosition,
|
||||
setPinTopicsToTop,
|
||||
setTray as _setTray,
|
||||
setTrayOnClose,
|
||||
setWindowStyle
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
import { FC } from 'react'
|
||||
import { Route, Routes } from 'react-router-dom'
|
||||
import { useAppDispatch } from '@renderer/store'
|
||||
import { setDefaultPaintingProvider } from '@renderer/store/settings'
|
||||
import { PaintingProvider } from '@renderer/types'
|
||||
import { FC, useEffect } from 'react'
|
||||
import { Route, Routes, useParams } from 'react-router-dom'
|
||||
|
||||
import AihubmixPage from './AihubmixPage'
|
||||
import DmxapiPage from './DmxapiPage'
|
||||
@ -8,9 +11,20 @@ import SiliconPage from './SiliconPage'
|
||||
const Options = ['aihubmix', 'silicon', 'dmxapi']
|
||||
|
||||
const PaintingsRoutePage: FC = () => {
|
||||
const params = useParams()
|
||||
const provider = params['*']
|
||||
const dispatch = useAppDispatch()
|
||||
|
||||
useEffect(() => {
|
||||
console.debug('defaultPaintingProvider', provider)
|
||||
if (provider && Options.includes(provider)) {
|
||||
dispatch(setDefaultPaintingProvider(provider as PaintingProvider))
|
||||
}
|
||||
}, [provider, dispatch])
|
||||
|
||||
return (
|
||||
<Routes>
|
||||
<Route path="/" element={<AihubmixPage Options={Options} />} />
|
||||
<Route path="*" element={<AihubmixPage Options={Options} />} />
|
||||
<Route path="/aihubmix" element={<AihubmixPage Options={Options} />} />
|
||||
<Route path="/silicon" element={<SiliconPage Options={Options} />} />
|
||||
<Route path="/dmxapi" element={<DmxapiPage Options={Options} />} />
|
||||
|
||||
@ -6,6 +6,7 @@ import {
|
||||
MathEngine,
|
||||
OpenAIServiceTier,
|
||||
OpenAISummaryText,
|
||||
PaintingProvider,
|
||||
ThemeMode,
|
||||
TranslateLanguageVarious
|
||||
} from '@renderer/types'
|
||||
@ -167,6 +168,7 @@ export interface SettingsState {
|
||||
backup: boolean
|
||||
knowledgeEmbed: boolean
|
||||
}
|
||||
defaultPaintingProvider: PaintingProvider
|
||||
}
|
||||
|
||||
export type MultiModelMessageStyle = 'horizontal' | 'vertical' | 'fold' | 'grid'
|
||||
@ -298,7 +300,8 @@ export const initialState: SettingsState = {
|
||||
assistant: false,
|
||||
backup: false,
|
||||
knowledgeEmbed: false
|
||||
}
|
||||
},
|
||||
defaultPaintingProvider: 'aihubmix'
|
||||
}
|
||||
|
||||
const settingsSlice = createSlice({
|
||||
@ -632,6 +635,9 @@ const settingsSlice = createSlice({
|
||||
},
|
||||
setNotificationSettings: (state, action: PayloadAction<SettingsState['notification']>) => {
|
||||
state.notification = action.payload
|
||||
},
|
||||
setDefaultPaintingProvider: (state, action: PayloadAction<PaintingProvider>) => {
|
||||
state.defaultPaintingProvider = action.payload
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -730,7 +736,8 @@ export const {
|
||||
setEnableBackspaceDeleteModel,
|
||||
setOpenAISummaryText,
|
||||
setOpenAIServiceTier,
|
||||
setNotificationSettings
|
||||
setNotificationSettings,
|
||||
setDefaultPaintingProvider
|
||||
} = settingsSlice.actions
|
||||
|
||||
export default settingsSlice.reducer
|
||||
|
||||
@ -185,6 +185,8 @@ export type PaintingParams = {
|
||||
files: FileType[]
|
||||
}
|
||||
|
||||
export type PaintingProvider = 'aihubmix' | 'silicon' | 'dmxapi'
|
||||
|
||||
export interface Painting extends PaintingParams {
|
||||
model?: string
|
||||
prompt?: string
|
||||
|
||||
Loading…
Reference in New Issue
Block a user