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
d58778dc
Commit
d58778dc
authored
Oct 09, 2024
by
chechunchi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "add env 408 cdb"
This reverts commit
2264b8a3
.
parent
2264b8a3
Pipeline
#30299
failed with stages
in 2 minutes and 56 seconds
Changes
6
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
127 additions
and
129 deletions
+127
-129
neos.config.json
neos.config.json
+0
-4
neos.config.prod.json
neos.config.prod.json
+0
-4
src/container/compat.ts
src/container/compat.ts
+2
-3
src/container/impl.ts
src/container/impl.ts
+1
-4
src/middleware/sqlite/index.ts
src/middleware/sqlite/index.ts
+113
-90
src/ui/Layout/utils.ts
src/ui/Layout/utils.ts
+11
-24
No files found.
neos.config.json
View file @
d58778dc
...
@@ -39,10 +39,6 @@
...
@@ -39,10 +39,6 @@
"lflist"
:
"https://cdn02.moecube.com:444/ygopro-database/zh-CN/lflist.conf"
,
"lflist"
:
"https://cdn02.moecube.com:444/ygopro-database/zh-CN/lflist.conf"
,
"config"
:
"https://cdn02.moecube.com:444/ygopro-super-pre/data/test-release-v2.json"
"config"
:
"https://cdn02.moecube.com:444/ygopro-super-pre/data/test-release-v2.json"
},
},
"env408Resource"
:
{
"cdb"
:
"https://cdn02.moecube.com:444/cn-database/env408-zh-CN/expansions/env408.cdb"
,
"lflist"
:
"https://cdn02.moecube.com:444/cn-database/env408-zh-CN/expansions/lflist.conf"
},
"stringsUrl"
:
"https://cdn02.moecube.com:444/ygopro-database/zh-CN/strings.conf"
,
"stringsUrl"
:
"https://cdn02.moecube.com:444/ygopro-database/zh-CN/strings.conf"
,
"replayUrl"
:
"replay.neos.moe"
,
"replayUrl"
:
"replay.neos.moe"
,
"loginUrl"
:
"https://accounts.moecube.com/signin"
,
"loginUrl"
:
"https://accounts.moecube.com/signin"
,
...
...
neos.config.prod.json
View file @
d58778dc
...
@@ -39,10 +39,6 @@
...
@@ -39,10 +39,6 @@
"lflist"
:
"https://cdn02.moecube.com:444/ygopro-database/zh-CN/lflist.conf"
,
"lflist"
:
"https://cdn02.moecube.com:444/ygopro-database/zh-CN/lflist.conf"
,
"config"
:
"https://cdn02.moecube.com:444/ygopro-super-pre/data/test-release-v2.json"
"config"
:
"https://cdn02.moecube.com:444/ygopro-super-pre/data/test-release-v2.json"
},
},
"env408Resource"
:
{
"cdb"
:
"https://cdn02.moecube.com:444/cn-database/env408-zh-CN/expansions/env408.cdb"
,
"lflist"
:
"https://cdn02.moecube.com:444/cn-database/env408-zh-CN/expansions/lflist.conf"
},
"stringsUrl"
:
"https://cdn02.moecube.com:444/ygopro-database/zh-CN/strings.conf"
,
"stringsUrl"
:
"https://cdn02.moecube.com:444/ygopro-database/zh-CN/strings.conf"
,
"replayUrl"
:
"replay.neos.moe"
,
"replayUrl"
:
"replay.neos.moe"
,
"loginUrl"
:
"https://accounts.moecube.com/signin"
,
"loginUrl"
:
"https://accounts.moecube.com/signin"
,
...
...
src/container/compat.ts
View file @
d58778dc
...
@@ -12,11 +12,10 @@ import {
...
@@ -12,11 +12,10 @@ import {
import
{
CONTAINERS
}
from
"
.
"
;
import
{
CONTAINERS
}
from
"
.
"
;
import
{
Context
}
from
"
./context
"
;
import
{
Context
}
from
"
./context
"
;
import
{
Container
}
from
"
./impl
"
;
import
{
Container
}
from
"
./impl
"
;
import
{
YgoCdb
}
from
"
@/middleware/sqlite
"
;
const
UI_KEY
=
"
NEOS_UI
"
;
const
UI_KEY
=
"
NEOS_UI
"
;
export
function
initUIContainer
(
conn
:
WebSocketStream
,
cdb
:
YgoCdb
)
{
export
function
initUIContainer
(
conn
:
WebSocketStream
)
{
const
context
=
new
Context
({
const
context
=
new
Context
({
matStore
,
matStore
,
cardStore
,
cardStore
,
...
@@ -26,7 +25,7 @@ export function initUIContainer(conn: WebSocketStream, cdb: YgoCdb) {
...
@@ -26,7 +25,7 @@ export function initUIContainer(conn: WebSocketStream, cdb: YgoCdb) {
sideStore
,
sideStore
,
historyStore
,
historyStore
,
});
});
const
container
=
new
Container
(
context
,
conn
,
cdb
);
const
container
=
new
Container
(
context
,
conn
);
CONTAINERS
.
set
(
UI_KEY
,
container
);
CONTAINERS
.
set
(
UI_KEY
,
container
);
}
}
...
...
src/container/impl.ts
View file @
d58778dc
import
{
WebSocketStream
}
from
"
@/infra
"
;
import
{
WebSocketStream
}
from
"
@/infra
"
;
import
{
Context
}
from
"
./context
"
;
import
{
Context
}
from
"
./context
"
;
import
{
YgoCdb
}
from
"
@/middleware/sqlite
"
;
export
class
Container
{
export
class
Container
{
public
context
:
Context
;
public
context
:
Context
;
public
conn
:
WebSocketStream
;
public
conn
:
WebSocketStream
;
public
cdb
:
YgoCdb
;
// ref: https://yugioh.fandom.com/wiki/Kuriboh
// ref: https://yugioh.fandom.com/wiki/Kuriboh
private
enableKuriboh
:
boolean
=
false
;
private
enableKuriboh
:
boolean
=
false
;
constructor
(
context
:
Context
,
conn
:
WebSocketStream
,
cdb
:
YgoCdb
)
{
constructor
(
context
:
Context
,
conn
:
WebSocketStream
)
{
this
.
context
=
context
;
this
.
context
=
context
;
this
.
conn
=
conn
;
this
.
conn
=
conn
;
this
.
cdb
=
cdb
;
}
}
public
setEnableKuriboh
(
value
:
boolean
)
{
public
setEnableKuriboh
(
value
:
boolean
)
{
...
...
src/middleware/sqlite/index.ts
View file @
d58778dc
...
@@ -39,13 +39,6 @@ export interface sqliteAction<T extends sqliteCmd> {
...
@@ -39,13 +39,6 @@ export interface sqliteAction<T extends sqliteCmd> {
};
};
}
}
interface
CdbInitInfo
{
main
:
string
;
sub
?:
string
;
i18n
:
boolean
;
progressCallback
?:
(
progress
:
number
)
=>
void
;
// 用于获取读取进度
}
export
interface
sqliteResult
{
export
interface
sqliteResult
{
selectResult
?:
CardMeta
;
selectResult
?:
CardMeta
;
ftsResult
?:
CardMeta
[];
ftsResult
?:
CardMeta
[];
...
@@ -55,48 +48,84 @@ const sqlPromise = initSqlJs({
...
@@ -55,48 +48,84 @@ const sqlPromise = initSqlJs({
locateFile
:
(
file
)
=>
`
${
NeosConfig
.
assetsPath
}
/
${
file
}
`
,
locateFile
:
(
file
)
=>
`
${
NeosConfig
.
assetsPath
}
/
${
file
}
`
,
});
});
export
class
YgoCdb
{
export
default
function
<
T
extends
sqliteCmd
>
(
private
main
?:
Database
;
action
:
sqliteAction
<
T
>
,
private
sub
?:
Database
;
):
T
extends
sqliteCmd
.
INIT
?
Promise
<
void
>
:
sqliteResult
{
return
helper
(
action
)
as
any
;
}
constructor
()
{}
// TODO: may defining a class be better?
interface
YgoDbs
{
release
:
Database
|
null
;
preRelease
:
Database
|
null
;
}
public
async
init
(
info
:
CdbInitInfo
):
Promise
<
void
>
{
let
YGODBS
:
YgoDbs
=
{
release
:
null
,
preRelease
:
null
};
if
(
info
.
i18n
)
{
const
language
=
localStorage
.
getItem
(
"
language
"
)
??
"
cn
"
;
// Update URLs based on the language
updateDbUrls
(
info
,
language
);
}
const
promises
=
[
pfetch
(
info
.
main
,
{
//It currently only supports en-US, es-ES, ja-JP, ko-KR, zh-CN
progressCallback
:
info
.
progressCallback
,
// Function to update URLs based on the language
}).
then
((
res
)
=>
res
.
arrayBuffer
())];
function
updateDbUrls
(
info
:
any
,
language
:
string
):
void
{
const
languageMap
:
{
[
key
:
string
]:
string
}
=
{
en
:
"
en-US
"
,
br
:
"
en-US
"
,
pt
:
"
en-US
"
,
fr
:
"
en-US
"
,
ja
:
"
ja-JP
"
,
ko
:
"
ko-KR
"
,
es
:
"
es-ES
"
,
};
if
(
info
.
sub
!==
undefined
)
{
const
locale
=
languageMap
[
language
]
||
"
zh-CN
"
;
promises
.
push
(
pfetch
(
info
.
sub
,
{
info
.
releaseDbUrl
=
info
.
releaseDbUrl
.
replace
(
"
zh-CN
"
,
locale
);
progressCallback
:
info
.
progressCallback
,
info
.
preReleaseDbUrl
=
info
.
preReleaseDbUrl
.
replace
(
"
zh-CN
"
,
locale
);
}).
then
((
res
)
=>
res
.
arrayBuffer
()));
}
}
const
sql
=
await
sqlPromise
;
// FIXME: 应该有个返回值,告诉业务方本次请求的结果,比如初始化DB失败
function
helper
<
T
extends
sqliteCmd
>
(
action
:
sqliteAction
<
T
>
)
{
switch
(
action
.
cmd
)
{
case
sqliteCmd
.
INIT
:
{
const
info
=
action
.
initInfo
;
if
(
info
)
{
const
language
=
localStorage
.
getItem
(
"
language
"
)
||
"
cn
"
;
// Update URLs based on the language
updateDbUrls
(
info
,
language
);
return
Promise
.
all
(
promises
).
then
(([
mainBuffer
,
subBuffer
])
=>
{
const
releasePromise
=
pfetch
(
info
.
releaseDbUrl
,
{
this
.
main
=
new
sql
.
Database
(
new
Uint8Array
(
mainBuffer
));
progressCallback
:
action
.
initInfo
?.
progressCallback
,
this
.
sub
=
new
sql
.
Database
(
}).
then
((
res
)
=>
res
.
arrayBuffer
());
// TODO: i18n
new
Uint8Array
(
subBuffer
),
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!
"
);
console
.
log
(
"
YGODB inited!
"
);
});
});
}
else
{
console
.
warn
(
"
init YGODB action without initInfo
"
);
return
{};
}
}
}
public
select
(
code
:
number
):
sqliteResult
{
case
sqliteCmd
.
SELECT
:
{
if
(
if
(
this
.
main
YGODBS
.
release
&&
YGODBS
.
preRelease
&&
action
.
payload
&&
action
.
payload
.
id
)
{
)
{
const
code
=
action
.
payload
.
id
;
const
db
=
isSuperReleaseCard
(
code
)
const
db
=
isSuperReleaseCard
(
code
)
?
this
.
sub
!
// must be initialized when `isSuperReleaseCard` return tru
e
?
YGODBS
.
preReleas
e
:
this
.
main
;
:
YGODBS
.
release
;
const
dataStmt
=
db
.
prepare
(
"
SELECT * FROM datas WHERE ID = $id
"
);
const
dataStmt
=
db
.
prepare
(
"
SELECT * FROM datas WHERE ID = $id
"
);
const
dataResult
=
dataStmt
.
getAsObject
({
$id
:
code
});
const
dataResult
=
dataStmt
.
getAsObject
({
$id
:
code
});
...
@@ -107,48 +136,45 @@ export class YgoCdb {
...
@@ -107,48 +136,45 @@ export class YgoCdb {
selectResult
:
constructCardMeta
(
code
,
dataResult
,
textResult
),
selectResult
:
constructCardMeta
(
code
,
dataResult
,
textResult
),
};
};
}
else
{
}
else
{
console
.
warn
(
"
ygo cdb not init!
"
);
if
(
action
.
payload
?.
id
!==
0
)
{
return
{};
// 0是无效的卡片ID,不需要报错,返回空即可
console
.
warn
(
"
ygo db not init or id not provied!
"
);
}
}
}
}
public
fts
(
params
:
FtsParams
):
sqliteResult
{
return
{};
}
case
sqliteCmd
.
FTS
:
{
if
(
if
(
this
.
main
YGODBS
.
release
&&
YGODBS
.
preRelease
&&
action
.
payload
&&
action
.
payload
.
ftsParams
)
{
)
{
let
metas
=
invokeFts
(
const
releaseMetas
=
invokeFts
(
this
.
main
,
YGODBS
.
release
,
params
,
action
.
payload
.
ftsParams
,
);
const
preReleaseMetas
=
invokeFts
(
YGODBS
.
preRelease
,
action
.
payload
.
ftsParams
,
);
);
if
(
this
.
sub
!==
undefined
)
{
const
metas
=
releaseMetas
.
concat
(
preReleaseMetas
);
metas
=
metas
.
concat
(
invokeFts
(
this
.
sub
,
params
));
}
return
{
ftsResult
:
metas
};
return
{
ftsResult
:
metas
};
}
else
{
}
else
{
console
.
warn
(
"
ygo db not init!
"
);
console
.
warn
(
"
ygo db not init or query not provied!
"
);
return
{};
}
}
}
}
// Function to update URLs based on the language
return
{};
//
}
// Note: it currently only supports en-US, es-ES, ja-JP, ko-KR, zh-CN for main cdb
default
:
{
function
updateDbUrls
(
info
:
CdbInitInfo
,
language
:
string
):
void
{
console
.
warn
(
`Unhandled sqlite command:
${
action
.
cmd
}
`
);
const
languageMap
:
{
[
key
:
string
]:
string
}
=
{
en
:
"
en-US
"
,
br
:
"
en-US
"
,
pt
:
"
en-US
"
,
fr
:
"
en-US
"
,
ja
:
"
ja-JP
"
,
ko
:
"
ko-KR
"
,
es
:
"
es-ES
"
,
};
const
locale
=
languageMap
[
language
]
??
"
zh-CN
"
;
return
{};
info
.
main
=
info
.
main
.
replace
(
"
zh-CN
"
,
locale
);
}
}
}
}
export
function
constructCardMeta
(
export
function
constructCardMeta
(
...
@@ -167,6 +193,3 @@ export function constructCardMeta(
...
@@ -167,6 +193,3 @@ export function constructCardMeta(
text
,
text
,
};
};
}
}
export
const
OCG_CDB
:
YgoCdb
=
new
YgoCdb
();
export
const
ENV_408_CDB
:
YgoCdb
=
new
YgoCdb
();
src/ui/Layout/utils.ts
View file @
d58778dc
...
@@ -10,39 +10,26 @@ import {
...
@@ -10,39 +10,26 @@ import {
}
from
"
@/api
"
;
}
from
"
@/api
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
useEnv
}
from
"
@/hook
"
;
import
{
useEnv
}
from
"
@/hook
"
;
import
sqliteMiddleWare
,
{
sqliteCmd
}
from
"
@/middleware/sqlite
"
;
import
{
accountStore
,
deckStore
,
initStore
,
type
User
}
from
"
@/stores
"
;
import
{
accountStore
,
deckStore
,
initStore
,
type
User
}
from
"
@/stores
"
;
import
{
ENV_408_CDB
,
OCG_CDB
}
from
"
@/middleware/sqlite
"
;
const
{
releaseResource
,
preReleaseResource
}
=
useConfig
();
const
{
releaseResource
,
preReleaseResource
,
env408Resource
}
=
useConfig
();
const
{
BASE_URL
}
=
useEnv
();
const
{
BASE_URL
}
=
useEnv
();
/** 加载
OCG
ygodb */
/** 加载ygodb */
export
const
init
OCGCdb
=
async
()
=>
{
export
const
init
Sqlite
=
async
()
=>
{
if
(
!
initStore
.
sqlite
.
progress
)
{
if
(
!
initStore
.
sqlite
.
progress
)
{
const
{
sqlite
}
=
initStore
;
const
{
sqlite
}
=
initStore
;
const
progressCallback
=
(
progress
:
number
)
=>
const
progressCallback
=
(
progress
:
number
)
=>
(
sqlite
.
progress
=
progress
*
0.9
);
(
sqlite
.
progress
=
progress
*
0.9
);
sqlite
.
progress
=
0.01
;
sqlite
.
progress
=
0.01
;
await
sqliteMiddleWare
({
await
OCG_CDB
.
init
({
cmd
:
sqliteCmd
.
INIT
,
main
:
releaseResource
.
cdb
,
sub
:
preReleaseResource
.
cdb
,
i18n
:
true
,
progressCallback
initInfo
:
{
});
releaseDbUrl
:
releaseResource
.
cdb
,
preReleaseDbUrl
:
preReleaseResource
.
cdb
,
sqlite
.
progress
=
1
;
progressCallback
,
}
},
};
/** 加载 408 环境 ygodb */
export
const
init408Cdb
=
async
()
=>
{
if
(
!
initStore
.
sqlite
.
progress
)
{
const
{
sqlite
}
=
initStore
;
const
progressCallback
=
(
progress
:
number
)
=>
(
sqlite
.
progress
=
progress
*
0.9
);
sqlite
.
progress
=
0.01
;
await
ENV_408_CDB
.
init
({
main
:
env408Resource
.
cdb
,
i18n
:
false
,
progressCallback
});
});
sqlite
.
progress
=
1
;
sqlite
.
progress
=
1
;
}
}
};
};
...
...
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