This commit is contained in:
parent
312637f6d4
commit
cabcd70555
|
|
@ -123,6 +123,50 @@ export function DetailPageHeader({ data }: { data: any }) {
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [statusText, setStatusText] = useState(data?.statusText || "加载中...");
|
const [statusText, setStatusText] = useState(data?.statusText || "加载中...");
|
||||||
|
|
||||||
|
// const handleClick = async (source: "icon" | "info") => {
|
||||||
|
// setLoading(true);
|
||||||
|
// setStatusText(source === "icon" ? "正在处理图标操作..." : "正在处理信息操作...");
|
||||||
|
|
||||||
|
// try {
|
||||||
|
// // 从 localStorage 获取用户信息
|
||||||
|
// const userData = JSON.parse(localStorage.getItem("UserData") || "null");
|
||||||
|
|
||||||
|
// if (!userData || !userData.user_name) {
|
||||||
|
// setStatusText("未登录,正在跳转登录页面...");
|
||||||
|
// window.location.href = "/auth/sign-in/";
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// const userName = userData.user_name;
|
||||||
|
|
||||||
|
// // 从组件 props 里的 data 中取 id
|
||||||
|
// const id = data?.id;
|
||||||
|
// if (!id) {
|
||||||
|
// setStatusText("数据缺失:找不到组件 ID");
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// await fetch("/api/v1/deploy/deploy", {
|
||||||
|
// method: "POST",
|
||||||
|
// headers: { "Content-Type": "application/json" },
|
||||||
|
// body: JSON.stringify({
|
||||||
|
// id,
|
||||||
|
// user_name: userName,
|
||||||
|
// }),
|
||||||
|
// });
|
||||||
|
|
||||||
|
// await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||||
|
// setStatusText(`操作成功:来自${source === "icon" ? "图标" : "信息区域"}`);
|
||||||
|
// } catch (err) {
|
||||||
|
// console.error("请求出错:", err);
|
||||||
|
// setStatusText("操作失败");
|
||||||
|
// } finally {
|
||||||
|
// setLoading(false);
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
|
||||||
|
// ✅ 删除函数
|
||||||
|
|
||||||
const handleClick = async (source: "icon" | "info") => {
|
const handleClick = async (source: "icon" | "info") => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
setStatusText(source === "icon" ? "正在处理图标操作..." : "正在处理信息操作...");
|
setStatusText(source === "icon" ? "正在处理图标操作..." : "正在处理信息操作...");
|
||||||
|
|
@ -146,7 +190,8 @@ export function DetailPageHeader({ data }: { data: any }) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await fetch("/api/v1/deploy/deploy", {
|
// 发起部署请求
|
||||||
|
const res = await fetch("/api/v1/deploy/deploy", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
|
|
@ -155,17 +200,27 @@ export function DetailPageHeader({ data }: { data: any }) {
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
if (!res.ok) {
|
||||||
setStatusText(`操作成功:来自${source === "icon" ? "图标" : "信息区域"}`);
|
throw new Error(`HTTP 请求失败:${res.status}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const json = await res.json();
|
||||||
|
|
||||||
|
if (json?.header?.code === 0) {
|
||||||
|
setStatusText(`✅ ${json.header.message || "操作成功"}`);
|
||||||
|
} else {
|
||||||
|
setStatusText(`❌ ${json.header.message || "操作失败(后端返回错误)"}`);
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("请求出错:", err);
|
console.error("请求出错:", err);
|
||||||
setStatusText("操作失败");
|
setStatusText("操作失败,请检查网络或服务状态");
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// ✅ 删除函数
|
|
||||||
|
|
||||||
const handleDelete = () => {
|
const handleDelete = () => {
|
||||||
if (loading) return;
|
if (loading) return;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
"referrerplaceholder": "Enter your referral code(Optional)",
|
"referrerplaceholder": "Enter your referral code(Optional)",
|
||||||
"mixplacehoder": "Enter your phone number or Email address",
|
"mixplacehoder": "Enter your phone number or Email address",
|
||||||
"creat_account": "Creat Account",
|
"creat_account": "Creat Account",
|
||||||
"frogot_password": "Frogot password?",
|
"frogot_password": "Forgot password?",
|
||||||
"account_not_found": "Account not found, did you mean to sign up?",
|
"account_not_found": "Account not found, did you mean to sign up?",
|
||||||
"change_your_password": "change your password",
|
"change_your_password": "change your password",
|
||||||
"security_code_sent": "Security code sent!",
|
"security_code_sent": "Security code sent!",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue