File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -130,11 +130,20 @@ class I18nCaseDetail {
130130 newContent = newContent . replace ( / [ ' " ] ❌ 未 能 完 全 绕 过 d e b u g g e r 断 点 [ ' " ] / ,
131131 `(window.currentLang === 'zh-CN' ? '❌ 未能完全绕过 debugger 断点' : '❌ Failed to completely bypass the debugger breakpoint')` ) ;
132132
133- // 处理变量重复声明问题
134- newContent = newContent . replace ( / l e t \s + i s T e s t R u n n i n g / g, 'window.isTestRunning = window.isTestRunning || false' ) ;
133+ // 完全移除变量重复声明的问题 - 不尝试替换变量声明
134+ // 而是在脚本开头预先定义所有可能的变量,避免重复声明
135+ let scriptPreamble = `
136+ // 预先定义国际化和测试所需变量,避免重复声明
137+ if (typeof window.currentLang === 'undefined') {
138+ window.currentLang = "${ currentLang } ";
139+ }
140+ if (typeof window.isTestRunning === 'undefined') {
141+ window.isTestRunning = false;
142+ }
143+ ` ;
135144
136- // 在脚本开头添加当前语言变量(如果不存在)
137- newContent = `if (typeof window.currentLang === 'undefined') { window.currentLang = " ${ currentLang } "; }\n` + newContent ;
145+ // 将前导代码添加到脚本开头
146+ newContent = scriptPreamble + newContent ;
138147
139148 newScript . textContent = newContent ;
140149 script . parentNode . replaceChild ( newScript , script ) ;
You can’t perform that action at this time.
0 commit comments