This commit is contained in:
parent
174eef5d92
commit
41f762095e
|
|
@ -90,27 +90,38 @@ 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"
|
||||||
|
|
||||||
|
|
||||||
// 发起部署请求
|
// 请求部署状态
|
||||||
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();
|
|
||||||
|
|
||||||
// 根据 API 返回值更新状态文本
|
|
||||||
let statusText = '';
|
let statusText = '';
|
||||||
let progress = '0%';
|
let progress = '0%';
|
||||||
|
let data: any;
|
||||||
|
|
||||||
if (json?.header?.code === 0) {
|
try {
|
||||||
statusText = `${json.header.message || "操作成功"}`;
|
data = await service.post('/api/v1/deploy/status', {
|
||||||
} else {
|
id: frontmatter.id, // 假设 frontmatter.id 是你需要的标识符
|
||||||
statusText = `${json.header.message || "操作失败(后端返回错误)"}`;
|
}, {
|
||||||
|
headers: {
|
||||||
|
// 'Authorization': token // 如果需要身份验证,可以在这里加上 token
|
||||||
|
}
|
||||||
|
}).then((result: any) => {
|
||||||
|
console.log("result:", result);
|
||||||
|
|
||||||
|
if (result && result.header.code !== 0) {
|
||||||
|
statusText = result.header.message || '操作失败(后端返回错误)';
|
||||||
|
return; // 如果返回失败,不继续处理
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 如果请求成功
|
||||||
|
statusText = result.header.message || '操作成功';
|
||||||
|
// 设置部署状态数据
|
||||||
|
progress = result.data.progress || '0%'; // 假设返回的数据里有进度
|
||||||
|
}).catch((err) => {
|
||||||
|
console.error('请求部署状态失败:', err);
|
||||||
|
statusText = '请求失败';
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.error('请求部署状态错误:', err);
|
||||||
|
statusText = '请求失败';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue