const { app, BrowserWindow, Menu, ipcRenderer } = require("electron");

const createWindow = () => {
  const win = new BrowserWindow({
    fullscreen: true,
    autoHideMenuBar: true,
  });
  win.loadFile("./dist/index.html");

  const template = [
    {
      label: "文件",
      submenu: [{ label: "退出", role: "quit" }],
    },
    {
      label: "页面",
      submenu: [
        {
          label: "刷新",
          role: "reload",
        },
        {
          label: "主页",
          click: () => {
            win.loadFile("./dist/index.html", {
              hash: "/",
            });
          },
        },

        {
          label: "文物管理",
          click: async () => {
            win.loadFile("./dist/index.html", {
              hash: "/backend",
            });
          },
        },
      ],
    },
    {
      label: "开发",
      submenu: [{ label: "控制台", role: "toggleDevTools" }],
    },
  ];
  const menu = Menu.buildFromTemplate(template);
  Menu.setApplicationMenu(menu);
};

app.on("window-all-closed", () => {
  if (process.platform !== "darwin") app.quit();
});
app.whenReady().then(() => {
  const main = createWindow();
});
