Skip to content

Commit

Permalink
fix: app initialization and new conversation errors (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayangweb committed Mar 23, 2023
1 parent d118471 commit fd3a3f1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/sqls/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ export const initSQL = async () => {
})

// 发版之后的表更新操作,只能对已存在的表进行增加列,不能删除列
// 1.2023-03-22 在session表中添加update_time列,记录对话的最后一次更新时间
// 1. 2023-03-22 在 session 表中添加 update_time 列,记录对话的最后一次更新时间
const sessionTable = (await executeSQL(
'SELECT * FROM session LIMIT 1;'
)) as any[]
if (sessionTable[0].update_time === undefined) {
if (sessionTable.length && !sessionTable[0].update_time) {
await executeSQL(`ALTER TABLE session ADD COLUMN update_time TIMESTAMP;`)
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/stores/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ export const useSessionStore = defineStore(

if (!isExist && currentRole?.id) {
currentSession.value.title = data.content
await insertSQL('session', currentSession.value)
await insertSQL('session', {
id: currentSession.value.id,
title: data.content,
role_id: currentRole.id
})
}

const { isMemory } = useSettingsStore()
Expand All @@ -96,6 +100,7 @@ export const useSessionStore = defineStore(

// 更新会话信息
const updateSession = async (payload: SessionPayload) => {
console.log('payload', payload)
const sql = `UPDATE session SET title = '${
payload.title
}', update_time = '${Date.now()}' WHERE id = '${payload.id}';`
Expand Down

0 comments on commit fd3a3f1

Please sign in to comment.