mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-10 17:33:02 +08:00
Lint Code [skip actions]
This commit is contained in:
parent
82e43d9072
commit
25d38344b0
10
src/handbook/package-lock.json
generated
10
src/handbook/package-lock.json
generated
@ -7,6 +7,7 @@
|
||||
"": {
|
||||
"name": "handbook",
|
||||
"version": "0.1.0",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"events": "^3.3.0",
|
||||
"react": "^18.2.0",
|
||||
@ -16,7 +17,6 @@
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-dsv": "^3.0.2",
|
||||
"@types/events": "^3.0.0",
|
||||
"@types/node": "^18.15.11",
|
||||
"@types/react": "^18.0.28",
|
||||
"@types/react-dom": "^18.0.11",
|
||||
"@types/react-virtualized": "^9.21.21",
|
||||
@ -750,7 +750,9 @@
|
||||
"version": "18.15.11",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.11.tgz",
|
||||
"integrity": "sha512-E5Kwq2n4SbMzQOn6wnmBjuK9ouqlURrcZDVfbo9ftDDTFt3nk7ZKK4GMOzoYgnpQJKcxwQw+lGaBvvlMo0qN/Q==",
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/@types/parse-json": {
|
||||
"version": "4.0.0",
|
||||
@ -4083,7 +4085,9 @@
|
||||
"version": "18.15.11",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.11.tgz",
|
||||
"integrity": "sha512-E5Kwq2n4SbMzQOn6wnmBjuK9ouqlURrcZDVfbo9ftDDTFt3nk7ZKK4GMOzoYgnpQJKcxwQw+lGaBvvlMo0qN/Q==",
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"peer": true
|
||||
},
|
||||
"@types/parse-json": {
|
||||
"version": "4.0.0",
|
||||
|
@ -31,7 +31,7 @@ export const sortedItems: TaggedItems = {
|
||||
* Sorts all items into their respective categories.
|
||||
*/
|
||||
export function setup(): void {
|
||||
getItems().forEach(item => {
|
||||
getItems().forEach((item) => {
|
||||
switch (item.type) {
|
||||
case ItemType.Weapon:
|
||||
sortedItems[ItemCategory.Weapon].push(item);
|
||||
|
@ -48,12 +48,17 @@ class VirtualizedGrid<T> extends React.Component<IProps<T>, IState> {
|
||||
}
|
||||
|
||||
return (
|
||||
<div key={props.key} style={{
|
||||
...props.style,
|
||||
gap: this.props.itemGap ?? 0
|
||||
}} className={"GridRow"}>
|
||||
{items.map((item, index) =>
|
||||
<div key={index}>{item}</div>)}
|
||||
<div
|
||||
key={props.key}
|
||||
style={{
|
||||
...props.style,
|
||||
gap: this.props.itemGap ?? 0
|
||||
}}
|
||||
className={"GridRow"}
|
||||
>
|
||||
{items.map((item, index) => (
|
||||
<div key={index}>{item}</div>
|
||||
))}
|
||||
<div style={{ height: this.props.gap ?? 0 }} />
|
||||
</div>
|
||||
);
|
||||
@ -65,12 +70,14 @@ class VirtualizedGrid<T> extends React.Component<IProps<T>, IState> {
|
||||
return (
|
||||
<AutoSizer>
|
||||
{({ height, width }) => (
|
||||
<List height={height - 150} width={width}
|
||||
rowHeight={itemHeight + (this.props.gap ?? 0)}
|
||||
rowCount={Math.ceil(list.length / (itemsPerRow ?? 10))}
|
||||
rowRenderer={this.rowRender.bind(this)}
|
||||
scrollTop={this.state.scrollTop}
|
||||
onScroll={(e) => this.setState({ scrollTop: e.scrollTop })}
|
||||
<List
|
||||
height={height - 150}
|
||||
width={width}
|
||||
rowHeight={itemHeight + (this.props.gap ?? 0)}
|
||||
rowCount={Math.ceil(list.length / (itemsPerRow ?? 10))}
|
||||
rowRenderer={this.rowRender.bind(this)}
|
||||
scrollTop={this.state.scrollTop}
|
||||
onScroll={(e) => this.setState({ scrollTop: e.scrollTop })}
|
||||
/>
|
||||
)}
|
||||
</AutoSizer>
|
||||
|
@ -91,23 +91,25 @@ class ItemsPage extends React.Component<{}, IState> {
|
||||
<h1 className={"ItemsPage_Title"}>Items</h1>
|
||||
|
||||
<div className={"ItemsPage_Search"}>
|
||||
<input type={"text"}
|
||||
className={"ItemsPage_Input"}
|
||||
placeholder={"Search..."}
|
||||
onChange={this.onChange.bind(this)}
|
||||
<input
|
||||
type={"text"}
|
||||
className={"ItemsPage_Input"}
|
||||
placeholder={"Search..."}
|
||||
onChange={this.onChange.bind(this)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{
|
||||
items.length > 0 ? (
|
||||
<VirtualizedGrid
|
||||
list={items.filter(item => this.showItem(item))} itemHeight={64}
|
||||
itemsPerRow={20} gap={5} itemGap={5}
|
||||
render={(item) => <Item key={item.id} data={item} />}
|
||||
/>
|
||||
) : undefined
|
||||
}
|
||||
{items.length > 0 ? (
|
||||
<VirtualizedGrid
|
||||
list={items.filter((item) => this.showItem(item))}
|
||||
itemHeight={64}
|
||||
itemsPerRow={20}
|
||||
gap={5}
|
||||
itemGap={5}
|
||||
render={(item) => <Item key={item.id} data={item} />}
|
||||
/>
|
||||
) : undefined}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -37,8 +37,7 @@ class Item extends React.Component<IProps, IState> {
|
||||
}
|
||||
|
||||
private forceReplace(): void {
|
||||
if (!this.state.loaded)
|
||||
this.replaceIcon();
|
||||
if (!this.state.loaded) this.replaceIcon();
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
@ -54,21 +53,20 @@ class Item extends React.Component<IProps, IState> {
|
||||
return (
|
||||
<div className={"Item"}>
|
||||
<div className={"Item_Background"}>
|
||||
{ this.state.icon && <img
|
||||
className={"Item_Icon"}
|
||||
alt={this.props.data.name}
|
||||
src={itemIcon(this.props.data)}
|
||||
onError={this.replaceIcon.bind(this)}
|
||||
onLoad={() => this.setState({ loaded: true })}
|
||||
/> }
|
||||
{this.state.icon && (
|
||||
<img
|
||||
className={"Item_Icon"}
|
||||
alt={this.props.data.name}
|
||||
src={itemIcon(this.props.data)}
|
||||
onError={this.replaceIcon.bind(this)}
|
||||
onLoad={() => this.setState({ loaded: true })}
|
||||
/>
|
||||
)}
|
||||
|
||||
{ (!this.state.loaded || !this.state.icon) &&
|
||||
<p className={"Item_Label"}>{this.props.data.name}</p> }
|
||||
{(!this.state.loaded || !this.state.icon) && <p className={"Item_Label"}>{this.props.data.name}</p>}
|
||||
</div>
|
||||
|
||||
<div className={"Item_Info"}>
|
||||
|
||||
</div>
|
||||
<div className={"Item_Info"}></div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -47,9 +47,12 @@ export function itemIcon(item: Item): string {
|
||||
}
|
||||
|
||||
switch (item.type) {
|
||||
default: return `https://api.ambr.top/assets/UI/UI_${item.icon}.png`;
|
||||
case ItemType.Furniture: return `https://api.ambr.top/assets/UI/furniture/UI_${item.icon}.png`;
|
||||
case ItemType.Reliquary: return `https://api.ambr.top/assets/UI/reliquary/UI_${item.icon}.png`;
|
||||
default:
|
||||
return `https://api.ambr.top/assets/UI/UI_${item.icon}.png`;
|
||||
case ItemType.Furniture:
|
||||
return `https://api.ambr.top/assets/UI/furniture/UI_${item.icon}.png`;
|
||||
case ItemType.Reliquary:
|
||||
return `https://api.ambr.top/assets/UI/reliquary/UI_${item.icon}.png`;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user