如何让我的电子应用程序出现在开始菜单窗口中

问题描述 投票:0回答:1

我有电子应用程序的示例,只是为了进行 POC。 但每当我尝试构建时。是的,安装程序在那里并成功安装了我的应用程序,并成功安装在我的 Windows 上。

但我的问题是,为什么我在搜索菜单上找不到我的应用程序? 顺便说一句,我正在使用电子锻造。

这是我的电子 main.js

    const { app, BrowserWindow } = require("electron");
const path = require('node:path');
const { autoUpdater } = require("electron-updater");

let mainWindow;
let isDev;
if (require('electron-squirrel-startup')) app.quit();

(async () => {
    isDev = (await import('electron-is-dev')).default;

    function createWindow() {
        mainWindow = new BrowserWindow({
            width: 1536,
            height: 864,
            webPreferences: {
                preload: path.join(__dirname, 'preload.js'),
                contextIsolation: true,
                nodeIntegration: true,
                enableRemoteModule: false,
                webSecurity: false,
            },
        });

        const indexPath = isDev
            ? path.join(__dirname, 'dist/electron-example/browser/index.html')
            : path.join(__dirname, 'dist', 'electron-example', 'browser', 'index.html');

        mainWindow.loadFile(indexPath);

        mainWindow.on("closed", function () {
            mainWindow = null;
        });
    }

    function setupAutoUpdater() {
        if (!isDev) {
            autoUpdater.checkForUpdatesAndNotify();

            autoUpdater.on("checking-for-update", () => {
                console.log("Checking for updates...");
            });

            autoUpdater.on("update-available", () => {
                console.log("Update available.");
            });

            autoUpdater.on("update-not-available", () => {
                console.log("No update available.");
            });

            autoUpdater.on("error", (err) => {
                console.error("Error in auto-updater:", err);
            });

            autoUpdater.on("update-downloaded", (info) => {
                console.log("Update downloaded:", info);
                // You can trigger the update installation here
                mainWindow.webContents.send("update-available", info);
                // Optional: Auto install the update (uncomment to use)
                // autoUpdater.quitAndInstall();
            });
        }
    }

    app.whenReady().then(() => {
        process.env.IS_ELECTRON = 'true';
        setupAutoUpdater();
        createWindow();

        app.on('activate', () => {
            if (BrowserWindow.getAllWindows().length === 0) createWindow();
        });
    });

    app.on("window-all-closed", function () {
        if (process.platform !== "darwin") app.quit();
    });
})();

我的 forge.config.js

const { FusesPlugin } = require('@electron-forge/plugin-fuses');
const { FuseV1Options, FuseVersion } = require('@electron/fuses');
const path = require('node:path');

module.exports = {
  packagerConfig: {
    asar: true,
    icon: path.join(__dirname, 'src/assets/electron/app-icon'),
  },
  rebuildConfig: {},
  makers: [
    {
      name: '@electron-forge/maker-squirrel',
      config: {
        name: 'exampleelectron',
        certificateFile: './cert.pfx',
        certificatePassword: "samplepassword",
        shortcutName: 'Electron Example',
        noMsi: true,
        version: '1.0.0',
        icon: './src/assets/electron/app-icon.ico',
        setupIcon: './src/assets/electron/app-icon.ico',
        loadingGif: './src/assets/electron/rocket.gif'
      },
    },
    {
      name: '@electron-forge/maker-zip',
      platforms: ['darwin'],
    },
    {
      name: '@electron-forge/maker-deb',
      config: {},
    },
    {
      name: '@electron-forge/maker-rpm',
      config: {},
    },
  ],
  plugins: [
    {
      name: '@electron-forge/plugin-auto-unpack-natives',
      config: {},
    },
    // Fuses are used to enable/disable various Electron functionality
    // at package time, before code signing the application
    new FusesPlugin({
      version: FuseVersion.V1,
      [FuseV1Options.RunAsNode]: false,
      [FuseV1Options.EnableCookieEncryption]: true,
      [FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false,
      [FuseV1Options.EnableNodeCliInspectArguments]: false,
      [FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true,
      [FuseV1Options.OnlyLoadAppFromAsar]: true,
    }),
  ],
};
angular electron electron-builder electron-packager electron-forge
1个回答
0
投票

现在看来 stackoverflow 很糟糕,甚至没有人试图回答,只是投反对票。 zzzz

© www.soinside.com 2019 - 2024. All rights reserved.