const fs = require('fs'); const path = require('path'); const d = 'E:/opencode/haoliang/frontend/src/views'; const fixes = [ ['(rows: any[])', '(rows: Record[])'], ['(record: any)', '(record: Record)'], ['const params: any =', 'const params: Record ='], ['(r: any) => r.id', '(r: {id:number}) => r.id'], ['function onFileChange(file: any)', 'function onFileChange(file: Record)'], ['params: { row: any; rowIndex', 'params: { row: Record; rowIndex'], ['const payload: any =', 'const payload: Record ='], ['(c: any) => c.configKey.toLowerCase().includes(kw) || c.description.t', '(c: {configKey:string;description:string}) => c.configKey.toLowerCase().includes(kw) || c.description.t'], ['_rule: any, value: string, callback: any', '_rule: unknown, value: string, callback: (err?:Error)=>void'], ['rule: any, value: any, callback: any', 'rule: unknown, value: string, callback: (err?:Error)=>void'], ]; let total = 0; fs.readdirSync(d).forEach(sub => { const subDir = path.join(d, sub); if (!fs.statSync(subDir).isDirectory()) return; fs.readdirSync(subDir).forEach(f => { if (!f.endsWith('.vue')) return; const fp = path.join(subDir, f); let c = fs.readFileSync(fp, 'utf8'); let n = 0; fixes.forEach(([from, to]) => { if (c.includes(from)) { c = c.split(from).join(to); n++; } }); if (n > 0) { fs.writeFileSync(fp, c, 'utf8'); console.log(f + ': ' + n); total += n; } }); }); console.log('Total fixed: ' + total);