fix: default assistant name empty
This commit is contained in:
parent
b487c68822
commit
ec49cf61d6
@ -94,7 +94,9 @@ app.whenReady().then(() => {
|
|||||||
.then((name) => console.log(`Added Extension: ${name}`))
|
.then((name) => console.log(`Added Extension: ${name}`))
|
||||||
.catch((err) => console.log('An error occurred: ', err))
|
.catch((err) => console.log('An error occurred: ', err))
|
||||||
|
|
||||||
setTimeout(() => new AppUpdater(), 3000)
|
if (app.isPackaged) {
|
||||||
|
setTimeout(() => new AppUpdater(), 3000)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// Quit when all windows are closed, except on macOS. There, it's common
|
// Quit when all windows are closed, except on macOS. There, it's common
|
||||||
|
|||||||
@ -225,7 +225,7 @@ const resources = {
|
|||||||
|
|
||||||
i18n.use(initReactI18next).init({
|
i18n.use(initReactI18next).init({
|
||||||
resources,
|
resources,
|
||||||
lng: localStorage.getItem('language') || 'en-US',
|
lng: localStorage.getItem('language') || navigator.language || 'en-US',
|
||||||
fallbackLng: 'en-US',
|
fallbackLng: 'en-US',
|
||||||
interpolation: {
|
interpolation: {
|
||||||
escapeValue: false
|
escapeValue: false
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
import changelogEn from '@renderer/assets/changelog/CHANGELOG.en.md?raw'
|
import changelogEn from '@renderer/assets/changelog/CHANGELOG.en.md?raw'
|
||||||
import changelogZh from '@renderer/assets/changelog/CHANGELOG.zh.md?raw'
|
import changelogZh from '@renderer/assets/changelog/CHANGELOG.zh.md?raw'
|
||||||
import i18next from 'i18next'
|
|
||||||
import { FC } from 'react'
|
import { FC } from 'react'
|
||||||
import Markdown from 'react-markdown'
|
import Markdown from 'react-markdown'
|
||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
import styles from '@renderer/assets/styles/changelog.module.scss'
|
import styles from '@renderer/assets/styles/changelog.module.scss'
|
||||||
|
import i18n from '@renderer/i18n'
|
||||||
|
|
||||||
const Changelog: FC = () => {
|
const Changelog: FC = () => {
|
||||||
const language = i18next.language
|
const language = i18n.language
|
||||||
const changelog = language === 'zh-CN' ? changelogZh : changelogEn
|
const changelog = language === 'zh-CN' ? changelogZh : changelogEn
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
import { Assistant, Model, Provider, Topic } from '@renderer/types'
|
import { Assistant, Model, Provider, Topic } from '@renderer/types'
|
||||||
import store from '@renderer/store'
|
import store from '@renderer/store'
|
||||||
import { uuid } from '@renderer/utils'
|
import { uuid } from '@renderer/utils'
|
||||||
import i18next from 'i18next'
|
import i18n from '@renderer/i18n'
|
||||||
|
|
||||||
export function getDefaultAssistant(): Assistant {
|
export function getDefaultAssistant(): Assistant {
|
||||||
return {
|
return {
|
||||||
id: 'default',
|
id: 'default',
|
||||||
name: i18next.t('assistant.default.name'),
|
name: i18n.t('assistant.default.name'),
|
||||||
prompt: '',
|
prompt: '',
|
||||||
topics: [getDefaultTopic()]
|
topics: [getDefaultTopic()]
|
||||||
}
|
}
|
||||||
@ -15,7 +15,7 @@ export function getDefaultAssistant(): Assistant {
|
|||||||
export function getDefaultTopic(): Topic {
|
export function getDefaultTopic(): Topic {
|
||||||
return {
|
return {
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
name: i18next.t('assistant.default.topic.name'),
|
name: i18n.t('assistant.default.topic.name'),
|
||||||
messages: []
|
messages: []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,7 @@ const persistedReducer = persistReducer(
|
|||||||
{
|
{
|
||||||
key: 'cherry-studio',
|
key: 'cherry-studio',
|
||||||
storage,
|
storage,
|
||||||
version: 7,
|
version: 8,
|
||||||
blacklist: ['runtime'],
|
blacklist: ['runtime'],
|
||||||
migrate
|
migrate
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
import { createMigrate } from 'redux-persist'
|
import { createMigrate } from 'redux-persist'
|
||||||
import { RootState } from '.'
|
import { RootState } from '.'
|
||||||
import { SYSTEM_MODELS } from '@renderer/config/models'
|
import { SYSTEM_MODELS } from '@renderer/config/models'
|
||||||
|
import { isEmpty } from 'lodash'
|
||||||
|
import i18n from '@renderer/i18n'
|
||||||
|
import { Assistant } from '@renderer/types'
|
||||||
|
|
||||||
const migrate = createMigrate({
|
const migrate = createMigrate({
|
||||||
// @ts-ignore store type is unknown
|
// @ts-ignore store type is unknown
|
||||||
@ -112,6 +115,32 @@ const migrate = createMigrate({
|
|||||||
language: navigator.language
|
language: navigator.language
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
// @ts-ignore store type is unknown
|
||||||
|
'8': (state: RootState) => {
|
||||||
|
const fixAssistantName = (assistant: Assistant) => {
|
||||||
|
if (isEmpty(assistant.name)) {
|
||||||
|
assistant.name = i18n.t(`assistant.${assistant.id}.name`)
|
||||||
|
}
|
||||||
|
|
||||||
|
assistant.topics = assistant.topics.map((topic) => {
|
||||||
|
if (isEmpty(topic.name)) {
|
||||||
|
topic.name = i18n.t(`assistant.${assistant.id}.topic.name`)
|
||||||
|
}
|
||||||
|
return topic
|
||||||
|
})
|
||||||
|
|
||||||
|
return assistant
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
assistants: {
|
||||||
|
...state.assistants,
|
||||||
|
defaultAssistant: fixAssistantName(state.assistants.defaultAssistant),
|
||||||
|
assistants: state.assistants.assistants.map((assistant) => fixAssistantName(assistant))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user