Skip to content

Commit 0ad2d7c

Browse files
authored
refactor: chat store use composition api and rename some vars (#625)
* refactor: rename history to chatRooms and update related methods Signed-off-by: Bob Du <i@bobdu.cc> * refactor: chat store use composition api Signed-off-by: Bob Du <i@bobdu.cc> --------- Signed-off-by: Bob Du <i@bobdu.cc>
1 parent 461910a commit 0ad2d7c

File tree

9 files changed

+300
-351
lines changed

9 files changed

+300
-351
lines changed

service/src/routes/room.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ router.get('/chatrooms', auth, async (req, res) => {
2525
const result = []
2626
rooms.forEach((r) => {
2727
result.push({
28-
uuid: r.roomId,
28+
roomId: r.roomId,
2929
title: r.title,
3030
isEdit: false,
3131
prompt: r.prompt,
@@ -65,7 +65,7 @@ router.get('/chatrooms-count', auth, async (req, res) => {
6565
const result = []
6666
rooms.data.forEach((r) => {
6767
result.push({
68-
uuid: r.roomId,
68+
roomId: r.roomId,
6969
title: r.title,
7070
userId: r.userId,
7171
name: r.username,

src/components/common/Setting/Prompt.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const props = defineProps<Props>()
77
const emit = defineEmits<Emit>()
88
99
const chatStore = useChatStore()
10-
const currentChatHistory = computed(() => chatStore.getChatHistoryByCurrentActive)
10+
const currentChatHistory = computed(() => chatStore.getChatRoomByCurrentActive)
1111
const ms = useMessage()
1212
const testing = ref(false)
1313
const title = `Prompt For [${currentChatHistory.value?.title}]`

src/store/modules/chat/helper.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { ss } from '@/utils/storage'
33
const LOCAL_NAME = 'chatStorage'
44

55
export function defaultState(): Chat.ChatState {
6-
const uuid = 1002
6+
const roomId = null
77
return {
8-
active: uuid,
8+
active: roomId,
99
usingContext: true,
10-
history: [{ uuid, title: 'New Chat', isEdit: false, usingContext: true, maxContextCount: 10 }],
11-
chat: [{ uuid, data: [] }],
10+
chatRooms: [{ roomId: 0, title: 'New Chat', isEdit: false, usingContext: true, maxContextCount: 10 }],
11+
chat: [{ roomId: 0, data: [] }],
1212
}
1313
}
1414

0 commit comments

Comments
 (0)