mirror of
https://github.com/Suwayomi/Tachidesk.git
synced 2025-12-23 21:12:37 +01:00
popular mangas UI
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
package ir.armor.tachidesk.database.dataclass
|
package ir.armor.tachidesk.database.dataclass
|
||||||
|
|
||||||
data class SourceDataClass(
|
data class SourceDataClass(
|
||||||
val id: Long,
|
val id: String,
|
||||||
val name: String,
|
val name: String,
|
||||||
val lang: String,
|
val lang: String,
|
||||||
val iconUrl: String,
|
val iconUrl: String,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ object ExtensionsTable : IntIdTable() {
|
|||||||
val pkgName = varchar("pkg_name", 128)
|
val pkgName = varchar("pkg_name", 128)
|
||||||
val versionName = varchar("version_name", 16)
|
val versionName = varchar("version_name", 16)
|
||||||
val versionCode = integer("version_code")
|
val versionCode = integer("version_code")
|
||||||
val lang = varchar("lang", 5)
|
val lang = varchar("lang", 10)
|
||||||
val isNsfw = bool("is_nsfw")
|
val isNsfw = bool("is_nsfw")
|
||||||
val apkName = varchar("apk_name", 1024)
|
val apkName = varchar("apk_name", 1024)
|
||||||
val iconUrl = varchar("icon_url", 2048)
|
val iconUrl = varchar("icon_url", 2048)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import org.jetbrains.exposed.dao.id.IdTable
|
|||||||
object SourcesTable : IdTable<Long>() {
|
object SourcesTable : IdTable<Long>() {
|
||||||
override val id = long("id").entityId()
|
override val id = long("id").entityId()
|
||||||
val name= varchar("name", 128)
|
val name= varchar("name", 128)
|
||||||
val lang = varchar("lang", 5)
|
val lang = varchar("lang", 10)
|
||||||
val extension = reference("extension", ExtensionsTable)
|
val extension = reference("extension", ExtensionsTable)
|
||||||
val partOfFactorySource = bool("part_of_factory_source").default(false)
|
val partOfFactorySource = bool("part_of_factory_source").default(false)
|
||||||
val positionInFactorySource = integer("position_in_factory_source").nullable()
|
val positionInFactorySource = integer("position_in_factory_source").nullable()
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ fun getSourceList(): List<SourceDataClass> {
|
|||||||
return transaction {
|
return transaction {
|
||||||
return@transaction SourcesTable.selectAll().map {
|
return@transaction SourcesTable.selectAll().map {
|
||||||
SourceDataClass(
|
SourceDataClass(
|
||||||
it[SourcesTable.id].value,
|
it[SourcesTable.id].value.toString(),
|
||||||
it[SourcesTable.name],
|
it[SourcesTable.name],
|
||||||
Locale(it[SourcesTable.lang]).getDisplayLanguage(Locale(it[SourcesTable.lang])),
|
Locale(it[SourcesTable.lang]).getDisplayLanguage(Locale(it[SourcesTable.lang])),
|
||||||
ExtensionsTable.select { ExtensionsTable.id eq it[SourcesTable.extension] }.first()[ExtensionsTable.iconUrl],
|
ExtensionsTable.select { ExtensionsTable.id eq it[SourcesTable.extension] }.first()[ExtensionsTable.iconUrl],
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import {
|
|||||||
BrowserRouter as Router,
|
BrowserRouter as Router,
|
||||||
Switch,
|
Switch,
|
||||||
Route,
|
Route,
|
||||||
|
useParams,
|
||||||
} from 'react-router-dom';
|
} from 'react-router-dom';
|
||||||
import Button from '@material-ui/core/Button';
|
import Button from '@material-ui/core/Button';
|
||||||
import NavBar from './components/NavBar';
|
import NavBar from './components/NavBar';
|
||||||
@@ -11,14 +12,15 @@ import SourceCard from './components/SourceCard';
|
|||||||
import MangaCard from './components/MangaCard';
|
import MangaCard from './components/MangaCard';
|
||||||
|
|
||||||
function MangaPage() {
|
function MangaPage() {
|
||||||
|
const { sourceId } = useParams<{sourceId: string}>();
|
||||||
let mapped;
|
let mapped;
|
||||||
const [mangas, setMangas] = useState<IManga[]>([]);
|
const [mangas, setMangas] = useState<IManga[]>([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetch('https://picsum.photos/v2/list')
|
fetch(`http://127.0.0.1:4567/api/v1/source/${sourceId}/popular`)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data: { author: string, download_url: string }[]) => setMangas(
|
.then((data: { title: string, thumbnail_url: string }[]) => setMangas(
|
||||||
data.map((it) => ({ name: it.author, imageUrl: it.download_url })),
|
data.map((it) => ({ title: it.title, thumbnailUrl: it.thumbnail_url })),
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -84,12 +86,13 @@ export default function App() {
|
|||||||
<NavBar />
|
<NavBar />
|
||||||
|
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path="/mangapage">
|
|
||||||
<MangaPage />
|
|
||||||
</Route>
|
|
||||||
<Route path="/extensions">
|
<Route path="/extensions">
|
||||||
<Extensions />
|
<Extensions />
|
||||||
</Route>
|
</Route>
|
||||||
|
{/* eslint-disable-next-line react/no-children-prop */}
|
||||||
|
<Route path="/sources/:sourceId/popular">
|
||||||
|
<MangaPage />
|
||||||
|
</Route>
|
||||||
<Route path="/sources">
|
<Route path="/sources">
|
||||||
<Sources />
|
<Sources />
|
||||||
</Route>
|
</Route>
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ interface IProps {
|
|||||||
export default function MangaCard(props: IProps) {
|
export default function MangaCard(props: IProps) {
|
||||||
const {
|
const {
|
||||||
manga: {
|
manga: {
|
||||||
name, imageUrl,
|
title, thumbnailUrl,
|
||||||
},
|
},
|
||||||
} = props;
|
} = props;
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
@@ -53,12 +53,12 @@ export default function MangaCard(props: IProps) {
|
|||||||
<CardMedia
|
<CardMedia
|
||||||
className={classes.image}
|
className={classes.image}
|
||||||
component="img"
|
component="img"
|
||||||
alt="Nagatoro"
|
alt={title}
|
||||||
image={imageUrl}
|
image={thumbnailUrl}
|
||||||
title="Nagatoro"
|
title={title}
|
||||||
/>
|
/>
|
||||||
<div className={classes.gradient} />
|
<div className={classes.gradient} />
|
||||||
<Typography className={classes.title} variant="h5" component="h2">{name}</Typography>
|
<Typography className={classes.title} variant="h5" component="h2">{title}</Typography>
|
||||||
</div>
|
</div>
|
||||||
</CardActionArea>
|
</CardActionArea>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ interface IProps {
|
|||||||
export default function SourceCard(props: IProps) {
|
export default function SourceCard(props: IProps) {
|
||||||
const {
|
const {
|
||||||
source: {
|
source: {
|
||||||
name, lang, iconUrl, supportsLatest,
|
id, name, lang, iconUrl, supportsLatest,
|
||||||
},
|
},
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ export default function SourceCard(props: IProps) {
|
|||||||
</div>
|
</div>
|
||||||
<div style={{ display: 'flex' }}>
|
<div style={{ display: 'flex' }}>
|
||||||
{supportsLatest && <Button variant="outlined">Latest</Button>}
|
{supportsLatest && <Button variant="outlined">Latest</Button>}
|
||||||
<Button variant="outlined" style={{ marginLeft: 20 }}>Browse</Button>
|
<Button variant="outlined" style={{ marginLeft: 20 }} onClick={() => { window.location.href = `sources/${id}/popular`; }}>Browse</Button>
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
7
webUI/react/src/typings.d.ts
vendored
7
webUI/react/src/typings.d.ts
vendored
@@ -8,14 +8,15 @@ interface IExtension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface ISource {
|
interface ISource {
|
||||||
id: number
|
id: string
|
||||||
name: string
|
name: string
|
||||||
lang: string
|
lang: string
|
||||||
iconUrl: string
|
iconUrl: string
|
||||||
supportsLatest: boolean
|
supportsLatest: boolean
|
||||||
|
history: any
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IManga {
|
interface IManga {
|
||||||
name: string
|
title: string
|
||||||
imageUrl: string
|
thumbnailUrl: string
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user