Commit 421051af authored by Chunchi Che's avatar Chunchi Che

remove pre-rerelease

parent 5d65cf42
Pipeline #26773 passed with stages
in 10 minutes and 33 seconds
......@@ -23,10 +23,7 @@
],
"assetsPath": "/neos-assets",
"releaseImgUrl": "https://cdn02.moecube.com:444/images/ygopro-images-zh-CN",
"preReleaseImgUrl": "https://cdn02.moecube.com:444/ygopro-super-pre/data/pics",
"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",
"preReleaseConfig": "https://cdn02.moecube.com:444/ygopro-super-pre/data/test-release-v2.json",
"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",
......
......@@ -2,8 +2,8 @@
"version": 4960,
"servers": [{
"name": "koishi",
"ip": "koishi.momobako.com",
"port": "7211"
"ip": "127.0.0.1",
"port": "8080"
},
{
"name": "mycard-athletic",
......@@ -23,10 +23,7 @@
],
"assetsPath": "/neos-assets",
"releaseImgUrl": "https://cdn02.moecube.com:444/images/ygopro-images-zh-CN",
"preReleaseImgUrl": "https://cdn02.moecube.com:444/ygopro-super-pre/data/pics",
"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",
"preReleaseConfig": "https://cdn02.moecube.com:444/ygopro-super-pre/data/test-release-v2.json",
"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",
......
......@@ -5,4 +5,3 @@ export * from "./mycard";
export * from "./ocgcore/idl/ocgcore";
export * from "./ocgcore/ocgHelper";
export * from "./strings";
export * from "./superPreRelease";
import { useConfig } from "@/config";
const { preReleaseConfig } = useConfig();
interface SuperPreInfo {
/* only use id currently, other fields see:
* https://cdn02.moecube.com:444/ygopro-super-pre/data/test-release-v2.json
* */
id: number;
}
let superPreList: SuperPreInfo[] = [];
export async function initSuperPrerelease() {
const json = await (await fetch(preReleaseConfig)).text();
const list: SuperPreInfo[] = JSON.parse(json);
superPreList = list;
}
export function isSuperReleaseCard(code: number): boolean {
if (superPreList.length === 0)
console.warn("Super pre release config has not been initialized!");
return superPreList.find(({ id }) => id === code) !== undefined;
}
......@@ -7,7 +7,6 @@
import initSqlJs, { Database } from "sql.js";
import { isSuperReleaseCard } from "@/api";
import { CardData, CardMeta, CardText } from "@/api/cards";
import { useConfig } from "@/config";
import { pfetch } from "@/infra";
......@@ -30,7 +29,6 @@ export interface sqliteAction<T extends sqliteCmd> {
// 初始化DB需要业务方传入的数据
initInfo?: {
releaseDbUrl: string;
preReleaseDbUrl: string;
progressCallback?: (progress: number) => void; // 用于获取读取进度
};
payload?: {
......@@ -57,10 +55,9 @@ export default function <T extends sqliteCmd>(
// TODO: may defining a class be better?
interface YgoDbs {
release: Database | null;
preRelease: Database | null;
}
let YGODBS: YgoDbs = { release: null, preRelease: null };
let YGODBS: YgoDbs = { release: null };
// FIXME: 应该有个返回值,告诉业务方本次请求的结果,比如初始化DB失败
function helper<T extends sqliteCmd>(action: sqliteAction<T>) {
......@@ -71,39 +68,24 @@ function helper<T extends sqliteCmd>(action: sqliteAction<T>) {
const releasePromise = pfetch(info.releaseDbUrl, {
progressCallback: action.initInfo?.progressCallback,
}).then((res) => res.arrayBuffer()); // TODO: i18n
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!");
});
return Promise.all([sqlPromise, releasePromise]).then(
([SQL, releaseBuffer]) => {
YGODBS.release = new SQL.Database(new Uint8Array(releaseBuffer));
console.log("YGODB inited!");
},
);
} else {
console.warn("init YGODB action without initInfo");
return {};
}
}
case sqliteCmd.SELECT: {
if (
YGODBS.release &&
YGODBS.preRelease &&
action.payload &&
action.payload.id
) {
if (YGODBS.release && action.payload && action.payload.id) {
const code = action.payload.id;
const db = isSuperReleaseCard(code)
? YGODBS.preRelease
: YGODBS.release;
const db = YGODBS.release;
const dataStmt = db.prepare("SELECT * FROM datas WHERE ID = $id");
const dataResult = dataStmt.getAsObject({ $id: code });
......@@ -123,22 +105,8 @@ function helper<T extends sqliteCmd>(action: sqliteAction<T>) {
return {};
}
case sqliteCmd.FTS: {
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);
if (YGODBS.release && action.payload && action.payload.ftsParams) {
const metas = invokeFts(YGODBS.release, action.payload.ftsParams);
return { ftsResult: metas };
} else {
......
......@@ -26,7 +26,6 @@ import {
initForbidden,
initI18N,
initSqlite,
initSuper,
initWASM,
} from "./utils";
......@@ -39,7 +38,6 @@ export const loader: LoaderFunction = async () => {
initWASM();
initForbidden();
initI18N();
initSuper();
return null;
};
......
......@@ -5,14 +5,13 @@ import {
forbidden,
getCookie,
initStrings,
initSuperPrerelease,
setCookie,
} from "@/api";
import { useConfig } from "@/config";
import { useEnv } from "@/hook";
import sqliteMiddleWare, { sqliteCmd } from "@/middleware/sqlite";
import { accountStore, deckStore, initStore, type User } from "@/stores";
const { releaseDbUrl, preReleaseDbUrl } = useConfig();
const { releaseDbUrl } = useConfig();
const { BASE_URL } = useEnv();
/** 加载ygodb */
......@@ -24,7 +23,7 @@ export const initSqlite = async () => {
sqlite.progress = 0.01;
await sqliteMiddleWare({
cmd: sqliteCmd.INIT,
initInfo: { releaseDbUrl, preReleaseDbUrl, progressCallback },
initInfo: { releaseDbUrl, progressCallback },
});
sqlite.progress = 1;
}
......@@ -64,14 +63,6 @@ export const initI18N = async () => {
}
};
/** 加载超先行服配置 */
export const initSuper = async () => {
if (!initStore.superprerelease) {
await initSuperPrerelease();
initStore.superprerelease = true;
}
};
/** sso登录跳转回来 */
export const handleSSOLogin = async (search: string) => {
/** 从SSO跳转回的URL之中,解析用户信息 */
......
import rustInit from "rust-src";
import { initStrings, initSuperPrerelease } from "@/api";
import { initStrings } from "@/api";
import { useConfig } from "@/config";
import socketMiddleWare, { socketCmd } from "@/middleware/socket";
import sqliteMiddleWare, { sqliteCmd } from "@/middleware/sqlite";
......@@ -27,16 +27,12 @@ export const connectSrvpro = async (params: {
cmd: sqliteCmd.INIT,
initInfo: {
releaseDbUrl: NeosConfig.releaseDbUrl,
preReleaseDbUrl: NeosConfig.preReleaseDbUrl,
},
});
// 初始化I18N文案
await initStrings();
// 初始化超先行配置
await initSuperPrerelease();
if (params.replay && params.replayData) {
// 连接回放websocket服务
socketMiddleWare({
......
import classNames from "classnames";
import { CSSProperties, useMemo } from "react";
import { isSuperReleaseCard } from "@/api";
import { useConfig } from "@/config";
import styles from "./index.module.scss";
......@@ -63,9 +62,5 @@ export function getCardImgUrl(code: number, back = false) {
return `${ASSETS_BASE}/card_back.jpg`;
}
if (isSuperReleaseCard(code)) {
return `${NeosConfig.preReleaseImgUrl}/${code}.jpg`;
} else {
return `${NeosConfig.releaseImgUrl}/${code}.jpg`;
}
return `${NeosConfig.releaseImgUrl}/${code}.jpg`;
}
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