First version running with npm run dev
This commit is contained in:
commit
f90ec06a4f
28 files changed
+12042
No files matched your search
@@ -0,0 +1,246 @@
|
||||
<script setup lang="ts">
|
||||
import LanguageSelector from "~/components/LanguageSelector.vue";
|
||||
import TextInput from "~/components/TextInput.vue";
|
||||
import TranslationOutput from "~/components/TranslationOutput.vue";
|
||||
import { useTranslation } from "~/composables/useTranslation";
|
||||
import { useOllamaStatus } from "~/composables/useOllamaStatus";
|
||||
import { useSettings } from "~/composables/useSettings";
|
||||
|
||||
const { model } = useSettings();
|
||||
const {
|
||||
sourceText,
|
||||
translatedText,
|
||||
sourceLang,
|
||||
targetLang,
|
||||
isLoading,
|
||||
error,
|
||||
translate,
|
||||
swapLanguages,
|
||||
clearInput,
|
||||
} = useTranslation({ model });
|
||||
|
||||
const { status, isReady, errorMessage, checkStatus } = useOllamaStatus();
|
||||
|
||||
function handleTranslate() {
|
||||
if (!isReady.value) {
|
||||
error.value = errorMessage.value || "Ollama service is not ready";
|
||||
return;
|
||||
}
|
||||
translate();
|
||||
}
|
||||
|
||||
function handleKeydown(event: KeyboardEvent) {
|
||||
if (event.ctrlKey && event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
handleTranslate();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="translation-page">
|
||||
<div
|
||||
v-if="!isReady"
|
||||
class="status-banner"
|
||||
:class="status.modelExists ? 'status-warning' : 'status-error'"
|
||||
>
|
||||
<div class="status-content">
|
||||
<span class="status-icon">{{ status.modelExists ? "⚠" : "❌" }}</span>
|
||||
<span class="status-message">{{ status.message }}</span>
|
||||
<button
|
||||
v-if="!status.available"
|
||||
class="btn status-btn"
|
||||
@click="checkStatus"
|
||||
type="button"
|
||||
>
|
||||
Retry
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="translation-controls">
|
||||
<div class="language-selectors">
|
||||
<LanguageSelector label="Translate from" v-model="sourceLang" />
|
||||
<button
|
||||
class="swap-button btn"
|
||||
@click="swapLanguages"
|
||||
type="button"
|
||||
aria-label="Swap languages"
|
||||
title="Swap languages"
|
||||
>
|
||||
⇆
|
||||
</button>
|
||||
<LanguageSelector label="Translate to" v-model="targetLang" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="translation-input">
|
||||
<TextInput
|
||||
label="Source Text"
|
||||
v-model="sourceText"
|
||||
placeholder="Enter text to translate..."
|
||||
:disabled="isLoading"
|
||||
@keydown="handleKeydown"
|
||||
/>
|
||||
<div class="input-actions">
|
||||
<button
|
||||
class="btn clear-btn"
|
||||
@click="clearInput"
|
||||
:disabled="!sourceText"
|
||||
type="button"
|
||||
>
|
||||
Clear
|
||||
</button>
|
||||
<button
|
||||
class="btn translate-btn"
|
||||
@click="handleTranslate"
|
||||
:disabled="!sourceText.trim() || isLoading"
|
||||
type="button"
|
||||
>
|
||||
{{ isLoading ? "Translating..." : "Translate" }}
|
||||
{{ isLoading || !sourceLang ? "" : "(Ctrl+Enter)" }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="translation-output-section">
|
||||
<TranslationOutput
|
||||
label="Translation"
|
||||
:text="translatedText"
|
||||
:loading="isLoading"
|
||||
:error="error"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.translation-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2rem;
|
||||
}
|
||||
|
||||
.translation-controls {
|
||||
background: var(--surface-color);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 8px;
|
||||
padding: 1rem;
|
||||
transition:
|
||||
background-color 0.3s,
|
||||
border-color 0.3s;
|
||||
}
|
||||
|
||||
.language-selectors {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.swap-button {
|
||||
padding: 0.5rem 0.75rem;
|
||||
font-size: 1.25rem;
|
||||
line-height: 1;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.translation-input {
|
||||
background: var(--surface-color);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 8px;
|
||||
padding: 1rem;
|
||||
transition:
|
||||
background-color 0.3s,
|
||||
border-color 0.3s;
|
||||
}
|
||||
|
||||
.input-actions {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
margin-top: 1rem;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.clear-btn {
|
||||
background-color: var(--clear-btn-color);
|
||||
}
|
||||
|
||||
.translate-btn {
|
||||
background-color: var(--primary-color);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.translation-output-section {
|
||||
background: var(--surface-color);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 8px;
|
||||
padding: 1rem;
|
||||
transition:
|
||||
background-color 0.3s,
|
||||
border-color 0.3s;
|
||||
}
|
||||
|
||||
.status-banner {
|
||||
background: var(--banner-warning-bg);
|
||||
border: 1px solid var(--banner-warning-border);
|
||||
border-radius: 8px;
|
||||
padding: 1rem;
|
||||
color: var(--banner-warning-text);
|
||||
}
|
||||
|
||||
.status-banner.status-error {
|
||||
background: var(--banner-error-bg);
|
||||
border-color: var(--banner-error-border);
|
||||
color: var(--banner-error-text);
|
||||
}
|
||||
|
||||
.status-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.status-icon {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
|
||||
.status-message {
|
||||
flex: 1;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.status-btn {
|
||||
padding: 0.25rem 0.75rem;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.language-selectors {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.swap-button {
|
||||
margin: 0.5rem 0;
|
||||
order: -1;
|
||||
}
|
||||
|
||||
.input-actions {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.input-actions .btn {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.status-content {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.status-btn {
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user