Refined UI,code logic for improved user experience

This commit is contained in:
2023-06-23 20:07:43 +08:00
parent 8420085fb1
commit 6711506acd
16 changed files with 170 additions and 320 deletions
+44 -29
View File
@@ -19,7 +19,7 @@ export enum Theme {
export const DEFAULT_CONFIG = {
// submitKey: SubmitKey.CtrlEnter as SubmitKey,
submitKey: SubmitKey.Enter as SubmitKey,
submitKey: SubmitKey.Enter,
avatar: "1f603",
fontSize: 14,
theme: Theme.Auto as Theme,
@@ -156,35 +156,50 @@ export const ModalConfigValidator = {
},
};
export const useAppConfig = create<ChatConfigStore>()(
persist(
(set, get) => ({
...DEFAULT_CONFIG,
// export const useAppConfig = create<ChatConfigStore>()(
// persist(
// (set, get) => ({
// ...DEFAULT_CONFIG,
reset() {
set(() => ({ ...DEFAULT_CONFIG }));
},
// reset() {
// set(() => ({ ...DEFAULT_CONFIG }));
// },
update(updater) {
const config = { ...get() };
updater(config);
set(() => config);
},
}),
{
name: StoreKey.Config,
version: 2,
migrate(persistedState, version) {
if (version === 2) return persistedState as any;
// update(updater) {
// const config = { ...get() };
// updater(config);
// set(() => config);
// },
// }),
// {
// name: StoreKey.Config,
// version: 2,
// migrate(persistedState, version) {
// if (version === 2) return persistedState as any;
const state = persistedState as ChatConfig;
state.modelConfig.sendMemory = true;
state.modelConfig.historyMessageCount = 4;
state.modelConfig.compressMessageLengthThreshold = 1000;
state.dontShowMaskSplashScreen = false;
// const state = persistedState as ChatConfig;
// state.modelConfig.sendMemory = true;
// state.modelConfig.historyMessageCount = 4;
// state.modelConfig.compressMessageLengthThreshold = 1000;
// state.dontShowMaskSplashScreen = false;
return state;
},
},
),
);
// return state;
// },
// },
// ),
// );
// 取消 AppConfig 的持久化
export const useAppConfig = create<ChatConfigStore>((set, get) => ({
...DEFAULT_CONFIG,
reset() {
set(() => ({ ...DEFAULT_CONFIG }));
},
update(updater) {
const config = { ...get() };
updater(config);
set(() => config);
},
}));