Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix: electron whitescreen (#4013)

Peng Xiao7b0e5b89ed25
diff --git a/apps/core/.webpack/config.ts b/apps/core/.webpack/config.ts
index 84333df92a..896940eec8 100644
--- a/apps/core/.webpack/config.ts
+++ b/apps/core/.webpack/config.ts
@@ -69,19 +69,20 @@ const OptimizeOptionOptions: (
},
});
-export const publicPath = (function () {
+export const getPublicPath = (buildFlags: BuildFlags) => {
const { BUILD_TYPE } = process.env;
const publicPath = process.env.PUBLIC_PATH ?? '/';
- if (process.env.COVERAGE) {
+ if (process.env.COVERAGE || buildFlags.distribution === 'desktop') {
return publicPath;
}
+
if (BUILD_TYPE === 'canary') {
return `https://dev.affineassets.com/${gitShortHash()}/`;
} else if (BUILD_TYPE === 'beta' || BUILD_TYPE === 'stable') {
return `https://prod.affineassets.com/${gitShortHash()}/`;
}
return publicPath;
-})();
+};
export const createConfiguration: (
buildFlags: BuildFlags,
@@ -119,7 +120,7 @@ export const createConfiguration: (
path: join(rootPath, 'dist'),
clean: buildFlags.mode === 'production',
globalObject: 'globalThis',
- publicPath,
+ publicPath: getPublicPath(buildFlags),
},
target: ['web', 'es2022'],
diff --git a/apps/core/.webpack/webpack.config.ts b/apps/core/.webpack/webpack.config.ts
index ac759e3ca3..0fe4ebcead 100644
--- a/apps/core/.webpack/webpack.config.ts
+++ b/apps/core/.webpack/webpack.config.ts
@@ -1,4 +1,4 @@
-import { createConfiguration, rootPath, publicPath } from './config.js';
+import { createConfiguration, rootPath, getPublicPath } from './config.js';
import { merge } from 'webpack-merge';
import { join, resolve } from 'node:path';
import type { BuildFlags } from '@affine/cli/config';
@@ -55,7 +55,7 @@ export default async function (cli_env: any, _: any) {
inject: 'body',
scriptLoading: 'module',
minify: false,
- publicPath,
+ publicPath: getPublicPath(flags),
chunks: [
'_plugin/index.test',
'plugin',
diff --git a/apps/electron/src/main/protocol.ts b/apps/electron/src/main/protocol.ts
index 23039f7b6d..1c1993b3ad 100644
--- a/apps/electron/src/main/protocol.ts
+++ b/apps/electron/src/main/protocol.ts
@@ -57,7 +57,6 @@ async function handleHttpRequest(request: Request) {
}
export function registerProtocol() {
- // it seems that there is some issue to postMessage between renderer with custom protocol & helper process
protocol.handle('http', request => {
return handleHttpRequest(request);
});