Fix
This commit is contained in:
@ -7,27 +7,12 @@ import EpisodeDetail from './components/EpisodeDetail'
|
|||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const location = useLocation()
|
const location = useLocation()
|
||||||
const isEpisodeDetail = location.pathname.startsWith('/episode/')
|
const isMainPage = ['/', '/feeds', '/feed-requests'].includes(location.pathname)
|
||||||
const isFeedDetail = location.pathname.startsWith('/feeds/') && location.pathname.split('/').length === 3
|
|
||||||
|
|
||||||
if (isEpisodeDetail) {
|
|
||||||
return (
|
|
||||||
<Routes>
|
|
||||||
<Route path="/episode/:episodeId" element={<EpisodeDetail />} />
|
|
||||||
</Routes>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isFeedDetail) {
|
|
||||||
return (
|
|
||||||
<Routes>
|
|
||||||
<Route path="/feeds/:feedId" element={<FeedDetail />} />
|
|
||||||
</Routes>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container">
|
<div className="container">
|
||||||
|
{isMainPage && (
|
||||||
|
<>
|
||||||
<div className="header">
|
<div className="header">
|
||||||
<div className="title">Voice RSS Summary</div>
|
<div className="title">Voice RSS Summary</div>
|
||||||
<div className="subtitle">RSS フィードから自動生成された音声ポッドキャスト</div>
|
<div className="subtitle">RSS フィードから自動生成された音声ポッドキャスト</div>
|
||||||
@ -53,12 +38,16 @@ function App() {
|
|||||||
フィードリクエスト
|
フィードリクエスト
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className="content">
|
<div className="content">
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/" element={<EpisodeList />} />
|
<Route path="/" element={<EpisodeList />} />
|
||||||
<Route path="/feeds" element={<FeedList />} />
|
<Route path="/feeds" element={<FeedList />} />
|
||||||
<Route path="/feed-requests" element={<FeedManager />} />
|
<Route path="/feed-requests" element={<FeedManager />} />
|
||||||
|
<Route path="/episode/:episodeId" element={<EpisodeDetail />} />
|
||||||
|
<Route path="/feeds/:feedId" element={<FeedDetail />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -34,7 +34,7 @@ function EpisodeList() {
|
|||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
const [error, setError] = useState<string | null>(null)
|
const [error, setError] = useState<string | null>(null)
|
||||||
const [currentAudio, setCurrentAudio] = useState<string | null>(null)
|
const [currentAudio, setCurrentAudio] = useState<string | null>(null)
|
||||||
const [useDatabase, setUseDatabase] = useState(true)
|
const [useDatabase, setUseDatabase] = useState(false)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchEpisodes()
|
fetchEpisodes()
|
||||||
@ -43,6 +43,7 @@ function EpisodeList() {
|
|||||||
const fetchEpisodes = async () => {
|
const fetchEpisodes = async () => {
|
||||||
try {
|
try {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
|
setError(null)
|
||||||
|
|
||||||
if (useDatabase) {
|
if (useDatabase) {
|
||||||
// Try to fetch from database first
|
// Try to fetch from database first
|
||||||
@ -51,9 +52,18 @@ function EpisodeList() {
|
|||||||
throw new Error('データベースからの取得に失敗しました')
|
throw new Error('データベースからの取得に失敗しました')
|
||||||
}
|
}
|
||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
setEpisodes(data.episodes || [])
|
const dbEpisodes = data.episodes || []
|
||||||
|
|
||||||
|
if (dbEpisodes.length === 0) {
|
||||||
|
// Database is empty, fallback to XML
|
||||||
|
console.log('Database is empty, falling back to XML parsing...')
|
||||||
|
setUseDatabase(false)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
setEpisodes(dbEpisodes)
|
||||||
} else {
|
} else {
|
||||||
// Fallback to XML parsing (existing functionality)
|
// Use XML parsing as primary source
|
||||||
const response = await fetch('/api/episodes-from-xml')
|
const response = await fetch('/api/episodes-from-xml')
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
const errorData = await response.json()
|
const errorData = await response.json()
|
||||||
@ -168,10 +178,15 @@ function EpisodeList() {
|
|||||||
<div>
|
<div>
|
||||||
<div style={{ marginBottom: '20px', display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
<div style={{ marginBottom: '20px', display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
||||||
<h2>エピソード一覧 ({episodes.length}件)</h2>
|
<h2>エピソード一覧 ({episodes.length}件)</h2>
|
||||||
|
<div style={{ display: 'flex', gap: '10px', alignItems: 'center' }}>
|
||||||
|
<span style={{ fontSize: '12px', color: '#666' }}>
|
||||||
|
データソース: {useDatabase ? 'データベース' : 'XML'}
|
||||||
|
</span>
|
||||||
<button className="btn btn-secondary" onClick={fetchEpisodes}>
|
<button className="btn btn-secondary" onClick={fetchEpisodes}>
|
||||||
更新
|
更新
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<table className="table">
|
<table className="table">
|
||||||
<thead>
|
<thead>
|
||||||
|
Reference in New Issue
Block a user