fix(service-party-app): 修复路由和启动问题

1. 将 BrowserRouter 改为 HashRouter - Electron 使用 file:// 协议
2. 移除生产环境自动打开浏览器的代码
3. HTTP 服务器仅在开发模式下启动

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-28 07:45:43 -08:00
parent 15cbb2401f
commit 47328c67d7
2 changed files with 8 additions and 9 deletions

View File

@ -165,13 +165,11 @@ function setupIpcHandlers() {
// 应用生命周期
app.whenReady().then(async () => {
await initServices();
startHttpServer();
createWindow();
// 自动打开浏览器 (可选)
if (process.env.OPEN_BROWSER !== 'false') {
shell.openExternal(`http://127.0.0.1:${HTTP_PORT}`);
// HTTP 服务器仅在开发模式下启动
if (process.env.NODE_ENV === 'development') {
startHttpServer();
}
createWindow();
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {

View File

@ -1,13 +1,14 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import { BrowserRouter } from 'react-router-dom';
import { HashRouter } from 'react-router-dom';
import App from './App';
import './styles/global.css';
// Electron 使用 file:// 协议,需要用 HashRouter 而不是 BrowserRouter
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<BrowserRouter>
<HashRouter>
<App />
</BrowserRouter>
</HashRouter>
</React.StrictMode>
);