Javascript 电子+;js:如何调试SSL自签名错误消息?
我使用electron.js和xmpp.js的组合来创建自己的客户端。我的主要项目由以下两个文件组成: 将电子放大:Javascript 电子+;js:如何调试SSL自签名错误消息?,javascript,electron,xmpp,node-xmpp,Javascript,Electron,Xmpp,Node Xmpp,我使用electron.js和xmpp.js的组合来创建自己的客户端。我的主要项目由以下两个文件组成: 将电子放大:index.js: const {app,BrowserWindow,ipcMain,dialog}=require('electron'); // const app=electron.app; // const BrowserWindow=electron.BrowserWindow; // Handle creating/removing shortcuts on Wind
index.js
:
const {app,BrowserWindow,ipcMain,dialog}=require('electron');
// const app=electron.app;
// const BrowserWindow=electron.BrowserWindow;
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require('electron-squirrel-startup')) { // eslint-disable-line global-require
app.quit();
}
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
const createWindow = () => {
console.log("Message");
// Create the browser window.
mainWindow = new BrowserWindow();
// and load the index.html of the app.
mainWindow.loadURL(`file://${__dirname}/ui/index.html`);
var env = process.env.NODE_ENV || 'production';
if(env==='dev'){
// Open the DevTools.
mainWindow.webContents.openDevTools();
}
// Emitted when the window is closed.
mainWindow.on('closed', () => {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
mainWindow.maximize();
const xmpp=require('./xmpp.js');
console.log(xmpp)
xmpp.xmppCli(mainWindow,ipcMain,dialog);
};
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow);
// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createWindow();
}
});
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and import them here.
并使用此文件处理它xmpp.js
:
const {app,BrowserWindow,ipcMain,dialog}=require('electron');
// const app=electron.app;
// const BrowserWindow=electron.BrowserWindow;
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require('electron-squirrel-startup')) { // eslint-disable-line global-require
app.quit();
}
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
const createWindow = () => {
console.log("Message");
// Create the browser window.
mainWindow = new BrowserWindow();
// and load the index.html of the app.
mainWindow.loadURL(`file://${__dirname}/ui/index.html`);
var env = process.env.NODE_ENV || 'production';
if(env==='dev'){
// Open the DevTools.
mainWindow.webContents.openDevTools();
}
// Emitted when the window is closed.
mainWindow.on('closed', () => {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
mainWindow.maximize();
const xmpp=require('./xmpp.js');
console.log(xmpp)
xmpp.xmppCli(mainWindow,ipcMain,dialog);
};
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow);
// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createWindow();
}
});
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and import them here.
const{client,xml,jid}=require('@xmpp/client')
var clientInstance=null;
log('xmpp.js-loaded')
常量initXmpp=函数(xmpp){
xmpp.on('error',err=>{
console.error(“发生错误”,err.toString())
dialog.batherRorBox('内部错误',err.toString())
})
xmpp.on('offline',()=>{
console.log(“当发生连接错误时,@xmpp/client
库似乎缺少api调用,如以下示例所示:
const{client,xml,jid}=require('@xmpp/client')
常量initXmpp=函数(xmpp){
xmpp.on('error',err=>{
console.error(“发生错误”,err.toString())
//dialog.batherRorBox('内部错误',err.toString())
})
xmpp.on('offline',()=>{
console.log('