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
love_飞影
Neos
Commits
990ac633
Commit
990ac633
authored
Aug 08, 2023
by
timel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: initStore
parent
bf06704b
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
169 additions
and
78 deletions
+169
-78
src/stores/index.ts
src/stores/index.ts
+3
-0
src/stores/initStore.ts
src/stores/initStore.ts
+15
-0
src/ui/BuildDeck/index.tsx
src/ui/BuildDeck/index.tsx
+106
-78
src/ui/BuildDeck/utils.ts
src/ui/BuildDeck/utils.ts
+10
-0
src/ui/Shared/Loading/index.module.scss
src/ui/Shared/Loading/index.module.scss
+15
-0
src/ui/Shared/Loading/index.tsx
src/ui/Shared/Loading/index.tsx
+19
-0
src/ui/Shared/index.ts
src/ui/Shared/index.ts
+1
-0
No files found.
src/stores/index.ts
View file @
990ac633
...
@@ -2,6 +2,7 @@ export * from "./accountStore";
...
@@ -2,6 +2,7 @@ export * from "./accountStore";
export
*
from
"
./cardStore
"
;
export
*
from
"
./cardStore
"
;
export
*
from
"
./chatStore
"
;
export
*
from
"
./chatStore
"
;
export
*
from
"
./deckStore
"
;
export
*
from
"
./deckStore
"
;
export
*
from
"
./initStore
"
;
export
*
from
"
./matStore
"
;
export
*
from
"
./matStore
"
;
export
*
from
"
./placeStore
"
;
export
*
from
"
./placeStore
"
;
export
*
from
"
./replayStore
"
;
export
*
from
"
./replayStore
"
;
...
@@ -15,6 +16,7 @@ import { accountStore } from "./accountStore";
...
@@ -15,6 +16,7 @@ import { accountStore } from "./accountStore";
import
{
cardStore
}
from
"
./cardStore
"
;
import
{
cardStore
}
from
"
./cardStore
"
;
import
{
chatStore
}
from
"
./chatStore
"
;
import
{
chatStore
}
from
"
./chatStore
"
;
import
{
deckStore
}
from
"
./deckStore
"
;
import
{
deckStore
}
from
"
./deckStore
"
;
import
{
initStore
}
from
"
./initStore
"
;
import
{
matStore
}
from
"
./matStore
"
;
import
{
matStore
}
from
"
./matStore
"
;
import
{
placeStore
}
from
"
./placeStore
"
;
import
{
placeStore
}
from
"
./placeStore
"
;
import
{
replayStore
}
from
"
./replayStore
"
;
import
{
replayStore
}
from
"
./replayStore
"
;
...
@@ -30,6 +32,7 @@ devtools(replayStore, { name: "replay", enabled: DEV });
...
@@ -30,6 +32,7 @@ devtools(replayStore, { name: "replay", enabled: DEV });
devtools
(
accountStore
,
{
name
:
"
account
"
,
enabled
:
DEV
});
devtools
(
accountStore
,
{
name
:
"
account
"
,
enabled
:
DEV
});
devtools
(
roomStore
,
{
name
:
"
room
"
,
enabled
:
DEV
});
devtools
(
roomStore
,
{
name
:
"
room
"
,
enabled
:
DEV
});
devtools
(
deckStore
,
{
name
:
"
deck
"
,
enabled
:
DEV
});
devtools
(
deckStore
,
{
name
:
"
deck
"
,
enabled
:
DEV
});
devtools
(
initStore
,
{
name
:
"
init
"
,
enabled
:
DEV
});
// 重置所有`Store`
// 重置所有`Store`
export
const
resetUniverse
=
()
=>
{
export
const
resetUniverse
=
()
=>
{
...
...
src/stores/initStore.ts
0 → 100644
View file @
990ac633
import
{
proxy
}
from
"
valtio
"
;
import
{
type
NeosStore
}
from
"
./shared
"
;
export
const
initStore
=
proxy
({
sqlite
:
{
initialized
:
false
,
progress
:
0
,
},
i18n
:
{
initialized
:
false
,
},
// ...
reset
()
{},
}
satisfies
NeosStore
);
src/ui/BuildDeck/index.tsx
View file @
990ac633
...
@@ -15,15 +15,22 @@ import {
...
@@ -15,15 +15,22 @@ import {
Space
,
Space
,
type
ThemeConfig
,
type
ThemeConfig
,
}
from
"
antd
"
;
}
from
"
antd
"
;
import
{
useEffect
,
useState
}
from
"
react
"
;
import
{
Suspense
,
useEffect
,
useState
}
from
"
react
"
;
import
{
Await
,
defer
,
type
LoaderFunction
,
useLoaderData
,
}
from
"
react-router-dom
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
import
{
useSnapshot
}
from
"
valtio
"
;
import
{
deckStore
,
type
IDeck
}
from
"
@/stores
"
;
import
{
deckStore
,
type
IDeck
,
initStore
}
from
"
@/stores
"
;
import
{
Background
,
ScrollableArea
,
YgoCard
}
from
"
@/ui/Shared
"
;
import
{
Background
,
Loading
,
ScrollableArea
,
YgoCard
}
from
"
@/ui/Shared
"
;
import
{
CardDetail
}
from
"
./CardDetail
"
;
import
{
CardDetail
}
from
"
./CardDetail
"
;
import
{
DeckSelect
}
from
"
./DeckSelect
"
;
import
{
DeckSelect
}
from
"
./DeckSelect
"
;
import
styles
from
"
./index.module.scss
"
;
import
styles
from
"
./index.module.scss
"
;
import
{
initSqlite
}
from
"
./utils
"
;
const
theme
:
ThemeConfig
=
{
const
theme
:
ThemeConfig
=
{
components
:
{
components
:
{
...
@@ -33,7 +40,18 @@ const theme: ThemeConfig = {
...
@@ -33,7 +40,18 @@ const theme: ThemeConfig = {
},
},
};
};
export
const
loader
:
LoaderFunction
=
async
()
=>
{
return
defer
({
initialized
:
initStore
.
sqlite
.
initialized
?
true
:
initSqlite
().
then
(()
=>
(
initStore
.
sqlite
.
initialized
=
true
)),
});
};
export
const
Component
:
React
.
FC
=
()
=>
{
export
const
Component
:
React
.
FC
=
()
=>
{
const
data
=
useLoaderData
<
{
initialized
:
boolean
;
}
>
();
const
snapDecks
=
useSnapshot
(
deckStore
);
const
snapDecks
=
useSnapshot
(
deckStore
);
const
[
selectedDeck
,
setSelectedDeck
]
=
useState
<
IDeck
>
(
deckStore
.
decks
[
0
]);
const
[
selectedDeck
,
setSelectedDeck
]
=
useState
<
IDeck
>
(
deckStore
.
decks
[
0
]);
...
@@ -57,8 +75,22 @@ export const Component: React.FC = () => {
...
@@ -57,8 +75,22 @@ export const Component: React.FC = () => {
<
CardDetail
code=
{
123
}
open=
{
false
}
onClose=
{
()
=>
{}
}
/>
<
CardDetail
code=
{
123
}
open=
{
false
}
onClose=
{
()
=>
{}
}
/>
</
div
>
</
div
>
<
div
className=
{
styles
.
content
}
>
<
div
className=
{
styles
.
content
}
>
<
Deck
deck=
{
selectedDeck
}
onSave=
{
()
=>
{}
}
/>
<
div
className=
{
styles
.
deck
}
>
<
DeckEditor
deck=
{
selectedDeck
}
onSave=
{
()
=>
{}
}
/>
</
div
>
<
div
className=
{
styles
.
select
}
>
<
Suspense
fallback=
{
<
div
className=
{
styles
.
container
}
>
<
Loading
/>
</
div
>
}
>
<
Await
resolve=
{
data
.
initialized
}
>
<
CardSelect
/>
<
CardSelect
/>
</
Await
>
</
Suspense
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</
ConfigProvider
>
</
ConfigProvider
>
...
@@ -67,7 +99,7 @@ export const Component: React.FC = () => {
...
@@ -67,7 +99,7 @@ export const Component: React.FC = () => {
Component
.
displayName
=
"
Build
"
;
Component
.
displayName
=
"
Build
"
;
/** 正在编辑的卡组 */
/** 正在编辑的卡组 */
const
Deck
:
React
.
FC
<
{
const
Deck
Editor
:
React
.
FC
<
{
deck
:
IDeck
;
deck
:
IDeck
;
onSave
:
(
deck
:
IDeck
)
=>
void
;
onSave
:
(
deck
:
IDeck
)
=>
void
;
}
>
=
({
deck
,
onSave
})
=>
{
}
>
=
({
deck
,
onSave
})
=>
{
...
@@ -76,7 +108,6 @@ const Deck: React.FC<{
...
@@ -76,7 +108,6 @@ const Deck: React.FC<{
setEditingDeck
(
deck
);
setEditingDeck
(
deck
);
},
[
deck
]);
},
[
deck
]);
return
(
return
(
<
div
className=
{
styles
.
deck
}
>
<
div
className=
{
styles
.
container
}
>
<
div
className=
{
styles
.
container
}
>
<
Space
className=
{
styles
.
title
}
>
<
Space
className=
{
styles
.
title
}
>
<
Input
<
Input
...
@@ -120,14 +151,12 @@ const Deck: React.FC<{
...
@@ -120,14 +151,12 @@ const Deck: React.FC<{
))
}
))
}
</
ScrollableArea
>
</
ScrollableArea
>
</
div
>
</
div
>
</
div
>
);
);
};
};
/** 卡片库,选择卡片加入正在编辑的卡组 */
/** 卡片库,选择卡片加入正在编辑的卡组 */
const
CardSelect
:
React
.
FC
=
()
=>
{
const
CardSelect
:
React
.
FC
=
()
=>
{
return
(
return
(
<
div
className=
{
styles
.
select
}
>
<
div
className=
{
styles
.
container
}
>
<
div
className=
{
styles
.
container
}
>
<
div
className=
{
styles
.
title
}
>
<
div
className=
{
styles
.
title
}
>
<
Input
<
Input
...
@@ -158,6 +187,5 @@ const CardSelect: React.FC = () => {
...
@@ -158,6 +187,5 @@ const CardSelect: React.FC = () => {
</
div
>
</
div
>
</
ScrollableArea
>
</
ScrollableArea
>
</
div
>
</
div
>
</
div
>
);
);
};
};
src/ui/BuildDeck/utils.ts
0 → 100644
View file @
990ac633
import
{
useConfig
}
from
"
@/config
"
;
import
sqliteMiddleWare
,
{
sqliteCmd
}
from
"
@/middleware/sqlite
"
;
const
{
cardsDbUrl
}
=
useConfig
();
export
const
initSqlite
=
()
=>
sqliteMiddleWare
({
cmd
:
sqliteCmd
.
INIT
,
initInfo
:
{
dbUrl
:
cardsDbUrl
},
});
src/ui/Shared/Loading/index.module.scss
0 → 100644
View file @
990ac633
.loading
{
height
:
100%
;
width
:
100%
;
display
:
flex
;
flex-direction
:
column
;
justify-content
:
center
;
align-items
:
center
;
gap
:
10px
;
.text
{
font-size
:
14px
;
}
.icon
{
font-size
:
20px
;
}
}
src/ui/Shared/Loading/index.tsx
0 → 100644
View file @
990ac633
import
{
LoadingOutlined
}
from
"
@ant-design/icons
"
;
import
styles
from
"
./index.module.scss
"
;
export
const
Loading
:
React
.
FC
<
{
progress
?:
number
;
hiddenText
?:
boolean
}
>
=
({
progress
,
hiddenText
,
})
=>
(
<
div
className=
{
styles
.
loading
}
>
<
span
className=
{
styles
.
icon
}
>
<
LoadingOutlined
/>
</
span
>
{
!
hiddenText
&&
(
<
span
className=
{
styles
.
text
}
>
{
progress
?
`${progress}%`
:
"
加载中
"
}
</
span
>
)
}
</
div
>
);
src/ui/Shared/index.ts
View file @
990ac633
export
*
from
"
./Background
"
;
export
*
from
"
./Background
"
;
export
*
from
"
./css
"
;
export
*
from
"
./css
"
;
export
*
from
"
./IconFont
"
;
export
*
from
"
./IconFont
"
;
export
*
from
"
./Loading
"
;
export
*
from
"
./Scrollbar
"
;
export
*
from
"
./Scrollbar
"
;
export
*
from
"
./Select
"
;
export
*
from
"
./Select
"
;
export
*
from
"
./SpecialButton
"
;
export
*
from
"
./SpecialButton
"
;
...
...
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