feat: 更新数据集创建功能,使用 TargetModels 类型替代字符串作为目标模型

This commit is contained in:
Vixalie
2026-03-28 08:30:43 +08:00
parent 5a0e1aa9aa
commit c8576425a4
2 changed files with 14 additions and 2 deletions
+3 -1
View File
@@ -1,6 +1,8 @@
import type { TargetModels } from "$lib/types/models";
export type DatasetMeta = { export type DatasetMeta = {
name: string; name: string;
targetModel: string; targetModel: TargetModels;
loraType: string; loraType: string;
unifiedImageSize: boolean; unifiedImageSize: boolean;
unifiedImageRatio: boolean; unifiedImageRatio: boolean;
+11 -1
View File
@@ -4,6 +4,7 @@ import Close from '$lib/components/icons/Close.svelte';
import { activeDatasetMeta, openedDatasetDir, updateActiveDatasetMeta } from '$lib/stores/dataset'; import { activeDatasetMeta, openedDatasetDir, updateActiveDatasetMeta } from '$lib/stores/dataset';
import { currentActivate } from '$lib/stores/navigate'; import { currentActivate } from '$lib/stores/navigate';
import type { DatasetMeta } from '$lib/types/meta'; import type { DatasetMeta } from '$lib/types/meta';
import { ModelChoices } from '$lib/types/models';
import { message, open } from '@tauri-apps/plugin-dialog'; import { message, open } from '@tauri-apps/plugin-dialog';
import { readDir } from '@tauri-apps/plugin-fs'; import { readDir } from '@tauri-apps/plugin-fs';
import { isNil } from 'es-toolkit'; import { isNil } from 'es-toolkit';
@@ -14,6 +15,7 @@ afterNavigate(() => {
let storePath = $state(''); let storePath = $state('');
let datasetName = $state(''); let datasetName = $state('');
let targetModel = $state(ModelChoices[0].value);
async function backToBoot() { async function backToBoot() {
await goto('/boot'); await goto('/boot');
@@ -58,7 +60,7 @@ async function createDataset() {
if (!isNil(storePath) && !isNil(datasetName) && storePath.trim() && datasetName.trim()) { if (!isNil(storePath) && !isNil(datasetName) && storePath.trim() && datasetName.trim()) {
const datasetMeta: DatasetMeta = { const datasetMeta: DatasetMeta = {
name: datasetName.trim(), name: datasetName.trim(),
targetModel: '', targetModel: targetModel,
loraType: '', loraType: '',
unifiedImageSize: true, unifiedImageSize: true,
unifiedImageRatio: true, unifiedImageRatio: true,
@@ -109,5 +111,13 @@ async function createDataset() {
<span class="label min-w-[10em]">Dataset Name</span> <span class="label min-w-[10em]">Dataset Name</span>
<input type="text" class="min-w-[20em]" bind:value={datasetName} /> <input type="text" class="min-w-[20em]" bind:value={datasetName} />
</label> </label>
<label class="input input-md focus-within:outline-0 w-fit">
<span class="label min-w-[10em]">Target Model</span>
<select class="min-w-[20em] focus:outline-0" bind:value={targetModel}>
{#each ModelChoices as model}
<option value={model.value}>{model.label}</option>
{/each}
</select>
</label>
<button class="btn btn-primary btn-md w-fit self-center" onclick={createDataset}>Create</button> <button class="btn btn-primary btn-md w-fit self-center" onclick={createDataset}>Create</button>
</main> </main>