This commit is contained in:
hailin 2025-04-06 13:53:38 +08:00
parent 5f2621f07a
commit dbe42d1e41
2 changed files with 5 additions and 41 deletions

View File

@ -93,46 +93,6 @@ const BlogArticleWrapper = async ({ params }: { params: { slug: string, locale:
// // 请求部署状态
let statusText = '';
let progress = '0%';
// let data: any;
// try {
// data = await service.post('/api/v1/deploy/status', {
// id: frontmatter.id, // 假设 frontmatter.id 是你需要的标识符
// }, {
// headers: {
// // 'Authorization': token // 如果需要身份验证,可以在这里加上 token
// }
// }).then((result: any) => {
// console.log("==================>result:", result);
// if (result && result.header.code !== 1006) {
// statusText = result.header.message || '操作失败(后端返回错误)';
// return; // 如果返回失败,不继续处理
// }
// if (result.header.code !== 1006){
// // 如果请求成功
// statusText = "";
// // 设置部署状态数据
// progress = '0%'; // 假设返回的数据里有进度
// }
// else{
// // 如果请求成功
// statusText = result.header.message || '操作成功';
// // 设置部署状态数据
// progress = result.data.progress || '0%'; // 假设返回的数据里有进度
// }
// }).catch((err) => {
// console.error('请求部署状态失败:', err);
// statusText = '请求失败';
// });
// } catch (err) {
// console.error('请求部署状态错误:', err);
// statusText = '请求失败';
// }
return (
<>
{/* <NavBack /> */}

View File

@ -408,6 +408,7 @@ export function DetailPageHeader({ data }: { data: any }) {
const [statusText, setStatusText] = useState(data?.statusText || "加载中...");
const [progress, setProgress] = useState(data?.progress || "0%");
const [progressBarColor, setProgressBarColor] = useState("bg-blue-500"); // ✅ 默认蓝色
const [showProgressBar, setShowProgressBar] = useState(false);
const [showDelete, setShowDelete] = useState(false);
const [hasWSConnected, setHasWSConnected] = useState(false);
const [statusLoaded, setStatusLoaded] = useState(false);
@ -577,18 +578,21 @@ export function DetailPageHeader({ data }: { data: any }) {
setStatusText("尚未部署");
setShowDelete(false);
setProgress("0%");
setShowProgressBar(false)
return;
}
if (status === "deploying" && userName && id && !hasWSConnected) {
setStatusText("检测到正在部署,连接中...");
initWebSocket(userName, id);
setShowProgressBar(true)
}
if (status === "running" || status === "stopped") {
console.log("✅ 允许删除status =", status, ")");
setShowDelete(true);
setProgress("100%");
setShowProgressBar(true)
if (status === "running") {
setStatusText("运行中");
@ -678,7 +682,7 @@ export function DetailPageHeader({ data }: { data: any }) {
</div>
</div>
{(progress !== "0%" || statusText) && (
{showProgressBar && (progress !== "0%" || statusText) && (
<div className="w-full mt-4 bg-gray-200 h-6">
<div
className={`${progressBarColor} h-full text-white text-center text-sm flex items-center justify-center transition-all duration-300 px-2 overflow-hidden whitespace-nowrap text-ellipsis`}