feat: Import and use constants from "meta.ts" instead of "agentConfig"

The changes involve importing and using constants from a new file called "meta.ts" instead of importing them from the "agentConfig" file. The constants include DEFAULT_AVATAR, DEFAULT_USER_AVATAR, DEFAULT_BACKGROUND_COLOR, and DEFAULT_TITLE. The changes also involve updating the usage of these constants in different parts of the code.

- Import and use constants from "meta.ts" instead of "agentConfig"
- Update the usage of constants in various parts of the code
This commit is contained in:
canisminor1990
2023-07-24 18:29:59 +08:00
parent 64c8782ba0
commit 1eb6a177e5
7 changed files with 10 additions and 13 deletions

3
src/const/meta.ts Normal file
View File

@@ -0,0 +1,3 @@
export const DEFAULT_AVATAR = '🤖';
export const DEFAULT_USER_AVATAR = '😀';
export const DEFAULT_BACKGROUND_COLOR = 'rgba(0,0,0,0)';

View File

@@ -7,7 +7,6 @@ import { Flexbox } from 'react-layout-kit';
import { shallow } from 'zustand/shallow';
import { chatSelectors, sessionSelectors, useSessionStore } from '@/store/session';
import { DEFAULT_TITLE } from '@/store/session/slices/agentConfig';
import { useSettings } from '@/store/settings';
import { useStyles } from './style';
@@ -96,7 +95,7 @@ const SessionItem: FC<SessionItemProps> = memo(({ id, active = true, loading })
}
loading={loading}
style={{ color: theme.colorText }}
title={title || t(DEFAULT_TITLE)}
title={title || t('defaultSession')}
/>
<Popconfirm
arrow={false}

View File

@@ -2,8 +2,8 @@ import { Swatches, primaryColorsSwatches } from '@lobehub/ui';
import { memo } from 'react';
import { shallow } from 'zustand/shallow';
import { DEFAULT_BACKGROUND_COLOR } from '@/const/meta';
import { agentSelectors, useSessionStore } from '@/store/session';
import { DEFAULT_BACKGROUND_COLOR } from '@/store/session/slices/agentConfig';
const BackgroundSwatches = memo(() => {
const [backgroundColor, updateAgentMeta] = useSessionStore(

View File

@@ -16,12 +16,6 @@ export const initialLobeAgentConfig: LobeAgentConfig = {
systemRole: '',
};
export const DEFAULT_AVATAR = '🤖';
export const DEFAULT_BACKGROUND_COLOR = 'rgba(0,0,0,0)';
export const DEFAULT_TITLE = 'defaultSession';
export const initialAgentConfigState: AgentConfigState = {
// // loading 中间态
autocompleteLoading: {

View File

@@ -1,10 +1,11 @@
import { DEFAULT_AVATAR, DEFAULT_BACKGROUND_COLOR } from '@/const/meta';
import { SessionStore } from '@/store/session';
import { LanguageModel } from '@/types/llm';
import { MetaData } from '@/types/meta';
import { LobeAgentConfig } from '@/types/session';
import { sessionSelectors } from '../session';
import { DEFAULT_AVATAR, DEFAULT_BACKGROUND_COLOR, initialLobeAgentConfig } from './initialState';
import { initialLobeAgentConfig } from './initialState';
const currentAgentMeta = (s: SessionStore): MetaData => {
const session = sessionSelectors.currentSession(s);

View File

@@ -1,9 +1,9 @@
import { DEFAULT_USER_AVATAR } from '@/const/meta';
import { agentSelectors } from '@/store/session';
import { useSettings } from '@/store/settings';
import { ChatMessage } from '@/types/chatMessage';
import type { SessionStore } from '../../../store';
import { DEFAULT_AVATAR } from '../../agentConfig';
import { sessionSelectors } from '../../session';
import { organizeChats } from './utils';
@@ -14,7 +14,7 @@ export const currentChats = (s: SessionStore): ChatMessage[] => {
return organizeChats(session, {
assistant: agentSelectors.currentAgentAvatar(s),
user: useSettings.getState().settings.avatar || DEFAULT_AVATAR,
user: useSettings.getState().settings.avatar || DEFAULT_USER_AVATAR,
});
};

View File

@@ -1,4 +1,4 @@
import { DEFAULT_AVATAR } from '@/store/session/slices/agentConfig';
import { DEFAULT_AVATAR } from '@/const/meta';
import { MetaData } from '@/types/meta';
export const getAgentAvatar = (s: MetaData) => s.avatar || DEFAULT_AVATAR;