2025-12-18 01:00:25 +08:00
|
|
|
<script setup lang="ts">
|
|
|
|
|
import type { ChatMessage } from '@/types/chat'
|
|
|
|
|
import { useScroll } from '@vueuse/core'
|
|
|
|
|
import { isDark, toggleDark } from '@/composables/dark'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Sample chat data for demonstration
|
|
|
|
|
const messages = ref<ChatMessage[]>([
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
const inputText = ref('')
|
|
|
|
|
const isLoading = ref(false)
|
|
|
|
|
const messagesContainer = ref<HTMLElement>()
|
|
|
|
|
|
|
|
|
|
const { arrivedState } = useScroll(messagesContainer, {
|
|
|
|
|
offset: { bottom: 100 },
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// Auto-scroll to bottom when new messages arrive
|
|
|
|
|
watch(messages, () => {
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
if (messagesContainer.value && arrivedState.bottom) {
|
|
|
|
|
messagesContainer.value.scrollTop = messagesContainer.value.scrollHeight
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}, { deep: true })
|
|
|
|
|
|
|
|
|
|
function handleSend(text: string) {
|
refactor: remove i18n dependency and hardcode strings in components
- Updated ChatInput.vue to remove i18n and handle model value updates directly.
- Refactored NavBar.vue to use a static title map instead of i18n.
- Simplified TabBar.vue by replacing i18n calls with hardcoded titles.
- Removed i18n usage in various pages (charts, counter, forgot-password, index, keepalive, llm-chat, login, mock, profile, register, scroll-cache, settings, unocss).
- Deleted localization files (en-US.json, zh-CN.json) and i18n utility functions.
- Updated constants to provide static app name and description.
- Adjusted page titles in set-page-title.ts to use static names.
- Cleaned up TypeScript types by removing unused i18n types.
2025-12-19 10:09:47 +08:00
|
|
|
if (!text.trim())
|
|
|
|
|
return
|
2025-12-18 01:00:25 +08:00
|
|
|
|
|
|
|
|
// Add user message
|
|
|
|
|
const userMessage: ChatMessage = {
|
|
|
|
|
id: Date.now(),
|
|
|
|
|
content: text,
|
|
|
|
|
sender: 'user',
|
|
|
|
|
timestamp: new Date(),
|
refactor: remove i18n dependency and hardcode strings in components
- Updated ChatInput.vue to remove i18n and handle model value updates directly.
- Refactored NavBar.vue to use a static title map instead of i18n.
- Simplified TabBar.vue by replacing i18n calls with hardcoded titles.
- Removed i18n usage in various pages (charts, counter, forgot-password, index, keepalive, llm-chat, login, mock, profile, register, scroll-cache, settings, unocss).
- Deleted localization files (en-US.json, zh-CN.json) and i18n utility functions.
- Updated constants to provide static app name and description.
- Adjusted page titles in set-page-title.ts to use static names.
- Cleaned up TypeScript types by removing unused i18n types.
2025-12-19 10:09:47 +08:00
|
|
|
status: 'sent',
|
2025-12-18 01:00:25 +08:00
|
|
|
}
|
|
|
|
|
messages.value.push(userMessage)
|
|
|
|
|
|
|
|
|
|
// Clear input
|
|
|
|
|
inputText.value = ''
|
|
|
|
|
|
|
|
|
|
// Simulate AI response after delay
|
|
|
|
|
isLoading.value = true
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
userMessage.status = 'sent'
|
|
|
|
|
|
|
|
|
|
const aiMessage: ChatMessage = {
|
|
|
|
|
id: Date.now() + 1,
|
|
|
|
|
content: `I received your message: "${text}". This is a simulated response.`,
|
|
|
|
|
sender: 'ai',
|
|
|
|
|
timestamp: new Date(),
|
|
|
|
|
status: 'sent',
|
|
|
|
|
}
|
|
|
|
|
messages.value.push(aiMessage)
|
|
|
|
|
isLoading.value = false
|
|
|
|
|
}, 1000)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleKeydown(e: KeyboardEvent) {
|
|
|
|
|
// You can add additional keyboard shortcuts here
|
|
|
|
|
console.log('Keydown event:', e.key)
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
refactor: remove i18n dependency and hardcode strings in components
- Updated ChatInput.vue to remove i18n and handle model value updates directly.
- Refactored NavBar.vue to use a static title map instead of i18n.
- Simplified TabBar.vue by replacing i18n calls with hardcoded titles.
- Removed i18n usage in various pages (charts, counter, forgot-password, index, keepalive, llm-chat, login, mock, profile, register, scroll-cache, settings, unocss).
- Deleted localization files (en-US.json, zh-CN.json) and i18n utility functions.
- Updated constants to provide static app name and description.
- Adjusted page titles in set-page-title.ts to use static names.
- Cleaned up TypeScript types by removing unused i18n types.
2025-12-19 10:09:47 +08:00
|
|
|
<div class="bg-gray-50 flex flex-col h-screen dark:bg-gray-950">
|
2025-12-18 01:00:25 +08:00
|
|
|
|
|
|
|
|
<!-- Messages container -->
|
|
|
|
|
<van-list
|
|
|
|
|
ref="messagesContainer"
|
2025-12-19 17:03:54 +08:00
|
|
|
class="p-4 pb-24 flex-1"
|
2025-12-18 01:00:25 +08:00
|
|
|
:finished="true"
|
|
|
|
|
:loading="false"
|
|
|
|
|
finished-text=""
|
|
|
|
|
loading-text=""
|
|
|
|
|
>
|
|
|
|
|
<van-empty
|
|
|
|
|
v-if="messages.length === 0"
|
|
|
|
|
description="No messages yet. Start a conversation!"
|
|
|
|
|
class="mt-20"
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<div v-else>
|
|
|
|
|
<ChatBubble
|
|
|
|
|
v-for="message in messages"
|
|
|
|
|
:key="message.id"
|
|
|
|
|
:message="message"
|
|
|
|
|
:show-timestamp="true"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</van-list>
|
|
|
|
|
|
|
|
|
|
<!-- Input area -->
|
refactor: remove i18n dependency and hardcode strings in components
- Updated ChatInput.vue to remove i18n and handle model value updates directly.
- Refactored NavBar.vue to use a static title map instead of i18n.
- Simplified TabBar.vue by replacing i18n calls with hardcoded titles.
- Removed i18n usage in various pages (charts, counter, forgot-password, index, keepalive, llm-chat, login, mock, profile, register, scroll-cache, settings, unocss).
- Deleted localization files (en-US.json, zh-CN.json) and i18n utility functions.
- Updated constants to provide static app name and description.
- Adjusted page titles in set-page-title.ts to use static names.
- Cleaned up TypeScript types by removing unused i18n types.
2025-12-19 10:09:47 +08:00
|
|
|
<div class="bottom-0 left-0 right-0 fixed z-10">
|
2025-12-18 01:00:25 +08:00
|
|
|
<ChatInput
|
|
|
|
|
v-model="inputText"
|
|
|
|
|
:disabled="isLoading"
|
|
|
|
|
:loading="isLoading"
|
|
|
|
|
placeholder="Type your message..."
|
|
|
|
|
@send="handleSend"
|
|
|
|
|
@keydown="handleKeydown"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<route lang="json5">
|
|
|
|
|
{
|
|
|
|
|
name: 'LLMChat',
|
|
|
|
|
meta: {
|
|
|
|
|
title: 'AI Chat',
|
|
|
|
|
requiresAuth: false
|
|
|
|
|
}
|
|
|
|
|
}
|
refactor: remove i18n dependency and hardcode strings in components
- Updated ChatInput.vue to remove i18n and handle model value updates directly.
- Refactored NavBar.vue to use a static title map instead of i18n.
- Simplified TabBar.vue by replacing i18n calls with hardcoded titles.
- Removed i18n usage in various pages (charts, counter, forgot-password, index, keepalive, llm-chat, login, mock, profile, register, scroll-cache, settings, unocss).
- Deleted localization files (en-US.json, zh-CN.json) and i18n utility functions.
- Updated constants to provide static app name and description.
- Adjusted page titles in set-page-title.ts to use static names.
- Cleaned up TypeScript types by removing unused i18n types.
2025-12-19 10:09:47 +08:00
|
|
|
</route>
|