forked from XiaoMo/ChatGPT-Next-Web
feat: clear session only
This commit is contained in:
parent
c93a46a02f
commit
506cdbc83c
@ -46,14 +46,14 @@ function SettingItem(props: {
|
|||||||
|
|
||||||
export function Settings(props: { closeSettings: () => void }) {
|
export function Settings(props: { closeSettings: () => void }) {
|
||||||
const [showEmojiPicker, setShowEmojiPicker] = useState(false);
|
const [showEmojiPicker, setShowEmojiPicker] = useState(false);
|
||||||
const [config, updateConfig, resetConfig, clearAllData] = useChatStore(
|
const [config, updateConfig, resetConfig, clearAllData, clearSessions] =
|
||||||
(state) => [
|
useChatStore((state) => [
|
||||||
state.config,
|
state.config,
|
||||||
state.updateConfig,
|
state.updateConfig,
|
||||||
state.resetConfig,
|
state.resetConfig,
|
||||||
state.clearAllData,
|
state.clearAllData,
|
||||||
]
|
state.clearSessions,
|
||||||
);
|
]);
|
||||||
|
|
||||||
const updateStore = useUpdateStore();
|
const updateStore = useUpdateStore();
|
||||||
const [checkingUpdate, setCheckingUpdate] = useState(false);
|
const [checkingUpdate, setCheckingUpdate] = useState(false);
|
||||||
@ -93,7 +93,7 @@ export function Settings(props: { closeSettings: () => void }) {
|
|||||||
<div className={styles["window-action-button"]}>
|
<div className={styles["window-action-button"]}>
|
||||||
<IconButton
|
<IconButton
|
||||||
icon={<ClearIcon />}
|
icon={<ClearIcon />}
|
||||||
onClick={clearAllData}
|
onClick={clearSessions}
|
||||||
bordered
|
bordered
|
||||||
title={Locale.Settings.Actions.ClearAll}
|
title={Locale.Settings.Actions.ClearAll}
|
||||||
/>
|
/>
|
||||||
|
@ -177,6 +177,7 @@ interface ChatStore {
|
|||||||
config: ChatConfig;
|
config: ChatConfig;
|
||||||
sessions: ChatSession[];
|
sessions: ChatSession[];
|
||||||
currentSessionIndex: number;
|
currentSessionIndex: number;
|
||||||
|
clearSessions: () => void;
|
||||||
removeSession: (index: number) => void;
|
removeSession: (index: number) => void;
|
||||||
selectSession: (index: number) => void;
|
selectSession: (index: number) => void;
|
||||||
newSession: () => void;
|
newSession: () => void;
|
||||||
@ -211,6 +212,13 @@ export const useChatStore = create<ChatStore>()(
|
|||||||
...DEFAULT_CONFIG,
|
...DEFAULT_CONFIG,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
clearSessions(){
|
||||||
|
set(() => ({
|
||||||
|
sessions: [createEmptySession()],
|
||||||
|
currentSessionIndex: 0,
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
|
||||||
resetConfig() {
|
resetConfig() {
|
||||||
set(() => ({ config: { ...DEFAULT_CONFIG } }));
|
set(() => ({ config: { ...DEFAULT_CONFIG } }));
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user