Skip to content

Commit 1624a00

Browse files
committed
fix: bug fix
1 parent 81d8637 commit 1624a00

File tree

4 files changed

+98
-39
lines changed

4 files changed

+98
-39
lines changed

frontend/src/i18n/en.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@
114114
"today": "Today",
115115
"week": "This Week",
116116
"earlier": "Earlier",
117-
"no_time": "No Time"
117+
"no_time": "No Time",
118+
"rename_conversation_title": "Rename conversation title",
119+
"conversation_title": "Conversation title"
118120
},
119121
"ds": {
120122
"title": "Data Source",
@@ -502,4 +504,4 @@
502504
"back_community": "Restore to Community Edition",
503505
"confirm_tips": "Are you sure to restore to Community Edition?"
504506
}
505-
}
507+
}

frontend/src/i18n/zh-CN.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@
117117
"today": "今天",
118118
"week": "7天内",
119119
"earlier": "更早以前",
120-
"no_time": "没有时间"
120+
"no_time": "没有时间",
121+
"rename_conversation_title": "重命名对话标题",
122+
"conversation_title": "对话标题"
121123
},
122124
"ds": {
123125
"title": "数据源",
@@ -514,4 +516,4 @@
514516
"back_community": "还原至社区版",
515517
"confirm_tips": "确定还原至社区版?"
516518
}
517-
}
519+
}

frontend/src/views/chat/ChatList.vue

Lines changed: 89 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import icon_expand_down_filled from '@/assets/embedded/icon_expand-down_filled.s
44
import rename from '@/assets/svg/icon_rename_outlined.svg'
55
import delIcon from '@/assets/svg/icon_delete.svg'
66
import { type Chat, chatApi } from '@/api/chat.ts'
7-
import { computed, ref } from 'vue'
7+
import { computed, nextTick, reactive, ref } from 'vue'
88
import dayjs from 'dayjs'
99
import { getDate } from '@/utils/utils.ts'
1010
import { groupBy } from 'lodash-es'
@@ -107,39 +107,9 @@ function handleCommand(command: string | number | object, chat: Chat) {
107107
if (chat && chat.id !== undefined) {
108108
switch (command) {
109109
case 'rename':
110-
ElMessageBox.prompt('Please enter new brief', 'Rename', {
111-
confirmButtonText: 'OK',
112-
cancelButtonText: 'Cancel',
113-
customStyle: { 'padding-left': 'unset', padding: 'var(--ed-messagebox-padding-primary)' },
114-
inputValue: chat.brief,
115-
inputValidator: (value: string) => {
116-
if (!value) return false
117-
if (value.trim().length == 0) return false
118-
return true
119-
},
120-
}).then(({ value }) => {
121-
_loading.value = true
122-
chatApi
123-
.renameChat(chat.id, value)
124-
.then((res) => {
125-
ElMessage({
126-
type: 'success',
127-
message: 'Successfully renamed chat',
128-
})
129-
emits('chatRenamed', { id: chat.id, brief: res })
130-
})
131-
.catch((err) => {
132-
ElMessage({
133-
type: 'error',
134-
message: err.message,
135-
})
136-
console.error(err)
137-
})
138-
.finally(() => {
139-
_loading.value = false
140-
})
141-
})
142-
110+
password.id = chat.id
111+
password.name = chat.brief as string
112+
dialogVisiblePassword.value = true
143113
break
144114
case 'delete':
145115
ElMessageBox.confirm('This action will permanently delete the chat. Continue?', 'Warning', {
@@ -173,6 +143,56 @@ function handleCommand(command: string | number | object, chat: Chat) {
173143
}
174144
}
175145
}
146+
147+
const passwordRef = ref()
148+
const dialogVisiblePassword = ref(false)
149+
const password = reactive({
150+
name: '',
151+
id: 0,
152+
})
153+
154+
const passwordRules = {
155+
name: [
156+
{
157+
required: true,
158+
message: t('datasource.please_enter') + t('common.empty') + t('qa.conversation_title'),
159+
trigger: 'blur',
160+
},
161+
],
162+
}
163+
164+
const handleClosePassword = () => {
165+
passwordRef.value.clearValidate()
166+
dialogVisiblePassword.value = false
167+
password.id = 0
168+
password.name = ''
169+
}
170+
const handleConfirmPassword = () => {
171+
passwordRef.value.validate((res: any) => {
172+
if (res) {
173+
chatApi
174+
.renameChat(password.id, password.name)
175+
.then((res) => {
176+
ElMessage({
177+
type: 'success',
178+
message: t('common.save_success'),
179+
})
180+
emits('chatRenamed', { id: password.id, brief: res })
181+
handleClosePassword()
182+
})
183+
.catch((err) => {
184+
ElMessage({
185+
type: 'error',
186+
message: err.message,
187+
})
188+
console.error(err)
189+
})
190+
.finally(() => {
191+
_loading.value = false
192+
})
193+
}
194+
})
195+
}
176196
</script>
177197

178198
<template>
@@ -222,6 +242,41 @@ function handleCommand(command: string | number | object, chat: Chat) {
222242
</div>
223243
</div>
224244
</el-scrollbar>
245+
<el-dialog
246+
v-model="dialogVisiblePassword"
247+
:title="$t('qa.rename_conversation_title')"
248+
width="420"
249+
:before-close="handleClosePassword"
250+
>
251+
<el-form
252+
ref="passwordRef"
253+
:model="password"
254+
label-width="180px"
255+
label-position="top"
256+
:rules="passwordRules"
257+
class="form-content_error"
258+
@submit.prevent
259+
>
260+
<el-form-item prop="name" :label="t('qa.conversation_title')">
261+
<el-input
262+
v-model="password.name"
263+
maxlength="20"
264+
:placeholder="
265+
$t('datasource.please_enter') + $t('common.empty') + $t('qa.conversation_title')
266+
"
267+
autocomplete="off"
268+
/>
269+
</el-form-item>
270+
</el-form>
271+
<template #footer>
272+
<div class="dialog-footer">
273+
<el-button secondary @click="handleClosePassword">{{ $t('common.cancel') }}</el-button>
274+
<el-button type="primary" @click="handleConfirmPassword">
275+
{{ $t('common.save') }}
276+
</el-button>
277+
</div>
278+
</template>
279+
</el-dialog>
225280
</template>
226281

227282
<style scoped lang="less">

frontend/src/views/system/user/User.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@
279279
</el-form>
280280
<template #footer>
281281
<div class="dialog-footer">
282-
<el-button @click="handleClosePassword">{{ $t('common.cancel') }}</el-button>
282+
<el-button secondary @click="handleClosePassword">{{ $t('common.cancel') }}</el-button>
283283
<el-button type="primary" @click="handleConfirmPassword">
284284
{{ $t('common.save') }}
285285
</el-button>

0 commit comments

Comments
 (0)