feat: improve plugin market style, finish pagination

This commit is contained in:
HYana
2025-04-27 19:26:54 +08:00
committed by Junyan Qin
parent b85f798364
commit 1175cf9bbf
3 changed files with 73 additions and 29 deletions
+2 -2
View File
@@ -14,7 +14,7 @@ export default function PluginConfigPage() {
const [nowPageType, setNowPageType] = useState(PageType.INSTALLED) const [nowPageType, setNowPageType] = useState(PageType.INSTALLED)
return ( return (
<div className={``}> <div className={`${styles.pageContainer}`}>
<div> <div>
<Radio.Group <Radio.Group
block block
@@ -32,7 +32,7 @@ export default function PluginConfigPage() {
}} }}
/> />
</div> </div>
<div className={``}> <div className={`${styles.pageContainer}`}>
{ {
nowPageType === PageType.INSTALLED && <PluginInstalledComponent/> nowPageType === PageType.INSTALLED && <PluginInstalledComponent/>
} }
@@ -4,10 +4,10 @@ import {useCallback, useEffect, useState} from "react";
import styles from "@/app/home/plugins/plugins.module.css"; import styles from "@/app/home/plugins/plugins.module.css";
import {PluginMarketCardVO} from "@/app/home/plugins/plugin-market/plugin-market-card/PluginMarketCardVO"; import {PluginMarketCardVO} from "@/app/home/plugins/plugin-market/plugin-market-card/PluginMarketCardVO";
import PluginMarketCardComponent from "@/app/home/plugins/plugin-market/plugin-market-card/PluginMarketCardComponent"; import PluginMarketCardComponent from "@/app/home/plugins/plugin-market/plugin-market-card/PluginMarketCardComponent";
import {Input} from "antd"; import {Input, Pagination} from "antd";
import {debounce} from "lodash" import {debounce} from "lodash"
export default function PluginInstalledComponent () { export default function PluginMarketComponent () {
const [marketPluginList, setMarketPluginList] = useState<PluginMarketCardVO[]>([]) const [marketPluginList, setMarketPluginList] = useState<PluginMarketCardVO[]>([])
const [searchKeyword, setSearchKeyword] = useState("") const [searchKeyword, setSearchKeyword] = useState("")
@@ -16,9 +16,7 @@ export default function PluginInstalledComponent () {
}, []) }, [])
function initData() { function initData() {
getPluginList().then((value) => { getPluginList()
setMarketPluginList(value)
})
} }
function onInputSearchKeyword(keyword: string) { function onInputSearchKeyword(keyword: string) {
@@ -35,7 +33,7 @@ export default function PluginInstalledComponent () {
}, 500), [] }, 500), []
) )
async function searchPlugin(keyword: string): Promise<PluginMarketCardVO[]> { async function searchPlugin(keyword: string, pageNumber: number = 1): Promise<PluginMarketCardVO[]> {
// TODO 实现搜索 // TODO 实现搜索
const demoResult: PluginMarketCardVO[] = [] const demoResult: PluginMarketCardVO[] = []
for (let i = 0; i < keyword.length; i ++) { for (let i = 0; i < keyword.length; i ++) {
@@ -52,33 +50,66 @@ export default function PluginInstalledComponent () {
return demoResult return demoResult
} }
async function getPluginList(): Promise<PluginMarketCardVO[]> { function getPluginList(pageNumber: number = 1) {
return [ new Promise<PluginMarketCardVO[]>((resolve, reject) => {
new PluginMarketCardVO({ const result = [
pluginId: "aaa", new PluginMarketCardVO({
description: "一般的描述", pluginId: "aaa",
name: "插件AAA", description: "一般的描述",
author: "/hana", name: "插件AAA",
version: "0.1", author: "/hana",
githubURL: "", version: "0.1",
starCount: 23 githubURL: "",
}), starCount: 23
] }),
]
for (let i = 0; i < pageNumber; i ++) {
result.push(
new PluginMarketCardVO({
pluginId: "aaa",
description: "一般的描述",
name: "插件AAA",
author: "/hana",
version: "0.1",
githubURL: "",
starCount: 23
})
)
}
resolve(result)
}).then((value) => {
setMarketPluginList(value)
})
} }
return ( return (
<div className={`${styles.pluginListContainer}`}> <div className={`${styles.marketComponentBody}`}>
<Input <Input
style={{
width: '300px',
marginTop: '10px',
}}
value={searchKeyword} value={searchKeyword}
placeholder="搜索插件"
onChange={(e) => onInputSearchKeyword(e.target.value)} onChange={(e) => onInputSearchKeyword(e.target.value)}
/> />
{ <div className={`${styles.pluginListContainer}`}>
marketPluginList.map((vo, index) => { {
return <div key={index}> marketPluginList.map((vo, index) => {
<PluginMarketCardComponent cardVO={vo}/> return <div key={index}>
</div> <PluginMarketCardComponent cardVO={vo}/>
}) </div>
} })
}
</div>
<Pagination
defaultCurrent={1}
total={500}
onChange={(pageNumber) => {
getPluginList(pageNumber)
}}
/>
</div> </div>
) )
} }
+14 -1
View File
@@ -1,7 +1,19 @@
.pageContainer {
width: 100%;
height: calc(100% - 30px);
}
.marketComponentBody {
width: 100%;
height: calc(100% - 60px);
}
.pluginListContainer { .pluginListContainer {
align-self: flex-start; align-self: flex-start;
justify-self: flex-start; justify-self: flex-start;
width: calc(100% - 60px); width: calc(100% - 60px);
height: 100%;
max-height: 100%;
margin: auto; margin: auto;
display: grid; display: grid;
grid-template-rows: repeat(auto-fill, minmax(160px, 1fr)); grid-template-rows: repeat(auto-fill, minmax(160px, 1fr));
@@ -9,6 +21,7 @@
gap: 15px; gap: 15px;
justify-items: center; justify-items: center;
align-items: center; align-items: center;
overflow-y: scroll;
} }
.modalTitle { .modalTitle {
@@ -22,4 +35,4 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: space-around; justify-content: space-around;
} }