fix: 修复CodeQL检测到的代码问题

This commit is contained in:
yhh
2025-12-03 18:08:19 +08:00
parent f7535a2aac
commit 293ac2dca3
18 changed files with 60 additions and 67 deletions

View File

@@ -186,9 +186,9 @@ export class ShaderAnalyzer {
* 从源代码中移除注释。
*/
private removeComments(source: string): string {
// Remove single-line comments.
// 移除单行注释。
let result = source.replace(/\/\/.*$/gm, '');
// Remove single-line comments (non-greedy, stop at newline).
// 移除单行注释(非贪婪,遇到换行停止)
let result = source.replace(/\/\/[^\n\r]*/g, '');
// Remove multi-line comments.
// 移除多行注释。
result = result.replace(/\/\*[\s\S]*?\*\//g, '');

View File

@@ -38,7 +38,7 @@ export function ShaderEditorPanel({ filePath: propFilePath }: ShaderEditorPanelP
const [activeTab, setActiveTab] = useState<'vertex' | 'fragment'>('fragment');
const [showAnalysis, setShowAnalysis] = useState(true);
const [showPreview, setShowPreview] = useState(true);
const [_showPreview, _setShowPreview] = useState(true);
const [vertexAnalysis, setVertexAnalysis] = useState<ShaderAnalysis | null>(null);
const [fragmentAnalysis, setFragmentAnalysis] = useState<ShaderAnalysis | null>(null);
const [compileError, setCompileError] = useState<string | null>(null);