Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion apps/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@
],
"afterPack": "scripts/evs-sign.js",
"mac": {
"target": "dmg",
"target": [
{
"target": "dmg",
"arch": ["x64", "arm64"]
}
],
"category": "public.app-category.developer-tools",
"icon": "assets/icon.icns",
"hardenedRuntime": true,
Expand Down
62 changes: 62 additions & 0 deletions apps/browser/src/main/html-generator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* Generate HTML templates for renderer pages
*/

interface HtmlOptions {
title: string;
themeColor: string;
scriptPath: string;
cssPath?: string;
queryParams?: Record<string, string>;
}

export function generateHtml(options: HtmlOptions): string {
const { title, themeColor, scriptPath, cssPath, queryParams } = options;

// Inject query parameters as a global variable
const queryParamsScript = queryParams
? `<script>window.__QUERY_PARAMS__ = ${JSON.stringify(queryParams)};</script>`
: '';

return `<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, viewport-fit=cover"
/>
<meta name="theme-color" content="${themeColor}" />
<title>${title}</title>
${cssPath ? `<link rel="stylesheet" href="${cssPath}" />` : ''}
${queryParamsScript}
</head>
<body>
<div id="root"></div>
<script type="module" src="${scriptPath}"></script>
</body>
</html>`;
}

export function generateBlankPageHtml(scriptPath: string, cssPath?: string): string {
return generateHtml({
title: 'Blank Page',
themeColor: '#1c1c1e',
scriptPath,
cssPath,
});
}

export function generateErrorPageHtml(
scriptPath: string,
cssPath?: string,
queryParams?: Record<string, string>
): string {
return generateHtml({
title: 'Error',
themeColor: '#2d2d2d',
scriptPath,
cssPath,
queryParams,
});
}
9 changes: 6 additions & 3 deletions apps/browser/src/main/ipc-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,13 @@ export class IPCHandlers {
}
if (this.state.webContentsView && !this.state.webContentsView.webContents.isDestroyed()) {
const url = this.state.webContentsView.webContents.getURL();
console.log("[IPC] webcontents-get-url raw URL:", url);
// Return "/" for blank-page and error-page
if (url.includes("blank-page.html") || url.startsWith("data:text/html")) {
if (url.includes("blank-page-tab-") || url.includes("error-page-tab-")) {
console.log("[IPC] Returning / for temporary file");
return "/";
}
console.log("[IPC] Returning original URL:", url);
return url;
}
return "";
Expand All @@ -272,11 +275,11 @@ export class IPCHandlers {
if (this.state.webContentsView && !this.state.webContentsView.webContents.isDestroyed()) {
const url = this.state.webContentsView.webContents.getURL();
// Return "Blank Page" for blank-page
if (url.includes("blank-page.html")) {
if (url.includes("blank-page-tab-")) {
return "Blank Page";
}
// Return actual title for error-page (it's set in the HTML)
if (url.startsWith("data:text/html")) {
if (url.includes("error-page-tab-")) {
return this.state.webContentsView.webContents.getTitle();
}
return this.state.webContentsView.webContents.getTitle();
Expand Down
Loading