Migrate frontend to Svelte 5 runes semantics
This commit is contained in:
@@ -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)}
|
||||
|
||||
Reference in New Issue
Block a user