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
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
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
Biluo Shen
Neos
Commits
4545182b
Commit
4545182b
authored
Apr 06, 2024
by
Chunchi Che
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix/change_side' into 'main'
修复断线重连后,Side卡组消失的问题 See merge request
mycard/Neos!361
parents
d672bb4c
68e8da12
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
6 deletions
+25
-6
src/stores/sideStore.ts
src/stores/sideStore.ts
+21
-2
src/ui/Side/index.tsx
src/ui/Side/index.tsx
+3
-3
src/ui/WaitRoom/index.tsx
src/ui/WaitRoom/index.tsx
+1
-1
No files found.
src/stores/sideStore.ts
View file @
4545182b
...
...
@@ -3,6 +3,8 @@ import { proxy } from "valtio";
import
{
emptyDeck
,
IDeck
}
from
"
./deckStore
"
;
import
{
type
NeosStore
}
from
"
./shared
"
;
const
KEY
=
"
side_deck
"
;
export
enum
SideStage
{
NONE
=
0
,
// 没有进入SIDE阶段
SIDE_CHANGING
=
1
,
// 正在更换副卡组
...
...
@@ -15,10 +17,27 @@ export enum SideStage {
class
SideStore
implements
NeosStore
{
stage
:
SideStage
=
SideStage
.
NONE
;
deck
:
IDeck
=
emptyDeck
;
// 因为在上一局可能会出现断线重连,
// 所以side deck应该持久化存储在浏览器缓存里,
// 同时为了逻辑的收敛,暂时在`SideStore`提供接口。
//
// TODO: 后续应该有个`Storage`模块统一管理浏览器存储的数据,
// 这样一来卡组cdb还有文案的一些数据都可以做持久化存储,减少
// 网络请求量。
setSideDeck
(
deck
:
IDeck
)
{
try
{
localStorage
.
setItem
(
KEY
,
JSON
.
stringify
(
deck
));
}
catch
(
err
)
{
console
.
warn
(
`save side in localStorage error:
${
err
}
`
);
}
}
getSideDeck
():
IDeck
{
const
json
=
localStorage
.
getItem
(
KEY
);
return
json
?
JSON
.
parse
(
json
)
:
emptyDeck
;
}
reset
():
void
{
this
.
stage
=
SideStage
.
NONE
;
this
.
deck
=
emptyDeck
;
}
}
...
...
src/ui/Side/index.tsx
View file @
4545182b
...
...
@@ -18,10 +18,9 @@ import { TpModal } from "./TpModal";
export
const
Component
:
React
.
FC
=
()
=>
{
const
{
message
}
=
App
.
useApp
();
const
{
deck
:
sideDeck
}
=
sideStore
;
const
initialDeck
=
sideStore
.
getSideDeck
()
;
const
{
stage
}
=
useSnapshot
(
sideStore
);
const
{
errorMsg
}
=
useSnapshot
(
roomStore
);
const
initialDeck
=
JSON
.
parse
(
JSON
.
stringify
(
sideDeck
));
const
[
deck
,
setDeck
]
=
useState
<
IDeck
>
(
initialDeck
);
const
[
selectedCard
,
setSelectedCard
]
=
useState
(
0
);
const
navigate
=
useNavigate
();
...
...
@@ -55,11 +54,12 @@ export const Component: React.FC = () => {
});
};
const
onReset
=
()
=>
{
setDeck
(
JSON
.
parse
(
JSON
.
stringify
(
sideDeck
))
);
setDeck
(
initialDeck
);
message
.
info
(
"
重置成功
"
);
};
const
onSummit
=
()
=>
{
sendUpdateDeck
(
deck
);
sideStore
.
setSideDeck
(
deck
);
};
useEffect
(()
=>
{
...
...
src/ui/WaitRoom/index.tsx
View file @
4545182b
...
...
@@ -56,7 +56,7 @@ export const Component: React.FC = () => {
const
updateDeck
=
(
deck
:
IDeck
)
=>
{
sendUpdateDeck
(
deck
);
// 设置side里面的卡组
sideStore
.
deck
=
deck
;
sideStore
.
setSideDeck
(
deck
)
;
};
const
onDeckSelected
=
(
deckName
:
string
)
=>
{
...
...
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