From f4e0eb5854858987703cd56c5f486b1c09b1992f Mon Sep 17 00:00:00 2001 From: xiaoxustudio Date: Sat, 21 Mar 2026 23:34:27 +0800 Subject: [PATCH 1/2] add: vconsole support --- packages/webgal/package.json | 1 + .../util/coreInitialFunction/infoFetcher.ts | 11 +++++++ packages/webgal/src/Core/webgalCore.ts | 3 +- yarn.lock | 30 +++++++++++++++++++ 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/packages/webgal/package.json b/packages/webgal/package.json index 892349f77..6b8aaebba 100644 --- a/packages/webgal/package.json +++ b/packages/webgal/package.json @@ -31,6 +31,7 @@ "react-redux": "^8.0.1", "sass": "^1.49.9", "uuid": "^9.0.0", + "vconsole": "^3.15.1", "vite-plugin-package-version": "^1.0.2" }, "devDependencies": { diff --git a/packages/webgal/src/Core/util/coreInitialFunction/infoFetcher.ts b/packages/webgal/src/Core/util/coreInitialFunction/infoFetcher.ts index f49fdca9e..6a8e84133 100644 --- a/packages/webgal/src/Core/util/coreInitialFunction/infoFetcher.ts +++ b/packages/webgal/src/Core/util/coreInitialFunction/infoFetcher.ts @@ -9,6 +9,7 @@ import { getFastSaveFromStorage, getSavesFromStorage } from '@/Core/controller/s import { logger } from '@/Core/util/logger'; import axios from 'axios'; import { IGameVar } from '@/store/stageInterface'; +import VConsole from 'vconsole'; /** * 获取游戏信息 @@ -67,6 +68,16 @@ export const infoFetcher = (url: string) => { const appId = String(res); WebGAL.steam.initialize(appId); } + if (command === 'Show_Console') { + if (res === true) { + WebGAL.vconsole = new VConsole({ + disableLogScrolling: false, + target: document.querySelector('body') as HTMLElement, + }); + } else { + WebGAL.vconsole?.destroy(); + } + } } } }); diff --git a/packages/webgal/src/Core/webgalCore.ts b/packages/webgal/src/Core/webgalCore.ts index 98d1c53ec..722bc5b02 100644 --- a/packages/webgal/src/Core/webgalCore.ts +++ b/packages/webgal/src/Core/webgalCore.ts @@ -1,5 +1,5 @@ import { BacklogManager } from '@/Core/Modules/backlog'; -import mitt from 'mitt'; +import VConsole from 'vconsole'; import { SceneManager } from '@/Core/Modules/scene'; import { AnimationManager } from '@/Core/Modules/animations'; import { Gameplay } from './Modules/gamePlay'; @@ -19,4 +19,5 @@ export class WebgalCore { public steam = new SteamIntegration(); public template: WebgalTemplate | null = null; public styleObjects: Map = new Map(); + public vconsole: VConsole | null = null; } diff --git a/yarn.lock b/yarn.lock index 062e2199d..80c29d301 100644 --- a/yarn.lock +++ b/yarn.lock @@ -201,6 +201,11 @@ dependencies: regenerator-runtime "^0.14.0" +"@babel/runtime@^7.17.2": + version "7.29.2" + resolved "https://registry.npmmirror.com/@babel/runtime/-/runtime-7.29.2.tgz#9a6e2d05f4b6692e1801cd4fb176ad823930ed5e" + integrity sha512-JiDShH45zKHWyGe4ZNVRrCjBz8Nh9TMmZG1kh4QTK8hCBTWBi8Da+i7s1fJw7/lYpM4ccepSNfqzZ/QvABBi5g== + "@babel/template@^7.22.15", "@babel/template@^7.24.0": version "7.24.0" resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.24.0.tgz#c6a524aa93a4a05d66aaf31654258fae69d87d50" @@ -2029,6 +2034,16 @@ cookie@0.6.0: resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.6.0.tgz#2798b04b071b0ecbff0dbb62a505a8efa4e19051" integrity sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw== +copy-text-to-clipboard@^3.0.1: + version "3.2.2" + resolved "https://registry.npmmirror.com/copy-text-to-clipboard/-/copy-text-to-clipboard-3.2.2.tgz#99bc79db3f2d355ec33a08d573aff6804491ddb9" + integrity sha512-T6SqyLd1iLuqPA90J5N4cTalrtovCySh58iiZDGJ6FGznbclKh4UI+FGacQSgFzwKG77W7XT5gwbVEbd9cIH1A== + +core-js@^3.11.0: + version "3.49.0" + resolved "https://registry.npmmirror.com/core-js/-/core-js-3.49.0.tgz#8b4d520ac034311fa21aa616f017ada0e0dbbddd" + integrity sha512-es1U2+YTtzpwkxVLwAFdSpaIMyQaq0PBgm3YD1W3Qpsn1NAmO3KSgZfu+oGSWVu6NvLHoHCV/aYcsE5wiB7ALg== + core-util-is@~1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85" @@ -4041,6 +4056,11 @@ multistream@^4.1.0: once "^1.4.0" readable-stream "^3.6.0" +mutation-observer@^1.0.3: + version "1.0.3" + resolved "https://registry.npmmirror.com/mutation-observer/-/mutation-observer-1.0.3.tgz#42e9222b101bca82e5ba9d5a7acf4a14c0f263d0" + integrity sha512-M/O/4rF2h776hV7qGMZUH3utZLO/jK7p8rnNgGkjKUw8zCGjRQPxB8z6+5l8+VjRUQ3dNYu4vjqXYLr+U8ZVNA== + nanoid@^3.3.7: version "3.3.7" resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.7.tgz#d0c301a691bc8d54efa0a2226ccf3fe2fd656bd8" @@ -5717,6 +5737,16 @@ vary@~1.1.2: resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg== +vconsole@^3.15.1: + version "3.15.1" + resolved "https://registry.npmmirror.com/vconsole/-/vconsole-3.15.1.tgz#569a8ab15f353259527bbcf004f02946b4482cff" + integrity sha512-KH8XLdrq9T5YHJO/ixrjivHfmF2PC2CdVoK6RWZB4yftMykYIaXY1mxZYAic70vADM54kpMQF+dYmvl5NRNy1g== + dependencies: + "@babel/runtime" "^7.17.2" + copy-text-to-clipboard "^3.0.1" + core-js "^3.11.0" + mutation-observer "^1.0.3" + vite-node@0.28.5: version "0.28.5" resolved "https://registry.yarnpkg.com/vite-node/-/vite-node-0.28.5.tgz#56d0f78846ea40fddf2e28390899df52a4738006" From 304dbae8cbef2cd7bfff91c61c7c4ce51cbdc0ee Mon Sep 17 00:00:00 2001 From: xiaoxustudio Date: Sun, 22 Mar 2026 00:24:15 +0800 Subject: [PATCH 2/2] refactor: modify vconsole initialization time --- .../Core/util/coreInitialFunction/infoFetcher.ts | 8 ++------ packages/webgal/src/Core/webgalCore.ts | 14 +++++++++++++- packages/webgal/src/types/vconsole.ts | 7 +++++++ 3 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 packages/webgal/src/types/vconsole.ts diff --git a/packages/webgal/src/Core/util/coreInitialFunction/infoFetcher.ts b/packages/webgal/src/Core/util/coreInitialFunction/infoFetcher.ts index 6a8e84133..a4d622948 100644 --- a/packages/webgal/src/Core/util/coreInitialFunction/infoFetcher.ts +++ b/packages/webgal/src/Core/util/coreInitialFunction/infoFetcher.ts @@ -9,7 +9,6 @@ import { getFastSaveFromStorage, getSavesFromStorage } from '@/Core/controller/s import { logger } from '@/Core/util/logger'; import axios from 'axios'; import { IGameVar } from '@/store/stageInterface'; -import VConsole from 'vconsole'; /** * 获取游戏信息 @@ -70,12 +69,9 @@ export const infoFetcher = (url: string) => { } if (command === 'Show_Console') { if (res === true) { - WebGAL.vconsole = new VConsole({ - disableLogScrolling: false, - target: document.querySelector('body') as HTMLElement, - }); + WebGAL.vconsole?.show(); } else { - WebGAL.vconsole?.destroy(); + WebGAL.vconsole?.hide(); } } } diff --git a/packages/webgal/src/Core/webgalCore.ts b/packages/webgal/src/Core/webgalCore.ts index 722bc5b02..f56156083 100644 --- a/packages/webgal/src/Core/webgalCore.ts +++ b/packages/webgal/src/Core/webgalCore.ts @@ -7,6 +7,18 @@ import { Events } from '@/Core/Modules/events'; import { SteamIntegration } from '@/Core/integration/steamIntegration'; import { WebgalTemplate } from '@/types/template'; import { IWebGALStyleObj } from 'webgal-parser/build/types/styleParser'; +import { IVConsole } from '@/types/vconsole'; + +const vconsole = { + instance: new VConsole({ target: 'body' }), + show() { + (document.querySelector('#__vconsole') as HTMLDivElement).style.display = 'block'; + }, + hide() { + (document.querySelector('#__vconsole') as HTMLDivElement).style.display = 'none'; + }, +}; +vconsole.hide(); export class WebgalCore { public sceneManager = new SceneManager(); @@ -19,5 +31,5 @@ export class WebgalCore { public steam = new SteamIntegration(); public template: WebgalTemplate | null = null; public styleObjects: Map = new Map(); - public vconsole: VConsole | null = null; + public vconsole: IVConsole = vconsole; } diff --git a/packages/webgal/src/types/vconsole.ts b/packages/webgal/src/types/vconsole.ts new file mode 100644 index 000000000..d9116763c --- /dev/null +++ b/packages/webgal/src/types/vconsole.ts @@ -0,0 +1,7 @@ +import VConsole from 'vconsole'; + +export interface IVConsole { + instance: VConsole; + show: () => void; + hide: () => void; +}