修复运行使用生产模式打包的程序,进入主界面时,提示找不到electron-tabs.js文件的问题。

This commit is contained in:
Allen 2025-05-18 19:46:17 +08:00
parent 3c23ea4c74
commit 7da3a62852
3 changed files with 13 additions and 5 deletions

View File

@ -50,7 +50,9 @@
<!-- 帮助图标 --> <!-- 帮助图标 -->
<img id="helpIcon" src="./assets/help.png" alt="帮助图标" class="help-icon"> <img id="helpIcon" src="./assets/help.png" alt="帮助图标" class="help-icon">
<script src="node_modules/electron-tabs/dist/electron-tabs.js"></script> <script type="module">
import 'electron-tabs';
</script>
<script type="module" src="./src/index.ts"></script> <script type="module" src="./src/index.ts"></script>
</body> </body>

View File

@ -245,10 +245,7 @@ function bindHelpIconClickEvent(menuItem: MenuItem): void {
if (tab) { if (tab) {
tab.activate(); tab.activate();
} else { } else {
const newTab: Tab | null = await addTabAsync(tabGroup, menuItem); await addTabAsync(tabGroup, menuItem);
if (newTab) {
newTab.setPosition(0);
}
} }
} }
}); });

View File

@ -20,9 +20,18 @@ export default defineConfig({
input: { input: {
login: 'login.html', login: 'login.html',
index: 'index.html' index: 'index.html'
},
output: {
// 确保 electron-tabs.js 被正确打包
manualChunks: {
'electron-tabs': ['electron-tabs']
}
} }
} }
}, },
optimizeDeps: {
include: ['electron-tabs']
},
// 使用 Vite 的 env 配置 // 使用 Vite 的 env 配置
envPrefix: ['EIAC_DESKTOP_API_HOST', 'NODE_ENV'], envPrefix: ['EIAC_DESKTOP_API_HOST', 'NODE_ENV'],
// 定义环境变量 // 定义环境变量