diff --git a/.github/workflows/client-app.yml b/.github/workflows/client-app.yml index 867e3d21cc..0eac79804d 100644 --- a/.github/workflows/client-app.yml +++ b/.github/workflows/client-app.yml @@ -6,7 +6,7 @@ on: version: description: App Version required: true - default: 0.1.0 + default: 0.0.0 is-draft: description: 'Draft Release?' type: boolean diff --git a/apps/electron/layers/main/src/main-window.ts b/apps/electron/layers/main/src/main-window.ts index 56c5151851..114df53404 100644 --- a/apps/electron/layers/main/src/main-window.ts +++ b/apps/electron/layers/main/src/main-window.ts @@ -21,7 +21,7 @@ async function createWindow() { sandbox: false, webviewTag: false, // The webview tag is not recommended. Consider alternatives like iframe or Electron's BrowserView. https://www.electronjs.org/docs/latest/api/webview-tag#warning spellcheck: false, // FIXME: enable? - preload: join(__dirname, '../../preload/dist/index.js'), + preload: join(__dirname, '../preload/index.js'), }, }); diff --git a/apps/electron/layers/main/src/protocol.ts b/apps/electron/layers/main/src/protocol.ts index 4575ed4e85..fd441d9b18 100644 --- a/apps/electron/layers/main/src/protocol.ts +++ b/apps/electron/layers/main/src/protocol.ts @@ -2,15 +2,22 @@ import { protocol } from 'electron'; import { join } from 'path'; export function registerProtocol() { - protocol.interceptFileProtocol('file', (request, callback) => { - const url = request.url.replace(/^file:\/\//, ''); - if (url.startsWith('./')) { - const realpath = join( - __dirname, - '../../../resources/web-static', - decodeURIComponent(url) - ); - callback(realpath); - } - }); + if (process.env.NODE_ENV === 'production') { + protocol.interceptFileProtocol('file', (request, callback) => { + const url = request.url.replace(/^file:\/\//, ''); + const webStaticDir = join(__dirname, '../../../resources/web-static'); + if (url.startsWith('./')) { + // if is a file type, load the file in resources + if (url.split('/').at(-1)?.includes('.')) { + const realpath = join(webStaticDir, decodeURIComponent(url)); + callback(realpath); + } else { + // else, fallback to load the index.html instead + const realpath = join(webStaticDir, 'index.html'); + console.log(realpath, 'realpath', url, 'url'); + callback(realpath); + } + } + }); + } }