mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-23 07:10:46 +00:00
Lint Code [skip actions]
This commit is contained in:
parent
65532ffd90
commit
5ac93645e4
@ -1,7 +1,5 @@
|
||||
export type Page = "Home" | "Commands" | "Avatars" | "Items"
|
||||
| "Entities" | "Scenes";
|
||||
export type Days = "Sunday" | "Monday" | "Tuesday"
|
||||
| "Wednesday" | "Thursday" | "Friday" | "Saturday";
|
||||
export type Page = "Home" | "Commands" | "Avatars" | "Items" | "Entities" | "Scenes";
|
||||
export type Days = "Sunday" | "Monday" | "Tuesday" | "Wednesday" | "Thursday" | "Friday" | "Saturday";
|
||||
|
||||
export type Command = {
|
||||
name: string[];
|
||||
@ -136,13 +134,21 @@ export function isPage(page: string): page is Page {
|
||||
*/
|
||||
export function itemTypeToString(type: ItemType): string {
|
||||
switch (type) {
|
||||
default: return "Unknown";
|
||||
case ItemType.None: return "None";
|
||||
case ItemType.Virtual: return "Virtual";
|
||||
case ItemType.Material: return "Material";
|
||||
case ItemType.Reliquary: return "Reliquary";
|
||||
case ItemType.Weapon: return "Weapon";
|
||||
case ItemType.Display: return "Display";
|
||||
case ItemType.Furniture: return "Furniture";
|
||||
default:
|
||||
return "Unknown";
|
||||
case ItemType.None:
|
||||
return "None";
|
||||
case ItemType.Virtual:
|
||||
return "Virtual";
|
||||
case ItemType.Material:
|
||||
return "Material";
|
||||
case ItemType.Reliquary:
|
||||
return "Reliquary";
|
||||
case ItemType.Weapon:
|
||||
return "Weapon";
|
||||
case ItemType.Display:
|
||||
return "Display";
|
||||
case ItemType.Furniture:
|
||||
return "Furniture";
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,8 @@ class EntitiesPage extends React.Component<{}, IState> {
|
||||
* @private
|
||||
*/
|
||||
private async setSelectedItem(entity: EntityType): Promise<void> {
|
||||
let data: EntityInfo | null = null; try {
|
||||
let data: EntityInfo | null = null;
|
||||
try {
|
||||
data = await fetchEntityData(entity);
|
||||
} catch {}
|
||||
|
||||
@ -124,24 +125,25 @@ class EntitiesPage extends React.Component<{}, IState> {
|
||||
|
||||
{entities.length > 0 ? (
|
||||
<VirtualizedGrid
|
||||
list={entities.filter(entity => this.showEntity(entity))}
|
||||
list={entities.filter((entity) => this.showEntity(entity))}
|
||||
itemHeight={64}
|
||||
itemsPerRow={18}
|
||||
gap={5}
|
||||
itemGap={5}
|
||||
render={(entity) => <MiniCard
|
||||
key={entity.id} data={entity} icon={entityIcon(entity)}
|
||||
render={(entity) => (
|
||||
<MiniCard
|
||||
key={entity.id}
|
||||
data={entity}
|
||||
icon={entityIcon(entity)}
|
||||
onClick={() => this.setSelectedItem(entity)}
|
||||
/>}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
) : undefined}
|
||||
</div>
|
||||
|
||||
<div className={"EntitiesPage_Card"}>
|
||||
<EntityCard
|
||||
entity={this.state.selected}
|
||||
info={this.state.selectedInfo}
|
||||
/>
|
||||
<EntityCard entity={this.state.selected} info={this.state.selectedInfo} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
@ -97,7 +97,8 @@ class ItemsPage extends React.Component<{}, IState> {
|
||||
* @private
|
||||
*/
|
||||
private async setSelectedItem(item: ItemType): Promise<void> {
|
||||
let data: ItemInfo | null = null; try {
|
||||
let data: ItemInfo | null = null;
|
||||
try {
|
||||
data = await fetchItemData(item);
|
||||
} catch {}
|
||||
|
||||
@ -133,19 +134,20 @@ class ItemsPage extends React.Component<{}, IState> {
|
||||
itemsPerRow={18}
|
||||
gap={5}
|
||||
itemGap={5}
|
||||
render={(item) => <MiniCard
|
||||
key={item.id} data={item} icon={itemIcon(item)}
|
||||
render={(item) => (
|
||||
<MiniCard
|
||||
key={item.id}
|
||||
data={item}
|
||||
icon={itemIcon(item)}
|
||||
onClick={() => this.setSelectedItem(item)}
|
||||
/>}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
) : undefined}
|
||||
</div>
|
||||
|
||||
<div className={"ItemsPage_Card"}>
|
||||
<ItemCard
|
||||
item={this.state.selected}
|
||||
info={this.state.selectedInfo}
|
||||
/>
|
||||
<ItemCard item={this.state.selected} info={this.state.selectedInfo} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
@ -13,8 +13,7 @@ import "@css/widgets/ItemCard.scss";
|
||||
function toDescription(description: string | undefined): JSX.Element[] {
|
||||
if (!description) return [];
|
||||
|
||||
return description.split("\\n")
|
||||
.map((line, index) => {
|
||||
return description.split("\\n").map((line, index) => {
|
||||
return <p key={index}>{line}</p>;
|
||||
});
|
||||
}
|
||||
@ -64,8 +63,7 @@ class EntityCard extends React.Component<IProps, IState> {
|
||||
private addCount(positive: boolean, multiple: boolean) {
|
||||
let { count } = this.state;
|
||||
if (count === "") count = 1;
|
||||
if (typeof count == "string")
|
||||
count = parseInt(count);
|
||||
if (typeof count == "string") count = parseInt(count);
|
||||
if (count < 1) count = 1;
|
||||
|
||||
let increment = 1;
|
||||
@ -104,28 +102,33 @@ class EntityCard extends React.Component<IProps, IState> {
|
||||
<p>{data?.type ?? ""}</p>
|
||||
</div>
|
||||
|
||||
{ this.state.icon && <img
|
||||
{this.state.icon && (
|
||||
<img
|
||||
className={"ItemCard_Icon"}
|
||||
alt={entity.name}
|
||||
src={entityIcon(entity)}
|
||||
onError={() => this.setState({ icon: false })}
|
||||
/> }
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className={"ItemCard_Description"}>
|
||||
{toDescription(data?.description)}
|
||||
</div>
|
||||
<div className={"ItemCard_Description"}>{toDescription(data?.description)}</div>
|
||||
</div>
|
||||
|
||||
<div className={"ItemCard_Actions"}>
|
||||
<div className={"ItemCard_Counter"}>
|
||||
<div onClick={() => this.addCount(false, false)}
|
||||
<div
|
||||
onClick={() => this.addCount(false, false)}
|
||||
onContextMenu={(e) => {
|
||||
e.preventDefault();
|
||||
this.addCount(false, true);
|
||||
}}
|
||||
className={"ItemCard_Operation"}>-</div>
|
||||
<input type={"text"}
|
||||
className={"ItemCard_Operation"}
|
||||
>
|
||||
-
|
||||
</div>
|
||||
<input
|
||||
type={"text"}
|
||||
value={this.state.count}
|
||||
className={"ItemCard_Count"}
|
||||
onChange={this.updateCount.bind(this)}
|
||||
@ -135,18 +138,21 @@ class EntityCard extends React.Component<IProps, IState> {
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<div onClick={() => this.addCount(true, false)}
|
||||
<div
|
||||
onClick={() => this.addCount(true, false)}
|
||||
onContextMenu={(e) => {
|
||||
e.preventDefault();
|
||||
this.addCount(true, true);
|
||||
}}
|
||||
className={"ItemCard_Operation"}>+</div>
|
||||
className={"ItemCard_Operation"}
|
||||
>
|
||||
+
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
className={"ItemCard_Submit"}
|
||||
onClick={this.summonAtPlayer.bind(this)}
|
||||
>Summon</button>
|
||||
<button className={"ItemCard_Submit"} onClick={this.summonAtPlayer.bind(this)}>
|
||||
Summon
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
) : undefined;
|
||||
|
@ -5,7 +5,7 @@ import { itemIcon } from "@app/utils";
|
||||
import "@css/widgets/MiniCard.scss";
|
||||
|
||||
interface IProps {
|
||||
data: { name: string; };
|
||||
data: { name: string };
|
||||
icon: string;
|
||||
|
||||
onClick?: () => void;
|
||||
@ -53,9 +53,7 @@ class MiniCard extends React.Component<IProps, IState> {
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className={"MiniCard"}
|
||||
onClick={this.props.onClick}
|
||||
>
|
||||
<div className={"MiniCard"} onClick={this.props.onClick}>
|
||||
<div className={"MiniCard_Background"}>
|
||||
{this.state.icon && (
|
||||
<img
|
||||
@ -67,7 +65,9 @@ class MiniCard extends React.Component<IProps, IState> {
|
||||
/>
|
||||
)}
|
||||
|
||||
{(!this.state.loaded || !this.state.icon) && <p className={"MiniCard_Label"}>{this.props.data.name}</p>}
|
||||
{(!this.state.loaded || !this.state.icon) && (
|
||||
<p className={"MiniCard_Label"}>{this.props.data.name}</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user