Commit aa88001e authored by timel's avatar timel

fix: small

parent 8d5fd312
Pipeline #23039 passed with stages
in 14 minutes and 27 seconds
import { isNil } from "lodash-es";
import { Database } from "sql.js"; import { Database } from "sql.js";
import { CardData, CardMeta, CardText } from "@/api"; import { CardData, CardMeta, CardText } from "@/api";
import { isNil } from "lodash-es";
import { constructCardMeta } from "."; import { constructCardMeta } from ".";
const TYPE_MONSTER = 0x1; const TYPE_MONSTER = 0x1;
......
...@@ -4,10 +4,9 @@ import { ...@@ -4,10 +4,9 @@ import {
InputNumber, InputNumber,
type InputNumberProps, type InputNumberProps,
Select, Select,
type SelectProps,
Tooltip, Tooltip,
} from "antd"; } from "antd";
import { useEffect, useState } from "react"; import { useState } from "react";
import { fetchStrings, Region } from "@/api"; import { fetchStrings, Region } from "@/api";
import { import {
...@@ -17,8 +16,6 @@ import { ...@@ -17,8 +16,6 @@ import {
} from "@/common"; } from "@/common";
import { FtsConditions } from "@/middleware/sqlite/fts"; import { FtsConditions } from "@/middleware/sqlite/fts";
import { debounce } from "lodash-es";
import styles from "./Filter.module.scss"; import styles from "./Filter.module.scss";
const levels = Array.from({ length: 12 }, (_, index) => ({ const levels = Array.from({ length: 12 }, (_, index) => ({
......
import { proxy } from "valtio"; import { proxy } from "valtio";
import { type CardMeta } from "@/api"; import { type CardMeta } from "@/api";
import { isExtraDeckCard, isToken } from "@/common";
import { compareCards, type EditingDeck, type Type } from "./utils"; import { compareCards, type EditingDeck, type Type } from "./utils";
import { isExtraDeckCard, isToken } from "@/common";
export const editDeckStore = proxy({ export const editDeckStore = proxy({
deckName: "", deckName: "",
......
...@@ -9,7 +9,6 @@ import { ...@@ -9,7 +9,6 @@ import {
} from "@ant-design/icons"; } from "@ant-design/icons";
import { import {
App, App,
Badge,
Button, Button,
ConfigProvider, ConfigProvider,
Dropdown, Dropdown,
...@@ -19,11 +18,11 @@ import { ...@@ -19,11 +18,11 @@ import {
type ThemeConfig, type ThemeConfig,
} from "antd"; } from "antd";
import classNames from "classnames"; import classNames from "classnames";
import { isEqual } from "lodash-es";
import { memo, useEffect, useRef, useState } from "react"; import { memo, useEffect, useRef, useState } from "react";
import { DndProvider, useDrag, useDrop } from "react-dnd"; import { DndProvider, useDrag, useDrop } from "react-dnd";
import { HTML5Backend } from "react-dnd-html5-backend"; import { HTML5Backend } from "react-dnd-html5-backend";
import { LoaderFunction } from "react-router-dom"; import { LoaderFunction } from "react-router-dom";
import { v4 as v4uuid } from "uuid";
import { useSnapshot } from "valtio"; import { useSnapshot } from "valtio";
import { subscribeKey } from "valtio/utils"; import { subscribeKey } from "valtio/utils";
...@@ -45,7 +44,6 @@ import { editDeckStore } from "./editDeckStore"; ...@@ -45,7 +44,6 @@ import { editDeckStore } from "./editDeckStore";
import { Filter } from "./Filter"; import { Filter } from "./Filter";
import styles from "./index.module.scss"; import styles from "./index.module.scss";
import { editingDeckToIDeck, iDeckToEditingDeck, type Type } from "./utils"; import { editingDeckToIDeck, iDeckToEditingDeck, type Type } from "./utils";
import { isEqual } from "lodash-es";
const theme: ThemeConfig = { const theme: ThemeConfig = {
components: { components: {
...@@ -252,13 +250,11 @@ const Search: React.FC = () => { ...@@ -252,13 +250,11 @@ const Search: React.FC = () => {
] as const ] as const
).map(([label, onClick], key) => ({ key, label, onClick })); ).map(([label, onClick], key) => ({ key, label, onClick }));
const handleSearch = async () => { const handleSearch = async (conditions: FtsConditions = searchConditions) => {
const result = ( const result = (await searchCards({ query: searchWord, conditions }))
await searchCards({ query: searchWord, conditions: searchConditions })
)
.filter((card) => !isToken(card.data.type ?? 0)) .filter((card) => !isToken(card.data.type ?? 0))
.sort(sortRef.current); // 衍生物不显示 .sort(sortRef.current); // 衍生物不显示
setSearchResult(result); setSearchResult(() => result);
}; };
const [_, dropRef] = useDrop({ const [_, dropRef] = useDrop({
...@@ -284,7 +280,7 @@ const Search: React.FC = () => { ...@@ -284,7 +280,7 @@ const Search: React.FC = () => {
onConfirm={(newConditions) => { onConfirm={(newConditions) => {
setSearchConditions(newConditions); setSearchConditions(newConditions);
destroy(); destroy();
setTimeout(handleSearch, 200); // 先收起再搜索 setTimeout(() => handleSearch(newConditions), 200); // 先收起再搜索
}} }}
onCancel={() => destroy()} onCancel={() => destroy()}
/> />
...@@ -303,7 +299,7 @@ const Search: React.FC = () => { ...@@ -303,7 +299,7 @@ const Search: React.FC = () => {
<Button <Button
type="text" type="text"
icon={<SearchOutlined />} icon={<SearchOutlined />}
onClick={handleSearch} onClick={() => handleSearch()}
/> />
} }
value={searchWord} value={searchWord}
...@@ -404,10 +400,10 @@ const DeckZone: React.FC<{ ...@@ -404,10 +400,10 @@ const DeckZone: React.FC<{
ref={dropRef} ref={dropRef}
> >
<div className={styles["card-continer"]}> <div className={styles["card-continer"]}>
{cards.map((card) => ( {cards.map((card, i) => (
<Card <Card
value={card} value={card}
key={v4uuid()} key={card.id + i + type}
source={type} source={type}
onRightClick={() => editDeckStore.remove(type, card)} onRightClick={() => editDeckStore.remove(type, card)}
/> />
......
import { type CardMeta, fetchCard } from "@/api"; import { type CardMeta, fetchCard } from "@/api";
import { isExtraDeckCard, isToken, tellCardBasicType } from "@/common"; import { tellCardBasicType } from "@/common";
import { type IDeck } from "@/stores"; import { type IDeck } from "@/stores";
export type Type = "main" | "extra" | "side"; export type Type = "main" | "extra" | "side";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment