From e0fe4be7bc8ac670abe18242e2e0eac7ebc31ff9 Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Mon, 25 Sep 2023 18:01:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20config.json=E4=B8=A2=E5=A4=B1=E5=BC=95?= =?UTF-8?q?=E8=B5=B7=E7=BC=96=E8=BE=91=E5=99=A8=E7=99=BD=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/dev.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/script/dev.ts b/script/dev.ts index 5789694..86a08e4 100644 --- a/script/dev.ts +++ b/script/dev.ts @@ -582,6 +582,14 @@ async function startWsServer(http: Server) { }); } +async function ensureConfig() { + try { + fs.readFile(resolvePath('_server/config.json')); + } catch { + fs.writeFile(resolvePath('_server/config.json'), '{}', 'utf-8'); + } +} + (async function () { // 1. 启动vite服务 const vite = await createServer(); @@ -589,6 +597,7 @@ async function startWsServer(http: Server) { console.log(`游戏地址:http://localhost:5173/games/${config.name}/`); // 2. 启动样板http服务 + await ensureConfig(); const server = await startHttpServer(3000); // 3. 启动样板ws热重载服务