@@ -91,13 +130,18 @@ export function NewChat() {
现在开始,与面具背后的灵魂思维碰撞
- {masks.map((masks, i) => (
+ {groups.map((masks, i) => (
{masks.map((mask, index) => (
-
+
))}
))}
diff --git a/app/icons/dark.svg b/app/icons/dark.svg
index 3eebc373e..c96c188bb 100644
--- a/app/icons/dark.svg
+++ b/app/icons/dark.svg
@@ -1 +1 @@
-
+
diff --git a/app/icons/light.svg b/app/icons/light.svg
index 22cfa1fff..a425e0107 100644
--- a/app/icons/light.svg
+++ b/app/icons/light.svg
@@ -1 +1 @@
-
+
diff --git a/app/icons/mask.svg b/app/icons/mask.svg
new file mode 100644
index 000000000..69b600c57
--- /dev/null
+++ b/app/icons/mask.svg
@@ -0,0 +1 @@
+
diff --git a/app/icons/prompt.svg b/app/icons/prompt.svg
new file mode 100644
index 000000000..686f4c17d
--- /dev/null
+++ b/app/icons/prompt.svg
@@ -0,0 +1 @@
+
diff --git a/app/store/chat.ts b/app/store/chat.ts
index a95d767b7..6482988b0 100644
--- a/app/store/chat.ts
+++ b/app/store/chat.ts
@@ -48,7 +48,7 @@ export interface ChatSession {
memoryPrompt: string;
messages: Message[];
stat: ChatStat;
- lastUpdate: string;
+ lastUpdate: number;
lastSummarizeIndex: number;
mask: Mask;
@@ -61,8 +61,6 @@ export const BOT_HELLO: Message = createMessage({
});
function createEmptySession(): ChatSession {
- const createDate = new Date().toLocaleString();
-
return {
id: Date.now(),
topic: DEFAULT_TOPIC,
@@ -73,7 +71,7 @@ function createEmptySession(): ChatSession {
wordCount: 0,
charCount: 0,
},
- lastUpdate: createDate,
+ lastUpdate: Date.now(),
lastSummarizeIndex: 0,
mask: createEmptyMask(),
};
@@ -82,11 +80,12 @@ function createEmptySession(): ChatSession {
interface ChatStore {
sessions: ChatSession[];
currentSessionIndex: number;
+ globalId: number;
clearSessions: () => void;
removeSession: (index: number) => void;
moveSession: (from: number, to: number) => void;
selectSession: (index: number) => void;
- newSession: () => void;
+ newSession: (mask?: Mask) => void;
deleteSession: (index?: number) => void;
currentSession: () => ChatSession;
onNewMessage: (message: Message) => void;
@@ -117,6 +116,7 @@ export const useChatStore = create
()(
(set, get) => ({
sessions: [createEmptySession()],
currentSessionIndex: 0,
+ globalId: 0,
clearSessions() {
set(() => ({
@@ -181,10 +181,20 @@ export const useChatStore = create()(
});
},
- newSession() {
+ newSession(mask) {
+ const session = createEmptySession();
+
+ set(() => ({ globalId: get().globalId + 1 }));
+ session.id = get().globalId;
+
+ if (mask) {
+ session.mask = { ...mask };
+ session.topic = mask.name;
+ }
+
set((state) => ({
currentSessionIndex: 0,
- sessions: [createEmptySession()].concat(state.sessions),
+ sessions: [session].concat(state.sessions),
}));
},
@@ -231,7 +241,7 @@ export const useChatStore = create()(
onNewMessage(message) {
get().updateCurrentSession((session) => {
- session.lastUpdate = new Date().toLocaleString();
+ session.lastUpdate = Date.now();
});
get().updateStat(message);
get().summarizeSession();
diff --git a/app/store/mask.ts b/app/store/mask.ts
index 9a9d985ef..b42860cff 100644
--- a/app/store/mask.ts
+++ b/app/store/mask.ts
@@ -22,10 +22,11 @@ export const DEFAULT_MASK_STATE = {
export type MaskState = typeof DEFAULT_MASK_STATE;
type MaskStore = MaskState & {
- create: (mask: Partial) => Mask;
+ create: (mask?: Partial) => Mask;
update: (id: number, updater: (mask: Mask) => void) => void;
delete: (id: number) => void;
search: (text: string) => Mask[];
+ get: (id?: number) => Mask | null;
getAll: () => Mask[];
};
@@ -37,7 +38,7 @@ export const createEmptyMask = () =>
avatar: DEFAULT_MASK_AVATAR,
name: DEFAULT_TOPIC,
context: [],
- modelConfig: useAppConfig.getState().modelConfig,
+ modelConfig: { ...useAppConfig.getState().modelConfig },
lang: getLang(),
} as Mask);
@@ -74,6 +75,10 @@ export const useMaskStore = create()(
delete masks[id];
set(() => ({ masks }));
},
+
+ get(id) {
+ return get().masks[id ?? 1145141919810];
+ },
getAll() {
return Object.values(get().masks).sort((a, b) => a.id - b.id);
},
diff --git a/app/styles/globals.scss b/app/styles/globals.scss
index 9caf663d7..36ab0bd57 100644
--- a/app/styles/globals.scss
+++ b/app/styles/globals.scss
@@ -329,9 +329,11 @@ pre {
}
}
-.user-avtar {
+.user-avatar {
height: 30px;
+ min-height: 30px;
width: 30px;
+ min-width: 30px;
display: flex;
align-items: center;
justify-content: center;
diff --git a/app/utils.ts b/app/utils.ts
index 0ebcc93ac..efcd47291 100644
--- a/app/utils.ts
+++ b/app/utils.ts
@@ -47,11 +47,18 @@ export function isIOS() {
return /iphone|ipad|ipod/.test(userAgent);
}
-export function useMobileScreen() {
- const [isMobileScreen_, setIsMobileScreen] = useState(isMobileScreen());
+export function useWindowSize() {
+ const [size, setSize] = useState({
+ width: window.innerWidth,
+ height: window.innerHeight,
+ });
+
useEffect(() => {
const onResize = () => {
- setIsMobileScreen(isMobileScreen());
+ setSize({
+ width: window.innerWidth,
+ height: window.innerHeight,
+ });
};
window.addEventListener("resize", onResize);
@@ -61,14 +68,21 @@ export function useMobileScreen() {
};
}, []);
- return isMobileScreen_;
+ return size;
+}
+
+export const MOBILE_MAX_WIDTH = 600;
+export function useMobileScreen() {
+ const { width } = useWindowSize();
+
+ return width <= MOBILE_MAX_WIDTH;
}
export function isMobileScreen() {
if (typeof window === "undefined") {
return false;
}
- return window.innerWidth <= 600;
+ return window.innerWidth <= MOBILE_MAX_WIDTH;
}
export function isFirefox() {