const fs = require('fs');
['src/pages/chanxiao/supplyXuQiu.vue', 'src/pages/chanxiao/purchaseXuQiu.vue'].forEach(filePath => {
    let file = fs.readFileSync(filePath, 'utf8');
    
    // Make wrapper clicks conditional
    file = file.replace(/@click="show\.address = true"/g, '@click="isSave && (show.address = true)"');
    file = file.replace(/@click="show\.time1 = true"/g, '@click="isSave && (show.time1 = true)"');
    file = file.replace(/@click="show\.time2 = true"/g, '@click="isSave && (show.time2 = true)"');
    file = file.replace(/@click="show\.classify = true"/g, '@click="isSave && (show.classify = true)"');
    file = file.replace(/@click="show\.time = true"/g, '@click="isSave && (show.time = true)"');

    // Remove `isSave ? '\`...`' : ''` syntax error 
    // From `:placeholder="isSave ? '\`请输入${pageText}标题\`' : ''"` 
    // To `:placeholder="isSave ? \`请输入${pageText}标题\` : ''"`
    file = file.replace(/:placeholder="isSave \? '\\`(.*?)\\`' : ''"/g, ':placeholder="isSave ? \\`$1\\` : \'\'"');
    
    fs.writeFileSync(filePath, file);
});
