57 lines
1.8 KiB
Vue
57 lines
1.8 KiB
Vue
<script setup lang="ts">
|
|
import { ref } from 'vue';
|
|
import Input from './components/Input.vue';
|
|
import {load, Store} from "@tauri-apps/plugin-store";
|
|
import { invoke } from '@tauri-apps/api/core';
|
|
|
|
const initialized = ref(false);
|
|
const ollama_url = ref("");
|
|
const ollama_api_key = ref("");
|
|
|
|
const home_page=ref(false);
|
|
|
|
async function submit(ev){
|
|
ev.preventDefault();
|
|
await store.set("url",ollama_url.value);
|
|
await store.set("api-key",ollama_api_key.value);
|
|
await store.save();
|
|
try {
|
|
await invoke("connect_ollama",{url: ollama_url.value, apiKey: ollama_api_key.value});
|
|
} catch(e){
|
|
window.alert("Verbindung nicht möglich: "+e);
|
|
return;
|
|
}
|
|
home_page.value=true;
|
|
}
|
|
let store: Store;
|
|
|
|
async function init(){
|
|
store = await load('store.json', { autoSave: false });
|
|
if (await store.has("url")){
|
|
ollama_url.value=await store.get("url");
|
|
}
|
|
if (await store.has("api-key")){
|
|
ollama_api_key.value=await store.get("api-key");
|
|
}
|
|
initialized.value=true;
|
|
}
|
|
init();
|
|
</script>
|
|
<template>
|
|
<main class="w-screen h-screen overflow-hidden flex items-center justify-center p-10" v-if="initialized">
|
|
<div class="w-full h-full border rounded-2xl transition-all ease-in-out duration-200 p-6 overflow-y-scroll">
|
|
<div v-if="!home_page">
|
|
<h1>Moin!</h1>
|
|
<p>Mit dieser App kannst du verschiedene Modelle über die Ollama API ausprobieren und vergleichen.</p>
|
|
<form @submit="submit">
|
|
<Input placeholder="Ollama URL (z.B. http://localhost:11434)" class="w-full" v-model="ollama_url"/> <br>
|
|
<Input placeholder="API Key (optional)" class="w-full" type="password" v-model="ollama_api_key"/> <br>
|
|
<br>
|
|
<input value="Weiter" class="w-full border" type="submit"/>
|
|
</form>
|
|
</div>
|
|
<RouterView v-else/>
|
|
</div>
|
|
</main>
|
|
|
|
</template> |