|
@@ -0,0 +1,435 @@
|
|
|
|
|
+// src/components/admin/plugins/PluginPublishModal.tsx
|
|
|
|
|
+'use client';
|
|
|
|
|
+
|
|
|
|
|
+import { useState, useEffect } from 'react';
|
|
|
|
|
+import {
|
|
|
|
|
+ X,
|
|
|
|
|
+ Upload,
|
|
|
|
|
+ Link as LinkIcon,
|
|
|
|
|
+ FileCode,
|
|
|
|
|
+ CheckCircle2,
|
|
|
|
|
+ AlertCircle,
|
|
|
|
|
+ Loader2,
|
|
|
|
|
+ Sparkles,
|
|
|
|
|
+} from 'lucide-react';
|
|
|
|
|
+import { pluginService } from '@/lib/services/pluginService';
|
|
|
|
|
+import { PluginItem } from '@/types';
|
|
|
|
|
+
|
|
|
|
|
+interface PluginPublishModalProps {
|
|
|
|
|
+ isOpen: boolean;
|
|
|
|
|
+ onClose: () => void;
|
|
|
|
|
+ onSuccess: () => void;
|
|
|
|
|
+ initialPlugin?: PluginItem | null; // 若传入,则为当前插件发布新版本
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+export default function PluginPublishModal({
|
|
|
|
|
+ isOpen,
|
|
|
|
|
+ onClose,
|
|
|
|
|
+ onSuccess,
|
|
|
|
|
+ initialPlugin,
|
|
|
|
|
+}: PluginPublishModalProps) {
|
|
|
|
|
+ const [sourceType, setSourceType] = useState<'file' | 'url'>('file');
|
|
|
|
|
+ const [loading, setLoading] = useState(false);
|
|
|
|
|
+ const [errorMsg, setErrorMsg] = useState('');
|
|
|
|
|
+
|
|
|
|
|
+ // 表单字段
|
|
|
|
|
+ const [name, setName] = useState('');
|
|
|
|
|
+ const [displayName, setDisplayName] = useState('');
|
|
|
|
|
+ const [version, setVersion] = useState('');
|
|
|
|
|
+ const [description, setDescription] = useState('');
|
|
|
|
|
+ const [changelog, setChangelog] = useState('');
|
|
|
|
|
+ const [setAsLatest, setSetAsLatest] = useState(true);
|
|
|
|
|
+
|
|
|
|
|
+ // 文件与 URL
|
|
|
|
|
+ const [selectedFile, setSelectedFile] = useState<File | null>(null);
|
|
|
|
|
+ const [downloadUrl, setDownloadUrl] = useState('');
|
|
|
|
|
+ const [sha256, setSha256] = useState('');
|
|
|
|
|
+
|
|
|
|
|
+ const isNewPlugin = !initialPlugin;
|
|
|
|
|
+
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ if (isOpen) {
|
|
|
|
|
+ setErrorMsg('');
|
|
|
|
|
+ if (initialPlugin) {
|
|
|
|
|
+ setName(initialPlugin.name);
|
|
|
|
|
+ setDisplayName(initialPlugin.display_name || '');
|
|
|
|
|
+ setDescription(initialPlugin.description || '');
|
|
|
|
|
+ setVersion('');
|
|
|
|
|
+ setChangelog('');
|
|
|
|
|
+ setSetAsLatest(true);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ setName('');
|
|
|
|
|
+ setDisplayName('');
|
|
|
|
|
+ setVersion('1.0.0');
|
|
|
|
|
+ setDescription('');
|
|
|
|
|
+ setChangelog('');
|
|
|
|
|
+ setSetAsLatest(true);
|
|
|
|
|
+ }
|
|
|
|
|
+ setSelectedFile(null);
|
|
|
|
|
+ setDownloadUrl('');
|
|
|
|
|
+ setSha256('');
|
|
|
|
|
+ setSourceType('file');
|
|
|
|
|
+ }
|
|
|
|
|
+ }, [isOpen, initialPlugin]);
|
|
|
|
|
+
|
|
|
|
|
+ if (!isOpen) return null;
|
|
|
|
|
+
|
|
|
|
|
+ const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
|
|
|
+ const file = e.target.files?.[0];
|
|
|
|
|
+ if (file) {
|
|
|
|
|
+ if (!file.name.endsWith('.py')) {
|
|
|
|
|
+ setErrorMsg('请上传以 .py 结尾的 Python 插件代码文件');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ setSelectedFile(file);
|
|
|
|
|
+ setErrorMsg('');
|
|
|
|
|
+ // 如果插件名为空,尝试用文件名填补
|
|
|
|
|
+ if (!name) {
|
|
|
|
|
+ const baseName = file.name.replace(/\.py$/, '');
|
|
|
|
|
+ setName(baseName);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const handleSubmit = async (e: React.FormEvent) => {
|
|
|
|
|
+ e.preventDefault();
|
|
|
|
|
+ setErrorMsg('');
|
|
|
|
|
+
|
|
|
|
|
+ const cleanName = name.trim();
|
|
|
|
|
+ const cleanVersion = version.trim();
|
|
|
|
|
+
|
|
|
|
|
+ if (!cleanName) {
|
|
|
|
|
+ setErrorMsg('请输入插件唯一英文标识 (name)');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!cleanVersion) {
|
|
|
|
|
+ setErrorMsg('请输入版本号 (如 1.0.0)');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (sourceType === 'file') {
|
|
|
|
|
+ if (!selectedFile) {
|
|
|
|
|
+ setErrorMsg('请选择要上传的 .py 插件文件');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (!downloadUrl.trim()) {
|
|
|
|
|
+ setErrorMsg('请输入有效的文件下载地址 (download_url)');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ setLoading(true);
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (sourceType === 'file' && selectedFile) {
|
|
|
|
|
+ const formData = new FormData();
|
|
|
|
|
+ formData.append('name', cleanName);
|
|
|
|
|
+ formData.append('version', cleanVersion);
|
|
|
|
|
+ if (displayName.trim()) formData.append('display_name', displayName.trim());
|
|
|
|
|
+ if (description.trim()) formData.append('description', description.trim());
|
|
|
|
|
+ if (changelog.trim()) formData.append('changelog', changelog.trim());
|
|
|
|
|
+ formData.append('set_as_latest', String(setAsLatest));
|
|
|
|
|
+ formData.append('file', selectedFile);
|
|
|
|
|
+
|
|
|
|
|
+ const res = await pluginService.publish(formData);
|
|
|
|
|
+ if (res.code !== 0 && res.code !== undefined) {
|
|
|
|
|
+ throw new Error(res.msg || '发布失败');
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ const payload = {
|
|
|
|
|
+ name: cleanName,
|
|
|
|
|
+ version: cleanVersion,
|
|
|
|
|
+ display_name: displayName.trim() || undefined,
|
|
|
|
|
+ description: description.trim() || undefined,
|
|
|
|
|
+ download_url: downloadUrl.trim(),
|
|
|
|
|
+ sha256: sha256.trim() || undefined,
|
|
|
|
|
+ changelog: changelog.trim() || undefined,
|
|
|
|
|
+ set_as_latest: setAsLatest,
|
|
|
|
|
+ };
|
|
|
|
|
+ const res = await pluginService.publish(payload);
|
|
|
|
|
+ if (res.code !== 0 && res.code !== undefined) {
|
|
|
|
|
+ throw new Error(res.msg || '发布失败');
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ onSuccess();
|
|
|
|
|
+ onClose();
|
|
|
|
|
+ } catch (err: any) {
|
|
|
|
|
+ console.error(err);
|
|
|
|
|
+ setErrorMsg(
|
|
|
|
|
+ err.response?.data?.msg ||
|
|
|
|
|
+ err.response?.data?.message ||
|
|
|
|
|
+ err.message ||
|
|
|
|
|
+ '发布失败,请检查网络或参数'
|
|
|
|
|
+ );
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ setLoading(false);
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ return (
|
|
|
|
|
+ <div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-slate-900/60 backdrop-blur-sm animate-fadeIn">
|
|
|
|
|
+ <div className="bg-white rounded-2xl shadow-2xl border border-slate-200 w-full max-w-2xl overflow-hidden flex flex-col max-h-[90vh]">
|
|
|
|
|
+ {/* Header */}
|
|
|
|
|
+ <div className="px-6 py-5 border-b border-slate-100 flex items-center justify-between bg-slate-50/80">
|
|
|
|
|
+ <div className="flex items-center gap-3">
|
|
|
|
|
+ <div className="w-10 h-10 rounded-xl bg-blue-600/10 text-blue-600 flex items-center justify-center font-bold">
|
|
|
|
|
+ <Sparkles size={20} />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <h3 className="text-lg font-bold text-slate-900">
|
|
|
|
|
+ {isNewPlugin ? '发布新插件' : `发布新版本: ${initialPlugin.name}`}
|
|
|
|
|
+ </h3>
|
|
|
|
|
+ <p className="text-xs text-slate-500 mt-0.5">
|
|
|
|
|
+ {isNewPlugin
|
|
|
|
|
+ ? '录入插件元数据并上传首发版本代码文件'
|
|
|
|
|
+ : `当前最新版本为 ${initialPlugin.latest_version},上传并迭代新版本`}
|
|
|
|
|
+ </p>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <button
|
|
|
|
|
+ onClick={onClose}
|
|
|
|
|
+ className="text-slate-400 hover:text-slate-600 hover:bg-slate-100 p-2 rounded-lg transition"
|
|
|
|
|
+ >
|
|
|
|
|
+ <X size={18} />
|
|
|
|
|
+ </button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ {/* Content */}
|
|
|
|
|
+ <form onSubmit={handleSubmit} className="flex-1 overflow-y-auto p-6 space-y-5">
|
|
|
|
|
+ {errorMsg && (
|
|
|
|
|
+ <div className="p-3.5 rounded-xl bg-rose-50 border border-rose-200 text-rose-700 text-sm flex items-start gap-2.5">
|
|
|
|
|
+ <AlertCircle size={18} className="flex-shrink-0 mt-0.5" />
|
|
|
|
|
+ <div className="flex-1">{errorMsg}</div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ )}
|
|
|
|
|
+
|
|
|
|
|
+ {/* 基础信息 */}
|
|
|
|
|
+ <div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <label className="block text-xs font-semibold text-slate-700 uppercase tracking-wider mb-1.5">
|
|
|
|
|
+ 插件唯一英文标识 <span className="text-rose-500">*</span>
|
|
|
|
|
+ </label>
|
|
|
|
|
+ <input
|
|
|
|
|
+ type="text"
|
|
|
|
|
+ value={name}
|
|
|
|
|
+ onChange={(e) => setName(e.target.value)}
|
|
|
|
|
+ placeholder="例如: tls_plugin"
|
|
|
|
|
+ disabled={!isNewPlugin}
|
|
|
|
|
+ required
|
|
|
|
|
+ className="w-full px-3.5 py-2.5 rounded-xl border border-slate-200 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 bg-white disabled:bg-slate-100 disabled:text-slate-500 transition"
|
|
|
|
|
+ />
|
|
|
|
|
+ <p className="text-[11px] text-slate-400 mt-1">代码中调用的模块唯一名称</p>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <label className="block text-xs font-semibold text-slate-700 uppercase tracking-wider mb-1.5">
|
|
|
|
|
+ 版本号 (SemVer) <span className="text-rose-500">*</span>
|
|
|
|
|
+ </label>
|
|
|
|
|
+ <input
|
|
|
|
|
+ type="text"
|
|
|
|
|
+ value={version}
|
|
|
|
|
+ onChange={(e) => setVersion(e.target.value)}
|
|
|
|
|
+ placeholder="例如: 1.0.1"
|
|
|
|
|
+ required
|
|
|
|
|
+ className="w-full px-3.5 py-2.5 rounded-xl border border-slate-200 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 bg-white transition"
|
|
|
|
|
+ />
|
|
|
|
|
+ <p className="text-[11px] text-slate-400 mt-1">请遵循三位版本号规范</p>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <label className="block text-xs font-semibold text-slate-700 uppercase tracking-wider mb-1.5">
|
|
|
|
|
+ 中文展示名称
|
|
|
|
|
+ </label>
|
|
|
|
|
+ <input
|
|
|
|
|
+ type="text"
|
|
|
|
|
+ value={displayName}
|
|
|
|
|
+ onChange={(e) => setDisplayName(e.target.value)}
|
|
|
|
|
+ placeholder="例如: TLSContact欧洲多国签证预约插件"
|
|
|
|
|
+ className="w-full px-3.5 py-2.5 rounded-xl border border-slate-200 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 bg-white transition"
|
|
|
|
|
+ />
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <label className="block text-xs font-semibold text-slate-700 uppercase tracking-wider mb-1.5">
|
|
|
|
|
+ 功能简述
|
|
|
|
|
+ </label>
|
|
|
|
|
+ <input
|
|
|
|
|
+ type="text"
|
|
|
|
|
+ value={description}
|
|
|
|
|
+ onChange={(e) => setDescription(e.target.value)}
|
|
|
|
|
+ placeholder="简述插件的核心机制或适配站点"
|
|
|
|
|
+ className="w-full px-3.5 py-2.5 rounded-xl border border-slate-200 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 bg-white transition"
|
|
|
|
|
+ />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ {/* 代码文件提供方式 Tabs */}
|
|
|
|
|
+ <div className="space-y-3 pt-1 border-t border-slate-100">
|
|
|
|
|
+ <div className="flex items-center justify-between">
|
|
|
|
|
+ <label className="text-xs font-semibold text-slate-700 uppercase tracking-wider">
|
|
|
|
|
+ 代码包来源 <span className="text-rose-500">*</span>
|
|
|
|
|
+ </label>
|
|
|
|
|
+ <div className="inline-flex p-0.5 rounded-lg bg-slate-100 border border-slate-200 text-xs font-medium">
|
|
|
|
|
+ <button
|
|
|
|
|
+ type="button"
|
|
|
|
|
+ onClick={() => setSourceType('file')}
|
|
|
|
|
+ className={`px-3 py-1 rounded-md transition flex items-center gap-1.5 ${
|
|
|
|
|
+ sourceType === 'file'
|
|
|
|
|
+ ? 'bg-white text-blue-600 shadow-sm font-semibold'
|
|
|
|
|
+ : 'text-slate-600 hover:text-slate-900'
|
|
|
|
|
+ }`}
|
|
|
|
|
+ >
|
|
|
|
|
+ <Upload size={13} />
|
|
|
|
|
+ 直接上传代码 (.py)
|
|
|
|
|
+ </button>
|
|
|
|
|
+ <button
|
|
|
|
|
+ type="button"
|
|
|
|
|
+ onClick={() => setSourceType('url')}
|
|
|
|
|
+ className={`px-3 py-1 rounded-md transition flex items-center gap-1.5 ${
|
|
|
|
|
+ sourceType === 'url'
|
|
|
|
|
+ ? 'bg-white text-blue-600 shadow-sm font-semibold'
|
|
|
|
|
+ : 'text-slate-600 hover:text-slate-900'
|
|
|
|
|
+ }`}
|
|
|
|
|
+ >
|
|
|
|
|
+ <LinkIcon size={13} />
|
|
|
|
|
+ 外部下载 URL
|
|
|
|
|
+ </button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ {sourceType === 'file' ? (
|
|
|
|
|
+ <div className="border-2 border-dashed border-slate-200 hover:border-blue-400 rounded-xl p-5 text-center transition bg-slate-50/50">
|
|
|
|
|
+ <input
|
|
|
|
|
+ type="file"
|
|
|
|
|
+ id="py-file-input"
|
|
|
|
|
+ accept=".py"
|
|
|
|
|
+ onChange={handleFileChange}
|
|
|
|
|
+ className="hidden"
|
|
|
|
|
+ />
|
|
|
|
|
+ <label
|
|
|
|
|
+ htmlFor="py-file-input"
|
|
|
|
|
+ className="cursor-pointer flex flex-col items-center justify-center gap-2"
|
|
|
|
|
+ >
|
|
|
|
|
+ <div className="w-11 h-11 rounded-full bg-blue-50 text-blue-600 flex items-center justify-center">
|
|
|
|
|
+ <FileCode size={22} />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div>
|
|
|
|
|
+ {selectedFile ? (
|
|
|
|
|
+ <div className="space-y-1">
|
|
|
|
|
+ <p className="text-sm font-semibold text-blue-600 flex items-center justify-center gap-1.5">
|
|
|
|
|
+ <CheckCircle2 size={16} /> {selectedFile.name}
|
|
|
|
|
+ </p>
|
|
|
|
|
+ <p className="text-xs text-slate-400">
|
|
|
|
|
+ 文件大小: {(selectedFile.size / 1024).toFixed(1)} KB (点击可重新选择)
|
|
|
|
|
+ </p>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ ) : (
|
|
|
|
|
+ <>
|
|
|
|
|
+ <p className="text-sm font-medium text-slate-700">
|
|
|
|
|
+ 点击或拖拽上传 Python 文件
|
|
|
|
|
+ </p>
|
|
|
|
|
+ <p className="text-xs text-slate-400 mt-0.5">
|
|
|
|
|
+ 仅支持 .py 文件(后端将自动计算 SHA256 并托管存储)
|
|
|
|
|
+ </p>
|
|
|
|
|
+ </>
|
|
|
|
|
+ )}
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </label>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ ) : (
|
|
|
|
|
+ <div className="space-y-3 bg-slate-50/70 p-4 rounded-xl border border-slate-200">
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <label className="block text-xs font-medium text-slate-700 mb-1">
|
|
|
|
|
+ 下载 URL <span className="text-rose-500">*</span>
|
|
|
|
|
+ </label>
|
|
|
|
|
+ <input
|
|
|
|
|
+ type="url"
|
|
|
|
|
+ value={downloadUrl}
|
|
|
|
|
+ onChange={(e) => setDownloadUrl(e.target.value)}
|
|
|
|
|
+ placeholder="https://oss.example.com/plugins/tls_plugin-1.0.1.py"
|
|
|
|
|
+ className="w-full px-3 py-2 rounded-lg border border-slate-200 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 bg-white transition"
|
|
|
|
|
+ />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <label className="block text-xs font-medium text-slate-700 mb-1">
|
|
|
|
|
+ 文件 SHA256 校验码 (可选)
|
|
|
|
|
+ </label>
|
|
|
|
|
+ <input
|
|
|
|
|
+ type="text"
|
|
|
|
|
+ value={sha256}
|
|
|
|
|
+ onChange={(e) => setSha256(e.target.value)}
|
|
|
|
|
+ placeholder="例如: 5d41402abc4b2a76b9719d911017c592..."
|
|
|
|
|
+ className="w-full px-3 py-2 rounded-lg border border-slate-200 text-sm font-mono text-xs focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 bg-white transition"
|
|
|
|
|
+ />
|
|
|
|
|
+ <p className="text-[11px] text-slate-400 mt-1">用于 Coordinate 节点防篡改与完整性校验</p>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ )}
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ {/* 更新日志 */}
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <label className="block text-xs font-semibold text-slate-700 uppercase tracking-wider mb-1.5">
|
|
|
|
|
+ 版本更新说明 (Changelog)
|
|
|
|
|
+ </label>
|
|
|
|
|
+ <textarea
|
|
|
|
|
+ rows={3}
|
|
|
|
|
+ value={changelog}
|
|
|
|
|
+ onChange={(e) => setChangelog(e.target.value)}
|
|
|
|
|
+ placeholder="例如: 修复CF验证码重试卡死问题,优化页面加载等待时序"
|
|
|
|
|
+ className="w-full px-3.5 py-2.5 rounded-xl border border-slate-200 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 bg-white transition resize-none"
|
|
|
|
|
+ />
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ {/* 设为最新版本开关 */}
|
|
|
|
|
+ <div className="flex items-center gap-3 p-3.5 bg-blue-50/50 rounded-xl border border-blue-100">
|
|
|
|
|
+ <input
|
|
|
|
|
+ type="checkbox"
|
|
|
|
|
+ id="set-as-latest"
|
|
|
|
|
+ checked={setAsLatest}
|
|
|
|
|
+ onChange={(e) => setSetAsLatest(e.target.checked)}
|
|
|
|
|
+ className="w-4 h-4 text-blue-600 rounded border-slate-300 focus:ring-blue-500"
|
|
|
|
|
+ />
|
|
|
|
|
+ <label htmlFor="set-as-latest" className="text-xs text-slate-700 cursor-pointer select-none">
|
|
|
|
|
+ <span className="font-semibold text-slate-900 block">设为当前生效/推荐版本 (latest_version)</span>
|
|
|
|
|
+ 勾选后将自动更新主表最新生效版本,下发集群升级时默认拉取此版本
|
|
|
|
|
+ </label>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </form>
|
|
|
|
|
+
|
|
|
|
|
+ {/* Footer */}
|
|
|
|
|
+ <div className="px-6 py-4 border-t border-slate-100 bg-slate-50/80 flex items-center justify-end gap-3">
|
|
|
|
|
+ <button
|
|
|
|
|
+ type="button"
|
|
|
|
|
+ onClick={onClose}
|
|
|
|
|
+ disabled={loading}
|
|
|
|
|
+ className="px-4 py-2 text-sm font-medium text-slate-600 hover:text-slate-800 hover:bg-slate-100 rounded-xl transition"
|
|
|
|
|
+ >
|
|
|
|
|
+ 取消
|
|
|
|
|
+ </button>
|
|
|
|
|
+ <button
|
|
|
|
|
+ type="button"
|
|
|
|
|
+ onClick={handleSubmit}
|
|
|
|
|
+ disabled={loading}
|
|
|
|
|
+ className="px-5 py-2 text-sm font-semibold text-white bg-blue-600 hover:bg-blue-700 active:bg-blue-800 rounded-xl shadow-md shadow-blue-500/20 flex items-center gap-2 transition disabled:opacity-50"
|
|
|
|
|
+ >
|
|
|
|
|
+ {loading ? (
|
|
|
|
|
+ <>
|
|
|
|
|
+ <Loader2 size={16} className="animate-spin" />
|
|
|
|
|
+ 正在发布...
|
|
|
|
|
+ </>
|
|
|
|
|
+ ) : (
|
|
|
|
|
+ <>
|
|
|
|
|
+ <Upload size={16} />
|
|
|
|
|
+ 确认发布
|
|
|
|
|
+ </>
|
|
|
|
|
+ )}
|
|
|
|
|
+ </button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ );
|
|
|
|
|
+}
|