318 lines
6.2 KiB
Vue
318 lines
6.2 KiB
Vue
<script setup lang="ts">
|
|
interface Props {
|
|
visible: boolean;
|
|
currentModel: string;
|
|
}
|
|
|
|
const props = defineProps<Props>();
|
|
const emit = defineEmits<{
|
|
(e: "update:visible", value: boolean): void;
|
|
(e: "update:currentModel", value: string): void;
|
|
}>();
|
|
|
|
const MODEL_OPTIONS = [
|
|
{
|
|
value: "translategemma:12b",
|
|
label: "TranslateGemma 12B",
|
|
description: " (Best Quality ~12GB VRAM)",
|
|
},
|
|
{
|
|
value: "translategemma:4b",
|
|
label: "TranslateGemma 4B",
|
|
description: "(Balanced speed/quality ~4GB VRAM)",
|
|
},
|
|
];
|
|
|
|
const selectedModel = ref(props.currentModel);
|
|
|
|
watch(
|
|
() => props.currentModel,
|
|
(val) => {
|
|
selectedModel.value = val;
|
|
},
|
|
);
|
|
|
|
watch(
|
|
() => props.visible,
|
|
(val) => {
|
|
if (val) {
|
|
selectedModel.value = props.currentModel;
|
|
}
|
|
},
|
|
);
|
|
|
|
function save() {
|
|
emit("update:currentModel", selectedModel.value);
|
|
close();
|
|
}
|
|
|
|
function close() {
|
|
emit("update:visible", false);
|
|
}
|
|
|
|
function handleOverlayClick(event: MouseEvent) {
|
|
if ((event.target as HTMLElement).classList.contains("settings-overlay")) {
|
|
close();
|
|
}
|
|
}
|
|
|
|
function handleKeydown(event: KeyboardEvent) {
|
|
if (event.key === "Escape") {
|
|
close();
|
|
}
|
|
}
|
|
|
|
onMounted(() => {
|
|
document.addEventListener("keydown", handleKeydown);
|
|
});
|
|
|
|
onUnmounted(() => {
|
|
document.removeEventListener("keydown", handleKeydown);
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<Teleport to="body">
|
|
<Transition name="modal">
|
|
<div v-if="visible" class="settings-overlay" @click="handleOverlayClick">
|
|
<div
|
|
class="settings-modal"
|
|
role="dialog"
|
|
aria-modal="true"
|
|
aria-label="Settings"
|
|
>
|
|
<div class="settings-header">
|
|
<h2 class="settings-title">Settings</h2>
|
|
<button
|
|
class="settings-close"
|
|
@click="close"
|
|
type="button"
|
|
aria-label="Close settings"
|
|
>
|
|
✕
|
|
</button>
|
|
</div>
|
|
|
|
<div class="settings-body">
|
|
<div class="setting-group">
|
|
<label class="setting-label">Translation Model</label>
|
|
<p class="setting-description">
|
|
Choose the model size for translation quality vs speed.
|
|
</p>
|
|
<div class="model-options">
|
|
<label
|
|
v-for="option in MODEL_OPTIONS"
|
|
:key="option.value"
|
|
class="model-option"
|
|
:class="{ selected: selectedModel === option.value }"
|
|
>
|
|
<input
|
|
type="radio"
|
|
:value="option.value"
|
|
v-model="selectedModel"
|
|
class="model-radio"
|
|
/>
|
|
<div class="model-info">
|
|
<span class="model-name">{{ option.label }}</span>
|
|
<span class="model-desc">{{ option.description }}</span>
|
|
</div>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="settings-footer">
|
|
<button
|
|
class="btn settings-cancel-btn"
|
|
@click="close"
|
|
type="button"
|
|
>
|
|
Cancel
|
|
</button>
|
|
<button class="btn settings-save-btn" @click="save" type="button">
|
|
Save
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</Transition>
|
|
</Teleport>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.settings-overlay {
|
|
position: fixed;
|
|
inset: 0;
|
|
background-color: var(--overlay-color);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
z-index: 9000;
|
|
padding: 1rem;
|
|
}
|
|
|
|
.settings-modal {
|
|
background-color: var(--modal-bg);
|
|
border: 1px solid var(--border-color);
|
|
border-radius: 12px;
|
|
width: 100%;
|
|
max-width: 480px;
|
|
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
|
|
}
|
|
|
|
.settings-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
padding: 1.25rem 1.5rem;
|
|
border-bottom: 1px solid var(--border-color);
|
|
}
|
|
|
|
.settings-title {
|
|
font-size: 1.25rem;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.settings-close {
|
|
background: none;
|
|
border: none;
|
|
font-size: 1.25rem;
|
|
cursor: pointer;
|
|
color: var(--muted-color);
|
|
padding: 0.25rem;
|
|
line-height: 1;
|
|
border-radius: 4px;
|
|
transition: color 0.2s;
|
|
}
|
|
|
|
.settings-close:hover {
|
|
color: var(--text-color);
|
|
}
|
|
|
|
.settings-body {
|
|
padding: 1.5rem;
|
|
}
|
|
|
|
.setting-group {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 0.5rem;
|
|
}
|
|
|
|
.setting-label {
|
|
font-weight: 600;
|
|
font-size: 0.9375rem;
|
|
}
|
|
|
|
.setting-description {
|
|
font-size: 0.8125rem;
|
|
color: var(--muted-color);
|
|
margin-bottom: 0.5rem;
|
|
}
|
|
|
|
.model-options {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 0.5rem;
|
|
}
|
|
|
|
.model-option {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.75rem;
|
|
padding: 0.75rem 1rem;
|
|
border: 1px solid var(--border-color);
|
|
border-radius: 8px;
|
|
cursor: pointer;
|
|
transition:
|
|
border-color 0.2s,
|
|
background-color 0.2s;
|
|
}
|
|
|
|
.model-option:hover {
|
|
border-color: var(--primary-color);
|
|
}
|
|
|
|
.model-option.selected {
|
|
border-color: var(--primary-color);
|
|
background-color: var(--surface-alt-color);
|
|
}
|
|
|
|
.model-radio {
|
|
accent-color: var(--primary-color);
|
|
width: 1rem;
|
|
height: 1rem;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.model-info {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 0.125rem;
|
|
}
|
|
|
|
.model-name {
|
|
font-weight: 500;
|
|
font-size: 0.9375rem;
|
|
}
|
|
|
|
.model-desc {
|
|
font-size: 0.75rem;
|
|
color: var(--muted-color);
|
|
}
|
|
|
|
.settings-footer {
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
gap: 0.75rem;
|
|
padding: 1rem 1.5rem;
|
|
border-top: 1px solid var(--border-color);
|
|
}
|
|
|
|
.settings-cancel-btn {
|
|
background-color: var(--clear-btn-color);
|
|
}
|
|
|
|
.settings-save-btn {
|
|
background-color: var(--primary-color);
|
|
}
|
|
|
|
.modal-enter-active {
|
|
transition: opacity 0.2s ease;
|
|
}
|
|
|
|
.modal-enter-active .settings-modal {
|
|
transition: transform 0.2s ease;
|
|
}
|
|
|
|
.modal-leave-active {
|
|
transition: opacity 0.2s ease;
|
|
}
|
|
|
|
.modal-leave-active .settings-modal {
|
|
transition: transform 0.2s ease;
|
|
}
|
|
|
|
.modal-enter-from {
|
|
opacity: 0;
|
|
}
|
|
|
|
.modal-enter-from .settings-modal {
|
|
transform: scale(0.95);
|
|
}
|
|
|
|
.modal-leave-to {
|
|
opacity: 0;
|
|
}
|
|
|
|
.modal-leave-to .settings-modal {
|
|
transform: scale(0.95);
|
|
}
|
|
|
|
@media (max-width: 640px) {
|
|
.settings-modal {
|
|
max-width: 100%;
|
|
}
|
|
}
|
|
</style>
|