mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-10 15:49:29 +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
e73f6505e9
commit
42bda59392
@ -137,7 +137,7 @@ const MainMenus: FC = () => {
|
|||||||
const { hideMinappPopup } = useMinappPopup()
|
const { hideMinappPopup } = useMinappPopup()
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { pathname } = useLocation()
|
const { pathname } = useLocation()
|
||||||
const { sidebarIcons } = useSettings()
|
const { sidebarIcons, defaultPaintingProvider } = useSettings()
|
||||||
const { minappShow } = useRuntime()
|
const { minappShow } = useRuntime()
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const { theme } = useTheme()
|
const { theme } = useTheme()
|
||||||
@ -158,7 +158,7 @@ const MainMenus: FC = () => {
|
|||||||
const pathMap = {
|
const pathMap = {
|
||||||
assistants: '/',
|
assistants: '/',
|
||||||
agents: '/agents',
|
agents: '/agents',
|
||||||
paintings: '/paintings',
|
paintings: `/paintings/${defaultPaintingProvider}`,
|
||||||
translate: '/translate',
|
translate: '/translate',
|
||||||
minapp: '/apps',
|
minapp: '/apps',
|
||||||
knowledge: '/knowledge',
|
knowledge: '/knowledge',
|
||||||
|
|||||||
@ -6,13 +6,13 @@ import {
|
|||||||
setAutoCheckUpdate as _setAutoCheckUpdate,
|
setAutoCheckUpdate as _setAutoCheckUpdate,
|
||||||
setLaunchOnBoot,
|
setLaunchOnBoot,
|
||||||
setLaunchToTray,
|
setLaunchToTray,
|
||||||
|
setPinTopicsToTop,
|
||||||
setSendMessageShortcut as _setSendMessageShortcut,
|
setSendMessageShortcut as _setSendMessageShortcut,
|
||||||
setSidebarIcons,
|
setSidebarIcons,
|
||||||
setTargetLanguage,
|
setTargetLanguage,
|
||||||
setTheme,
|
setTheme,
|
||||||
SettingsState,
|
SettingsState,
|
||||||
setTopicPosition,
|
setTopicPosition,
|
||||||
setPinTopicsToTop,
|
|
||||||
setTray as _setTray,
|
setTray as _setTray,
|
||||||
setTrayOnClose,
|
setTrayOnClose,
|
||||||
setWindowStyle
|
setWindowStyle
|
||||||
|
|||||||
@ -1,5 +1,8 @@
|
|||||||
import { FC } from 'react'
|
import { useAppDispatch } from '@renderer/store'
|
||||||
import { Route, Routes } from 'react-router-dom'
|
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 AihubmixPage from './AihubmixPage'
|
||||||
import DmxapiPage from './DmxapiPage'
|
import DmxapiPage from './DmxapiPage'
|
||||||
@ -8,9 +11,20 @@ import SiliconPage from './SiliconPage'
|
|||||||
const Options = ['aihubmix', 'silicon', 'dmxapi']
|
const Options = ['aihubmix', 'silicon', 'dmxapi']
|
||||||
|
|
||||||
const PaintingsRoutePage: FC = () => {
|
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 (
|
return (
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/" element={<AihubmixPage Options={Options} />} />
|
<Route path="*" element={<AihubmixPage Options={Options} />} />
|
||||||
<Route path="/aihubmix" element={<AihubmixPage Options={Options} />} />
|
<Route path="/aihubmix" element={<AihubmixPage Options={Options} />} />
|
||||||
<Route path="/silicon" element={<SiliconPage Options={Options} />} />
|
<Route path="/silicon" element={<SiliconPage Options={Options} />} />
|
||||||
<Route path="/dmxapi" element={<DmxapiPage Options={Options} />} />
|
<Route path="/dmxapi" element={<DmxapiPage Options={Options} />} />
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import {
|
|||||||
MathEngine,
|
MathEngine,
|
||||||
OpenAIServiceTier,
|
OpenAIServiceTier,
|
||||||
OpenAISummaryText,
|
OpenAISummaryText,
|
||||||
|
PaintingProvider,
|
||||||
ThemeMode,
|
ThemeMode,
|
||||||
TranslateLanguageVarious
|
TranslateLanguageVarious
|
||||||
} from '@renderer/types'
|
} from '@renderer/types'
|
||||||
@ -167,6 +168,7 @@ export interface SettingsState {
|
|||||||
backup: boolean
|
backup: boolean
|
||||||
knowledgeEmbed: boolean
|
knowledgeEmbed: boolean
|
||||||
}
|
}
|
||||||
|
defaultPaintingProvider: PaintingProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
export type MultiModelMessageStyle = 'horizontal' | 'vertical' | 'fold' | 'grid'
|
export type MultiModelMessageStyle = 'horizontal' | 'vertical' | 'fold' | 'grid'
|
||||||
@ -298,7 +300,8 @@ export const initialState: SettingsState = {
|
|||||||
assistant: false,
|
assistant: false,
|
||||||
backup: false,
|
backup: false,
|
||||||
knowledgeEmbed: false
|
knowledgeEmbed: false
|
||||||
}
|
},
|
||||||
|
defaultPaintingProvider: 'aihubmix'
|
||||||
}
|
}
|
||||||
|
|
||||||
const settingsSlice = createSlice({
|
const settingsSlice = createSlice({
|
||||||
@ -632,6 +635,9 @@ const settingsSlice = createSlice({
|
|||||||
},
|
},
|
||||||
setNotificationSettings: (state, action: PayloadAction<SettingsState['notification']>) => {
|
setNotificationSettings: (state, action: PayloadAction<SettingsState['notification']>) => {
|
||||||
state.notification = action.payload
|
state.notification = action.payload
|
||||||
|
},
|
||||||
|
setDefaultPaintingProvider: (state, action: PayloadAction<PaintingProvider>) => {
|
||||||
|
state.defaultPaintingProvider = action.payload
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -730,7 +736,8 @@ export const {
|
|||||||
setEnableBackspaceDeleteModel,
|
setEnableBackspaceDeleteModel,
|
||||||
setOpenAISummaryText,
|
setOpenAISummaryText,
|
||||||
setOpenAIServiceTier,
|
setOpenAIServiceTier,
|
||||||
setNotificationSettings
|
setNotificationSettings,
|
||||||
|
setDefaultPaintingProvider
|
||||||
} = settingsSlice.actions
|
} = settingsSlice.actions
|
||||||
|
|
||||||
export default settingsSlice.reducer
|
export default settingsSlice.reducer
|
||||||
|
|||||||
@ -185,6 +185,8 @@ export type PaintingParams = {
|
|||||||
files: FileType[]
|
files: FileType[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type PaintingProvider = 'aihubmix' | 'silicon' | 'dmxapi'
|
||||||
|
|
||||||
export interface Painting extends PaintingParams {
|
export interface Painting extends PaintingParams {
|
||||||
model?: string
|
model?: string
|
||||||
prompt?: string
|
prompt?: string
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user