第一次合并develop-fech

This commit is contained in:
Winnie
2026-08-03 18:27:53 +08:00
parent d7bd88335c
commit feae98cc24
4 changed files with 88 additions and 60 deletions
@@ -17,7 +17,7 @@ import {
type Visibility,
type WorkspaceDirectory,
} from "../../services/api";
import { useApi, useAuth } from "~/context/AuthContext";
import { useApi, useAuth } from "../../context/AuthContext";
import Icon from "../../components/Icon";
import SchedulePage from "../schedules/SchedulePage";
import { DashboardPage, SystemAdminPage } from "../admin/AdminPages";
@@ -593,6 +593,19 @@ function AuthenticatedModelPlatformApp() {
const submitCreate = async (event: FormEvent) => {
event.preventDefault();
if (!form.name.trim()) return;
const suffix = form.scriptType === "notebook" ? ".ipynb" : ".py";
const requestedName = form.name.trim();
const normalizedName = requestedName.toLocaleLowerCase().endsWith(suffix)
? requestedName
: `${requestedName}${suffix}`;
const duplicate = scripts.some((script) =>
script.script_type === form.scriptType
&& script.script_name.toLocaleLowerCase() === normalizedName.toLocaleLowerCase()
);
if (duplicate) {
setToast({ tone: "error", message: `${normalizedName} 已存在,请更换名称` });
return;
}
setCreating(true);
try {
const created = await api.createScript(form);