2026-07-11 12:13:20 +08:00
|
|
|
|
"use client";
|
|
|
|
|
|
|
2026-07-16 20:26:13 +08:00
|
|
|
|
import { useState, useCallback, useMemo, useEffect } from "react";
|
2026-07-11 12:13:20 +08:00
|
|
|
|
import {
|
|
|
|
|
|
Modal,
|
|
|
|
|
|
Steps,
|
|
|
|
|
|
Button,
|
|
|
|
|
|
Space,
|
|
|
|
|
|
Checkbox,
|
|
|
|
|
|
Table,
|
|
|
|
|
|
Select,
|
|
|
|
|
|
Row,
|
|
|
|
|
|
Col,
|
2026-07-16 15:22:06 +08:00
|
|
|
|
Flex,
|
2026-07-11 12:13:20 +08:00
|
|
|
|
Progress,
|
|
|
|
|
|
Typography,
|
|
|
|
|
|
Empty,
|
2026-07-16 20:26:13 +08:00
|
|
|
|
Tag,
|
2026-07-16 14:34:56 +08:00
|
|
|
|
theme,
|
2026-07-11 12:13:20 +08:00
|
|
|
|
} from "antd";
|
|
|
|
|
|
import { ReloadOutlined } from "@ant-design/icons";
|
2026-07-13 09:29:00 +08:00
|
|
|
|
import type { BaseVersion, Config, UploadReleaseType } from "@/types";
|
2026-07-11 12:13:20 +08:00
|
|
|
|
import type { ParsedProject } from "@/services/project";
|
2026-07-13 09:29:00 +08:00
|
|
|
|
import { platforms } from "@/services/publish.schemas";
|
2026-07-16 16:05:13 +08:00
|
|
|
|
import { Template } from "@/lib/utils/template";
|
|
|
|
|
|
import type { McVersionEntry } from "@/lib/utils/mcVersion";
|
2026-07-16 20:26:13 +08:00
|
|
|
|
import { computeVersionRanges } from "@/lib/utils/mcVersion";
|
|
|
|
|
|
import { getModrinthMcVersions, getCurseForgeMcVersions } from "@/services/meta";
|
2026-07-11 12:13:20 +08:00
|
|
|
|
|
|
|
|
|
|
const { Text } = Typography;
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
// Types
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
interface PublishVersion {
|
|
|
|
|
|
key: string;
|
|
|
|
|
|
mc_version: string;
|
|
|
|
|
|
artifact: string | null;
|
|
|
|
|
|
sources: string | null;
|
2026-07-16 20:26:13 +08:00
|
|
|
|
mrRange: string;
|
|
|
|
|
|
cfRange: string;
|
2026-07-16 16:05:13 +08:00
|
|
|
|
modrinthVersion: string;
|
|
|
|
|
|
modrinthVersionName: string;
|
2026-07-11 12:13:20 +08:00
|
|
|
|
existsModrinth: boolean;
|
|
|
|
|
|
existsCurseforge: boolean;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
interface PublishModalProps {
|
|
|
|
|
|
open: boolean;
|
|
|
|
|
|
config: Config;
|
|
|
|
|
|
project: ParsedProject;
|
2026-07-16 20:26:13 +08:00
|
|
|
|
lastVersionEnd: string | null;
|
2026-07-11 12:13:20 +08:00
|
|
|
|
onClose: () => void;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-13 09:29:00 +08:00
|
|
|
|
type ReleaseType = Extract<BaseVersion["version_type"], UploadReleaseType>;
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
// Helpers
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
2026-07-16 20:26:13 +08:00
|
|
|
|
function entriesToMap(
|
|
|
|
|
|
entries: McVersionEntry[] | null,
|
|
|
|
|
|
field: "explicit" | "wildcard",
|
|
|
|
|
|
): Map<string, string> {
|
|
|
|
|
|
const map = new Map<string, string>();
|
|
|
|
|
|
if (entries) {
|
|
|
|
|
|
for (const entry of entries) {
|
|
|
|
|
|
map.set(entry.version, entry[field]);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return map;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-13 09:29:00 +08:00
|
|
|
|
const RELEASE_TYPE_LABEL_MAP: Record<ReleaseType, string> = {
|
|
|
|
|
|
release: "Release",
|
|
|
|
|
|
beta: "Beta",
|
|
|
|
|
|
alpha: "Alpha"
|
|
|
|
|
|
};
|
|
|
|
|
|
const RELEASE_TYPES = Object.entries(RELEASE_TYPE_LABEL_MAP).map(v => ({ value: v[0], label: v[1] }));
|
|
|
|
|
|
|
2026-07-11 12:13:20 +08:00
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
// Component
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
export function PublishModal({
|
|
|
|
|
|
open,
|
|
|
|
|
|
config,
|
|
|
|
|
|
project,
|
2026-07-16 20:26:13 +08:00
|
|
|
|
lastVersionEnd,
|
2026-07-11 12:13:20 +08:00
|
|
|
|
onClose,
|
|
|
|
|
|
}: PublishModalProps) {
|
2026-07-16 14:34:56 +08:00
|
|
|
|
const { token } = theme.useToken();
|
2026-07-11 12:13:20 +08:00
|
|
|
|
const [currentStep, setCurrentStep] = useState(0);
|
|
|
|
|
|
|
|
|
|
|
|
// Version selection
|
|
|
|
|
|
const [selectedVersions, setSelectedVersions] = useState<Set<string>>(
|
|
|
|
|
|
new Set(),
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
// Publish settings
|
|
|
|
|
|
const [changelog, setChangelog] = useState("");
|
2026-07-13 09:29:00 +08:00
|
|
|
|
const [versionType, setVersionType] = useState<ReleaseType>(
|
2026-07-11 12:13:20 +08:00
|
|
|
|
"release",
|
|
|
|
|
|
);
|
|
|
|
|
|
|
2026-07-16 14:34:56 +08:00
|
|
|
|
// Progress & result
|
2026-07-11 12:13:20 +08:00
|
|
|
|
const [publishing, setPublishing] = useState(false);
|
2026-07-16 14:34:56 +08:00
|
|
|
|
const [publishDone, setPublishDone] = useState(false);
|
2026-07-13 09:29:00 +08:00
|
|
|
|
const [progress, setProgress] = useState<
|
|
|
|
|
|
Record<typeof platforms[number], { done: number; total: number }>
|
|
|
|
|
|
>({
|
|
|
|
|
|
modrinth: { done: 0, total: 0 },
|
2026-07-16 14:34:56 +08:00
|
|
|
|
curseforge: { done: 0, total: 0 },
|
2026-07-13 09:29:00 +08:00
|
|
|
|
});
|
2026-07-16 14:34:56 +08:00
|
|
|
|
const [publishResult, setPublishResult] = useState<{
|
|
|
|
|
|
success: number;
|
|
|
|
|
|
failed: number;
|
|
|
|
|
|
} | null>(null);
|
2026-07-11 12:13:20 +08:00
|
|
|
|
|
2026-07-16 20:26:13 +08:00
|
|
|
|
// Platform MC versions — loaded when modal opens
|
2026-07-11 12:13:20 +08:00
|
|
|
|
const [loadingExisting, setLoadingExisting] = useState(false);
|
2026-07-16 20:26:13 +08:00
|
|
|
|
const [modrinthMcVersions, setModrinthMcVersions] = useState<string[]>([]);
|
|
|
|
|
|
const [curseforgeMcVersions, setCurseforgeMcVersions] = useState<string[]>([]);
|
2026-07-11 12:13:20 +08:00
|
|
|
|
const [existingModrinth, setExistingModrinth] = useState<string[]>([]);
|
|
|
|
|
|
const [existingCurseforge, setExistingCurseforge] = useState<string[]>([]);
|
|
|
|
|
|
|
|
|
|
|
|
const loadExisting = useCallback(async () => {
|
|
|
|
|
|
setLoadingExisting(true);
|
|
|
|
|
|
try {
|
2026-07-16 20:26:13 +08:00
|
|
|
|
const [mrVersions, cfVersions] = await Promise.all([
|
|
|
|
|
|
getModrinthMcVersions(),
|
|
|
|
|
|
getCurseForgeMcVersions(),
|
|
|
|
|
|
]);
|
|
|
|
|
|
setModrinthMcVersions(mrVersions);
|
|
|
|
|
|
setCurseforgeMcVersions(cfVersions);
|
2026-07-11 12:13:20 +08:00
|
|
|
|
// TODO: Fetch existing versions from both platforms via tRPC/Server Action
|
|
|
|
|
|
setExistingModrinth([]);
|
|
|
|
|
|
setExistingCurseforge([]);
|
2026-07-16 20:26:13 +08:00
|
|
|
|
} catch (e) {
|
|
|
|
|
|
console.error(e);
|
2026-07-11 12:13:20 +08:00
|
|
|
|
} finally {
|
|
|
|
|
|
setLoadingExisting(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
2026-07-16 20:26:13 +08:00
|
|
|
|
// Auto-load MC versions when modal opens
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
if (open) {
|
|
|
|
|
|
loadExisting();
|
|
|
|
|
|
}
|
|
|
|
|
|
}, [open, loadExisting]);
|
|
|
|
|
|
|
2026-07-16 16:05:13 +08:00
|
|
|
|
// Pre-compute version display values
|
|
|
|
|
|
const versionTmpl = useMemo(() => new Template(config.modrinth.version), [config.modrinth.version]);
|
|
|
|
|
|
const versionNameTmpl = useMemo(() => new Template(config.modrinth.version_name), [config.modrinth.version_name]);
|
|
|
|
|
|
|
2026-07-16 20:26:13 +08:00
|
|
|
|
// Compute per-platform version ranges
|
|
|
|
|
|
const projectVersions = useMemo(
|
|
|
|
|
|
() => project.artifacts.map((a) => a.mc_version),
|
|
|
|
|
|
[project],
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
const mrRanges = useMemo(() => {
|
|
|
|
|
|
if (modrinthMcVersions.length === 0) return null;
|
|
|
|
|
|
return computeVersionRanges(projectVersions, modrinthMcVersions, lastVersionEnd ?? undefined);
|
|
|
|
|
|
}, [projectVersions, modrinthMcVersions, lastVersionEnd]);
|
|
|
|
|
|
|
|
|
|
|
|
const cfRanges = useMemo(() => {
|
|
|
|
|
|
if (curseforgeMcVersions.length === 0) return null;
|
|
|
|
|
|
return computeVersionRanges(projectVersions, curseforgeMcVersions, lastVersionEnd ?? undefined);
|
|
|
|
|
|
}, [projectVersions, curseforgeMcVersions, lastVersionEnd]);
|
|
|
|
|
|
|
|
|
|
|
|
// Build per-platform range maps (mc_version → explicit)
|
|
|
|
|
|
const mrExplicitMap = useMemo(() => entriesToMap(mrRanges, "explicit"), [mrRanges]);
|
|
|
|
|
|
const cfExplicitMap = useMemo(() => entriesToMap(cfRanges, "explicit"), [cfRanges]);
|
2026-07-16 16:05:13 +08:00
|
|
|
|
|
2026-07-11 12:13:20 +08:00
|
|
|
|
// Build publish version rows from project artifacts
|
2026-07-16 16:05:13 +08:00
|
|
|
|
const publishVersions: PublishVersion[] = useMemo(() =>
|
|
|
|
|
|
project.artifacts.map((a) => {
|
2026-07-16 20:26:13 +08:00
|
|
|
|
// Note: version_name template uses Modrinth explicit range for ${mc_version_range}
|
|
|
|
|
|
const mrRange = mrExplicitMap.get(a.mc_version) ?? a.mc_version;
|
2026-07-16 16:05:13 +08:00
|
|
|
|
const tmplValues = {
|
|
|
|
|
|
version: project.version,
|
|
|
|
|
|
mc_version: a.mc_version,
|
2026-07-16 20:26:13 +08:00
|
|
|
|
mc_version_range: mrRange,
|
2026-07-16 16:05:13 +08:00
|
|
|
|
};
|
|
|
|
|
|
return {
|
|
|
|
|
|
key: a.mc_version,
|
|
|
|
|
|
mc_version: a.mc_version,
|
|
|
|
|
|
artifact: a.artifact,
|
|
|
|
|
|
sources: a.sources,
|
2026-07-16 20:26:13 +08:00
|
|
|
|
mrRange: mrExplicitMap.get(a.mc_version) ?? a.mc_version,
|
|
|
|
|
|
cfRange: cfExplicitMap.get(a.mc_version) ?? a.mc_version,
|
2026-07-16 16:05:13 +08:00
|
|
|
|
modrinthVersion: versionTmpl.format(tmplValues),
|
|
|
|
|
|
modrinthVersionName: versionNameTmpl.format(tmplValues),
|
|
|
|
|
|
existsModrinth: existingModrinth.includes(a.mc_version),
|
|
|
|
|
|
existsCurseforge: existingCurseforge.includes(a.mc_version),
|
|
|
|
|
|
};
|
|
|
|
|
|
}),
|
2026-07-16 20:26:13 +08:00
|
|
|
|
[project, versionTmpl, versionNameTmpl, mrExplicitMap, cfExplicitMap, existingModrinth, existingCurseforge],
|
2026-07-16 16:05:13 +08:00
|
|
|
|
);
|
2026-07-11 12:13:20 +08:00
|
|
|
|
|
|
|
|
|
|
// --------------- Steps handling ---------------
|
|
|
|
|
|
|
|
|
|
|
|
const handleNext = useCallback(() => {
|
|
|
|
|
|
if (currentStep === 0) {
|
|
|
|
|
|
// Init selection with all non-existing entries
|
|
|
|
|
|
const preselected = new Set<string>();
|
|
|
|
|
|
for (const v of publishVersions) {
|
|
|
|
|
|
if (!v.existsModrinth || !v.existsCurseforge) {
|
|
|
|
|
|
preselected.add(v.key);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
setSelectedVersions(preselected);
|
|
|
|
|
|
}
|
2026-07-16 14:34:56 +08:00
|
|
|
|
setCurrentStep((prev) => Math.min(prev + 1, 2));
|
2026-07-11 12:13:20 +08:00
|
|
|
|
}, [currentStep, publishVersions]);
|
|
|
|
|
|
|
|
|
|
|
|
const handlePrev = useCallback(() => {
|
|
|
|
|
|
setCurrentStep((prev) => Math.max(prev - 1, 0));
|
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
|
|
const handleConfirmPublish = useCallback(async () => {
|
|
|
|
|
|
setPublishing(true);
|
2026-07-16 14:34:56 +08:00
|
|
|
|
setPublishDone(false);
|
|
|
|
|
|
setPublishResult(null);
|
|
|
|
|
|
setCurrentStep(2);
|
|
|
|
|
|
// TODO: Call tRPC mutation to publish, update progress & result
|
|
|
|
|
|
setPublishResult({ success: 0, failed: 0 });
|
|
|
|
|
|
setPublishDone(true);
|
2026-07-11 12:13:20 +08:00
|
|
|
|
setPublishing(false);
|
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
|
|
const handleClose = useCallback(() => {
|
|
|
|
|
|
if (publishing) return;
|
|
|
|
|
|
setCurrentStep(0);
|
|
|
|
|
|
setSelectedVersions(new Set());
|
|
|
|
|
|
setChangelog("");
|
|
|
|
|
|
setVersionType("release");
|
2026-07-16 14:34:56 +08:00
|
|
|
|
setPublishResult(null);
|
|
|
|
|
|
setPublishDone(false);
|
2026-07-11 12:13:20 +08:00
|
|
|
|
onClose();
|
|
|
|
|
|
}, [publishing, onClose]);
|
|
|
|
|
|
|
|
|
|
|
|
// --------------- Render: Step 1 — Version Selection ---------------
|
|
|
|
|
|
|
|
|
|
|
|
const renderStep1 = () => {
|
|
|
|
|
|
const modrinthColumns = [
|
|
|
|
|
|
{
|
2026-07-16 16:05:13 +08:00
|
|
|
|
title: "版本号",
|
|
|
|
|
|
dataIndex: "modrinthVersion",
|
|
|
|
|
|
key: "modrinthVersion",
|
2026-07-11 12:13:20 +08:00
|
|
|
|
},
|
2026-07-16 20:26:13 +08:00
|
|
|
|
{
|
|
|
|
|
|
title: "兼容范围",
|
|
|
|
|
|
dataIndex: "mrRange",
|
|
|
|
|
|
key: "mr_range",
|
|
|
|
|
|
width: 100,
|
|
|
|
|
|
render: (val: string) => <Tag>{val}</Tag>,
|
|
|
|
|
|
},
|
2026-07-11 12:13:20 +08:00
|
|
|
|
{
|
2026-07-16 16:05:13 +08:00
|
|
|
|
title: "版本名称",
|
|
|
|
|
|
dataIndex: "modrinthVersionName",
|
|
|
|
|
|
key: "modrinthVersionName",
|
2026-07-11 12:13:20 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: "",
|
|
|
|
|
|
key: "select",
|
|
|
|
|
|
width: 50,
|
|
|
|
|
|
render: (_: unknown, record: PublishVersion) => (
|
|
|
|
|
|
<Checkbox
|
|
|
|
|
|
disabled={record.existsModrinth}
|
|
|
|
|
|
checked={
|
|
|
|
|
|
record.existsModrinth || selectedVersions.has(record.key)
|
|
|
|
|
|
}
|
|
|
|
|
|
onChange={(e) => {
|
|
|
|
|
|
const next = new Set(selectedVersions);
|
|
|
|
|
|
if (e.target.checked) next.add(record.key);
|
|
|
|
|
|
else next.delete(record.key);
|
|
|
|
|
|
setSelectedVersions(next);
|
|
|
|
|
|
}}
|
|
|
|
|
|
/>
|
|
|
|
|
|
),
|
|
|
|
|
|
},
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
const curseforgeColumns = [
|
|
|
|
|
|
{
|
|
|
|
|
|
title: "MC 版本",
|
|
|
|
|
|
dataIndex: "mc_version",
|
|
|
|
|
|
key: "mc_version",
|
|
|
|
|
|
width: 100,
|
|
|
|
|
|
},
|
2026-07-16 20:26:13 +08:00
|
|
|
|
{
|
|
|
|
|
|
title: "兼容范围",
|
|
|
|
|
|
dataIndex: "cfRange",
|
|
|
|
|
|
key: "cf_range",
|
|
|
|
|
|
width: 100,
|
|
|
|
|
|
render: (val: string) => <Tag>{val}</Tag>,
|
|
|
|
|
|
},
|
2026-07-11 12:13:20 +08:00
|
|
|
|
{
|
2026-07-16 16:05:13 +08:00
|
|
|
|
title: "显示名称",
|
2026-07-11 12:13:20 +08:00
|
|
|
|
dataIndex: "artifact",
|
|
|
|
|
|
key: "artifact",
|
|
|
|
|
|
ellipsis: true,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: "",
|
|
|
|
|
|
key: "select",
|
|
|
|
|
|
width: 50,
|
|
|
|
|
|
render: (_: unknown, record: PublishVersion) => (
|
|
|
|
|
|
<Checkbox
|
|
|
|
|
|
disabled={record.existsCurseforge}
|
|
|
|
|
|
checked={
|
|
|
|
|
|
record.existsCurseforge || selectedVersions.has(record.key)
|
|
|
|
|
|
}
|
|
|
|
|
|
onChange={(e) => {
|
|
|
|
|
|
const next = new Set(selectedVersions);
|
|
|
|
|
|
if (e.target.checked) next.add(record.key);
|
|
|
|
|
|
else next.delete(record.key);
|
|
|
|
|
|
setSelectedVersions(next);
|
|
|
|
|
|
}}
|
|
|
|
|
|
/>
|
|
|
|
|
|
),
|
|
|
|
|
|
},
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<div
|
|
|
|
|
|
style={{
|
|
|
|
|
|
display: "flex",
|
|
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
|
alignItems: "center",
|
2026-07-16 14:34:56 +08:00
|
|
|
|
marginBottom: token.margin,
|
2026-07-11 12:13:20 +08:00
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
<Text strong>选择要发布的版本</Text>
|
|
|
|
|
|
<Button
|
|
|
|
|
|
icon={<ReloadOutlined />}
|
|
|
|
|
|
loading={loadingExisting}
|
|
|
|
|
|
onClick={loadExisting}
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
>
|
|
|
|
|
|
刷新已有版本
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
{loadingExisting ? (
|
|
|
|
|
|
<div style={{ textAlign: "center", padding: 40 }}>加载中…</div>
|
|
|
|
|
|
) : (
|
2026-07-16 14:34:56 +08:00
|
|
|
|
<Row gutter={token.margin}>
|
2026-07-16 20:26:13 +08:00
|
|
|
|
<Col span={14}>
|
2026-07-16 14:34:56 +08:00
|
|
|
|
<Text strong style={{ display: "block", marginBottom: token.marginXS }}>
|
2026-07-11 12:13:20 +08:00
|
|
|
|
Modrinth
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
{publishVersions.length > 0 ? (
|
|
|
|
|
|
<Table
|
|
|
|
|
|
dataSource={publishVersions}
|
|
|
|
|
|
columns={modrinthColumns}
|
|
|
|
|
|
pagination={false}
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
bordered
|
|
|
|
|
|
/>
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<Empty description="无版本" />
|
|
|
|
|
|
)}
|
|
|
|
|
|
</Col>
|
2026-07-16 20:26:13 +08:00
|
|
|
|
<Col span={10}>
|
2026-07-16 14:34:56 +08:00
|
|
|
|
<Text strong style={{ display: "block", marginBottom: token.marginXS }}>
|
2026-07-11 12:13:20 +08:00
|
|
|
|
CurseForge
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
{publishVersions.length > 0 ? (
|
|
|
|
|
|
<Table
|
|
|
|
|
|
dataSource={publishVersions}
|
|
|
|
|
|
columns={curseforgeColumns}
|
|
|
|
|
|
pagination={false}
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
bordered
|
|
|
|
|
|
/>
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<Empty description="无版本" />
|
|
|
|
|
|
)}
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// --------------- Render: Step 2 — Publish Settings ---------------
|
|
|
|
|
|
|
|
|
|
|
|
const renderStep2 = () => {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div>
|
|
|
|
|
|
{/* Changelog */}
|
2026-07-16 14:34:56 +08:00
|
|
|
|
<div style={{ marginBottom: token.marginLG }}>
|
|
|
|
|
|
<Text strong style={{ display: "block", marginBottom: token.marginSM }}>
|
2026-07-11 12:13:20 +08:00
|
|
|
|
Changelog (Markdown)
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
{/* TODO: Replace with @uiw/react-md-editor */}
|
|
|
|
|
|
<textarea
|
|
|
|
|
|
style={{
|
|
|
|
|
|
width: "100%",
|
|
|
|
|
|
minHeight: 160,
|
2026-07-16 14:34:56 +08:00
|
|
|
|
border: `1px solid ${token.colorBorder}`,
|
|
|
|
|
|
borderRadius: token.borderRadius,
|
|
|
|
|
|
padding: token.paddingSM,
|
|
|
|
|
|
fontFamily: token.fontFamilyCode ?? "monospace",
|
|
|
|
|
|
fontSize: token.fontSizeSM,
|
2026-07-11 12:13:20 +08:00
|
|
|
|
}}
|
|
|
|
|
|
placeholder="输入 Markdown 格式的更新日志…"
|
|
|
|
|
|
value={changelog}
|
|
|
|
|
|
onChange={(e) => setChangelog(e.target.value)}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
{/* Version type */}
|
2026-07-16 14:34:56 +08:00
|
|
|
|
<div>
|
|
|
|
|
|
<Text strong style={{ display: "block", marginBottom: token.marginSM }}>
|
2026-07-11 12:13:20 +08:00
|
|
|
|
版本类型
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
<Select
|
|
|
|
|
|
value={versionType}
|
|
|
|
|
|
onChange={(v) => setVersionType(v)}
|
|
|
|
|
|
style={{ width: 160 }}
|
2026-07-13 09:29:00 +08:00
|
|
|
|
options={RELEASE_TYPES}
|
2026-07-11 12:13:20 +08:00
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
2026-07-16 14:34:56 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
};
|
2026-07-11 12:13:20 +08:00
|
|
|
|
|
2026-07-16 14:34:56 +08:00
|
|
|
|
// --------------- Render: Step 3 — Progress & Result ---------------
|
|
|
|
|
|
|
|
|
|
|
|
const renderStep3 = () => {
|
|
|
|
|
|
const hasModrinth = publishVersions.some(
|
|
|
|
|
|
(v) =>
|
|
|
|
|
|
!v.existsModrinth &&
|
|
|
|
|
|
(selectedVersions.has(v.key) || v.existsModrinth),
|
|
|
|
|
|
);
|
|
|
|
|
|
const hasCurseforge = publishVersions.some(
|
|
|
|
|
|
(v) =>
|
|
|
|
|
|
!v.existsCurseforge &&
|
|
|
|
|
|
(selectedVersions.has(v.key) || v.existsCurseforge),
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div>
|
|
|
|
|
|
{/* Progress bars */}
|
|
|
|
|
|
<div style={{ marginBottom: token.marginLG }}>
|
2026-07-16 15:22:06 +08:00
|
|
|
|
<Flex vertical gap={token.marginSM}>
|
|
|
|
|
|
{hasModrinth && (
|
|
|
|
|
|
<Flex align="center" gap={token.marginXS}>
|
|
|
|
|
|
<img
|
|
|
|
|
|
src="/platform/modrinth.svg"
|
|
|
|
|
|
alt="Modrinth"
|
|
|
|
|
|
style={{ width: 30, height: 30, flexShrink: 0 }}
|
|
|
|
|
|
/>
|
|
|
|
|
|
<Text style={{ width: 80, flexShrink: 0, fontFamily: "Inter", fontWeight: "bold" }}>Modrinth</Text>
|
|
|
|
|
|
<Progress
|
|
|
|
|
|
percent={Math.round(
|
|
|
|
|
|
(progress.modrinth.done /
|
|
|
|
|
|
Math.max(progress.modrinth.total, 1)) *
|
|
|
|
|
|
100,
|
|
|
|
|
|
)}
|
|
|
|
|
|
format={() =>
|
|
|
|
|
|
`${progress.modrinth.done} / ${progress.modrinth.total}`
|
|
|
|
|
|
}
|
|
|
|
|
|
style={{ flex: 1 }}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Flex>
|
|
|
|
|
|
)}
|
|
|
|
|
|
{hasCurseforge && (
|
|
|
|
|
|
<Flex align="center" gap={token.marginXS}>
|
|
|
|
|
|
<img
|
|
|
|
|
|
src="/platform/curseforge.svg"
|
|
|
|
|
|
alt="CurseForge"
|
|
|
|
|
|
style={{ width: 30, height: 30, flexShrink: 0 }}
|
|
|
|
|
|
/>
|
|
|
|
|
|
<Text style={{ width: 80, flexShrink: 0, fontFamily: "Inter", fontWeight: "bold" }}>CurseForge</Text>
|
|
|
|
|
|
<Progress
|
|
|
|
|
|
percent={Math.round(
|
|
|
|
|
|
(progress.curseforge.done /
|
|
|
|
|
|
Math.max(progress.curseforge.total, 1)) *
|
|
|
|
|
|
100,
|
|
|
|
|
|
)}
|
|
|
|
|
|
format={() =>
|
|
|
|
|
|
`${progress.curseforge.done} / ${progress.curseforge.total}`
|
|
|
|
|
|
}
|
|
|
|
|
|
style={{ flex: 1 }}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Flex>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</Flex>
|
2026-07-16 14:34:56 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
{/* Result */}
|
|
|
|
|
|
{publishDone && publishResult && (
|
|
|
|
|
|
<div
|
|
|
|
|
|
style={{
|
|
|
|
|
|
background: token.colorSuccessBg,
|
|
|
|
|
|
border: `1px solid ${token.colorSuccessBorder}`,
|
|
|
|
|
|
borderRadius: token.borderRadius,
|
|
|
|
|
|
padding: token.padding,
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
<Text strong>发布结果</Text>
|
|
|
|
|
|
<div style={{ marginTop: token.marginSM }}>
|
|
|
|
|
|
<Text>
|
|
|
|
|
|
成功 {publishResult.success} 个,失败 {publishResult.failed} 个
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
</div>
|
2026-07-11 12:13:20 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// --------------- Render ---------------
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<Modal
|
|
|
|
|
|
title="一键发布"
|
|
|
|
|
|
open={open}
|
|
|
|
|
|
onCancel={handleClose}
|
2026-07-16 20:26:13 +08:00
|
|
|
|
width={1200}
|
2026-07-11 12:13:20 +08:00
|
|
|
|
destroyOnHidden
|
|
|
|
|
|
footer={
|
|
|
|
|
|
publishing ? null : (
|
|
|
|
|
|
<Space>
|
2026-07-16 14:34:56 +08:00
|
|
|
|
{currentStep > 0 && currentStep < 2 && (
|
2026-07-11 12:13:20 +08:00
|
|
|
|
<Button onClick={handlePrev}>上一步</Button>
|
|
|
|
|
|
)}
|
2026-07-16 14:34:56 +08:00
|
|
|
|
{currentStep === 0 ? (
|
2026-07-11 12:13:20 +08:00
|
|
|
|
<Button type="primary" onClick={handleNext}>
|
|
|
|
|
|
下一步
|
|
|
|
|
|
</Button>
|
2026-07-16 14:34:56 +08:00
|
|
|
|
) : currentStep === 1 ? (
|
2026-07-11 12:13:20 +08:00
|
|
|
|
<Button type="primary" onClick={handleConfirmPublish}>
|
|
|
|
|
|
确认发布
|
|
|
|
|
|
</Button>
|
2026-07-16 14:34:56 +08:00
|
|
|
|
) : (
|
|
|
|
|
|
<Button type="primary" onClick={handleClose}>
|
|
|
|
|
|
关闭
|
|
|
|
|
|
</Button>
|
2026-07-11 12:13:20 +08:00
|
|
|
|
)}
|
|
|
|
|
|
</Space>
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
>
|
|
|
|
|
|
<Steps
|
|
|
|
|
|
current={currentStep}
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
style={{ marginBottom: 24 }}
|
|
|
|
|
|
items={[
|
|
|
|
|
|
{ title: "版本选择" },
|
|
|
|
|
|
{ title: "发布设置" },
|
2026-07-16 14:34:56 +08:00
|
|
|
|
{ title: "发布进度" },
|
2026-07-11 12:13:20 +08:00
|
|
|
|
]}
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
2026-07-16 14:34:56 +08:00
|
|
|
|
{currentStep === 0
|
|
|
|
|
|
? renderStep1()
|
|
|
|
|
|
: currentStep === 1
|
|
|
|
|
|
? renderStep2()
|
|
|
|
|
|
: renderStep3()}
|
2026-07-11 12:13:20 +08:00
|
|
|
|
</Modal>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|