|
|
@@ -21,16 +21,23 @@ const createWindow = () => {
|
|
|
mainWindow.setPosition(0, 0)
|
|
|
|
|
|
mainWindow.loadFile(path.join(__dirname, '../dist/index.html'))
|
|
|
+
|
|
|
+ // 添加 'close' 事件监听器
|
|
|
+ mainWindow.on('close', (event) => {
|
|
|
+ event.preventDefault(); // 阻止窗口立即关闭
|
|
|
+ mainWindow.webContents.send('clear-token-cache');
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
app.on('ready', () => {
|
|
|
- const filter = {urls: ['file:///C:/api/*', 'file:///api/*']};
|
|
|
- const url = 'http://127.0.0.1:8014'
|
|
|
- //const url = 'http://192.168.0.125:8014'
|
|
|
+ const filter = {urls: ['file:///C:/api/*', 'file:///api/*', 'file:///D:/api/*']};
|
|
|
+ //const url = 'http://127.0.0.1:8014'
|
|
|
+ const url = 'http://192.168.0.125:8014'
|
|
|
session.defaultSession.webRequest.onBeforeRequest(filter, (details, callback) => {
|
|
|
const val = details.url
|
|
|
let newUrl = val.replace('file:///api', url);
|
|
|
newUrl = newUrl.replace('file:///C:/api', url);
|
|
|
+ newUrl = newUrl.replace('file:///D:/api', url);
|
|
|
callback({ redirectURL: newUrl });
|
|
|
});
|
|
|
});
|
|
|
@@ -53,6 +60,7 @@ app.whenReady().then(() => {
|
|
|
|
|
|
// 监听渲染进程发来的缓存清理完成的消息
|
|
|
ipcMain.on('token-cache-cleared', () => {
|
|
|
+ console.log('token-cache-cleared')
|
|
|
if (mainWindow && !mainWindow.isDestroyed()) {
|
|
|
mainWindow.destroy();
|
|
|
}
|
|
|
@@ -68,9 +76,7 @@ app.on('before-quit', (event) => {
|
|
|
})
|
|
|
|
|
|
app.on('window-all-closed', () => {
|
|
|
- if (mainWindow && !mainWindow.isDestroyed()) {
|
|
|
- mainWindow.webContents.send('clear-token-cache');
|
|
|
- }
|
|
|
+ if (process.platform !== 'darwin') app.quit();
|
|
|
});
|
|
|
|
|
|
app.on('will-quit', () => {
|