Compare commits
No commits in common. "fbf84bb7aa12f2034939bc6bfd8a5eb748136155" and "94a6ebdac7b3dd13220aa4365304e94a7df4e9b3" have entirely different histories.
fbf84bb7aa
...
94a6ebdac7
|
|
@ -1,9 +1,8 @@
|
|||
// electron/ipc/tokenHandler.ts
|
||||
import { ipcMain } from 'electron';
|
||||
import { getToken, saveToken, clearToken } from '../utils/tokenHelper.js';
|
||||
import { getActiveApp, handleLogin, takeScreenshot } from '../utils/utilityFunctions.js';
|
||||
import { handleLogin, takeScreenshot } from '../utils/utilityFunctions.js';
|
||||
import api from '../api/axiosClient.js';
|
||||
import { getMainWindow } from '../main.js';
|
||||
|
||||
ipcMain.handle('get-token', async (_, TOKEN_KEY: "ACCESS_TOKEN" | "REFRESH_TOKEN") => {
|
||||
return await getToken(TOKEN_KEY);
|
||||
|
|
@ -34,31 +33,11 @@ ipcMain.handle('logout-request', async () => {
|
|||
console.log("Handle Logout listened")
|
||||
console.log("Token", await getToken("ACCESS_TOKEN"))
|
||||
const res = await api.get("/logout");
|
||||
if (res && ("success" in res) && res.success) {
|
||||
return { success: true, message: "Logout Successfully" }
|
||||
if(res && ("success" in res) && res.success) {
|
||||
return {success: true, message: "Logout Successfully"}
|
||||
}
|
||||
return { success: false, message: "" }
|
||||
} catch (error) {
|
||||
return { success: false, message: "" }
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('get-active-app', () => {
|
||||
return getActiveApp();
|
||||
});
|
||||
|
||||
ipcMain.handle('toggle-close-btn', (event, shouldEnable: boolean) => {
|
||||
const mainWindow = getMainWindow()
|
||||
console.log("toggle-close-btn Called", mainWindow)
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.setClosable(shouldEnable);
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('resize-window', (event, width: number, height: number) => {
|
||||
const mainWindow = getMainWindow()
|
||||
console.log("toggle-close-btn Called", mainWindow)
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.setSize(width, height);
|
||||
return {success: false, message: ""}
|
||||
} catch(error) {
|
||||
return {success: false, message: ""}
|
||||
}
|
||||
});
|
||||
|
|
@ -1,27 +1,20 @@
|
|||
import { app, BrowserWindow, ipcMain, session } from 'electron';
|
||||
import { app, BrowserWindow, session } from 'electron';
|
||||
import { ipcMainHandle, ipcMainOn, isDev } from './util.js';
|
||||
import { getStaticData, pollResources } from './resourceManager.js';
|
||||
import { getPreloadPath, getUIPath } from './pathResolver.js';
|
||||
|
||||
import "./ipc/ipcHandler.js";
|
||||
|
||||
let mainWindow:any = null;
|
||||
|
||||
app.on('ready', async () => {
|
||||
console.log("ready");
|
||||
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 500, // fixed width
|
||||
height: 600, // fixed height
|
||||
|
||||
const mainWindow = new BrowserWindow({
|
||||
width: 550, // fixed width
|
||||
height: 750, // fixed height
|
||||
resizable: false, // prevents resizing
|
||||
fullscreenable: false, // disables fullscreen toggle (F11 or double-click title bar)
|
||||
minimizable: false, // disables minimize button
|
||||
maximizable: false, // prevents maximize
|
||||
closable: true,
|
||||
alwaysOnTop: true,
|
||||
autoHideMenuBar: true,
|
||||
|
||||
frame: process.platform === 'darwin' ? false : true,
|
||||
webPreferences: {
|
||||
preload: getPreloadPath(),
|
||||
|
|
@ -40,28 +33,30 @@ app.on('ready', async () => {
|
|||
mainWindow.loadFile(getUIPath());
|
||||
}
|
||||
|
||||
// pollResources(mainWindow);
|
||||
pollResources(mainWindow);
|
||||
|
||||
// IPC handlers
|
||||
// ipcMainHandle('getStaticData', () => getStaticData());
|
||||
ipcMainHandle('getStaticData', () => getStaticData());
|
||||
|
||||
// ipcMainOn('sendFrameAction', (payload) => {
|
||||
// switch (payload) {
|
||||
// case 'CLOSE':
|
||||
// mainWindow.close();
|
||||
// break;
|
||||
// case 'MAXIMIZE':
|
||||
// // prevent maximize
|
||||
// break;
|
||||
// case 'MINIMIZE':
|
||||
// mainWindow.minimize();
|
||||
// break;
|
||||
// }
|
||||
// });
|
||||
ipcMainOn('sendFrameAction', (payload) => {
|
||||
switch (payload) {
|
||||
case 'CLOSE':
|
||||
mainWindow.close();
|
||||
break;
|
||||
case 'MAXIMIZE':
|
||||
// prevent maximize
|
||||
break;
|
||||
case 'MINIMIZE':
|
||||
mainWindow.minimize();
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
handleCloseEvents(mainWindow);
|
||||
});
|
||||
|
||||
|
||||
|
||||
function handleCloseEvents(mainWindow: BrowserWindow) {
|
||||
let willClose = false;
|
||||
|
||||
|
|
@ -85,6 +80,4 @@ function handleCloseEvents(mainWindow: BrowserWindow) {
|
|||
});
|
||||
}
|
||||
|
||||
export function getMainWindow() {
|
||||
return mainWindow;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,9 +7,6 @@ contextBridge.exposeInMainWorld('electron', {
|
|||
logout: () => ipcRenderer.invoke('logout-request'),
|
||||
getToken: (TOKEN_KEY: "ACCESS_TOKEN" | "REFRESH_TOKEN") => ipcRenderer.invoke('get-token', TOKEN_KEY),
|
||||
uploadScreenshot: () => ipcRenderer.invoke('upload-screenshot'),
|
||||
getActiveAppDetails: () => ipcRenderer.invoke('get-active-app'),
|
||||
toggleCloseBtn: (shouldEnable: boolean) => ipcRenderer.invoke('toggle-close-btn', shouldEnable),
|
||||
resizeWindow: (width: number, height: number) => ipcRenderer.invoke('resize-window', width, height),
|
||||
} satisfies Window['electron']);
|
||||
|
||||
// function ipcInvoke<Key extends keyof EventPayloadMapping>(
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import path from "path";
|
|||
import axios from 'axios';
|
||||
import sharp from 'sharp';
|
||||
import { saveToken } from "./tokenHelper.js";
|
||||
import { activeWindow } from "get-windows";
|
||||
|
||||
// Blur using an offscreen canvas
|
||||
async function blurAndCompressBase64Image(base64: string): Promise<Buffer> {
|
||||
|
|
@ -94,8 +93,3 @@ export const handleLogin = async (credentials: { email: string, password: string
|
|||
return { success: false, error: "Unexpected error occurred" };
|
||||
}
|
||||
}
|
||||
|
||||
export const getActiveApp = async () => {
|
||||
const result = await activeWindow();
|
||||
return result;
|
||||
};
|
||||
|
|
@ -104,16 +104,6 @@ const DashboardLayout: React.FC<DashboardLayoutProps> = ({ setUser }) => {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
setInterval(async () => {
|
||||
const details = await window.electron.getActiveAppDetails()
|
||||
console.log(details)
|
||||
}, 15000)
|
||||
}, [])
|
||||
|
||||
|
||||
const toggleSidebar = () => setSidebarOpen(!isSidebarOpen);
|
||||
|
||||
const closeSidebarOnMobile = () => {
|
||||
|
|
|
|||
|
|
@ -104,27 +104,6 @@ const Dashboard: React.FC = () => {
|
|||
>
|
||||
Screenshot Test
|
||||
</button>
|
||||
<button
|
||||
onClick={() => {
|
||||
window.electron.toggleCloseBtn(true)
|
||||
}}
|
||||
className="btn btn-xs btn-outline mt-2">
|
||||
Enable
|
||||
</button>
|
||||
<button
|
||||
onClick={() => {
|
||||
window.electron.toggleCloseBtn(false)
|
||||
}}
|
||||
className="btn btn-xs btn-outline mt-2">
|
||||
Disable
|
||||
</button>
|
||||
<button
|
||||
onClick={() => {
|
||||
window.electron.resizeWindow(500, 100)
|
||||
}}
|
||||
className="btn btn-xs btn-outline mt-2">
|
||||
Resize Toggle
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Widgets */}
|
||||
|
|
|
|||
|
|
@ -29,9 +29,6 @@ interface Window {
|
|||
logout: () => Promise<any>;
|
||||
getToken: (tokenKey: "ACCESS_TOKEN" | "REFRESH_TOKEN") => Promise<string | null>;
|
||||
uploadScreenshot: () => {};
|
||||
getActiveAppDetails: () => {};
|
||||
toggleCloseBtn: (shouldEnable: boolean) => {},
|
||||
resizeWindow: (width: number, height: number) => {},
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue