|
|
|
@ -98,7 +98,6 @@ class TriggerAnalyzer {
@@ -98,7 +98,6 @@ class TriggerAnalyzer {
|
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} catch (error) { |
|
|
|
|
console.warn(`分析模块 ${moduleName} 时出错:`, error.message) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 去重
|
|
|
|
@ -522,7 +521,6 @@ class TriggerAnalyzer {
@@ -522,7 +521,6 @@ class TriggerAnalyzer {
|
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} catch (error) { |
|
|
|
|
console.warn(`扫描模块 ${moduleDir} 的组件时出错:`, error.message) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -557,7 +555,6 @@ class TriggerAnalyzer {
@@ -557,7 +555,6 @@ class TriggerAnalyzer {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (error) { |
|
|
|
|
console.warn(`获取组件 ${componentName} 的authType时出错:`, error.message) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return null |
|
|
|
@ -618,7 +615,6 @@ class TriggerAnalyzer {
@@ -618,7 +615,6 @@ class TriggerAnalyzer {
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
|
console.warn(`分析组件 ${filePath} 时出错:`, error.message) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return triggerSources |
|
|
|
@ -645,7 +641,6 @@ class TriggerAnalyzer {
@@ -645,7 +641,6 @@ class TriggerAnalyzer {
|
|
|
|
|
|
|
|
|
|
return ast |
|
|
|
|
} catch (error) { |
|
|
|
|
console.warn('解析Vue组件脚本时出错:', error.message) |
|
|
|
|
return null |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -903,7 +898,6 @@ class TriggerAnalyzer {
@@ -903,7 +898,6 @@ class TriggerAnalyzer {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
|
console.warn(`追溯可视组件时出错:`, error.message) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return null |
|
|
|
@ -967,7 +961,6 @@ class TriggerAnalyzer {
@@ -967,7 +961,6 @@ class TriggerAnalyzer {
|
|
|
|
|
return this.findEventBindingInTemplate(templateAst, methodName, componentName, filePath) |
|
|
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
|
console.warn(`解析Vue模板时出错:`, error.message) |
|
|
|
|
return null |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -1249,7 +1242,6 @@ class TriggerAnalyzer {
@@ -1249,7 +1242,6 @@ class TriggerAnalyzer {
|
|
|
|
|
// 获取节点的位置信息
|
|
|
|
|
const loc = node.loc |
|
|
|
|
if (!loc) { |
|
|
|
|
console.warn(`节点没有位置信息,无法添加name属性`) |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1257,7 +1249,6 @@ class TriggerAnalyzer {
@@ -1257,7 +1249,6 @@ class TriggerAnalyzer {
|
|
|
|
|
const startLine = loc.start.line |
|
|
|
|
const startColumn = loc.start.column |
|
|
|
|
|
|
|
|
|
console.log(`尝试为第${startLine}行第${startColumn}列的button添加name属性: ${nameValue}`) |
|
|
|
|
|
|
|
|
|
// 将内容按行分割
|
|
|
|
|
const lines = content.split('\n') |
|
|
|
@ -1267,7 +1258,6 @@ class TriggerAnalyzer {
@@ -1267,7 +1258,6 @@ class TriggerAnalyzer {
|
|
|
|
|
const lineIndex = startLine - 1 |
|
|
|
|
let line = lines[lineIndex] |
|
|
|
|
|
|
|
|
|
console.log(`当前行内容: ${line}`) |
|
|
|
|
|
|
|
|
|
// 在button标签中添加name属性
|
|
|
|
|
// 查找button标签的开始位置
|
|
|
|
@ -1286,7 +1276,6 @@ class TriggerAnalyzer {
@@ -1286,7 +1276,6 @@ class TriggerAnalyzer {
|
|
|
|
|
const newContent = lines.join('\n') |
|
|
|
|
writeFileSync(filePath, newContent, 'utf-8') |
|
|
|
|
|
|
|
|
|
console.log(`已为 ${filePath} 中的button添加name属性: ${nameValue}`) |
|
|
|
|
} else { |
|
|
|
|
// 如果button标签跨行,查找button开始标签
|
|
|
|
|
const buttonStartMatch = line.match(/<button[^>]*$/) |
|
|
|
@ -1303,16 +1292,12 @@ class TriggerAnalyzer {
@@ -1303,16 +1292,12 @@ class TriggerAnalyzer {
|
|
|
|
|
const newContent = lines.join('\n') |
|
|
|
|
writeFileSync(filePath, newContent, 'utf-8') |
|
|
|
|
|
|
|
|
|
console.log(`已为 ${filePath} 中的跨行button添加name属性: ${nameValue}`) |
|
|
|
|
} else { |
|
|
|
|
console.warn(`未找到button标签`) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
console.warn(`行号超出范围: ${startLine}`) |
|
|
|
|
} |
|
|
|
|
} catch (error) { |
|
|
|
|
console.warn(`为Vue文件添加name属性时出错:`, error.message) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|