Commit 5e24a6a4 authored by tyyin lan's avatar tyyin lan

chore: 首页增加多语言

parent 5ca3f840
common_module:
cancel_btn_text: ' 消'
confirm_btn_text: ' 认'
cancel_btn_text: '取消'
confirm_btn_text: '确认'
prev_btn_text: '上一步'
next_btn_text: '下一步'
create: '新增'
......@@ -42,6 +42,16 @@ common_module:
publish_success_message: '发布成功'
clear_success_message: '清空成功'
add_success_message: '新增成功'
loading: '加载中'
updating: '更新中'
successful_update: '更新成功'
recommended_questions: '推荐问题'
exchange: '换一换'
tip: '提示'
during_operation: '操作中'
deletion_failed_please_try_again: '删除失败,请重试'
select_all: '全选'
quit: '退出'
dialogue_module:
continue_question_message: '你可以继续提问'
......@@ -68,7 +78,7 @@ common_module:
login_module:
app_welcome_words: '欢迎使用萃想POC'
please_enter_your_username: '请输入用户名'
please_enter_your_account_number: '请输入账号'
please_enter_your_password: '请输入密码'
please_enter_your_cell_phone_number: '请输入手机号'
please_enter_your_correct_cell_phone_number: '请输入正确手机号'
......@@ -85,6 +95,19 @@ login_module:
home_module:
agent_welcome_message: 'Hi, 欢迎使用SuperLink'
agent_description: '在这里,你可以体验多个平台的模型和专属的智能体'
currently_in_the_latest_session: '当前已是最新会话'
switching_over: '切换中...'
history_application_success: '历史记录应用成功'
history_application_failed_please_try_again: '历史记录应用失败,请重试'
cui_xiang_Assistant: '萃想助手'
starting_a_new_session: '发起新会话'
please_enter_a_question: '请输入问题(按enter+shift键可换行)'
all_of_the_above_content_is_generated_by_ai_and_is_for_reference_only: '以上内容均由AI生成,仅供参考'
history_record_item_delete_tip: '确定删除当前所选的会话记录?'
there_is_currently_no_history_to_work_with: '当前没有历史记录可操作'
the_selected_list_cannot_be_empty: '所选列表不能为空'
history_record_item_apply_tip: '是否确定应用此会话记录?'
historical_record: '历史记录'
router_title_module:
login: '登录'
......
......@@ -42,6 +42,16 @@ common_module:
publish_success_message: '發佈成功'
clear_success_message: '清空成功'
add_success_message: '新增成功'
loading: '加載中'
updating: '更新中'
successful_update: '更新成功'
recommended_questions: '推薦問題'
exchange: '換一換'
tip: '提示'
during_operation: '操作中'
deletion_failed_please_try_again: '刪除失敗,請重試'
select_all: '全選'
quit: '退出'
dialogue_module:
continue_question_message: '你可以繼續提問'
......@@ -68,7 +78,7 @@ common_module:
login_module:
app_welcome_words: '歡迎使用萃想POC'
please_enter_your_username: '請輸入用戶名'
please_enter_your_account_number: '請輸入賬號'
please_enter_your_password: '請輸入密碼'
please_enter_your_cell_phone_number: '請輸入手機號'
please_enter_your_correct_cell_phone_number: '請輸入正確手機號'
......@@ -85,6 +95,19 @@ login_module:
home_module:
agent_welcome_message: 'Hi, 歡迎使用SuperLink'
agent_description: '在這裏,你可以體驗多個平臺的模型和專屬的智'
currently_in_the_latest_session: '當前已是最新會話'
switching_over: '切換中...'
history_application_success: '歷史記錄應用成功'
history_application_failed_please_try_again: '歷史記錄應用失敗,請重試'
cui_xiang_Assistant: '萃想助手'
starting_a_new_session: '發起新會話'
please_enter_a_question: '請輸入問題(按enter+shift鍵可換行)'
all_of_the_above_content_is_generated_by_ai_and_is_for_reference_only: '以上內容均由AI生成,僅供參考'
history_record_item_delete_tip: '確定刪除當前所選的會話記錄?'
there_is_currently_no_history_to_work_with: '當前沒有歷史記錄可操作'
the_selected_list_cannot_be_empty: '所選列表不能為空'
history_record_item_apply_tip: '是否確定應用此會話記錄?'
historical_record: '歷史記錄'
router_title_module:
login: '登錄'
......
......@@ -48,13 +48,13 @@ function handleQuestionClick(question: string) {
const handleRecommendQuestionListUpdate = debounce(
() => {
const loadingCtl = window.$message.loading('更新中...')
const loadingCtl = window.$message.loading(`${t('common_module.updating')}...`)
getRecommendQuestionList().then(() => {
loadingCtl.destroy()
nextTick(() => {
window.$message.success('更新成功')
window.$message.success(t('common_module.successful_update'))
})
})
},
......@@ -77,7 +77,7 @@ const handleRecommendQuestionListUpdate = debounce(
</div>
<div class="mt-[39px] flex flex-1 flex-col overflow-hidden overflow-y-auto">
<h3 class="text-[14px] text-[#999]">推荐问题</h3>
<h3 class="text-[14px] text-[#999]">{{ t('common_module.recommended_questions') }}</h3>
<div class="flex-1 overflow-hidden overflow-y-auto py-[10px]">
<n-scrollbar>
......@@ -107,7 +107,7 @@ const handleRecommendQuestionListUpdate = debounce(
<i
class="iconfont icon-huanyihuan group-active:rotate-360 mr-[2px] inline-block text-[11px] transition-[rotate] duration-150 ease-in-out"
></i>
<span>换一换</span>
<span>{{ t('common_module.exchange') }}</span>
</span>
</li>
</ul>
......@@ -119,52 +119,11 @@ const handleRecommendQuestionListUpdate = debounce(
<div v-else class="flex-center flex">
<div class="font-600 flex items-center rounded-[31px] bg-[#ECEFFF] px-[38px] py-[11px] text-[18px]">
<div class="bg-px-home-cuixiang_icon-png mr-[6px] h-[28px] w-[28px] bg-no-repeat"></div>
<span>萃想助手</span>
<span>{{ t('home_module.cui_xiang_Assistant') }}</span>
</div>
</div>
</Transition>
</div>
<!-- <div v-if="isShowAgentAbout" class="flex flex-1 flex-col overflow-hidden overflow-y-auto">
<div class="flex items-center pr-[10px]">
<img class="h-[70px] w-[70px] rounded-full" src="@/assets/images/home/agent-avatar.png" alt="代理人頭像" />
<div class="ml-[20px]">
<h2 class="font-600 mb-[14px] text-[26px]">{{ t('home_module.agent_welcome_message') }}</h2>
<div class="text-theme-color text-[18px]">{{ t('home_module.agent_description') }}</div>
</div>
</div>
<div class="mt-[39px] flex flex-1 flex-col overflow-hidden overflow-y-auto">
<h3 class="text-[14px] text-[#999]">推荐问题:</h3>
<div class="flex-1 overflow-hidden overflow-y-auto py-[10px]">
<n-scrollbar>
<ul class="select-none pr-[10px]">
<li
v-for="item in 3"
:key="item"
class="mt-[14px] w-fit cursor-pointer rounded-[20px] bg-[#E1E1FC] px-[12px] py-[10px] transition first:mt-[4px] hover:bg-[#D1D1EB]"
>
如果视图离开屏幕,则可将其停用,并可随时重新用于新的可见项目。如果视图离开屏幕,则可将其停用,并可随时重新用于新的可见项目。如果视图离开屏幕,则可将其停用,并可随时重新用于新的可见项目。
</li>
<li class="mt-[10px] cursor-pointer pl-[20px] text-[12px] text-[#0B7DFF] transition hover:text-[#096EE0]">
<i class="iconfont icon-huanyihuan mr-[2px] text-[11px]"></i>
<span>换一换</span>
</li>
</ul>
</n-scrollbar>
</div>
</div>
</div>
<div v-else class="flex-center flex">
<div class="font-600 flex items-center rounded-[31px] bg-[#ECEFFF] px-[38px] py-[11px] text-[18px]">
<div class="bg-px-home-cuixiang_icon-png mr-[6px] h-[28px] w-[28px] bg-no-repeat"></div>
<span>萃想助手</span>
</div>
</div> -->
</template>
<style lang="scss" scoped>
......
......@@ -5,6 +5,7 @@ import { fetchAgentApplicationSelectList } from '@/apis/home-agent'
import { nanoid } from 'nanoid'
import fetchEventStreamSource from '../utils/fetch-event-stream-source'
import { throttle } from 'lodash-es'
import { useI18n } from 'vue-i18n'
interface Props {
currentSessionId: string
......@@ -24,6 +25,8 @@ const questionContent = defineModel<string>('questionContent', { required: true
const currentAgentApplication = defineModel<AgentApplicationRecordItem>('currentAgentApplication', { required: true })
const isAgentResponding = defineModel<boolean>('isAgentResponding', { required: true })
const { t } = useI18n()
const isShowApplicationSelectMenu = ref(false)
const agentApplicationSelectList = ref<AgentApplicationRecordItem[]>([])
......@@ -119,9 +122,7 @@ function questionSubmit() {
messageListScrollToBottomThrottle()
},
onend: () => {
console.log('🐞🐞🐞🐞🐞🐞响应结束🐞🐞🐞🐞🐞🐞')
},
onend: () => {},
onclose: () => {
isAgentResponding.value = false
......@@ -129,11 +130,8 @@ function questionSubmit() {
emit('historyRecordListUpdate')
})
},
onerror: (err) => {
onerror: () => {
emit('deleteMessageItem', currentLatestMessageItemKeyMap.value.get('assistant')!)
console.log('🐛🐛🐛🐛🐛🐛响应错误🐛🐛🐛🐛🐛🐛')
console.log(err)
},
},
)
......@@ -235,7 +233,7 @@ function handleQuestionSubmitEnter(event: KeyboardEvent) {
<n-button class="application-select-btn !h-[34px] !rounded-[10px] !p-0" @click="handleCreateNewSession">
<div class="box-border flex w-full items-center justify-between px-[12px]">
<i class="iconfont icon-session mr-[5px] text-[14px]"></i>
<span class="text-[14px]">发起新会话</span>
<span class="text-[14px]">{{ t('home_module.starting_a_new_session') }}</span>
</div>
</n-button>
</div>
......@@ -246,7 +244,7 @@ function handleQuestionSubmitEnter(event: KeyboardEvent) {
class="content-input"
type="textarea"
:autosize="{ minRows: 5, maxRows: 5 }"
placeholder="请输入问题"
:placeholder="t('home_module.please_enter_a_question')"
@keydown="handleQuestionSubmitEnter"
>
<template #suffix>
......@@ -259,7 +257,9 @@ function handleQuestionSubmitEnter(event: KeyboardEvent) {
</n-input>
</div>
<div class="mt-[20px] text-center text-[13px] text-[#999]">以上内容均由AI生成,仅供参考</div>
<div class="mt-[20px] text-center text-[13px] text-[#999]">
{{ t('home_module.all_of_the_above_content_is_generated_by_ai_and_is_for_reference_only') }}
</div>
</div>
</template>
......
......@@ -2,6 +2,7 @@
import { fetchHistoryRecordDelete, fetchSessionHistoryRecordList } from '@/apis/home-agent'
import { computed, ref, nextTick, toValue, useTemplateRef } from 'vue'
import MessageTipModal from './message-tip-modal.vue'
import { useI18n } from 'vue-i18n'
interface SessionHistoryRecordItem {
content: string
......@@ -14,6 +15,7 @@ const emit = defineEmits<{
const isShowHistoryMenu = defineModel<boolean>({ default: true })
const { t } = useI18n()
const messageTipModalRef = useTemplateRef<InstanceType<typeof MessageTipModal>>('messageTipModalRef')
const sessionHistoryRecordList = ref<SessionHistoryRecordItem[]>([])
......@@ -22,8 +24,8 @@ const isHistoryListEdit = ref(false)
const currentSelectHistoryRecordList = ref<SessionHistoryRecordItem['dialogsId'][]>([])
const messageTipModalOptions = ref<{ title: string; content: string }>({
title: '从收藏列表中移除应用',
content: '移除后,该应用在主页产生的聊天记录将会清空',
title: t('common_module.tip'),
content: t('home_module.history_record_item_delete_tip'),
})
const isSelectAllRecord = computed(() => {
......@@ -49,7 +51,7 @@ function handleShowHistoryMenuSwitch() {
function handleHistoryListEditSwitch() {
if (!isHistoryListEdit.value && sessionHistoryRecordList.value.length === 0) {
window.$message.warning('当前没有历史记录可操作')
window.$message.warning(t('home_module.there_is_currently_no_history_to_work_with'))
return
}
......@@ -86,29 +88,29 @@ function handleRecordSelectAll(checked: boolean) {
function handleRecordDelete() {
if (currentSelectHistoryRecordList.value.length === 0) {
window.$message.warning('所选列表不能为空')
window.$message.warning(t('home_module.the_selected_list_cannot_be_empty'))
return
}
messageTipModalOptions.value = {
title: '从收藏列表中移除应用',
content: '移除后,该应用在主页产生的聊天记录将会清空',
title: t('common_module.tip'),
content: t('home_module.history_record_item_delete_tip'),
}
if (messageTipModalRef.value) {
messageTipModalRef.value.showModal().then(() => {
const loadingCtl = window.$message.loading('操作中...')
const loadingCtl = window.$message.loading(`${t('common_module.during_operation')}...`)
fetchHistoryRecordDelete(toValue(currentSelectHistoryRecordList.value))
.then(() => {
nextTick(() => {
window.$message.success('删除成功')
window.$message.success(t('common_module.delete_success_message'))
getSessionHistoryRecordList()
})
})
.catch(() => {
nextTick(() => {
window.$message.error('删除失败,请重试')
window.$message.error(t('common_module.deletion_failed_please_try_again'))
})
})
.finally(() => {
......@@ -124,8 +126,8 @@ function onHistoryRecordListUpdate() {
function handleRecordItemApply(dialogsId: string) {
messageTipModalOptions.value = {
title: '提示',
content: '是否确定应用此会话记录?',
title: t('common_module.tip'),
content: t('home_module.history_record_item_apply_tip'),
}
if (messageTipModalRef.value) {
......@@ -165,7 +167,7 @@ defineExpose({
<h2 v-if="!isHistoryListEdit" class="flex items-center justify-between">
<span class="flex items-center">
<i class="iconfont icon-history mr-[5px] !text-[14px] text-[#333]"></i>
<span class="font-600 text-[14px]">历史记录</span>
<span class="font-600 text-[14px]">{{ t('home_module.historical_record') }}</span>
</span>
<span
......@@ -177,7 +179,7 @@ defineExpose({
<div v-else class="flex select-none justify-evenly rounded-[18px] bg-[#fff] py-[2px]">
<div class="rounded-[12px] px-[6px] py-[2px] transition hover:bg-[#f2f3f5]">
<n-checkbox size="small" :checked="isSelectAllRecord" :on-update:checked="handleRecordSelectAll">
<span class="!text-[14px]">全选</span>
<span class="!text-[14px]">{{ t('common_module.select_all') }}</span>
</n-checkbox>
</div>
......@@ -186,7 +188,7 @@ defineExpose({
@click="handleRecordDelete"
>
<span class="iconfont icon-delete cursor-pointer text-[14px]"></span>
<span class="ml-[5px] text-[14px]">删除</span>
<span class="ml-[5px] text-[14px]">{{ t('common_module.delete') }}</span>
</button>
<button
......@@ -194,7 +196,7 @@ defineExpose({
@click="handleHistoryListEditSwitch"
>
<span class="iconfont icon-close cursor-pointer text-[14px]"></span>
<span class="ml-[5px] text-[14px]">退出</span>
<span class="ml-[5px] text-[14px]">{{ t('common_module.quit') }}</span>
</button>
</div>
</Transition>
......
......@@ -3,6 +3,7 @@ import { computed, readonly } from 'vue'
import type { MessageItemInterface } from '../types'
import { useUserStore } from '@/store/modules/user'
import MessageBubbleLoading from './message-bubble-loading.vue'
import { useI18n } from 'vue-i18n'
interface Props {
messageItem: MessageItemInterface
......@@ -10,6 +11,7 @@ interface Props {
const props = defineProps<Props>()
const { t } = useI18n()
const userStore = useUserStore()
const agentAvatarUrl = readonly({ url: 'https://gsst-poe-sit.gz.bcebos.com/icon/agent-avatar.png' })
......@@ -41,7 +43,9 @@ const isAgentMessage = computed(() => {
>
<MarkdownRender
v-if="!messageItem.isAnswerLoading"
:raw-text-content="messageItem.content ? messageItem.content : '[空内容]'"
:raw-text-content="
messageItem.content ? messageItem.content : t('common_module.dialogue_module.empty_message_content')
"
:color="isAgentMessage ? '#fff' : '#192338'"
/>
......
<script setup lang="ts">
import { ref } from 'vue'
import { useI18n } from 'vue-i18n'
interface Props {
title?: string
content: string
}
const { title = '提示', content = '' } = defineProps<Props>()
const { title = '', content = '' } = defineProps<Props>()
const { t } = useI18n()
const isShowModal = ref(false)
......@@ -45,7 +48,7 @@ defineExpose({
<div>
<h2>
<i class="iconfont icon-tishi text-[18px] text-[#f25744]"></i>
<span class="font-600 ml-[5px] text-[18px]">{{ title }}</span>
<span class="font-600 ml-[5px] text-[18px]">{{ title || t('common_module.tip') }}</span>
</h2>
<div class="mt-[20px] indent-4 text-[16px]">{{ content }}</div>
......@@ -53,11 +56,11 @@ defineExpose({
<div class="mt-[50px] text-end">
<n-button color="#F5F5F5" round class="!px-[34px] !py-[10px] !text-[14px] !text-[#333]" @click="handleCancel">
取消
{{ t('common_module.cancel_btn_text') }}
</n-button>
<n-button color="#6F77FF" round class="!ml-[12px] !px-[34px] !py-[10px] !text-[14px]" @click="handleConfirm">
确定
{{ t('common_module.confirm_btn_text') }}
</n-button>
</div>
</div>
......
......@@ -10,6 +10,9 @@ import type { ValueOf } from 'type-fest'
import { useElementSize } from '@vueuse/core'
import { debounce } from 'lodash-es'
import { nanoid } from 'nanoid'
import { useI18n } from 'vue-i18n'
const { t } = useI18n()
const homeContainerRef = useTemplateRef<HTMLDivElement>('homeContainerRef')
const messageListRef = useTemplateRef<InstanceType<typeof MessageList>>('messageListRef')
......@@ -96,7 +99,7 @@ function createSessionId() {
function onCreateNewSession() {
if (messageList.value.size === 0) {
window.$message.warning('当前已是最新会话')
window.$message.warning(t('home_module.currently_in_the_latest_session'))
return
}
......@@ -148,7 +151,7 @@ function onHistoryRecordListUpdate() {
function onGetMessageRecordList(recordId: string) {
currentSessionId.value = recordId
const loadingCtl = window.$message.loading('切换中...')
const loadingCtl = window.$message.loading(t('home_module.switching_over'))
fetchMessageRecordList<MessageItemInterface[]>(recordId)
.then((res) => {
......@@ -159,7 +162,7 @@ function onGetMessageRecordList(recordId: string) {
messageList.value = new Map(messageListDraft as any)
window.$message.success('历史记录应用成功')
window.$message.success(t('home_module.history_application_success'))
setTimeout(() => {
messageListScrollToBottom()
......@@ -167,7 +170,7 @@ function onGetMessageRecordList(recordId: string) {
}
})
.catch(() => {
window.$message.error('历史记录应用失败,请重试')
window.$message.error(t('home_module.history_application_failed_please_try_again'))
})
.finally(() => {
loadingCtl.destroy()
......@@ -214,7 +217,7 @@ function onGetMessageRecordList(recordId: string) {
>
<n-spin :size="38" />
<div class="text-theme-color mt-[30px] text-[14px]">加载中...</div>
<div class="text-theme-color mt-[30px] text-[14px]">{{ t('common_module.loading') }}...</div>
</div>
</Transition>
</div>
......
......@@ -53,7 +53,7 @@ const emailLoginForm = ref({
})
const passwordLoginFormRules = shallowReadonly<FormRules>({
account: { required: true, message: t('login_module.please_enter_your_username'), trigger: 'blur' },
account: { required: true, message: t('login_module.please_enter_your_account_number'), trigger: 'blur' },
password: { required: true, message: t('login_module.please_enter_your_password'), trigger: 'blur' },
})
const smsLoginFormRules = shallowReadonly<FormRules>({
......@@ -327,8 +327,8 @@ function handleEmailCodeGain() {
<n-input
v-model:value="passwordLoginForm.account"
:allow-input="noSideSpace"
:maxlength="11"
:placeholder="t('login_module.please_enter_your_username')"
:maxlength="50"
:placeholder="t('login_module.please_enter_your_account_number')"
>
<template #prefix>
<div class="mr-[6px]">
......@@ -467,6 +467,7 @@ function handleEmailCodeGain() {
v-model:value="emailLoginForm.email"
:allow-input="noSideSpace"
:placeholder="t('login_module.please_enter_your_email_address')"
:maxlength="50"
>
<template #prefix>
<div class="mr-[6px]">
......
......@@ -43,6 +43,16 @@ declare namespace I18n {
publish_success_message: string
clear_success_message: string
add_success_message: string
loading: string
updating: string
successful_update: string
recommended_questions: string
exchange: string
tip: string
during_operation: string
deletion_failed_please_try_again: string
select_all: string
quit: string
dialogue_module: {
continue_question_message: string
......@@ -73,7 +83,7 @@ declare namespace I18n {
login_module: {
app_welcome_words: string
please_enter_your_username: string
please_enter_your_account_number: string
please_enter_your_password: string
please_enter_your_cell_phone_number: string
please_enter_your_correct_cell_phone_number: string
......@@ -90,6 +100,19 @@ declare namespace I18n {
home_module: {
agent_welcome_message: string
agent_description: string
currently_in_the_latest_session: string
switching_over: string
history_application_success: string
history_application_failed_please_try_again: string
cui_xiang_Assistant: string
starting_a_new_session: string
please_enter_a_question: string
all_of_the_above_content_is_generated_by_ai_and_is_for_reference_only: string
history_record_item_delete_tip: string
there_is_currently_no_history_to_work_with: string
the_selected_list_cannot_be_empty: string
history_record_item_apply_tip: string
historical_record: string
}
router_title_module: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment