mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-27 13:29:15 +07:00
✨ feat: 支持缓存角色面板的展开折叠状态
This commit is contained in:
@@ -5,7 +5,7 @@ import { shallow } from 'zustand/shallow';
|
||||
|
||||
import HeaderSpacing from '@/components/HeaderSpacing';
|
||||
import { CHAT_SIDEBAR_WIDTH } from '@/const/layoutTokens';
|
||||
import { useSessionStore } from '@/store/session';
|
||||
import { useSettings } from '@/store/settings';
|
||||
|
||||
import SideBar from './SideBar';
|
||||
|
||||
@@ -23,8 +23,8 @@ const useStyles = createStyles(({ cx, css, token, stylish }) => ({
|
||||
|
||||
const Config = () => {
|
||||
const { styles } = useStyles();
|
||||
const [showAgentSettings, toggleConfig] = useSessionStore(
|
||||
(s) => [s.showAgentSettings, s.toggleConfig],
|
||||
const [showAgentSettings, toggleConfig] = useSettings(
|
||||
(s) => [s.showAgentConfig, s.toggleAgentPanel],
|
||||
shallow,
|
||||
);
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import { shallow } from 'zustand/shallow';
|
||||
|
||||
import HeaderTitle from '@/components/HeaderTitle';
|
||||
import { agentSelectors, useSessionStore } from '@/store/session';
|
||||
import { useSettings } from '@/store/settings';
|
||||
|
||||
const Header = memo(() => {
|
||||
const { t } = useTranslation('common');
|
||||
@@ -24,8 +25,8 @@ const Header = memo(() => {
|
||||
shallow,
|
||||
);
|
||||
|
||||
const [showAgentSettings, toggleConfig] = useSessionStore(
|
||||
(s) => [s.showAgentSettings, s.toggleConfig],
|
||||
const [showAgentSettings, toggleConfig] = useSettings(
|
||||
(s) => [s.showAgentConfig, s.toggleAgentPanel],
|
||||
shallow,
|
||||
);
|
||||
|
||||
|
||||
@@ -46,11 +46,6 @@ export interface AgentAction {
|
||||
internalUpdateAgentMeta: (id: string) => any;
|
||||
toggleAgentPlugin: (pluginId: string) => void;
|
||||
|
||||
/**
|
||||
* 切换配置
|
||||
* @param showPanel - 是否显示面板,默认为 true
|
||||
*/
|
||||
toggleConfig: (showPanel?: boolean) => void;
|
||||
/**
|
||||
* 更新代理配置
|
||||
* @param config - 部分 LobeAgentConfig 的配置
|
||||
@@ -214,12 +209,6 @@ export const createAgentSlice: StateCreator<
|
||||
get().dispatchSession({ config, id: activeId, type: 'updateSessionConfig' });
|
||||
},
|
||||
|
||||
toggleConfig: (newValue) => {
|
||||
const showAgentSettings = typeof newValue === 'boolean' ? newValue : !get().showAgentSettings;
|
||||
|
||||
set({ showAgentSettings });
|
||||
},
|
||||
|
||||
updateAgentConfig: (config) => {
|
||||
const { activeId } = get();
|
||||
const session = sessionSelectors.currentSession(get());
|
||||
|
||||
@@ -6,8 +6,6 @@ export type SessionLoadingState = Record<Partial<keyof MetaData>, boolean>;
|
||||
|
||||
export interface AgentConfigState {
|
||||
autocompleteLoading: SessionLoadingState;
|
||||
|
||||
showAgentSettings: boolean;
|
||||
}
|
||||
|
||||
export const initialLobeAgentConfig: LobeAgentConfig = {
|
||||
@@ -32,6 +30,4 @@ export const initialAgentConfigState: AgentConfigState = {
|
||||
tag: false,
|
||||
title: false,
|
||||
},
|
||||
|
||||
showAgentSettings: true,
|
||||
};
|
||||
|
||||
@@ -215,6 +215,7 @@ export const chatMessage: StateCreator<
|
||||
|
||||
await realFetchAIResponse(histories, latestMsg.id);
|
||||
},
|
||||
|
||||
sendMessage: async (message) => {
|
||||
const { dispatchMessage, realFetchAIResponse, autocompleteSessionAgentMeta, activeTopicId } =
|
||||
get();
|
||||
|
||||
@@ -36,6 +36,7 @@ export interface SettingsAction {
|
||||
* @param key - 选中的侧边栏选项
|
||||
*/
|
||||
switchSideBar: (key: SidebarTabKey) => void;
|
||||
toggleAgentPanel: (visible?: boolean) => void;
|
||||
}
|
||||
|
||||
export const createSettings: StateCreator<
|
||||
@@ -71,4 +72,9 @@ export const createSettings: StateCreator<
|
||||
switchSideBar: (key) => {
|
||||
set({ sidebarKey: key });
|
||||
},
|
||||
toggleAgentPanel: (newValue) => {
|
||||
const showAgentConfig = typeof newValue === 'boolean' ? newValue : !get().showAgentConfig;
|
||||
|
||||
set({ showAgentConfig });
|
||||
},
|
||||
});
|
||||
|
||||
@@ -31,6 +31,7 @@ export interface SettingsState {
|
||||
sessionExpandable?: boolean;
|
||||
sessionsWidth: number;
|
||||
settings: GlobalSettings;
|
||||
showAgentConfig?: boolean;
|
||||
sidebarKey: SidebarTabKey;
|
||||
}
|
||||
|
||||
@@ -39,5 +40,6 @@ export const initialState: SettingsState = {
|
||||
sessionExpandable: true,
|
||||
sessionsWidth: 320,
|
||||
settings: DEFAULT_SETTINGS,
|
||||
showAgentConfig: true,
|
||||
sidebarKey: 'chat',
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user