Electron 接口未被修改文件中的程序读取
我对电子枪有问题。 我试图用readline一行接一行地读取文件,但不起作用。 当我们使用没有电子的nodejs函数时,它工作没有问题,但是,只要我在electronjs中实现它,程序就不适合my_接口。 你知道为什么和怎么做吗? 先谢谢你 下面是我的main.js程序:Electron 接口未被修改文件中的程序读取,electron,Electron,我对电子枪有问题。 我试图用readline一行接一行地读取文件,但不起作用。 当我们使用没有电子的nodejs函数时,它工作没有问题,但是,只要我在electronjs中实现它,程序就不适合my_接口。 你知道为什么和怎么做吗? 先谢谢你 下面是我的main.js程序: const { app, BrowserWindow } = require('electron') function createWindow () { const f_width = 800; const f
const { app, BrowserWindow } = require('electron')
function createWindow () {
const f_width = 800;
const f_heigth = 600;
const win = new BrowserWindow({
width: f_width,
maxWidth: f_width,
minWidth: f_width,
height: f_heigth,
maxHeight: f_heigth,
minHeight: f_heigth,
//frame: false,
webPreferences: {
nodeIntegration: true,
// enableRemoteModule : true
}
})
win.loadFile('index.html');
win.webContents.openDevTools();
}
app.whenReady().then(createWindow);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (win === null) {
createWindow()
}
})
导致我出现问题的函数:
exports.modification_de_la_ligne_du_fichier = async (fichier_source,fichier_destination,ma_regex) => {
logger.info("DEBUT fonction modification_de_la_ligne_du_fichier.");
const ma_regex_REM = RegExp("^REM ");
const ma_regex_jdk = RegExp("^java");
const f_fichier_source = fs.createReadStream(fichier_source);
const f_fichier_destination = fs.createWriteStream(fichier_destination, { encoding: "utf8"} );
var i = 0;
var donnees_lus = "";
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//// Problème avec l'interface
logger.warn('Avant interface');
logger.fatal("Entrer dans l'interface impossible !");
var mon_interface = readline.createInterface({
logger.warn("Interface");
input: f_fichier_source,
terminal: false,
historySize: 0
}).on('line', function (line) {
logger.error('Interface');
i++;
if(ma_regex.test(line)){
logger.warn('REGEX OK : REM java = REM java');
const modif = line.replace('REM ','');
donnees_lus = donnees_lus + modif + '\n';
}
else if( ma_regex.test("REM " + line)){
console.log("j : " + j);
donnees_lus = donnees_lus + line + '\n';
}
else{
if(ma_regex_jdk.test(line)){
const modif = line.replace('java','REM java');
donnees_lus = donnees_lus + modif + '\n';
}
else{
donnees_lus = donnees_lus + line + '\n';
}
}
if(i == nombre_de_ligne_du_fichier_source){
f_fichier_destination.write(donnees_lus);
f_fichier_destination.end();
f_fichier_destination.close();
f_fichier_source.close();
mon_interface.close();
logger.info("Fin de la copie du fichier java_version vers java_version2");
this.modification_d_un_flux_entrant_vers_un_flux_sortant('./java_version2.bat','./java_version.bat');
}
});
logger.info("Fin de la fonction modification_de_la_ligne_du_fichier !");
}
exports.modification_d_un_flux_entrant_vers_un_flux_sortant = async (fichier_source,fichier_destination) => {
const source = await createReadStream(fichier_source);
const destination = await createWriteStream(fichier_destination);
source.pipe(destination).on('finish', () => {
console.log("Copie terminée !")
destination.end();
});
logger.info("Fin de la fonction modification_d_un_flux_entrant_vers_un_flux_sortant !");
}
如果您需要更多信息,请随时告诉我
先谢谢你