Commit 1cce4706 authored by zhangshize's avatar zhangshize

style: fix lint

parent c92e6d78
Pipeline #23373 failed with stages
in 12 minutes and 13 seconds
...@@ -13,9 +13,9 @@ import { ...@@ -13,9 +13,9 @@ import {
Dropdown, Dropdown,
Input, Input,
type MenuProps, type MenuProps,
message,
Pagination, Pagination,
Space, Space,
message,
} from "antd"; } from "antd";
import { isEqual } from "lodash-es"; import { isEqual } from "lodash-es";
import { type OverlayScrollbarsComponentRef } from "overlayscrollbars-react"; import { type OverlayScrollbarsComponentRef } from "overlayscrollbars-react";
...@@ -164,9 +164,12 @@ export const DeckEditor: React.FC<{ ...@@ -164,9 +164,12 @@ export const DeckEditor: React.FC<{
const handleSwitchCard = (type: Type, card: CardMeta) => { const handleSwitchCard = (type: Type, card: CardMeta) => {
const cardType = card.data.type ?? 0; const cardType = card.data.type ?? 0;
const isSide = type === 'side'; const isSide = type === "side";
const targetType = isSide ? const targetType = isSide
(isExtraDeckCard(cardType) ? 'extra' : 'main') : 'side'; ? isExtraDeckCard(cardType)
? "extra"
: "main"
: "side";
const { result, reason } = editDeckStore.canAdd(card, targetType, type); const { result, reason } = editDeckStore.canAdd(card, targetType, type);
if (result) { if (result) {
editDeckStore.remove(type, card); editDeckStore.remove(type, card);
...@@ -174,14 +177,17 @@ export const DeckEditor: React.FC<{ ...@@ -174,14 +177,17 @@ export const DeckEditor: React.FC<{
} else { } else {
message.error(reason); message.error(reason);
} }
} };
const showSelectedCard = (card: CardMeta) => { const showSelectedCard = (card: CardMeta) => {
selectedCard.id = card.id; selectedCard.id = card.id;
selectedCard.open = true; selectedCard.open = true;
} };
const handleMouseUp = (type: 'main' | 'extra' | 'side', payload: DeckCardMouseUpEvent) => { const handleMouseUp = (
type: "main" | "extra" | "side",
payload: DeckCardMouseUpEvent,
) => {
const { event, card } = payload; const { event, card } = payload;
switch (event.button) { switch (event.button) {
// 左键 // 左键
...@@ -200,7 +206,7 @@ export const DeckEditor: React.FC<{ ...@@ -200,7 +206,7 @@ export const DeckEditor: React.FC<{
break; break;
} }
event.preventDefault(); event.preventDefault();
} };
return ( return (
<div className={styles.container}> <div className={styles.container}>
...@@ -467,7 +473,6 @@ const SearchResults: React.FC<{ ...@@ -467,7 +473,6 @@ const SearchResults: React.FC<{
selectedCard.open = true; selectedCard.open = true;
}; };
const handleAddCardToMain = (card: CardMeta) => { const handleAddCardToMain = (card: CardMeta) => {
const cardType = card.data.type ?? 0; const cardType = card.data.type ?? 0;
const isExtraCard = isExtraDeckCard(cardType); const isExtraCard = isExtraDeckCard(cardType);
...@@ -478,7 +483,7 @@ const SearchResults: React.FC<{ ...@@ -478,7 +483,7 @@ const SearchResults: React.FC<{
} else { } else {
message.error(reason); message.error(reason);
} }
} };
const handleAddCardToSide = (card: CardMeta) => { const handleAddCardToSide = (card: CardMeta) => {
const { result, reason } = editDeckStore.canAdd(card, "side", "search"); const { result, reason } = editDeckStore.canAdd(card, "side", "search");
...@@ -487,7 +492,7 @@ const SearchResults: React.FC<{ ...@@ -487,7 +492,7 @@ const SearchResults: React.FC<{
} else { } else {
message.error(reason); message.error(reason);
} }
} };
/** safari 不支持 onAuxClick,所以使用 mousedown 模拟 */ /** safari 不支持 onAuxClick,所以使用 mousedown 模拟 */
const handleMouseUp = (payload: DeckCardMouseUpEvent) => { const handleMouseUp = (payload: DeckCardMouseUpEvent) => {
...@@ -508,7 +513,7 @@ const SearchResults: React.FC<{ ...@@ -508,7 +513,7 @@ const SearchResults: React.FC<{
default: default:
break; break;
} }
} };
return ( return (
<> <>
......
...@@ -38,12 +38,14 @@ export const DeckCard: React.FC<{ ...@@ -38,12 +38,14 @@ export const DeckCard: React.FC<{
className={styles.card} className={styles.card}
ref={ref} ref={ref}
style={{ opacity: isDragging && source !== "search" ? 0 : 1 }} style={{ opacity: isDragging && source !== "search" ? 0 : 1 }}
onMouseUp={event => onMouseUp?.({ onMouseUp={(event) =>
event, onMouseUp?.({
card: value, event,
})} card: value,
})
}
onMouseEnter={onMouseEnter} onMouseEnter={onMouseEnter}
onContextMenu={e => { onContextMenu={(e) => {
e.preventDefault(); e.preventDefault();
}} }}
> >
......
...@@ -32,51 +32,51 @@ export const DeckZone: React.FC<{ ...@@ -32,51 +32,51 @@ export const DeckZone: React.FC<{
onChange, onChange,
onElementMouseUp: onElementMouseUp, onElementMouseUp: onElementMouseUp,
}) => { }) => {
const { message } = App.useApp(); const { message } = App.useApp();
const [allowToDrop, setAllowToDrop] = useState(false); const [allowToDrop, setAllowToDrop] = useState(false);
const [{ isOver }, dropRef] = useDrop({ const [{ isOver }, dropRef] = useDrop({
accept: ["Card"], // 指明该区域允许接收的拖放物。可以是单个,也可以是数组 accept: ["Card"], // 指明该区域允许接收的拖放物。可以是单个,也可以是数组
// 里面的值就是useDrag所定义的type // 里面的值就是useDrag所定义的type
// 当拖拽物在这个拖放区域放下时触发,这个item就是拖拽物的item(拖拽物携带的数据) // 当拖拽物在这个拖放区域放下时触发,这个item就是拖拽物的item(拖拽物携带的数据)
drop: ({ value, source }: { value: CardMeta; source: Type | "search" }) => { drop: ({ value, source }: { value: CardMeta; source: Type | "search" }) => {
if (type === source) return; if (type === source) return;
const { result, reason } = canAdd(value, type, source); const { result, reason } = canAdd(value, type, source);
if (result) { if (result) {
onChange(value, source, type); onChange(value, source, type);
} else { } else {
message.error(reason); message.error(reason);
} }
}, },
hover: ({ value, source }) => { hover: ({ value, source }) => {
setAllowToDrop( setAllowToDrop(
type !== source ? canAdd(value, type, source).result : true, type !== source ? canAdd(value, type, source).result : true,
); );
}, },
collect: (monitor) => ({ collect: (monitor) => ({
isOver: monitor.isOver(), isOver: monitor.isOver(),
}), }),
}); });
return ( return (
<div <div
className={classNames(styles[type], { className={classNames(styles[type], {
[styles.over]: isOver, [styles.over]: isOver,
[styles["not-allow-to-drop"]]: isOver && !allowToDrop, [styles["not-allow-to-drop"]]: isOver && !allowToDrop,
})} })}
ref={dropRef} ref={dropRef}
> >
<div className={styles["card-continer"]}> <div className={styles["card-continer"]}>
{cards.map((card, i) => ( {cards.map((card, i) => (
<DeckCard <DeckCard
value={card} value={card}
key={card.id + i + type} key={card.id + i + type}
source={type} source={type}
onMouseUp={onElementMouseUp} onMouseUp={onElementMouseUp}
/> />
))} ))}
<div className={styles["editing-zone-name"]}> <div className={styles["editing-zone-name"]}>
{`${type.toUpperCase()}: ${cards.length}`} {`${type.toUpperCase()}: ${cards.length}`}
</div>
</div> </div>
</div> </div>
); </div>
}; );
};
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