"use client"; import {useState} from "react"; import "./resetdata.css"; const RESET_ENDPOINT="/api/risk-agent/project-assistant/demo/reset"; export default function ResetDataPage(){ const [busy,setBusy]=useState(false); async function reset(){ if(!window.confirm("确认恢复演示初始数据?DEMO-A、DEMO-B、DEMO-C 当前演示操作将被归档。"))return; setBusy(true); try{ const response=await fetch(RESET_ENDPOINT,{ method:"POST", headers:{"Content-Type":"application/json","X-Xingbang-Demo-Role":"admin"}, body:JSON.stringify({confirmation:"RESET-DEMO-A-B-C"}), }); const result=await response.json(); if(!response.ok)throw Error(typeof result.detail==="string"?result.detail:"数据恢复失败"); window.alert("演示数据已恢复到初始状态。"); }catch(error){ window.alert(error instanceof Error?error.message:"数据恢复失败,请稍后重试。"); }finally{setBusy(false)} } return
; }