mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-24 18:02:47 +08:00
refactor: migrate environment to BUILD_CONFIG (#8206)
This commit is contained in:
@@ -43,8 +43,8 @@ const desktopWhiteList = [
|
||||
'/magic-link',
|
||||
];
|
||||
if (
|
||||
!environment.isElectron &&
|
||||
environment.isDebug &&
|
||||
!BUILD_CONFIG.isElectron &&
|
||||
BUILD_CONFIG.debug &&
|
||||
desktopWhiteList.every(path => !location.pathname.startsWith(path))
|
||||
) {
|
||||
document.body.innerHTML = `<h1 style="color:red;font-size:5rem;text-align:center;">Don't run electron entry in browser.</h1>`;
|
||||
|
||||
@@ -39,7 +39,7 @@ function main() {
|
||||
performanceMainLogger.info('skip setup');
|
||||
} else {
|
||||
performanceMainLogger.info('setup start');
|
||||
if (window.SENTRY_RELEASE || environment.isDebug) {
|
||||
if (BUILD_CONFIG.debug || window.SENTRY_RELEASE) {
|
||||
// https://docs.sentry.io/platforms/javascript/guides/electron/
|
||||
init({
|
||||
dsn: process.env.SENTRY_DSN,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AppFallback } from '@affine/core/components/affine/app-container';
|
||||
import { ShellAppFallback } from '@affine/core/components/affine/app-container';
|
||||
import { useAppSettingHelper } from '@affine/core/hooks/affine/use-app-setting-helper';
|
||||
import { AppTabsHeader } from '@affine/core/modules/app-tabs-header';
|
||||
import { SplitViewFallback } from '@affine/core/modules/workbench/view/split-view/split-view';
|
||||
@@ -8,15 +8,15 @@ import * as styles from './shell.css';
|
||||
export function ShellRoot() {
|
||||
const { appSettings } = useAppSettingHelper();
|
||||
const translucent =
|
||||
environment.isElectron &&
|
||||
BUILD_CONFIG.isElectron &&
|
||||
environment.isMacOs &&
|
||||
appSettings.enableBlurBackground;
|
||||
return (
|
||||
<div className={styles.root} data-translucent={translucent}>
|
||||
<AppTabsHeader mode="shell" className={styles.appTabsHeader} />
|
||||
<AppFallback className={styles.fallbackRoot}>
|
||||
<ShellAppFallback className={styles.fallbackRoot}>
|
||||
<SplitViewFallback className={styles.splitViewFallback} />
|
||||
</AppFallback>
|
||||
</ShellAppFallback>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
||||
import { getRuntimeConfig } from '@affine/cli/src/webpack/runtime-config';
|
||||
import { getBuildConfig } from '@affine/cli/src/webpack/runtime-config';
|
||||
import { sentryEsbuildPlugin } from '@sentry/esbuild-plugin';
|
||||
import type { BuildOptions, Plugin } from 'esbuild';
|
||||
|
||||
@@ -20,8 +20,8 @@ export const config = (): BuildOptions => {
|
||||
|
||||
define['REPLACE_ME_BUILD_ENV'] = `"${process.env.BUILD_TYPE ?? 'stable'}"`;
|
||||
|
||||
define['runtimeConfig'] = JSON.stringify(
|
||||
getRuntimeConfig({
|
||||
define['BUILD_CONFIG'] = JSON.stringify(
|
||||
getBuildConfig({
|
||||
channel: (process.env.BUILD_TYPE as any) ?? 'canary',
|
||||
distribution: 'desktop',
|
||||
mode:
|
||||
|
||||
@@ -254,10 +254,10 @@ export async function openUrlInHiddenWindow(urlObj: URL) {
|
||||
preload: join(__dirname, './preload.js'),
|
||||
additionalArguments: await getWindowAdditionalArguments(),
|
||||
},
|
||||
show: environment.isDebug,
|
||||
show: BUILD_CONFIG.debug,
|
||||
});
|
||||
|
||||
if (environment.isDebug) {
|
||||
if (BUILD_CONFIG.debug) {
|
||||
win.webContents.openDevTools({
|
||||
mode: 'detach',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user