All checks were successful
CI / PHP 8.3 / mariadb:10.6 (pull_request) Has been skipped
CI / PHP 8.4 / mariadb:10.6 (pull_request) Has been skipped
CI / PHP 8.3 / mariadb:11.4 (pull_request) Has been skipped
CI / PHP 8.4 / mariadb:11.4 (pull_request) Has been skipped
CI / PHP 8.3 / mysql:8.0 (pull_request) Has been skipped
CI / PHP 8.4 / mysql:8.0 (pull_request) Has been skipped
CI / PHP 8.3 / mysql:8.4 (pull_request) Has been skipped
CI / PHP 8.4 / mysql:8.4 (pull_request) Has been skipped
CI / Browser-Tests (pull_request) Successful in 14m21s
CI / PHP 8.3 / mysql:8.4-1 (pull_request) Successful in 19m7s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 5m20s
CI / Build-Artefakte aktuell (pull_request) Successful in 5m46s
- AskBubble unten rechts (abschaltbar), Gespräch bleibt beim Seitenwechsel - Antwortanzeige als gemeinsame Komponente AskAnswer - Trefferliste der Kopfzeilen-Suche in der App-Oberfläche linksbündig - CI: optionale Kern-Plugins für Browser-Tests einschalten, Suchtest mit Demo-Inhalt Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
118 lines
4.9 KiB
Vue
118 lines
4.9 KiB
Vue
<script setup>
|
||
import { nextTick, onMounted, ref } from 'vue';
|
||
import { LoaderCircle, MessageCircleQuestion, Sparkles } from '@lucide/vue';
|
||
import AppLayout from '@/layouts/AppLayout.vue';
|
||
import PageHeader from '@/components/PageHeader.vue';
|
||
import Panel from '@/components/Panel.vue';
|
||
import { Button } from '@/components/ui/button';
|
||
import AskAnswer from '@/components/ask/AskAnswer.vue';
|
||
import { askPortal } from '@/lib/ask';
|
||
|
||
const props = defineProps({
|
||
question: { type: String, default: '' },
|
||
sources: { type: Array, default: () => [] },
|
||
provider: { type: String, default: null },
|
||
});
|
||
|
||
const input = ref(props.question);
|
||
const asked = ref('');
|
||
const loading = ref(false);
|
||
const error = ref('');
|
||
const result = ref(null);
|
||
const field = ref(null);
|
||
|
||
const examples = ['Wie beantrage ich Urlaub?', 'Was mache ich bei einem Arbeitsunfall?', 'Wer ist in der Mitarbeitervertretung?'];
|
||
|
||
async function ask(question = input.value) {
|
||
const text = question.trim();
|
||
if (text.length < 3 || loading.value) return;
|
||
|
||
input.value = text;
|
||
asked.value = text;
|
||
loading.value = true;
|
||
error.value = '';
|
||
result.value = null;
|
||
|
||
// Frage in der Adresse, damit man sie teilen und zurückkehren kann
|
||
window.history.replaceState(window.history.state, '', `/frag-das-portal?frage=${encodeURIComponent(text)}`);
|
||
|
||
try {
|
||
result.value = await askPortal(text);
|
||
} catch (e) {
|
||
error.value = e.message;
|
||
} finally {
|
||
loading.value = false;
|
||
}
|
||
}
|
||
|
||
onMounted(() => {
|
||
if (props.question) ask(props.question);
|
||
else nextTick(() => field.value?.focus());
|
||
});
|
||
</script>
|
||
|
||
<template>
|
||
<AppLayout title="Frag das Portal" width="medium">
|
||
<PageHeader
|
||
title="Frag das Portal"
|
||
:description="`Stellen Sie eine Frage – die Antwort kommt aus ${sources.length ? sources.join(', ') : 'den Inhalten des Portals'}.`"
|
||
icon="message-circle-question"
|
||
/>
|
||
|
||
<div class="grid min-w-0 grid-cols-1 gap-5">
|
||
<form class="grid min-w-0 gap-3" @submit.prevent="ask()">
|
||
<label for="ask-question" class="sr-only">Ihre Frage</label>
|
||
<div class="flex flex-col gap-2 rounded-xl border bg-card p-2 shadow-xs focus-within:border-brand-400 focus-within:ring-3 focus-within:ring-ring/30 sm:flex-row sm:items-end">
|
||
<textarea
|
||
id="ask-question"
|
||
ref="field"
|
||
v-model="input"
|
||
rows="2"
|
||
maxlength="300"
|
||
placeholder="z. B. Wie beantrage ich eine Fortbildung?"
|
||
class="min-h-14 w-full min-w-0 flex-1 resize-none bg-transparent px-2 py-1.5 text-base outline-none placeholder:text-muted-foreground"
|
||
@keydown.enter.exact.prevent="ask()"
|
||
/>
|
||
<Button type="submit" :disabled="loading || input.trim().length < 3" class="shrink-0">
|
||
<LoaderCircle v-if="loading" class="animate-spin" />
|
||
<Sparkles v-else />
|
||
Fragen
|
||
</Button>
|
||
</div>
|
||
<div v-if="!asked" class="flex flex-wrap gap-2">
|
||
<button
|
||
v-for="example in examples"
|
||
:key="example"
|
||
type="button"
|
||
class="rounded-pill border bg-card px-3.5 py-1.5 text-[13px] text-muted-foreground hover:bg-accent hover:text-foreground"
|
||
@click="ask(example)"
|
||
>{{ example }}</button>
|
||
</div>
|
||
</form>
|
||
|
||
<div aria-live="polite" class="grid min-w-0 grid-cols-1 gap-5">
|
||
<Panel v-if="loading">
|
||
<div class="flex items-center gap-3 text-muted-foreground">
|
||
<LoaderCircle class="size-5 animate-spin text-brand" />
|
||
Ich suche im Portal nach einer Antwort …
|
||
</div>
|
||
</Panel>
|
||
|
||
<p v-else-if="error" class="rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-3 text-sm text-destructive">{{ error }}</p>
|
||
|
||
<Panel v-else-if="result">
|
||
<p class="mb-3 text-sm font-medium text-muted-foreground">{{ asked }}</p>
|
||
<AskAnswer :result="result" />
|
||
</Panel>
|
||
</div>
|
||
|
||
<p class="flex items-start gap-2 text-xs text-muted-foreground">
|
||
<MessageCircleQuestion class="mt-px size-3.5 shrink-0" />
|
||
<span>
|
||
Gesucht wird nur in Inhalten, die Sie sehen dürfen. Fragen werden ohne Ihren Namen gespeichert, damit die Redaktion fehlende Inhalte ergänzen kann.
|
||
<template v-if="provider"> Die Frage und passende Textstellen werden zur Beantwortung an {{ provider }} übermittelt.</template>
|
||
</span>
|
||
</p>
|
||
</div>
|
||
</AppLayout>
|
||
</template>
|