Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Neos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Neos
Commits
5120df34
Commit
5120df34
authored
Jun 11, 2024
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix copy mdpro deck locally
parent
0cb3e38c
Pipeline
#27681
passed with stages
in 8 minutes and 40 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
10 deletions
+55
-10
src/api/mdproDeck/index.ts
src/api/mdproDeck/index.ts
+1
-0
src/api/mdproDeck/mget.ts
src/api/mdproDeck/mget.ts
+31
-0
src/api/mdproDeck/schema.ts
src/api/mdproDeck/schema.ts
+1
-1
src/ui/BuildDeck/DeckDatabase/DeckResults/index.tsx
src/ui/BuildDeck/DeckDatabase/DeckResults/index.tsx
+22
-9
No files found.
src/api/mdproDeck/index.ts
View file @
5120df34
export
*
from
"
./mget
"
;
export
*
from
"
./pull
"
;
export
*
from
"
./update
"
;
export
*
from
"
./upload
"
;
src/api/mdproDeck/mget.ts
0 → 100644
View file @
5120df34
import
{
useConfig
}
from
"
@/config
"
;
import
{
MdproDeck
}
from
"
./schema
"
;
import
{
mdproHeaders
}
from
"
./util
"
;
const
{
mdproServer
}
=
useConfig
();
const
API_PATH
=
"
/api/mdpro3/deck
"
;
interface
MgetResp
{
code
:
number
;
message
:
string
;
data
?:
MdproDeck
;
}
export
async
function
mgetDeck
(
id
:
string
):
Promise
<
MgetResp
|
undefined
>
{
const
myHeaders
=
mdproHeaders
();
const
resp
=
await
fetch
(
`
${
mdproServer
}
/
${
API_PATH
}
/
${
id
}
`
,
{
method
:
"
GET
"
,
headers
:
myHeaders
,
redirect
:
"
follow
"
,
});
if
(
!
resp
.
ok
)
{
console
.
error
(
`[Mget of Mdpro Decks] HTTPS error! status:
${
resp
.
status
}
`
);
return
undefined
;
}
else
{
return
await
resp
.
json
();
}
}
src/api/mdproDeck/schema.ts
View file @
5120df34
...
...
@@ -16,6 +16,6 @@ export interface MdproDeck {
deckUploadDate
?:
string
;
deckUpdateDate
?:
string
;
/* Content of the deck. */
deckYdk
:
string
;
deckYdk
?
:
string
;
deckCase
:
number
;
}
src/ui/BuildDeck/DeckDatabase/DeckResults/index.tsx
View file @
5120df34
...
...
@@ -3,7 +3,7 @@ import React, { memo, useEffect } from "react";
import
{
type
INTERNAL_Snapshot
as
Snapshot
,
proxy
,
useSnapshot
}
from
"
valtio
"
;
import
YGOProDeck
from
"
ygopro-deck-encode
"
;
import
{
pullDecks
}
from
"
@/api
"
;
import
{
mgetDeck
,
pullDecks
}
from
"
@/api
"
;
import
{
MdproDeck
}
from
"
@/api/mdproDeck/schema
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
IconFont
}
from
"
@/ui/Shared
"
;
...
...
@@ -120,17 +120,30 @@ const MdproDeckBlock: React.FC<Snapshot<MdproDeck>> = (deck) => (
);
const
copyMdproDeckToEditing
=
async
(
mdproDeck
:
MdproDeck
)
=>
{
const
deck
=
YGOProDeck
.
fromYdkString
(
mdproDeck
.
deckYdk
);
// currently the content of the deck, which we named `Ydk`,
// haven't been downloaded, so we need to fetch from server again by `mgetDeck`
// API.
if
(
!
(
deck
.
main
.
length
+
deck
.
extra
.
length
+
deck
.
side
.
length
===
0
))
{
const
deckName
=
mdproDeck
.
deckName
;
const
ideck
=
{
deckName
,
...
deck
};
const
editingDeck
=
await
iDeckToEditingDeck
(
ideck
);
const
deckID
=
mdproDeck
.
deckId
;
const
resp
=
await
mgetDeck
(
deckID
);
setSelectedDeck
(
ideck
);
editDeckStore
.
set
(
editingDeck
);
if
(
resp
?.
code
!==
0
)
{
message
.
error
(
resp
?.
message
);
}
else
if
(
resp
.
data
?.
deckYdk
!==
undefined
)
{
const
deck
=
YGOProDeck
.
fromYdkString
(
resp
.
data
.
deckYdk
);
if
(
!
(
deck
.
main
.
length
+
deck
.
extra
.
length
+
deck
.
side
.
length
===
0
))
{
const
deckName
=
mdproDeck
.
deckName
;
const
ideck
=
{
deckName
,
...
deck
};
const
editingDeck
=
await
iDeckToEditingDeck
(
ideck
);
setSelectedDeck
(
ideck
);
editDeckStore
.
set
(
editingDeck
);
}
else
{
message
.
error
(
"
卡组解析失败,请联系技术人员解决:<ccc@neos.moe>
"
);
}
}
else
{
message
.
error
(
"
卡组
解析失败,请联系技术人员解决
:<ccc@neos.moe>
"
);
message
.
error
(
"
卡组
复制失败,请联系技术人员结局
:<ccc@neos.moe>
"
);
}
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment