From 0a3f2a3e21be4c37d25f90ca9a238e2d208a0bb4 Mon Sep 17 00:00:00 2001 From: yhh <359807859@qq.com> Date: Wed, 3 Dec 2025 21:31:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DCodeQL=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E5=88=B0=E7=9A=84=E4=BB=A3=E7=A0=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/codeql/codeql-config.yml | 8 +++++ .github/workflows/codeql.yml | 1 + .../ui/src/systems/UICanvasScalerSystem.ts | 5 ++- scripts/update-module-sizes.mjs | 34 ++++++++----------- 4 files changed, 25 insertions(+), 23 deletions(-) create mode 100644 .github/codeql/codeql-config.yml diff --git a/.github/codeql/codeql-config.yml b/.github/codeql/codeql-config.yml new file mode 100644 index 00000000..19b6a3d7 --- /dev/null +++ b/.github/codeql/codeql-config.yml @@ -0,0 +1,8 @@ +name: "CodeQL Config" + +# Paths to exclude from analysis +paths-ignore: + - thirdparty + - "**/node_modules" + - "**/dist" + - "**/bin" diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 1349e9b8..f737dc7a 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -31,6 +31,7 @@ jobs: with: languages: ${{ matrix.language }} queries: security-and-quality + config-file: ./.github/codeql/codeql-config.yml - name: Autobuild uses: github/codeql-action/autobuild@v3 diff --git a/packages/ui/src/systems/UICanvasScalerSystem.ts b/packages/ui/src/systems/UICanvasScalerSystem.ts index 9935ae12..55738edc 100644 --- a/packages/ui/src/systems/UICanvasScalerSystem.ts +++ b/packages/ui/src/systems/UICanvasScalerSystem.ts @@ -237,7 +237,6 @@ export class UICanvasScalerSystem extends EntitySystem { let finalCanvasWidth = this.screenInfo.width; let finalCanvasHeight = this.screenInfo.height; - let finalScale = 1; // 处理 CanvasScaler 组件 // Process CanvasScaler components @@ -252,8 +251,8 @@ export class UICanvasScalerSystem extends EntitySystem { finalCanvasWidth = scaler.computedCanvasWidth; finalCanvasHeight = scaler.computedCanvasHeight; - finalScale = scaler.computedScale; - break; // 只使用第一个 CanvasScaler + // scaler.computedScale is stored in the component for other uses + break; // 只使用第一个 CanvasScaler | Only use the first CanvasScaler } } diff --git a/scripts/update-module-sizes.mjs b/scripts/update-module-sizes.mjs index 70428cb1..d141fc8f 100644 --- a/scripts/update-module-sizes.mjs +++ b/scripts/update-module-sizes.mjs @@ -36,30 +36,24 @@ function updateModuleSizes() { } try { + // Read module.json first + const content = fs.readFileSync(moduleJsonPath, 'utf-8'); + const moduleJson = JSON.parse(content); + const oldSize = moduleJson.estimatedSize; + // Get actual file size const stat = fs.statSync(distIndexPath); const actualSize = stat.size; - // Read module.json - use file descriptor to avoid race condition - const fd = fs.openSync(moduleJsonPath, 'r+'); - try { - const content = fs.readFileSync(fd, 'utf-8'); - const moduleJson = JSON.parse(content); - const oldSize = moduleJson.estimatedSize; - - // Update if different - if (oldSize !== actualSize) { - moduleJson.estimatedSize = actualSize; - const newContent = JSON.stringify(moduleJson, null, 2) + '\n'; - fs.ftruncateSync(fd, 0); - fs.writeSync(fd, newContent, 0, 'utf-8'); - const oldKB = oldSize ? (oldSize / 1024).toFixed(1) : 'N/A'; - const newKB = (actualSize / 1024).toFixed(1); - console.log(` ${pkg}: ${oldKB} KB -> ${newKB} KB`); - updated++; - } - } finally { - fs.closeSync(fd); + // Update if different + if (oldSize !== actualSize) { + moduleJson.estimatedSize = actualSize; + const newContent = JSON.stringify(moduleJson, null, 2) + '\n'; + fs.writeFileSync(moduleJsonPath, newContent, 'utf-8'); + const oldKB = oldSize ? (oldSize / 1024).toFixed(1) : 'N/A'; + const newKB = (actualSize / 1024).toFixed(1); + console.log(` ${pkg}: ${oldKB} KB -> ${newKB} KB`); + updated++; } } catch (err) { console.error(` Error processing ${pkg}:`, err.message);