【极速系列】零基础制作windows软件 - exe套壳+url网站内容

时间:2024-10-22 07:49:57

效果图

 

需要准备

  1. 可以访问的你的网站地址,例如 /
  2. windows开发电脑一台
  3. win安装编辑器fiddle /fiddle,如图
  4. 点击fiddle左上角第三行的ELectron版本信息,选择下载非beta的版本下载,推荐v17.0.0
  5. 如果下不动,证明被墙了,试试手机4G5G网络....

 

详细步骤

  1. 打开Fiddle,即可看到默认创建好的一套代码,包括,等
  2. 左上角File,Save as,另存为D:/app/demo/下
  3. 修改为以下内容再保存,注意里面的网址要改改:
    1. // Modules to control application life and create native browser window
    2. const { app, BrowserWindow } = require('electron')
    3. const path = require('path')
    4. function createWindow () {
    5. // Create the browser window.
    6. const mainWindow = new BrowserWindow({
    7. width: 800,
    8. height: 600,
    9. webPreferences: {
    10. preload: path.join(__dirname, '')
    11. }
    12. })
    13. mainWindow.loadURL('/')
    14. // and load the of the app.
    15. // ('')
    16. // Open the DevTools.
    17. // ()
    18. }
    19. // This method will be called when Electron has finished
    20. // initialization and is ready to create browser windows.
    21. // Some APIs can only be used after this event occurs.
    22. app.whenReady().then(() => {
    23. createWindow()
    24. app.on('activate', function () {
    25. // On macOS it's common to re-create a window in the app when the
    26. // dock icon is clicked and there are no other windows open.
    27. if (BrowserWindow.getAllWindows().length === 0) createWindow()
    28. })
    29. })
    30. // Quit when all windows are closed, except on macOS. There, it's common
    31. // for applications and their menu bar to stay active until the user quits
    32. // explicitly with Cmd + Q.
    33. app.on('window-all-closed', function () {
    34. if (process.platform !== 'darwin') app.quit()
    35. })
    36. // In this file you can include the rest of your app's specific main process
    37. // code. You can also put them in separate files and require them here.

  4. 点击左上角的Run,即可看到效果,关闭弹出的程序
  5. 【开始创建exe可执行文件】
    点击任务栏Tasks => Package Fiddle

    弹出控制台并显示进度,例如
    1. added 556 packages from 450 contributors in 46.72s
    2. 55 packages are looking for funding
    3. run `npm fund` for details
    4. > testy-cap-eliminate-pqrwl@1.0.0 package C:\Users\mac\AppData\Local\Temp\tmp-30168-uEFoWEyz2LV0
    5. > electron-forge package
    6. ✅ Installers successfully created.
    可以看到程序已经部署到了 C:\Users\mac\AppData\Local\Temp\tmp-30168-uEFoWEyz2LV0,打开这个文件夹,可以找到里面的out文件夹的子目录,就是本软件的安装后的文件夹

    打包本文件夹即可获得桌面app
  6. 里面的exe文件就是程序主入口
  7. 至于为什么这么巨大,和怎么瘦身,还在研究中。。。

 

Good luck!