当前位置:网站首页>6. Electron borderless window and transparent window lock mode setting window icon

6. Electron borderless window and transparent window lock mode setting window icon

2022-07-07 14:33:00 51CTO

 

index.js

6、Electron Borderless windows and transparent windows Lock mode Set window icons _ico

6、Electron Borderless windows and transparent windows Lock mode Set window icons _ios_02

      
      
/**
* Borderless windows and transparent windows
* frame:false Borderless window
* transparent:true, Transparent window
*/

/**
* Lock mode
* If the window handles full screen , Parallel locking status , stay Mac OS X The only way to exit the window is through <Command+Q> Composite key
* If in Mac OS X Next , Use setKiosk Method to switch the locking mode of the window , Can't be fullscreen Property set to true
*/

/**
* Set window icons
* icon: icon:"images\\logn.jpg",//icon:".\\images\\logn.jpg",
* if(process.platform!="darwin"){// Not Mac OS X The system uses the following method to set the icon
win.setIcon("images\\logn.jpg");
}
*/

const {app,BrowserWindow} = require('electron');
function createWindow(){
win = new BrowserWindow({
//frame:false,transparent:true,
//icon:"images\\logn.jpg",//icon:".\\images\\logn.jpg",
//fullscreen:true,
//kiosk:true,
webPreferences:{
nodeIntegration: true, // Is it integrated Nodejs
enableRemoteModule: true,
contextIsolation: false,
//,preload:path.join(__dirname,'index.js')
}
});
win.loadFile('index.html');
if(process.platform!="darwin"){
win.setIcon("images\\logn.jpg");
}
win.on('closed',()=>{
console.log('closed')
win=null;
});
}
app.on('ready',createWindow);
app.on('window-all-closed',()=>{
console.log('window-all-closed');
if(process.platform!='darwin'){

}
});
app.on('activate',()=>{
console.log('activate');
if(win==null){
createWindow();
}
});
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.

View Code

index.html

6、Electron Borderless windows and transparent windows Lock mode Set window icons _ico

6、Electron Borderless windows and transparent windows Lock mode Set window icons _ios_02

      
      
<!DOCTYPE html>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title> Window size </title>
<script src="event.js"></script>
<body>
<img src="./images/shj8.jpg">

<h1> Title :<i> And seas </i></h1>
<br/>
<br/>
Press. :<u> Dadi Publishing House </u>
<br/>
<br/>
The original price :<strike>69</strike> element Promotional price :59
<br/>
<br/>
<button id="idInLock" onclick="onClick()"> Enter lock mode </button>
</body>
</html>
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.

View Code

 

even.js

6、Electron Borderless windows and transparent windows Lock mode Set window icons _ico

6、Electron Borderless windows and transparent windows Lock mode Set window icons _ios_02

      
      
const remote = window.require('electron').remote;
function onClick()
{
const idInLock=document.getElementById("idInLock");
const win = remote.getCurrentWindow();
if(win.isKiosk()){
// In indeterminate mode
win.setKiosk(false);
idInLock.innerText=" Enter lock mode ";
}
else
{
// In lock mode
win.setKiosk(true);
idInLock.innerText=" Exit lock mode ";
}

}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.

View Code

 



原网站

版权声明
本文为[51CTO]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071233108823.html