前端: 修复Electron加载本地HTML问题,添加index.html入口

This commit is contained in:
Frontend Developer 2026-03-10 09:46:56 +00:00
parent 96855c1c43
commit c7808b3f17
2 changed files with 18 additions and 8 deletions

View File

@ -14,13 +14,12 @@ function createWindow() {
} }
}); });
// Load the app // Load the app - use proper file path
if (process.env.NODE_ENV === 'development') { const indexPath = path.join(__dirname, '../renderer/index.html');
mainWindow.loadURL('http://localhost:3000'); mainWindow.loadFile(indexPath);
mainWindow.webContents.openDevTools();
} else { // Open DevTools in development
mainWindow.loadFile(path.join(__dirname, '../renderer/index.html')); // mainWindow.webContents.openDevTools();
}
mainWindow.on('closed', () => { mainWindow.on('closed', () => {
mainWindow = null; mainWindow = null;
@ -57,7 +56,6 @@ ipcMain.handle('select-folder', async () => {
}); });
ipcMain.handle('show-message', async (event, { title, message, type }) => { ipcMain.handle('show-message', async (event, { title, message, type }) => {
const { dialog } = require('electron');
return dialog.showMessageBox(mainWindow, { return dialog.showMessageBox(mainWindow, {
type: type || 'info', type: type || 'info',
title: title || 'CloudDisk', title: title || 'CloudDisk',

View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CloudDisk</title>
</head>
<body>
<div id="root"></div>
<script src="./renderer.js"></script>
</body>
</html>