mirror of
https://github.com/tachiyomiorg/tachiyomi-extensions-inspector.git
synced 2024-11-01 06:55:06 +01:00
reader done
This commit is contained in:
parent
5d9173d3f7
commit
a7e63565ef
@ -81,9 +81,10 @@ class Main {
|
|||||||
ctx.json(getChapterList(mangaId))
|
ctx.json(getChapterList(mangaId))
|
||||||
}
|
}
|
||||||
|
|
||||||
app.get("/api/v1/chapter/:chapterId") { ctx ->
|
app.get("/api/v1/manga/:mangaId/chapter/:chapterId") { ctx ->
|
||||||
val chapterId = ctx.pathParam("chapterId").toInt()
|
val chapterId = ctx.pathParam("chapterId").toInt()
|
||||||
ctx.json(getPages(chapterId))
|
val mangaId = ctx.pathParam("mangaId").toInt()
|
||||||
|
ctx.json(getPages(chapterId,mangaId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,10 +56,10 @@ fun getChapterList(mangaId: Int): List<ChapterDataClass> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getPages(chapterId: Int): List<PageDataClass> {
|
fun getPages(chapterId: Int, mangaId: Int): List<PageDataClass> {
|
||||||
return transaction {
|
return transaction {
|
||||||
val chapterEntry = ChapterTable.select { ChapterTable.id eq chapterId }.firstOrNull()!!
|
val chapterEntry = ChapterTable.select { ChapterTable.id eq chapterId }.firstOrNull()!!
|
||||||
val mangaId = chapterEntry[ChapterTable.manga].value
|
assert(mangaId == chapterEntry[ChapterTable.manga].value) // sanity check
|
||||||
val mangaEntry = MangaTable.select { MangaTable.id eq mangaId }.firstOrNull()!!
|
val mangaEntry = MangaTable.select { MangaTable.id eq mangaId }.firstOrNull()!!
|
||||||
val source = getHttpSource(mangaEntry[MangaTable.sourceReference].value)
|
val source = getHttpSource(mangaEntry[MangaTable.sourceReference].value)
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import Sources from './screens/Sources';
|
|||||||
import Extensions from './screens/Extensions';
|
import Extensions from './screens/Extensions';
|
||||||
import MangaList from './screens/MangaList';
|
import MangaList from './screens/MangaList';
|
||||||
import Manga from './screens/Manga';
|
import Manga from './screens/Manga';
|
||||||
|
import Reader from './screens/Reader';
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
return (
|
return (
|
||||||
@ -27,6 +28,9 @@ export default function App() {
|
|||||||
<Route path="/sources">
|
<Route path="/sources">
|
||||||
<Sources />
|
<Sources />
|
||||||
</Route>
|
</Route>
|
||||||
|
<Route path="/manga/:mangaId/chapter/:chapterId">
|
||||||
|
<Reader />
|
||||||
|
</Route>
|
||||||
<Route path="/manga/:id">
|
<Route path="/manga/:id">
|
||||||
<Manga />
|
<Manga />
|
||||||
</Route>
|
</Route>
|
||||||
|
@ -60,7 +60,7 @@ export default function ChapterCard(props: IProps) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style={{ display: 'flex' }}>
|
<div style={{ display: 'flex' }}>
|
||||||
<Button variant="outlined" style={{ marginLeft: 20 }} onClick={() => { window.location.href = `http://127.0.0.1:4567/api/v1/chapter/${chapter.id}`; }}>open</Button>
|
<Button variant="outlined" style={{ marginLeft: 20 }} onClick={() => { window.location.href = `/manga/${chapter.mangaId}/chapter/${chapter.id}`; }}>open</Button>
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
45
webUI/react/src/screens/Reader.tsx
Normal file
45
webUI/react/src/screens/Reader.tsx
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import React, { useEffect, useState } from 'react';
|
||||||
|
import { useParams } from 'react-router-dom';
|
||||||
|
|
||||||
|
const style = {
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
justifyContent: 'center',
|
||||||
|
margin: '0 auto',
|
||||||
|
backgroundColor: '#343a40',
|
||||||
|
} as React.CSSProperties;
|
||||||
|
|
||||||
|
interface IPage {
|
||||||
|
index: number
|
||||||
|
imageUrl: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function Reader() {
|
||||||
|
const [pages, setPages] = useState<IPage[]>([]);
|
||||||
|
const { chapterId, mangaId } = useParams<{chapterId: string, mangaId: string}>();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
fetch(`http://127.0.0.1:4567/api/v1/manga/${mangaId}/chapter/${chapterId}`)
|
||||||
|
.then((response) => response.json())
|
||||||
|
.then((data) => setPages(data));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
pages.sort((a, b) => (a.index - b.index));
|
||||||
|
|
||||||
|
let mapped;
|
||||||
|
if (pages.length === 0) {
|
||||||
|
mapped = <h3>wait</h3>;
|
||||||
|
} else {
|
||||||
|
mapped = pages.map(({ imageUrl }) => (
|
||||||
|
<div style={{ margin: '0 auto' }}>
|
||||||
|
<img src={imageUrl} alt="f" style={{ maxWidth: '100%' }} />
|
||||||
|
</div>
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div style={style}>
|
||||||
|
{mapped}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user