This commit is contained in:
parent
a4f71b047a
commit
ca74fa086a
|
|
@ -90,46 +90,46 @@ const BlogArticleWrapper = async ({ params }: { params: { slug: string, locale:
|
||||||
const defaultImage = "https://gimg3.baidu.com/search/src=http%3A%2F%2Fpics3.baidu.com%2Ffeed%2F4ec2d5628535e5dd7c7cdc23847e08e2cc1b62c4.jpeg%40f_auto%3Ftoken%3D38327d5cbefb2cd45af58f8d47c0a0b5&refer=http%3A%2F%2Fwww.baidu.com&app=2021&size=f360,240&n=0&g=0n&q=75&fmt=auto?sec=1710435600&t=eafc0a27ff3295bb5b0b9065fc33a523"
|
const defaultImage = "https://gimg3.baidu.com/search/src=http%3A%2F%2Fpics3.baidu.com%2Ffeed%2F4ec2d5628535e5dd7c7cdc23847e08e2cc1b62c4.jpeg%40f_auto%3Ftoken%3D38327d5cbefb2cd45af58f8d47c0a0b5&refer=http%3A%2F%2Fwww.baidu.com&app=2021&size=f360,240&n=0&g=0n&q=75&fmt=auto?sec=1710435600&t=eafc0a27ff3295bb5b0b9065fc33a523"
|
||||||
|
|
||||||
|
|
||||||
// 请求部署状态
|
// // 请求部署状态
|
||||||
let statusText = '';
|
// let statusText = '';
|
||||||
let progress = '0%';
|
// let progress = '0%';
|
||||||
let data: any;
|
// let data: any;
|
||||||
|
|
||||||
try {
|
// try {
|
||||||
data = await service.post('/api/v1/deploy/status', {
|
// data = await service.post('/api/v1/deploy/status', {
|
||||||
id: frontmatter.id, // 假设 frontmatter.id 是你需要的标识符
|
// id: frontmatter.id, // 假设 frontmatter.id 是你需要的标识符
|
||||||
}, {
|
// }, {
|
||||||
headers: {
|
// headers: {
|
||||||
// 'Authorization': token // 如果需要身份验证,可以在这里加上 token
|
// // 'Authorization': token // 如果需要身份验证,可以在这里加上 token
|
||||||
}
|
// }
|
||||||
}).then((result: any) => {
|
// }).then((result: any) => {
|
||||||
console.log("==================>result:", result);
|
// console.log("==================>result:", result);
|
||||||
|
|
||||||
if (result && result.header.code !== 1006) {
|
// if (result && result.header.code !== 1006) {
|
||||||
statusText = result.header.message || '操作失败(后端返回错误)';
|
// statusText = result.header.message || '操作失败(后端返回错误)';
|
||||||
return; // 如果返回失败,不继续处理
|
// return; // 如果返回失败,不继续处理
|
||||||
}
|
// }
|
||||||
if (result.header.code !== 1006){
|
// if (result.header.code !== 1006){
|
||||||
// 如果请求成功
|
// // 如果请求成功
|
||||||
statusText = "";
|
// statusText = "";
|
||||||
// 设置部署状态数据
|
// // 设置部署状态数据
|
||||||
progress = '0%'; // 假设返回的数据里有进度
|
// progress = '0%'; // 假设返回的数据里有进度
|
||||||
}
|
// }
|
||||||
else{
|
// else{
|
||||||
// 如果请求成功
|
// // 如果请求成功
|
||||||
statusText = result.header.message || '操作成功';
|
// statusText = result.header.message || '操作成功';
|
||||||
// 设置部署状态数据
|
// // 设置部署状态数据
|
||||||
progress = result.data.progress || '0%'; // 假设返回的数据里有进度
|
// progress = result.data.progress || '0%'; // 假设返回的数据里有进度
|
||||||
}
|
// }
|
||||||
|
|
||||||
}).catch((err) => {
|
// }).catch((err) => {
|
||||||
console.error('请求部署状态失败:', err);
|
// console.error('请求部署状态失败:', err);
|
||||||
statusText = '请求失败';
|
// statusText = '请求失败';
|
||||||
});
|
// });
|
||||||
} catch (err) {
|
// } catch (err) {
|
||||||
console.error('请求部署状态错误:', err);
|
// console.error('请求部署状态错误:', err);
|
||||||
statusText = '请求失败';
|
// statusText = '请求失败';
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -236,6 +236,41 @@ export function DetailPageHeader({ data }: { data: any }) {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const fetchDeployStatus = async () => {
|
||||||
|
try {
|
||||||
|
const result = await fetch("/api/v1/deploy/status", {
|
||||||
|
method: "POST",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify({ id: data?.id }),
|
||||||
|
}).then((res) => res.json());
|
||||||
|
|
||||||
|
console.log("==================>result:", result);
|
||||||
|
|
||||||
|
if (!result || result.header?.code !== 1006) {
|
||||||
|
setStatusText(result?.header?.message || "操作失败(后端返回错误)");
|
||||||
|
setShowDelete(false); // 非 1006 隐藏删除按钮
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果成功返回
|
||||||
|
setStatusText(result.header.message || "部署成功");
|
||||||
|
setShowDelete(true); // code === 1006 可以显示删除按钮
|
||||||
|
// 如果还想设置进度的话,这里也可以 setProgress(result.data.progress || '0%')
|
||||||
|
} catch (err) {
|
||||||
|
console.error("请求部署状态失败:", err);
|
||||||
|
setStatusText("请求失败");
|
||||||
|
setShowDelete(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
fetchDeployStatus();
|
||||||
|
}, [data?.id]); // id 变化时重新获取
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 处理图标路径
|
// 处理图标路径
|
||||||
const isImagePath =
|
const isImagePath =
|
||||||
typeof data?.icon === "string" &&
|
typeof data?.icon === "string" &&
|
||||||
|
|
@ -292,7 +327,7 @@ export function DetailPageHeader({ data }: { data: any }) {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* 条件显示删除按钮 */}
|
{/* 条件显示删除按钮 */}
|
||||||
{true && (
|
{showDelete && (
|
||||||
<button
|
<button
|
||||||
onClick={handleDelete}
|
onClick={handleDelete}
|
||||||
className="hover:text-gray-700 transition self-end"
|
className="hover:text-gray-700 transition self-end"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue