Skip to content
This repository was archived by the owner on Jun 17, 2025. It is now read-only.

Commit 30c5c8c

Browse files
DongHuiTiaoayangweb
authored andcommitted
feat: extract variables for history
1 parent eed086e commit 30c5c8c

File tree

4 files changed

+51
-25
lines changed

4 files changed

+51
-25
lines changed

src/components/Function/components/HistoryDrawer.vue

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
import type { SessionPayload } from '@/types'
3-
3+
const { t } = useI18n()
44
const props = defineProps<{ visible: boolean; setVisible: () => void }>()
55
66
const sessionStore = useSessionStore()
@@ -22,7 +22,7 @@ const renderList = computed(() =>
2222
const isEdit = computed(() => sessionList.value.some((item) => item.isEdit))
2323
2424
const handleClick = (item: SessionPayload) => {
25-
if (isEdit.value) return Message.info('请先完成当前编辑')
25+
if (isEdit.value) return Message.info(t('message.pleaseFinishEdit'))
2626
2727
switchSession(item)
2828
@@ -46,21 +46,21 @@ const handleOpen = () => {
4646
}
4747
4848
const handleClose = () => {
49-
if (isEdit.value) return Message.info('请先完成当前编辑')
49+
if (isEdit.value) return Message.info(t('message.pleaseFinishEdit'))
5050
5151
search.value = ''
5252
5353
props.setVisible()
5454
}
5555
5656
const handleEdit = (item: SessionPayload) => {
57-
if (isEdit.value) return Message.info(`请先完成当前编辑`)
57+
if (isEdit.value) return Message.info(t('message.pleaseFinishEdit'))
5858
5959
item.isEdit = true
6060
}
6161
6262
const handleUpdate = (item: SessionPayload) => {
63-
if (!item.title.trim()) return Message.info('标题不能为空')
63+
if (!item.title.trim()) return Message.info(t('message.titleRequire'))
6464
6565
item.isEdit = false
6666
@@ -80,7 +80,7 @@ const handleUpdate = (item: SessionPayload) => {
8080
unmountOnClose
8181
>
8282
<!-- TODO:加入全部清除的按钮 -->
83-
<template #title> 会话历史 </template>
83+
<template #title> {{ $t('history.title') }} </template>
8484

8585
<ul class="flex flex-col gap-2" v-if="renderList.length">
8686
<li
@@ -112,7 +112,11 @@ const handleUpdate = (item: SessionPayload) => {
112112
{{ item.title }}
113113
</div>
114114

115-
<div class="truncate">与 {{ item.name }} 的会话</div>
115+
<div class="truncate">
116+
<i18n-t keypath="history.historyWith" tag="label">
117+
<span>{{ ` ${item.name} ` }}</span>
118+
</i18n-t>
119+
</div>
116120
</div>
117121

118122
<div
@@ -123,7 +127,7 @@ const handleUpdate = (item: SessionPayload) => {
123127
<icon-edit @click="handleEdit(item)" />
124128
<a-popconfirm
125129
type="error"
126-
content="确定删除该会话吗?"
130+
:content="t('history.confirmDelete')"
127131
@ok="deleteSession(item)"
128132
>
129133
<icon-delete />
@@ -139,14 +143,14 @@ const handleUpdate = (item: SessionPayload) => {
139143
</ul>
140144

141145
<div class="flex h-full items-center" v-else>
142-
<a-empty description="暂无历史会话" />
146+
<a-empty :description="t('history.empty')" />
143147
</div>
144148

145149
<template #footer>
146150
<a-input-search
147151
ref="searchRef"
148152
v-model="search"
149-
placeholder="搜索对话"
153+
:placeholder="t('history.searchPlaceholder')"
150154
allow-clear
151155
/>
152156
</template>

src/components/Function/index.vue

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
import { emit } from '@tauri-apps/api/event'
3-
3+
const { t } = useI18n()
44
const { currentRole } = storeToRefs(useRoleStore())
55
66
const { isThinking } = storeToRefs(useSessionStore())
@@ -23,13 +23,13 @@ const triggerScroll = () => {
2323

2424
<!-- 当前聊天角色对象 -->
2525
<div>
26-
正在与
27-
<a-tooltip content="点我回到底部">
28-
<span class="mark cursor-pointer" @click="triggerScroll">
29-
{{ currentRole?.name }}
30-
</span>
31-
</a-tooltip>
32-
对话
26+
<i18n-t keypath="session.sessionWith" tag="label">
27+
<a-tooltip content="点我回到底部">
28+
<span class="mark cursor-pointer" @click="triggerScroll">
29+
{{ currentRole?.name }}
30+
</span>
31+
</a-tooltip>
32+
</i18n-t>
3333
</div>
3434

3535
<!-- 功能按钮 -->
@@ -41,7 +41,7 @@ const triggerScroll = () => {
4141
<!-- 导出 -->
4242
<Export />
4343
<!-- 历史记录 -->
44-
<a-tooltip content="历史记录">
44+
<a-tooltip :content="`${t('history.title')}`">
4545
<a-button
4646
type="text"
4747
:disabled="isThinking"

src/locales/en.json

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
{
2-
"history": {},
3-
"session": {},
2+
"history": {
3+
"confirmDelete": "Are you sure you want to delete this conversation?",
4+
"empty": "No history session yet",
5+
"historyWith": "Session with {0}",
6+
"searchPlaceholder": "search session",
7+
"title": "session history"
8+
},
9+
"session": {
10+
"sessionWith": "Talking to {0}"
11+
},
412
"setting": {
513
"tab": {
614
"common": "Common",
@@ -44,7 +52,10 @@
4452
"checkUpdate": "Check for updates"
4553
}
4654
},
47-
"message": {},
55+
"message": {
56+
"pleaseFinishEdit": "Please complete the current edit first",
57+
"titleRequire": "The title can not be blank"
58+
},
4859
"errors": {},
4960
"tips": {
5061
"input": {

src/locales/zh.json

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
{
2-
"history": {},
3-
"session": {},
2+
"history": {
3+
"title": "会话记录",
4+
"historyWith": "与{0}的会话",
5+
"confirmDelete": "确定删除该会话吗?",
6+
"empty": "暂无历史会话",
7+
"searchPlaceholder": "搜索对话"
8+
},
9+
"session": {
10+
"sessionWith": "正在与{0}对话"
11+
},
412
"setting": {
513
"tab": {
614
"common": "通用",
@@ -44,7 +52,10 @@
4452
"checkUpdate": "检查更新"
4553
}
4654
},
47-
"message": {},
55+
"message": {
56+
"pleaseFinishEdit": "请先完成当前编辑",
57+
"titleRequire": "标题不能为空"
58+
},
4859
"errors": {},
4960
"tips": {
5061
"input": {

0 commit comments

Comments
 (0)