update: save version
This commit is contained in:
@@ -11,6 +11,7 @@ import { useLocation, useNavigate } from "react-router";
|
||||
|
||||
import {
|
||||
type ActiveEditSession,
|
||||
type LatestVersion,
|
||||
type ScriptItem,
|
||||
type ScriptType,
|
||||
type StableVersion,
|
||||
@@ -163,6 +164,10 @@ function AuthenticatedModelPlatformApp() {
|
||||
} | null>(null);
|
||||
const [versions, setVersions] = useState<StableVersion[]>([]);
|
||||
const [versionsLoading, setVersionsLoading] = useState(false);
|
||||
const [latestVersion, setLatestVersion] = useState<LatestVersion | null>(
|
||||
null,
|
||||
);
|
||||
const [latestVersionLoading, setLatestVersionLoading] = useState(false);
|
||||
const [publishTarget, setPublishTarget] = useState<ScriptItem | null>(null);
|
||||
const [releaseNote, setReleaseNote] = useState("");
|
||||
const [publishVisibility, setPublishVisibility] =
|
||||
@@ -244,10 +249,30 @@ function AuthenticatedModelPlatformApp() {
|
||||
useEffect(() => {
|
||||
if (!selectedId) {
|
||||
setVersions([]);
|
||||
setLatestVersion(null);
|
||||
return;
|
||||
}
|
||||
let ignore = false;
|
||||
setVersionsLoading(true);
|
||||
setLatestVersionLoading(true);
|
||||
void api.getLatestScriptVersion(selectedId)
|
||||
.then((item) => {
|
||||
if (!ignore) setLatestVersion(item);
|
||||
})
|
||||
.catch((error) => {
|
||||
if (!ignore) {
|
||||
setToast({
|
||||
tone: "error",
|
||||
message:
|
||||
error instanceof Error
|
||||
? error.message
|
||||
: "最新版本加载失败",
|
||||
});
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
if (!ignore) setLatestVersionLoading(false);
|
||||
});
|
||||
void api.listScriptVersions(selectedId)
|
||||
.then((items) => {
|
||||
if (!ignore) setVersions(items);
|
||||
@@ -1007,8 +1032,8 @@ function AuthenticatedModelPlatformApp() {
|
||||
? editorOpenError.message
|
||||
: null
|
||||
}
|
||||
latestVersion={versions[0] ?? null}
|
||||
versionsLoading={versionsLoading}
|
||||
latestVersion={latestVersion}
|
||||
versionsLoading={latestVersionLoading}
|
||||
onOpenEditor={() => void openScriptEditor(selected)}
|
||||
onEndEditing={() => void endEditing()}
|
||||
onClose={() => {
|
||||
|
||||
Reference in New Issue
Block a user