Commit 1e8a6a2e authored by Chunchi Che's avatar Chunchi Che

fix DeckUploder

parent fd8162b5
Pipeline #23052 passed with stages
in 15 minutes and 29 seconds
...@@ -6,7 +6,7 @@ import { ...@@ -6,7 +6,7 @@ import {
UploadOutlined, UploadOutlined,
} from "@ant-design/icons"; } from "@ant-design/icons";
import { App, Button, Dropdown, MenuProps, Upload, UploadProps } from "antd"; import { App, Button, Dropdown, MenuProps, Upload, UploadProps } from "antd";
import React, { useState } from "react"; import React, { useRef, useState } from "react";
import YGOProDeck from "ygopro-deck-encode"; import YGOProDeck from "ygopro-deck-encode";
import { deckStore, IDeck } from "@/stores"; import { deckStore, IDeck } from "@/stores";
...@@ -21,7 +21,7 @@ export const DeckSelect: React.FC<{ ...@@ -21,7 +21,7 @@ export const DeckSelect: React.FC<{
onDownload: (deckName: string) => void; onDownload: (deckName: string) => void;
onAdd: () => void; onAdd: () => void;
}> = ({ decks, selected, onSelect, onDelete, onDownload, onAdd }) => { }> = ({ decks, selected, onSelect, onDelete, onDownload, onAdd }) => {
const [newDeck, setNewDeck] = useState<IDeck | undefined>(undefined); const newDeck = useRef<IDeck | null>(null);
const { modal } = App.useApp(); const { modal } = App.useApp();
const showUploadModal = () => { const showUploadModal = () => {
const { destroy } = modal.info({ const { destroy } = modal.info({
...@@ -32,16 +32,15 @@ export const DeckSelect: React.FC<{ ...@@ -32,16 +32,15 @@ export const DeckSelect: React.FC<{
content: ( content: (
<DeckUploader <DeckUploader
onLoaded={(deck) => { onLoaded={(deck) => {
// 这里不生效,很奇怪 newDeck.current = deck;
setNewDeck(deck);
}} }}
/> />
), ),
okText: "上传", okText: "上传",
onCancel: () => destroy(), onCancel: () => destroy(),
onOk: async () => { onOk: async () => {
if (newDeck) { if (newDeck.current) {
await deckStore.add(newDeck); await deckStore.add(newDeck.current);
} }
}, },
}); });
......
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