This commit is contained in:
parent
0524cb4e51
commit
a7c0fd91e2
|
|
@ -75,6 +75,12 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const BlogArticleWrapper = async ({ params }: { params: { slug: string, locale: string, } }) => {
|
||||
|
||||
const { serialized, frontmatter, headings } = await getPostContent(params.locale, params.slug);
|
||||
|
|
@ -83,6 +89,44 @@ 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 [statusText, setStatusText] = useState<string>('未知');
|
||||
const [progress, setProgress] = useState<string>('0%');
|
||||
|
||||
// 在组件加载时发起部署请求
|
||||
useEffect(() => {
|
||||
async function fetchDeployStatus() {
|
||||
try {
|
||||
const res = await fetch("/api/v1/deploy/status", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
id: frontmatter.id, // 假设 frontmatter.id 是你需要的标识符
|
||||
}),
|
||||
});
|
||||
|
||||
const json = await res.json();
|
||||
|
||||
if (json?.header?.code === 0) {
|
||||
setStatusText(`${json.header.message || "操作成功"}`);
|
||||
} else {
|
||||
setStatusText(`${json.header.message || "操作失败(后端返回错误)"}`);
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('部署状态请求失败', error);
|
||||
setStatusText('请求失败');
|
||||
setProgress('0%');
|
||||
}
|
||||
}
|
||||
|
||||
fetchDeployStatus();
|
||||
}, [frontmatter.id]); // 依赖于 frontmatter.id,每次 id 改变时重新请求
|
||||
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* <NavBack /> */}
|
||||
|
|
@ -94,8 +138,8 @@ const BlogArticleWrapper = async ({ params }: { params: { slug: string, locale:
|
|||
category: frontmatter.tags,
|
||||
updated_at: frontmatter.date,
|
||||
company: frontmatter.title,
|
||||
progress: "75%",
|
||||
statusText: "运行中"
|
||||
progress: progress,
|
||||
statusText: deployStatus
|
||||
}}
|
||||
/>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue