-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: splashscreen #175
feat: splashscreen #175
Changes from 1 commit
c370844
be25cde
c347b1c
8b7b531
1f73890
0858f01
330d312
af57d76
8892794
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="Content-Security-Policy" content="script-src 'self'" /> | ||
<title>k6 Studio (experimental)</title> | ||
</head> | ||
<body> | ||
I AM SPLASHING | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,11 @@ import { queryClient } from './utils/query' | |
export function App() { | ||
const theme = useTheme() | ||
|
||
setTimeout(() => { | ||
console.log('REPLACE ME') | ||
window.studio.app.closeSplashscreen() | ||
}, 1000) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to be replaced: example of how to close the splashscreen and show the app |
||
|
||
return ( | ||
<QueryClientProvider client={queryClient}> | ||
<Theme accentColor="orange" appearance={theme}> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,12 +54,39 @@ export let proxyPort = 6000 | |
let currentBrowserProcess: Process | null | ||
let currentk6Process: K6Process | null | ||
let watcher: FSWatcher | ||
let splashscreenWindow: BrowserWindow | ||
|
||
// Handle creating/removing shortcuts on Windows when installing/uninstalling. | ||
if (require('electron-squirrel-startup')) { | ||
app.quit() | ||
} | ||
|
||
const createSplashWindow = async () => { | ||
splashscreenWindow = new BrowserWindow({ | ||
width: 500, | ||
height: 300, | ||
// transparent: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we want the window transparent , will depend on the splashscreen we use |
||
frame: false, | ||
alwaysOnTop: true, | ||
}) | ||
|
||
let splashscreenFile: string | ||
|
||
// if we are in dev server we take resources directly, otherwise look in the app resources folder. | ||
if (MAIN_WINDOW_VITE_DEV_SERVER_URL) { | ||
splashscreenFile = path.join( | ||
app.getAppPath(), | ||
'resources', | ||
'splashscreen.html' | ||
) | ||
} else { | ||
splashscreenFile = path.join(process.resourcesPath, 'splashscreen.html') | ||
} | ||
|
||
splashscreenWindow.loadFile(splashscreenFile) | ||
splashscreenWindow.center() | ||
} | ||
|
||
const createWindow = async () => { | ||
const icon = getAppIcon(process.env.NODE_ENV === 'development') | ||
if (getPlatform() === 'mac') { | ||
|
@@ -97,13 +124,6 @@ const createWindow = async () => { | |
) | ||
} | ||
|
||
// wait for the window to be ready before showing it. It prevents showing a white page on longer load times. | ||
mainWindow.once('ready-to-show', () => { | ||
// maximize will also show the window so mainWindow.show() is unneeded | ||
mainWindow.maximize() | ||
mainWindow.focus() | ||
}) | ||
|
||
// Open the DevTools. | ||
if (process.env.NODE_ENV === 'development') { | ||
mainWindow.webContents.openDevTools({ mode: 'detach' }) | ||
|
@@ -113,6 +133,7 @@ const createWindow = async () => { | |
} | ||
|
||
app.whenReady().then(async () => { | ||
await createSplashWindow() | ||
const mainWindow = await createWindow() | ||
setupProjectStructure() | ||
|
||
|
@@ -463,6 +484,16 @@ ipcMain.handle('browser:open:external:link', (_, url: string) => { | |
shell.openExternal(url) | ||
}) | ||
|
||
ipcMain.on('splashscreen:close', (event) => { | ||
console.info('splashscreen:close event received') | ||
|
||
const browserWindow = browserWindowFromEvent(event) | ||
|
||
splashscreenWindow.close() | ||
browserWindow.show() | ||
browserWindow.focus() | ||
}) | ||
|
||
const browserWindowFromEvent = ( | ||
event: Electron.IpcMainEvent | Electron.IpcMainInvokeEvent | ||
) => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,13 +138,20 @@ const generator = { | |
}, | ||
} as const | ||
|
||
const app = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added it as |
||
closeSplashscreen: () => { | ||
ipcRenderer.send('splashscreen:close') | ||
}, | ||
} as const | ||
|
||
const studio = { | ||
proxy, | ||
browser, | ||
script, | ||
har, | ||
ui, | ||
generator, | ||
app, | ||
} as const | ||
|
||
contextBridge.exposeInMainWorld('studio', studio) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the splashscreen is a simple
html
file so that we don't need to wait any kind of react loading to show it. It has to be quick and visible and simple~