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
a2e52969
Commit
a2e52969
authored
Feb 21, 2024
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update sqlite middleware to adjust super pre release
parent
5d9e7f31
Pipeline
#25496
passed with stages
in 16 minutes and 15 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
105 additions
and
15 deletions
+105
-15
neos.config.json
neos.config.json
+2
-1
neos.config.prod.json
neos.config.prod.json
+7
-1
src/middleware/sqlite/index.ts
src/middleware/sqlite/index.ts
+55
-10
src/ui/Layout/utils.ts
src/ui/Layout/utils.ts
+2
-2
src/ui/Match/util.ts
src/ui/Match/util.ts
+4
-1
super-pre-release.json
super-pre-release.json
+35
-0
No files found.
neos.config.json
View file @
a2e52969
...
...
@@ -19,7 +19,8 @@
],
"assetsPath"
:
"/neos-assets"
,
"cardImgUrl"
:
"https://cdn02.moecube.com:444/images/ygopro-images-zh-CN"
,
"cardsDbUrl"
:
"https://cdn02.moecube.com:444/ygopro-database/zh-CN/cards.cdb"
,
"releaseDbUrl"
:
"https://cdn02.moecube.com:444/ygopro-database/zh-CN/cards.cdb"
,
"preReleaseDbUrl"
:
"https://cdn02.moecube.com:444/ygopro-super-pre/data/test-release.cdb"
,
"stringsUrl"
:
"https://cdn02.moecube.com:444/ygopro-database/zh-CN/strings.conf"
,
"lflistUrl"
:
"https://cdn02.moecube.com:444/ygopro-database/zh-CN/lflist.conf"
,
"replayUrl"
:
"replay.neos.moe"
,
...
...
neos.config.prod.json
View file @
a2e52969
...
...
@@ -10,11 +10,17 @@
"name"
:
"mycard-athletic"
,
"ip"
:
"tiramisu.moecube.com"
,
"port"
:
"8912"
},
{
"name"
:
"pre-release"
,
"ip"
:
"koishi.momobako.com"
,
"port"
:
"889"
}
],
"assetsPath"
:
"/neos-assets"
,
"cardImgUrl"
:
"https://cdn02.moecube.com:444/images/ygopro-images-zh-CN"
,
"cardsDbUrl"
:
"https://cdn02.moecube.com:444/ygopro-database/zh-CN/cards.cdb"
,
"releaseDbUrl"
:
"https://cdn02.moecube.com:444/ygopro-database/zh-CN/cards.cdb"
,
"preReleaseDbUrl"
:
"https://cdn02.moecube.com:444/ygopro-super-pre/data/test-release.cdb"
,
"stringsUrl"
:
"https://cdn02.moecube.com:444/ygopro-database/zh-CN/strings.conf"
,
"lflistUrl"
:
"https://cdn02.moecube.com:444/ygopro-database/zh-CN/lflist.conf"
,
"replayUrl"
:
"replay.neos.moe"
,
...
...
src/middleware/sqlite/index.ts
View file @
a2e52969
...
...
@@ -11,6 +11,7 @@ import { CardData, CardMeta, CardText } from "@/api/cards";
import
{
useConfig
}
from
"
@/config
"
;
import
{
pfetch
}
from
"
@/infra
"
;
import
SuperReleaseData
from
"
../../../super-pre-release.json
"
;
import
{
FtsParams
,
invokeFts
}
from
"
./fts
"
;
const
NeosConfig
=
useConfig
();
...
...
@@ -28,7 +29,8 @@ export interface sqliteAction<T extends sqliteCmd> {
cmd
:
T
;
// 初始化DB需要业务方传入的数据
initInfo
?:
{
dbUrl
:
string
;
releaseDbUrl
:
string
;
preReleaseDbUrl
:
string
;
progressCallback
?:
(
progress
:
number
)
=>
void
;
// 用于获取读取进度
};
payload
?:
{
...
...
@@ -42,7 +44,6 @@ export interface sqliteResult {
ftsResult
?:
CardMeta
[];
}
let
YGODB
:
Database
|
null
=
null
;
const
sqlPromise
=
initSqlJs
({
locateFile
:
(
file
)
=>
`
${
NeosConfig
.
assetsPath
}
/
${
file
}
`
,
});
...
...
@@ -53,17 +54,37 @@ export default function <T extends sqliteCmd>(
return
helper
(
action
)
as
any
;
}
// TODO: may defining a class be better?
interface
YgoDbs
{
release
:
Database
|
null
;
preRelease
:
Database
|
null
;
}
let
YGODBS
:
YgoDbs
=
{
release
:
null
,
preRelease
:
null
};
// FIXME: 应该有个返回值,告诉业务方本次请求的结果,比如初始化DB失败
function
helper
<
T
extends
sqliteCmd
>
(
action
:
sqliteAction
<
T
>
)
{
switch
(
action
.
cmd
)
{
case
sqliteCmd
.
INIT
:
{
const
info
=
action
.
initInfo
;
if
(
info
)
{
const
dataPromise
=
pfetch
(
info
.
d
bUrl
,
{
const
releasePromise
=
pfetch
(
info
.
releaseD
bUrl
,
{
progressCallback
:
action
.
initInfo
?.
progressCallback
,
}).
then
((
res
)
=>
res
.
arrayBuffer
());
// TODO: i18n
return
Promise
.
all
([
sqlPromise
,
dataPromise
]).
then
(([
SQL
,
buffer
])
=>
{
YGODB
=
new
SQL
.
Database
(
new
Uint8Array
(
buffer
));
const
preReleasePromise
=
pfetch
(
info
.
preReleaseDbUrl
,
{
progressCallback
:
action
.
initInfo
?.
progressCallback
,
}).
then
((
res
)
=>
res
.
arrayBuffer
());
return
Promise
.
all
([
sqlPromise
,
releasePromise
,
preReleasePromise
,
]).
then
(([
SQL
,
releaseBuffer
,
preReleaseBuffer
])
=>
{
YGODBS
.
release
=
new
SQL
.
Database
(
new
Uint8Array
(
releaseBuffer
));
YGODBS
.
preRelease
=
new
SQL
.
Database
(
new
Uint8Array
(
preReleaseBuffer
),
);
console
.
log
(
"
YGODB inited!
"
);
});
}
else
{
...
...
@@ -72,12 +93,22 @@ function helper<T extends sqliteCmd>(action: sqliteAction<T>) {
}
}
case
sqliteCmd
.
SELECT
:
{
if
(
YGODB
&&
action
.
payload
&&
action
.
payload
.
id
)
{
if
(
YGODBS
.
release
&&
YGODBS
.
preRelease
&&
action
.
payload
&&
action
.
payload
.
id
)
{
const
code
=
action
.
payload
.
id
;
const
dataStmt
=
YGODB
.
prepare
(
"
SELECT * FROM datas WHERE ID = $id
"
);
const
db
=
SuperReleaseData
.
find
((
id
)
=>
id
===
code
)
!==
undefined
?
YGODBS
.
preRelease
:
YGODBS
.
release
;
const
dataStmt
=
db
.
prepare
(
"
SELECT * FROM datas WHERE ID = $id
"
);
const
dataResult
=
dataStmt
.
getAsObject
({
$id
:
code
});
const
textStmt
=
YGODB
.
prepare
(
"
SELECT * FROM texts WHERE ID = $id
"
);
const
textStmt
=
db
.
prepare
(
"
SELECT * FROM texts WHERE ID = $id
"
);
const
textResult
=
textStmt
.
getAsObject
({
$id
:
code
});
return
{
...
...
@@ -93,8 +124,22 @@ function helper<T extends sqliteCmd>(action: sqliteAction<T>) {
return
{};
}
case
sqliteCmd
.
FTS
:
{
if
(
YGODB
&&
action
.
payload
&&
action
.
payload
.
ftsParams
)
{
const
metas
=
invokeFts
(
YGODB
,
action
.
payload
.
ftsParams
);
if
(
YGODBS
.
release
&&
YGODBS
.
preRelease
&&
action
.
payload
&&
action
.
payload
.
ftsParams
)
{
const
releaseMetas
=
invokeFts
(
YGODBS
.
release
,
action
.
payload
.
ftsParams
,
);
const
preReleaseMetas
=
invokeFts
(
YGODBS
.
preRelease
,
action
.
payload
.
ftsParams
,
);
const
metas
=
releaseMetas
.
concat
(
preReleaseMetas
);
return
{
ftsResult
:
metas
};
}
else
{
...
...
src/ui/Layout/utils.ts
View file @
a2e52969
...
...
@@ -11,7 +11,7 @@ import { useConfig } from "@/config";
import
{
useEnv
}
from
"
@/hook
"
;
import
sqliteMiddleWare
,
{
sqliteCmd
}
from
"
@/middleware/sqlite
"
;
import
{
accountStore
,
deckStore
,
initStore
,
type
User
}
from
"
@/stores
"
;
const
{
cards
DbUrl
}
=
useConfig
();
const
{
releaseDbUrl
,
preRelease
DbUrl
}
=
useConfig
();
const
{
BASE_URL
}
=
useEnv
();
/** 加载ygodb */
...
...
@@ -23,7 +23,7 @@ export const initSqlite = async () => {
sqlite
.
progress
=
0.01
;
await
sqliteMiddleWare
({
cmd
:
sqliteCmd
.
INIT
,
initInfo
:
{
dbUrl
:
cards
DbUrl
,
progressCallback
},
initInfo
:
{
releaseDbUrl
,
preRelease
DbUrl
,
progressCallback
},
});
sqlite
.
progress
=
1
;
}
...
...
src/ui/Match/util.ts
View file @
a2e52969
...
...
@@ -26,7 +26,10 @@ export const connectSrvpro = async (params: {
// 初始化sqlite
await
sqliteMiddleWare
({
cmd
:
sqliteCmd
.
INIT
,
initInfo
:
{
dbUrl
:
NeosConfig
.
cardsDbUrl
},
initInfo
:
{
releaseDbUrl
:
NeosConfig
.
releaseDbUrl
,
preReleaseDbUrl
:
NeosConfig
.
preReleaseDbUrl
,
},
});
// 初始化I18N文案
...
...
super-pre-release.json
0 → 100644
View file @
a2e52969
[
100219001
,
100219002
,
100200251
,
101205000
,
101205001
,
101205002
,
101205003
,
101205004
,
101205005
,
101205006
,
101205033
,
101205053
,
101205054
,
101205055
,
101205068
,
101205069
,
101203081
,
101203082
,
101203083
,
101203084
,
101203085
,
101203086
,
101203087
,
101203088
,
101203089
,
101203090
,
101203091
,
101203092
,
101203093
,
101203094
,
101203095
,
101203096
,
100216001
]
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