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