mirror of
https://github.com/tachiyomiorg/tachiyomi-extensions-inspector.git
synced 2024-12-24 15:51:49 +01:00
handle manga page numbers
This commit is contained in:
parent
fade116a02
commit
32a9321b8a
@ -62,13 +62,15 @@ class Main {
|
||||
ctx.json(getSourceList())
|
||||
}
|
||||
|
||||
app.get("/api/v1/source/:source_id/popular") { ctx ->
|
||||
app.get("/api/v1/source/:source_id/popular/:pageNum") { ctx ->
|
||||
val sourceId = ctx.pathParam("source_id")
|
||||
ctx.json(getPopularManga(sourceId))
|
||||
val pageNum = ctx.pathParam("pageNum").toInt()
|
||||
ctx.json(getPopularManga(sourceId,pageNum))
|
||||
}
|
||||
app.get("/api/v1/source/:source_id/latest") { ctx ->
|
||||
app.get("/api/v1/source/:source_id/latest/:pageNum") { ctx ->
|
||||
val sourceId = ctx.pathParam("source_id")
|
||||
ctx.json(getLatestManga(sourceId))
|
||||
val pageNum = ctx.pathParam("pageNum").toInt()
|
||||
ctx.json(getLatestManga(sourceId,pageNum))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,8 +3,8 @@ package ir.armor.tachidesk.util
|
||||
import ir.armor.tachidesk.database.dataclass.MangaDataClass
|
||||
import ir.armor.tachidesk.database.table.MangaStatus
|
||||
|
||||
fun getPopularManga(sourceId: String): List<MangaDataClass> {
|
||||
val manguasPage = getHttpSource(sourceId.toLong()).fetchPopularManga(1).toBlocking().first()
|
||||
fun getPopularManga(sourceId: String, pageNum: Int = 1): List<MangaDataClass> {
|
||||
val manguasPage = getHttpSource(sourceId.toLong()).fetchPopularManga(pageNum).toBlocking().first()
|
||||
return manguasPage.mangas.map {
|
||||
MangaDataClass(
|
||||
sourceId.toLong(),
|
||||
@ -24,8 +24,8 @@ fun getPopularManga(sourceId: String): List<MangaDataClass> {
|
||||
}
|
||||
}
|
||||
|
||||
fun getLatestManga(sourceId: String): List<MangaDataClass> {
|
||||
val manguasPage = getHttpSource(sourceId.toLong()).fetchLatestUpdates(1).toBlocking().first()
|
||||
fun getLatestManga(sourceId: String, pageNum: Int = 1): List<MangaDataClass> {
|
||||
val manguasPage = getHttpSource(sourceId.toLong()).fetchLatestUpdates(pageNum).toBlocking().first()
|
||||
return manguasPage.mangas.map {
|
||||
MangaDataClass(
|
||||
sourceId.toLong(),
|
||||
|
@ -6,7 +6,7 @@ import NavBar from './components/NavBar';
|
||||
import Home from './screens/Home';
|
||||
import Sources from './screens/Sources';
|
||||
import Extensions from './screens/Extensions';
|
||||
import MangaList from './screens/PopularManga';
|
||||
import MangaList from './screens/MangaList';
|
||||
|
||||
export default function App() {
|
||||
return (
|
||||
@ -17,10 +17,10 @@ export default function App() {
|
||||
<Route path="/extensions">
|
||||
<Extensions />
|
||||
</Route>
|
||||
<Route path="/sources/:sourceId/popular">
|
||||
<Route path="/sources/:sourceId/popular/">
|
||||
<MangaList popular />
|
||||
</Route>
|
||||
<Route path="/sources/:sourceId/latest">
|
||||
<Route path="/sources/:sourceId/latest/">
|
||||
<MangaList popular={false} />
|
||||
</Route>
|
||||
<Route path="/sources">
|
||||
|
@ -65,8 +65,8 @@ export default function SourceCard(props: IProps) {
|
||||
</div>
|
||||
</div>
|
||||
<div style={{ display: 'flex' }}>
|
||||
{supportsLatest && <Button variant="outlined" style={{ marginLeft: 20 }} onClick={() => { window.location.href = `sources/${id}/latest`; }}>Latest</Button>}
|
||||
<Button variant="outlined" style={{ marginLeft: 20 }} onClick={() => { window.location.href = `sources/${id}/popular`; }}>Browse</Button>
|
||||
{supportsLatest && <Button variant="outlined" style={{ marginLeft: 20 }} onClick={() => { window.location.href = `sources/${id}/latest/`; }}>Latest</Button>}
|
||||
<Button variant="outlined" style={{ marginLeft: 20 }} onClick={() => { window.location.href = `sources/${id}/popular/`; }}>Browse</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
@ -11,10 +11,11 @@ export default function MangaList(props: { popular: boolean }) {
|
||||
const { sourceId } = useParams<{sourceId: string}>();
|
||||
let mapped;
|
||||
const [mangas, setMangas] = useState<IManga[]>([]);
|
||||
const [lastPageNum] = useState<number>(1);
|
||||
|
||||
useEffect(() => {
|
||||
const sourceType = props.popular ? 'popular' : 'latest';
|
||||
fetch(`http://127.0.0.1:4567/api/v1/source/${sourceId}/${sourceType}`)
|
||||
fetch(`http://127.0.0.1:4567/api/v1/source/${sourceId}/${sourceType}/${lastPageNum}`)
|
||||
.then((response) => response.json())
|
||||
.then((data: { title: string, thumbnail_url: string }[]) => setMangas(
|
||||
data.map((it) => ({ title: it.title, thumbnailUrl: it.thumbnail_url })),
|
Loading…
Reference in New Issue
Block a user