2026-03-28 15:08:05 +08:00
|
|
|
import { useState, useEffect } from "react";
|
|
|
|
|
import { ProgressBar, Label } from "@heroui/react";
|
2026-03-25 09:14:24 +08:00
|
|
|
import Card from "./components/Card";
|
2026-03-27 20:30:49 +08:00
|
|
|
import Guodegang from "./components/Guodegang";
|
2026-03-28 15:08:05 +08:00
|
|
|
import Topic from "./components/Topic";
|
2026-03-24 11:59:20 +08:00
|
|
|
|
2026-03-23 22:33:30 +08:00
|
|
|
function App() {
|
2026-03-28 15:08:05 +08:00
|
|
|
const [topic, setTopic] = useState('');
|
|
|
|
|
const [cardLoaded, setCardLoaded] = useState(false);
|
|
|
|
|
const [guodegangLoaded, setGuodegangLoaded] = useState(false);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
setCardLoaded(false);
|
|
|
|
|
setGuodegangLoaded(false);
|
|
|
|
|
}, [topic]);
|
|
|
|
|
|
|
|
|
|
const progress = (() => {
|
|
|
|
|
if (!topic) return 0;
|
|
|
|
|
if (cardLoaded && guodegangLoaded) return 100;
|
|
|
|
|
if (cardLoaded || guodegangLoaded) return 50;
|
|
|
|
|
return 10;
|
|
|
|
|
})();
|
|
|
|
|
|
2026-03-23 22:33:30 +08:00
|
|
|
return (
|
2026-03-28 15:08:05 +08:00
|
|
|
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '20px' }}>
|
|
|
|
|
<Topic onTopicSubmit={setTopic}/>
|
|
|
|
|
{topic && (
|
|
|
|
|
<div className="w-64">
|
|
|
|
|
<ProgressBar value={progress} color="accent">
|
|
|
|
|
<Label>Data Loading</Label>
|
|
|
|
|
<ProgressBar.Output />
|
|
|
|
|
<ProgressBar.Track>
|
|
|
|
|
<ProgressBar.Fill />
|
|
|
|
|
</ProgressBar.Track>
|
|
|
|
|
</ProgressBar>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
<div style={{ display: 'flex', gap: '20px' }}>
|
|
|
|
|
<Card topic={topic} onLoaded={setCardLoaded} />
|
|
|
|
|
<Guodegang topic={topic} onLoaded={setGuodegangLoaded} />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-03-25 09:14:24 +08:00
|
|
|
);
|
2026-03-23 22:33:30 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-25 09:14:24 +08:00
|
|
|
export default App;
|