Commit 8287645a authored by Chunchi Che's avatar Chunchi Che

migrate sql.js

parent 138fbc82
Pipeline #19736 passed with stages
in 3 minutes and 39 seconds
...@@ -40,6 +40,10 @@ export default async function (action: sqliteAction) { ...@@ -40,6 +40,10 @@ export default async function (action: sqliteAction) {
const [SQL, buffer] = await Promise.all([sqlPromise, dataPromise]); const [SQL, buffer] = await Promise.all([sqlPromise, dataPromise]);
YGODB = new SQL.Database(new Uint8Array(buffer)); YGODB = new SQL.Database(new Uint8Array(buffer));
console.info("YGODB inited!");
} else {
console.warn("init YGODB action without initInfo");
} }
break; break;
......
...@@ -80,7 +80,7 @@ export function createAsyncMetaThunk(name: string): AsyncThunk< ...@@ -80,7 +80,7 @@ export function createAsyncMetaThunk(name: string): AsyncThunk<
}) => { }) => {
const code = param.code; const code = param.code;
const meta = await fetchCard(code); const meta = await fetchCard(code, true);
const response = { const response = {
controler: param.controler, controler: param.controler,
sequence: param.sequence, sequence: param.sequence,
...@@ -110,7 +110,7 @@ export function createAsyncRepeatedMetaThunk( ...@@ -110,7 +110,7 @@ export function createAsyncRepeatedMetaThunk(
if (id == 0) { if (id == 0) {
return { id, data: {}, text: {} }; return { id, data: {}, text: {} };
} else { } else {
return await fetchCard(id); return await fetchCard(id, true);
} }
}) })
); );
......
...@@ -29,7 +29,7 @@ export const fetchSelectPlaceHintMeta = createAsyncThunk( ...@@ -29,7 +29,7 @@ export const fetchSelectPlaceHintMeta = createAsyncThunk(
const player = param[0]; const player = param[0];
const hintData = param[1]; const hintData = param[1];
const hintMeta = (await fetchCard(hintData)).text.name || "[?]"; const hintMeta = (await fetchCard(hintData, true)).text.name || "[?]";
const response: [number, string] = [player, hintMeta]; const response: [number, string] = [player, hintMeta];
return response; return response;
......
...@@ -58,7 +58,7 @@ export const fetchCheckCardMeta = createAsyncThunk( ...@@ -58,7 +58,7 @@ export const fetchCheckCardMeta = createAsyncThunk(
tagName: string; tagName: string;
option: { code: number; response: number; effectDescCode?: number }; option: { code: number; response: number; effectDescCode?: number };
}) => { }) => {
const meta = await fetchCard(param.option.code); const meta = await fetchCard(param.option.code, true);
const effectDesc = param.option.effectDescCode const effectDesc = param.option.effectDescCode
? getCardStr(meta, param.option.effectDescCode & 0xf) ? getCardStr(meta, param.option.effectDescCode & 0xf)
: undefined; : undefined;
......
...@@ -59,7 +59,7 @@ export const fetchCheckCardMetasV2 = createAsyncThunk( ...@@ -59,7 +59,7 @@ export const fetchCheckCardMetasV2 = createAsyncThunk(
}) => { }) => {
const metas = await Promise.all( const metas = await Promise.all(
param.options.map(async (option) => { param.options.map(async (option) => {
return await fetchCard(option.code); return await fetchCard(option.code, true);
}) })
); );
const response = { const response = {
......
...@@ -23,7 +23,7 @@ export const resetOptionModalImpl: CaseReducer<DuelState> = (state) => { ...@@ -23,7 +23,7 @@ export const resetOptionModalImpl: CaseReducer<DuelState> = (state) => {
export const fetchOptionMeta = createAsyncThunk( export const fetchOptionMeta = createAsyncThunk(
"duel/fetchOptionMeta", "duel/fetchOptionMeta",
async (param: { code: number; response: number }) => { async (param: { code: number; response: number }) => {
const meta = await fetchCard(param.code >> 4); const meta = await fetchCard(param.code >> 4, true);
const msg = getCardStr(meta, param.code & 0xf) || "[?]"; const msg = getCardStr(meta, param.code & 0xf) || "[?]";
const response = { msg, response: param.response }; const response = { msg, response: param.response };
......
...@@ -32,7 +32,7 @@ export const fetchYesNoMeta = createAsyncThunk( ...@@ -32,7 +32,7 @@ export const fetchYesNoMeta = createAsyncThunk(
) => string; ) => string;
}) => { }) => {
const desc = await fetchStrings("!system", param.descCode); const desc = await fetchStrings("!system", param.descCode);
const meta = await fetchCard(param.code); const meta = await fetchCard(param.code, true);
// TODO: 国际化文案 // TODO: 国际化文案
return param.textGenerator(desc, meta, param.location); return param.textGenerator(desc, meta, param.location);
......
...@@ -50,7 +50,10 @@ export default function WaitRoom() { ...@@ -50,7 +50,10 @@ export default function WaitRoom() {
} }
// 初始化sqlite // 初始化sqlite
sqliteMiddleWare({ cmd: sqliteCmd.INIT }); sqliteMiddleWare({
cmd: sqliteCmd.INIT,
initInfo: { dbUrl: "/ygopro-database/locales/zh-CN/cards.cdb" },
});
}, []); }, []);
const joined = useAppSelector(selectJoined); const joined = useAppSelector(selectJoined);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment