Update dependencies and enhance ChatInput component functionality. Upgraded Vite to version 8.0.1, updated various package versions in package-lock.json, and improved user experience in ChatInput.vue by adding dynamic placeholder text and error handling for message sending without an active conversation.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<input
|
||||
v-model="message"
|
||||
type="text"
|
||||
:placeholder="$t('button_send')"
|
||||
:placeholder="inputPlaceholder"
|
||||
@keyup.enter="sendMessage"
|
||||
/>
|
||||
<button @click="sendMessage">{{ $t('button_send') }}</button>
|
||||
@@ -17,7 +17,12 @@
|
||||
style="display: none"
|
||||
@change="handleImageUpload"
|
||||
/>
|
||||
<button class="no-style" @click="$refs.fileInput.click()" :title="$t('tooltip_send_image')">
|
||||
<button
|
||||
class="no-style"
|
||||
@click="$refs.fileInput.click()"
|
||||
:title="$t('tooltip_send_image')"
|
||||
:disabled="!hasConversation"
|
||||
>
|
||||
<img src="/image.png" alt="Image" />
|
||||
</button>
|
||||
|
||||
@@ -35,12 +40,18 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { ref, computed } from 'vue';
|
||||
import { useChatStore } from '../stores/chat';
|
||||
|
||||
const chatStore = useChatStore();
|
||||
const message = ref('');
|
||||
const showSmileys = ref(false);
|
||||
const hasConversation = computed(() => !!chatStore.currentConversation);
|
||||
const inputPlaceholder = computed(() =>
|
||||
hasConversation.value
|
||||
? 'Nachricht senden oder /Befehl eingeben'
|
||||
: 'Nur /Befehle eingeben (z.B. /login, /stat help)'
|
||||
);
|
||||
|
||||
// Smiley-Definitionen (wie im Original)
|
||||
const smileys = {
|
||||
@@ -70,7 +81,15 @@ function sendMessage() {
|
||||
const trimmed = message.value.trim();
|
||||
if (!trimmed) return;
|
||||
const isCommand = trimmed.startsWith('/');
|
||||
if (!isCommand && !chatStore.currentConversation) return;
|
||||
if (!isCommand && !hasConversation.value) {
|
||||
chatStore.errorMessage = 'Ohne aktive Konversation sind nur /Befehle erlaubt.';
|
||||
setTimeout(() => {
|
||||
if (chatStore.errorMessage === 'Ohne aktive Konversation sind nur /Befehle erlaubt.') {
|
||||
chatStore.errorMessage = null;
|
||||
}
|
||||
}, 4000);
|
||||
return;
|
||||
}
|
||||
|
||||
chatStore.sendMessage(chatStore.currentConversation, trimmed);
|
||||
message.value = '';
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
<span v-if="currentUserInfo">{{ currentUserInfo.country }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<ChatWindow v-if="!chatStore.errorMessage" />
|
||||
<ChatInput v-if="chatStore.currentConversation && !chatStore.errorMessage" />
|
||||
<ChatWindow />
|
||||
<ChatInput />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user