Migrate frontend to Svelte 5 runes semantics

This commit is contained in:
2026-03-11 11:29:24 +03:00
parent 765178f12e
commit 0083d9054e
61 changed files with 989 additions and 922 deletions

View File

@@ -11,25 +11,26 @@
import { requestApi } from "../../lib/api";
import { addToast } from "../../lib/toasts.js";
/** @type {Array} */
export let providers = [];
export let onSave = () => {};
let {
providers = [],
onSave = () => {},
} = $props();
let editingProvider = null;
let showForm = false;
let editingProvider = $state(null);
let showForm = $state(false);
let formData = {
let formData = $state({
name: "",
provider_type: "openai",
base_url: "https://api.openai.com/v1",
api_key: "",
default_model: "gpt-4o",
is_active: true,
};
});
let testStatus = { type: "", message: "" };
let isTesting = false;
let togglingProviderIds = new Set();
let testStatus = $state({ type: "", message: "" });
let isTesting = $state(false);
let togglingProviderIds = $state(new Set());
function isMultimodalModel(modelName) {
const token = (modelName || "").toLowerCase();
@@ -162,7 +163,7 @@
<button
type="button"
class="bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700 transition"
on:click|preventDefault={() => {
onclick={() => {
resetForm();
showForm = true;
}}
@@ -285,7 +286,7 @@
<button
type="button"
class="px-4 py-2 border rounded hover:bg-gray-50 flex-1"
on:click|preventDefault={() => {
onclick={() => {
showForm = false;
}}
>
@@ -295,14 +296,14 @@
type="button"
class="px-4 py-2 bg-gray-600 text-white rounded hover:bg-gray-700 flex-1"
disabled={isTesting}
on:click|preventDefault={testConnection}
onclick={testConnection}
>
{isTesting ? $t.llm.testing : $t.llm.test}
</button>
<button
type="button"
class="px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 flex-1"
on:click|preventDefault={handleSubmit}
onclick={handleSubmit}
>
{$t.llm.save}
</button>
@@ -340,14 +341,14 @@
<button
type="button"
class="text-sm text-blue-600 hover:underline"
on:click|preventDefault|stopPropagation={() => handleEdit(provider)}
onclick={() => handleEdit(provider)}
>
{$t.common.edit}
</button>
<button
type="button"
class={`text-sm ${provider.is_active ? "text-orange-600" : "text-green-600"} hover:underline`}
on:click|preventDefault|stopPropagation={() => toggleActive(provider)}
onclick={() => toggleActive(provider)}
disabled={togglingProviderIds.has(provider.id)}
>
{#if togglingProviderIds.has(provider.id)}