Commit 138fbc82 authored by Chunchi Che's avatar Chunchi Che

update small

parent 7b6edba2
Pipeline #19735 failed with stages
in 59 seconds
import axios from "axios";
import sqliteMiddleWare, { sqliteCmd } from "../middleware/sqlite";
export interface CardMeta {
id: number;
......@@ -42,7 +43,15 @@ export interface CardMeta {
* @returns 卡片数据
*
* */
export async function fetchCard(id: number): Promise<CardMeta> {
export async function fetchCard(
id: number,
local?: boolean
): Promise<CardMeta> {
if (local) {
return await sqliteMiddleWare({ cmd: sqliteCmd.SELECT, payload: id }).then(
(res) => (res ? res : { id, data: {}, text: {} })
);
}
const res = await axios.get<CardMeta>("http://localhost:3030/cards/" + id);
return res.data;
......
......@@ -21,6 +21,7 @@ import {
sendHsStart,
} from "../api/ocgcore/ocgHelper";
import socketMiddleWare, { socketCmd } from "../middleware/socket";
import sqliteMiddleWare, { sqliteCmd } from "../middleware/sqlite";
import { Button } from "antd";
const READY_STATE = "ready";
......@@ -47,6 +48,9 @@ export default function WaitRoom() {
},
});
}
// 初始化sqlite
sqliteMiddleWare({ cmd: sqliteCmd.INIT });
}, []);
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