diff --git a/packages/frontend/core/src/components/app-sidebar/quick-search-input/index.tsx b/packages/frontend/core/src/components/app-sidebar/quick-search-input/index.tsx
index 4e01d949f..0b4283d34 100644
--- a/packages/frontend/core/src/components/app-sidebar/quick-search-input/index.tsx
+++ b/packages/frontend/core/src/components/app-sidebar/quick-search-input/index.tsx
@@ -13,7 +13,6 @@ interface QuickSearchInputProps extends HTMLAttributes
{
// Although it is called an input, it is actually a button.
export function QuickSearchInput({ onClick, ...props }: QuickSearchInputProps) {
const t = useI18n();
- const isMac = environment.isMacOs;
return (
- {isMac ? ' ⌘ + K' : ' Ctrl + K'}
+ {environment.isMacOs ? ' ⌘ + K' : ' Ctrl + K'}
diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-header/menu/index.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-header/menu/index.tsx
index 0deba414c..18d70f2b4 100644
--- a/packages/frontend/core/src/components/blocksuite/block-suite-header/menu/index.tsx
+++ b/packages/frontend/core/src/components/blocksuite/block-suite-header/menu/index.tsx
@@ -292,8 +292,7 @@ export const PageHeaderMenuButton = ({
>
{t['com.affine.workbench.tab.page-menu-open']()}
-
- {environment.isElectron && (
+ {BUILD_CONFIG.isElectron && (
}
data-testid="editor-option-menu-open-in-split-new"
diff --git a/packages/frontend/core/src/components/page-list/operation-cell.tsx b/packages/frontend/core/src/components/page-list/operation-cell.tsx
index 2a106c64c..888de372d 100644
--- a/packages/frontend/core/src/components/page-list/operation-cell.tsx
+++ b/packages/frontend/core/src/components/page-list/operation-cell.tsx
@@ -176,12 +176,10 @@ export const PageOperationCell = ({
}>
{t['com.affine.page-properties.page-info.view']()}
-
}>
{t['com.affine.workbench.tab.page-menu-open']()}
-
- {environment.isElectron && enableSplitView ? (
+ {BUILD_CONFIG.isElectron && enableSplitView ? (
}>
{t['com.affine.workbench.split-view.page-menu-open']()}
diff --git a/packages/frontend/core/src/components/page-list/view/collection-operations.tsx b/packages/frontend/core/src/components/page-list/view/collection-operations.tsx
index e846137b4..1726c0b56 100644
--- a/packages/frontend/core/src/components/page-list/view/collection-operations.tsx
+++ b/packages/frontend/core/src/components/page-list/view/collection-operations.tsx
@@ -154,7 +154,7 @@ export const CollectionOperations = ({
name: t['com.affine.workbench.tab.page-menu-open'](),
click: openCollectionNewTab,
},
- ...(enableMultiView && environment.isElectron
+ ...(BUILD_CONFIG.isElectron && enableMultiView
? [
{
icon: ,
diff --git a/packages/frontend/core/src/components/pure/help-island/index.tsx b/packages/frontend/core/src/components/pure/help-island/index.tsx
index 66d505c92..0a98fe926 100644
--- a/packages/frontend/core/src/components/pure/help-island/index.tsx
+++ b/packages/frontend/core/src/components/pure/help-island/index.tsx
@@ -29,7 +29,9 @@ const DEFAULT_SHOW_LIST: IslandItemNames[] = [
const DESKTOP_SHOW_LIST: IslandItemNames[] = [...DEFAULT_SHOW_LIST];
type IslandItemNames = 'whatNew' | 'contact' | 'shortcuts';
-const showList = environment.isElectron ? DESKTOP_SHOW_LIST : DEFAULT_SHOW_LIST;
+const showList = BUILD_CONFIG.isElectron
+ ? DESKTOP_SHOW_LIST
+ : DEFAULT_SHOW_LIST;
export const HelpIsland = () => {
const { globalContextService } = useServices({
diff --git a/packages/frontend/core/src/components/root-app-sidebar/index.tsx b/packages/frontend/core/src/components/root-app-sidebar/index.tsx
index a78d54f8f..a11767098 100644
--- a/packages/frontend/core/src/components/root-app-sidebar/index.tsx
+++ b/packages/frontend/core/src/components/root-app-sidebar/index.tsx
@@ -106,7 +106,7 @@ export const RootAppSidebar = (): ReactElement => {
);
useEffect(() => {
- if (environment.isElectron) {
+ if (BUILD_CONFIG.isElectron) {
return events?.applicationMenu.onNewPageAction(() => {
apis?.ui
.isActiveTab()
@@ -197,7 +197,7 @@ export const RootAppSidebar = (): ReactElement => {
- {environment.isElectron ? : }
+ {BUILD_CONFIG.isElectron ? : }
);
diff --git a/packages/frontend/core/src/components/top-tip.tsx b/packages/frontend/core/src/components/top-tip.tsx
index f8b4bbff5..a1e185427 100644
--- a/packages/frontend/core/src/components/top-tip.tsx
+++ b/packages/frontend/core/src/components/top-tip.tsx
@@ -12,12 +12,12 @@ import { AuthService } from '../modules/cloud';
const minimumChromeVersion = 106;
const shouldShowWarning = (() => {
- if (environment.isElectron) {
+ if (BUILD_CONFIG.isElectron) {
// even though desktop has compatibility issues,
// we don't want to show the warning
return false;
}
- if (environment.isMobile) {
+ if (BUILD_CONFIG.isMobileEdition) {
return true;
}
if (environment.isChrome && environment.chromeVersion) {
@@ -75,8 +75,8 @@ export const TopTip = ({
}, [setAuthModal]);
if (
+ !BUILD_CONFIG.isElectron &&
showLocalDemoTips &&
- !environment.isElectron &&
workspace.flavour === WorkspaceFlavour.LOCAL
) {
return (
diff --git a/packages/frontend/core/src/components/workspace-selector/user-with-workspace-list/add-workspace/index.tsx b/packages/frontend/core/src/components/workspace-selector/user-with-workspace-list/add-workspace/index.tsx
index d03d6cfda..9653749b1 100644
--- a/packages/frontend/core/src/components/workspace-selector/user-with-workspace-list/add-workspace/index.tsx
+++ b/packages/frontend/core/src/components/workspace-selector/user-with-workspace-list/add-workspace/index.tsx
@@ -15,7 +15,7 @@ export const AddWorkspace = ({
return (
- {environment.isElectron ? (
+ {BUILD_CONFIG.isElectron && (
}
@@ -27,7 +27,7 @@ export const AddWorkspace = ({
{t['com.affine.workspace.local.import']()}
- ) : null}
+ )}
}
diff --git a/packages/frontend/core/src/components/workspace-selector/workspace-card/index.tsx b/packages/frontend/core/src/components/workspace-selector/workspace-card/index.tsx
index b07f5c15c..3b0ca8246 100644
--- a/packages/frontend/core/src/components/workspace-selector/workspace-card/index.tsx
+++ b/packages/frontend/core/src/components/workspace-selector/workspace-card/index.tsx
@@ -60,7 +60,7 @@ const UnSyncWorkspaceStatus = () => {
const LocalWorkspaceStatus = () => {
return (
<>
- {!environment.isElectron ? (
+ {!BUILD_CONFIG.isElectron ? (
) : (
@@ -98,7 +98,7 @@ const useSyncEngineSyncProgress = (meta: WorkspaceMetadata) => {
let content;
// TODO(@eyhn): add i18n
if (workspace.flavour === WorkspaceFlavour.LOCAL) {
- if (!environment.isElectron) {
+ if (!BUILD_CONFIG.isElectron) {
content = 'This is a local demo workspace.';
} else {
content = 'Saved locally';
diff --git a/packages/frontend/core/src/components/workspace/index.tsx b/packages/frontend/core/src/components/workspace/index.tsx
index c71602176..4618a06ef 100644
--- a/packages/frontend/core/src/components/workspace/index.tsx
+++ b/packages/frontend/core/src/components/workspace/index.tsx
@@ -28,8 +28,9 @@ export const AppContainer = ({
className,
...rest
}: WorkspaceRootProps) => {
- const noisyBackground = useNoisyBackground && environment.isElectron;
- const blurBackground = environment.isElectron && useBlurBackground;
+ const noisyBackground = BUILD_CONFIG.isElectron && useNoisyBackground;
+ const blurBackground =
+ BUILD_CONFIG.isElectron && environment.isMacOs && useBlurBackground;
return (
{
- if (!environment.isElectron) {
+ if (!BUILD_CONFIG.isElectron) {
return;
}
const unsubs: Array<() => void> = [];
diff --git a/packages/frontend/core/src/hooks/affine/use-shortcuts.ts b/packages/frontend/core/src/hooks/affine/use-shortcuts.ts
index 6b92dd8a5..efe9ea086 100644
--- a/packages/frontend/core/src/hooks/affine/use-shortcuts.ts
+++ b/packages/frontend/core/src/hooks/affine/use-shortcuts.ts
@@ -279,50 +279,56 @@ export const useWinMarkdownShortcuts = (): ShortcutMap => {
);
};
+const shortcutsMap = environment.isMacOs
+ ? {
+ useMarkdownShortcuts: useMacMarkdownShortcuts,
+ usePageShortcuts: useMacPageKeyboardShortcuts,
+ useEdgelessShortcuts: useMacEdgelessKeyboardShortcuts,
+ useGeneralShortcuts: useMacGeneralKeyboardShortcuts,
+ }
+ : {
+ useMarkdownShortcuts: useWinMarkdownShortcuts,
+ usePageShortcuts: useWinPageKeyboardShortcuts,
+ useEdgelessShortcuts: useWinEdgelessKeyboardShortcuts,
+ useGeneralShortcuts: useWinGeneralKeyboardShortcuts,
+ };
+
export const useMarkdownShortcuts = (): ShortcutsInfo => {
const t = useI18n();
+ const shortcuts = shortcutsMap.useMarkdownShortcuts();
- const macMarkdownShortcuts = useMacMarkdownShortcuts();
- const winMarkdownShortcuts = useWinMarkdownShortcuts();
- const isMac = environment.isMacOs;
return {
title: t['com.affine.shortcutsTitle.markdownSyntax'](),
- shortcuts: isMac ? macMarkdownShortcuts : winMarkdownShortcuts,
+ shortcuts,
};
};
export const usePageShortcuts = (): ShortcutsInfo => {
const t = useI18n();
+ const shortcuts = shortcutsMap.usePageShortcuts();
- const macPageShortcuts = useMacPageKeyboardShortcuts();
- const winPageShortcuts = useWinPageKeyboardShortcuts();
- const isMac = environment.isMacOs;
return {
title: t['com.affine.shortcutsTitle.page'](),
- shortcuts: isMac ? macPageShortcuts : winPageShortcuts,
+ shortcuts,
};
};
export const useEdgelessShortcuts = (): ShortcutsInfo => {
const t = useI18n();
+ const shortcuts = shortcutsMap.useEdgelessShortcuts();
- const macEdgelessShortcuts = useMacEdgelessKeyboardShortcuts();
- const winEdgelessShortcuts = useWinEdgelessKeyboardShortcuts();
- const isMac = environment.isMacOs;
return {
title: t['com.affine.shortcutsTitle.edgeless'](),
- shortcuts: isMac ? macEdgelessShortcuts : winEdgelessShortcuts,
+ shortcuts,
};
};
export const useGeneralShortcuts = (): ShortcutsInfo => {
const t = useI18n();
+ const shortcuts = shortcutsMap.useGeneralShortcuts();
- const macGeneralShortcuts = useMacGeneralKeyboardShortcuts();
- const winGeneralShortcuts = useWinGeneralKeyboardShortcuts();
- const isMac = environment.isMacOs;
return {
title: t['com.affine.shortcutsTitle.general'](),
- shortcuts: isMac ? macGeneralShortcuts : winGeneralShortcuts,
+ shortcuts,
};
};
diff --git a/packages/frontend/core/src/hooks/use-app-config-storage.ts b/packages/frontend/core/src/hooks/use-app-config-storage.ts
index ee1c7415a..b5416c3ab 100644
--- a/packages/frontend/core/src/hooks/use-app-config-storage.ts
+++ b/packages/frontend/core/src/hooks/use-app-config-storage.ts
@@ -1,5 +1,4 @@
import { apis } from '@affine/electron-api';
-import { setupGlobal } from '@affine/env/global';
import { assertExists } from '@blocksuite/global/utils';
import type { AppConfigSchema } from '@toeverything/infra';
import { AppConfigStorage, defaultAppConfig } from '@toeverything/infra';
@@ -33,9 +32,7 @@ class AppConfigProxy {
}
export const appConfigProxy = new AppConfigProxy();
-setupGlobal();
-
-const storage = environment.isElectron
+const storage = BUILD_CONFIG.isElectron
? new AppConfigStorage({
config: defaultAppConfig,
get: () => appConfigProxy.get(),
diff --git a/packages/frontend/core/src/hooks/use-app-updater.ts b/packages/frontend/core/src/hooks/use-app-updater.ts
index cf725b46a..e731aeba4 100644
--- a/packages/frontend/core/src/hooks/use-app-updater.ts
+++ b/packages/frontend/core/src/hooks/use-app-updater.ts
@@ -29,7 +29,7 @@ function rpcToObservable<
return new Observable
(subscriber => {
subscriber.next(initialValue);
onSubscribe?.();
- if (!environment.isElectron || !event) {
+ if (!BUILD_CONFIG.isElectron || !event) {
subscriber.complete();
return;
}
diff --git a/packages/frontend/core/src/hooks/use-global-state.ts b/packages/frontend/core/src/hooks/use-global-state.ts
index e7432c4d3..214c30174 100644
--- a/packages/frontend/core/src/hooks/use-global-state.ts
+++ b/packages/frontend/core/src/hooks/use-global-state.ts
@@ -3,7 +3,7 @@ import { useEffect } from 'react';
export function useDocumentTitle(newTitle?: string | null) {
useEffect(() => {
- if (environment.isElectron || !newTitle) {
+ if (BUILD_CONFIG.isElectron || !newTitle) {
return noop;
}
diff --git a/packages/frontend/core/src/layouts/workspace-layout.tsx b/packages/frontend/core/src/layouts/workspace-layout.tsx
index bb79fb1a8..2e5875d0a 100644
--- a/packages/frontend/core/src/layouts/workspace-layout.tsx
+++ b/packages/frontend/core/src/layouts/workspace-layout.tsx
@@ -211,6 +211,8 @@ const BrowserLayout = ({ children }: PropsWithChildren) => {
);
};
+const LayoutComponent = BUILD_CONFIG.isElectron ? DesktopLayout : BrowserLayout;
+
/**
* Wraps the workspace layout main router view
*/
@@ -223,9 +225,6 @@ const WorkspaceLayoutUIContainer = ({ children }: PropsWithChildren) => {
);
const resizing = useAtomValue(appSidebarResizingAtom);
- const LayoutComponent = environment.isElectron
- ? DesktopLayout
- : BrowserLayout;
return (
diff --git a/packages/frontend/core/src/mixpanel/mixpanel.ts b/packages/frontend/core/src/mixpanel/mixpanel.ts
index e886d4d00..96d4a1bf6 100644
--- a/packages/frontend/core/src/mixpanel/mixpanel.ts
+++ b/packages/frontend/core/src/mixpanel/mixpanel.ts
@@ -35,8 +35,8 @@ function createMixpanel() {
appVersion: BUILD_CONFIG.appVersion,
environment: BUILD_CONFIG.appBuildType,
editorVersion: BUILD_CONFIG.editorVersion,
- isSelfHosted: Boolean(BUILD_CONFIG.isSelfHosted),
- isDesktop: environment.isElectron,
+ isSelfHosted: BUILD_CONFIG.isSelfHosted,
+ isDesktop: BUILD_CONFIG.isElectron,
});
},
reset() {
diff --git a/packages/frontend/core/src/modules/app-tabs-header/views/app-tabs-header.tsx b/packages/frontend/core/src/modules/app-tabs-header/views/app-tabs-header.tsx
index 6812901fc..91882b39c 100644
--- a/packages/frontend/core/src/modules/app-tabs-header/views/app-tabs-header.tsx
+++ b/packages/frontend/core/src/modules/app-tabs-header/views/app-tabs-header.tsx
@@ -303,7 +303,8 @@ export const AppTabsHeader = ({
const sidebarWidth = useAtomValue(appSidebarWidthAtom);
const sidebarOpen = useAtomValue(appSidebarOpenAtom);
const sidebarResizing = useAtomValue(appSidebarResizingAtom);
- const isMacosDesktop = environment.isElectron && environment.isMacOs;
+ const isMacosDesktop = BUILD_CONFIG.isElectron && environment.isMacOs;
+ const isWindowsDesktop = BUILD_CONFIG.isElectron && environment.isWindows;
const fullScreen = useIsFullScreen();
const tabsHeaderService = useService(AppTabsHeaderService);
@@ -412,7 +413,7 @@ export const AppTabsHeader = ({
className={clsx(styles.root, className)}
style={style}
data-mode={mode}
- data-is-windows={environment.isElectron && environment.isWindows}
+ data-is-windows={isWindowsDesktop}
>
- {environment.isElectron && environment.isWindows ? (
+ {isWindowsDesktop && (
- ) : null}
+ )}
);
};
diff --git a/packages/frontend/core/src/modules/cloud/services/auth.ts b/packages/frontend/core/src/modules/cloud/services/auth.ts
index df0b4121b..82d5a2bbe 100644
--- a/packages/frontend/core/src/modules/cloud/services/auth.ts
+++ b/packages/frontend/core/src/modules/cloud/services/auth.ts
@@ -91,7 +91,7 @@ export class AuthService extends Service {
email,
// we call it [callbackUrl] instead of [redirect_uri]
// to make it clear the url is used to finish the sign-in process instead of redirect after signed-in
- callbackUrl: `/magic-link?client=${environment.isElectron ? appInfo?.schema : 'web'}`,
+ callbackUrl: `/magic-link?client=${BUILD_CONFIG.isElectron ? appInfo?.schema : 'web'}`,
}),
headers: {
'content-type': 'application/json',
diff --git a/packages/frontend/core/src/modules/cloud/services/fetch.ts b/packages/frontend/core/src/modules/cloud/services/fetch.ts
index 378737532..c37334ecb 100644
--- a/packages/frontend/core/src/modules/cloud/services/fetch.ts
+++ b/packages/frontend/core/src/modules/cloud/services/fetch.ts
@@ -5,7 +5,7 @@ import { fromPromise, Service } from '@toeverything/infra';
import { BackendError, NetworkError } from '../error';
export function getAffineCloudBaseUrl(): string {
- if (environment.isElectron) {
+ if (BUILD_CONFIG.isElectron) {
return BUILD_CONFIG.serverUrlPrefix;
}
const { protocol, hostname, port } = window.location;
diff --git a/packages/frontend/core/src/modules/cloud/stores/subscription.ts b/packages/frontend/core/src/modules/cloud/stores/subscription.ts
index 71024c8b8..bb7a1fe30 100644
--- a/packages/frontend/core/src/modules/cloud/stores/subscription.ts
+++ b/packages/frontend/core/src/modules/cloud/stores/subscription.ts
@@ -28,7 +28,7 @@ const getDefaultSubscriptionSuccessCallbackLink = (
plan === SubscriptionPlan.AI ? '/ai-upgrade-success' : '/upgrade-success';
const urlString = getAffineCloudBaseUrl() + path;
const url = new URL(urlString);
- if (environment.isElectron && appInfo) {
+ if (BUILD_CONFIG.isElectron && appInfo) {
url.searchParams.set('schema', appInfo.schema);
}
return url.toString();
diff --git a/packages/frontend/core/src/modules/explorer/views/nodes/collection/operations.tsx b/packages/frontend/core/src/modules/explorer/views/nodes/collection/operations.tsx
index c745a71e8..9aa6daed6 100644
--- a/packages/frontend/core/src/modules/explorer/views/nodes/collection/operations.tsx
+++ b/packages/frontend/core/src/modules/explorer/views/nodes/collection/operations.tsx
@@ -183,7 +183,7 @@ export const useExplorerCollectionNodeOperations = (
),
},
- ...(environment.isElectron && enableMultiView
+ ...(BUILD_CONFIG.isElectron && enableMultiView
? [
{
index: 99,
diff --git a/packages/frontend/core/src/modules/explorer/views/nodes/doc/operations.tsx b/packages/frontend/core/src/modules/explorer/views/nodes/doc/operations.tsx
index b0492e2a3..fbf1a4b10 100644
--- a/packages/frontend/core/src/modules/explorer/views/nodes/doc/operations.tsx
+++ b/packages/frontend/core/src/modules/explorer/views/nodes/doc/operations.tsx
@@ -192,7 +192,7 @@ export const useExplorerDocNodeOperations = (
),
},
- ...(enableMultiView && environment.isElectron
+ ...(BUILD_CONFIG.isElectron && enableMultiView
? [
{
index: 100,
diff --git a/packages/frontend/core/src/modules/explorer/views/nodes/tag/operations.tsx b/packages/frontend/core/src/modules/explorer/views/nodes/tag/operations.tsx
index cfc415609..64a2a6819 100644
--- a/packages/frontend/core/src/modules/explorer/views/nodes/tag/operations.tsx
+++ b/packages/frontend/core/src/modules/explorer/views/nodes/tag/operations.tsx
@@ -119,7 +119,7 @@ export const useExplorerTagNodeOperations = (
),
},
- ...(enableMultiView && environment.isElectron
+ ...(BUILD_CONFIG.isElectron && enableMultiView
? [
{
index: 100,
diff --git a/packages/frontend/core/src/modules/navigation/entities/navigator.ts b/packages/frontend/core/src/modules/navigation/entities/navigator.ts
index 9426b56c1..3fdfc4216 100644
--- a/packages/frontend/core/src/modules/navigation/entities/navigator.ts
+++ b/packages/frontend/core/src/modules/navigation/entities/navigator.ts
@@ -40,7 +40,7 @@ export class Navigator extends Entity {
);
back() {
- if (!environment.isElectron) {
+ if (!BUILD_CONFIG.isElectron) {
window.history.back();
} else {
this.history$.value.back();
@@ -48,7 +48,7 @@ export class Navigator extends Entity {
}
forward() {
- if (!environment.isElectron) {
+ if (!BUILD_CONFIG.isElectron) {
window.history.forward();
} else {
this.history$.value.forward();
diff --git a/packages/frontend/core/src/modules/navigation/view/navigation-buttons.tsx b/packages/frontend/core/src/modules/navigation/view/navigation-buttons.tsx
index 408363746..c54cfddfb 100644
--- a/packages/frontend/core/src/modules/navigation/view/navigation-buttons.tsx
+++ b/packages/frontend/core/src/modules/navigation/view/navigation-buttons.tsx
@@ -10,6 +10,14 @@ import * as styles from './navigation-buttons.css';
const tooltipSideBottom = { side: 'bottom' as const };
export const NavigationButtons = () => {
+ if (!BUILD_CONFIG.isElectron) {
+ return null;
+ }
+
+ return ;
+};
+
+const ElectronNavigationButtons = () => {
const t = useI18n();
const navigator = useService(NavigatorService).navigator;
@@ -44,10 +52,6 @@ export const NavigationButtons = () => {
};
}, [navigator]);
- if (!environment.isElectron) {
- return null;
- }
-
return (
,
nameKey: 'split-view',
name: t['com.affine.peek-view-controls.open-doc-in-split-view'](),
diff --git a/packages/frontend/core/src/modules/workbench/services/desktop-state-synchronizer.ts b/packages/frontend/core/src/modules/workbench/services/desktop-state-synchronizer.ts
index f7b4cd2a5..35ff87007 100644
--- a/packages/frontend/core/src/modules/workbench/services/desktop-state-synchronizer.ts
+++ b/packages/frontend/core/src/modules/workbench/services/desktop-state-synchronizer.ts
@@ -13,7 +13,7 @@ export class DesktopStateSynchronizer extends Service {
}
startSync = () => {
- if (!environment.isElectron) {
+ if (!BUILD_CONFIG.isElectron) {
return;
}
diff --git a/packages/frontend/core/src/modules/workbench/view/route-container.tsx b/packages/frontend/core/src/modules/workbench/view/route-container.tsx
index 2c38a9660..8a61b7045 100644
--- a/packages/frontend/core/src/modules/workbench/view/route-container.tsx
+++ b/packages/frontend/core/src/modules/workbench/view/route-container.tsx
@@ -54,7 +54,7 @@ export const RouteContainer = () => {
return (
- {viewPosition.isFirst && !environment.isElectron && (
+ {!BUILD_CONFIG.isElectron && viewPosition.isFirst && (
{
viewId={view.id}
className={styles.viewHeaderContainer}
/>
- {viewPosition.isLast && !environment.isElectron && (
+ {!BUILD_CONFIG.isElectron && viewPosition.isLast && (
))
diff --git a/packages/frontend/core/src/modules/workbench/view/sidebar/sidebar-header.tsx b/packages/frontend/core/src/modules/workbench/view/sidebar/sidebar-header.tsx
index e97080db6..9b5fe5583 100644
--- a/packages/frontend/core/src/modules/workbench/view/sidebar/sidebar-header.tsx
+++ b/packages/frontend/core/src/modules/workbench/view/sidebar/sidebar-header.tsx
@@ -44,7 +44,7 @@ export const Header = ({ floating, children, onToggle }: HeaderProps) => {
return (
{children}
- {!environment.isElectron && (
+ {!BUILD_CONFIG.isElectron && (
<>
diff --git a/packages/frontend/core/src/modules/workbench/view/workbench-link.tsx b/packages/frontend/core/src/modules/workbench/view/workbench-link.tsx
index 640d4ca7e..c430ab3ac 100644
--- a/packages/frontend/core/src/modules/workbench/view/workbench-link.tsx
+++ b/packages/frontend/core/src/modules/workbench/view/workbench-link.tsx
@@ -40,7 +40,7 @@ export const WorkbenchLink = forwardRef(
}
const at = (() => {
if (isNewTabTrigger(event)) {
- return event.altKey && enableMultiView && environment.isElectron
+ return BUILD_CONFIG.isElectron && event.altKey && enableMultiView
? 'tail'
: 'new-tab';
}
diff --git a/packages/frontend/core/src/modules/workbench/view/workbench-root.tsx b/packages/frontend/core/src/modules/workbench/view/workbench-root.tsx
index c6cc7cbcc..5db0940d4 100644
--- a/packages/frontend/core/src/modules/workbench/view/workbench-root.tsx
+++ b/packages/frontend/core/src/modules/workbench/view/workbench-root.tsx
@@ -22,7 +22,7 @@ import { ViewIslandRegistryProvider } from './view-islands';
import { ViewRoot } from './view-root';
import * as styles from './workbench-root.css';
-const useAdapter = environment.isElectron
+const useAdapter = BUILD_CONFIG.isElectron
? useBindWorkbenchToDesktopRouter
: useBindWorkbenchToBrowserRouter;
diff --git a/packages/frontend/core/src/modules/workspace-engine/impls/local.ts b/packages/frontend/core/src/modules/workspace-engine/impls/local.ts
index f48e867c2..647c1602a 100644
--- a/packages/frontend/core/src/modules/workspace-engine/impls/local.ts
+++ b/packages/frontend/core/src/modules/workspace-engine/impls/local.ts
@@ -51,7 +51,7 @@ export class LocalWorkspaceFlavourProvider
JSON.stringify(allWorkspaceIDs.filter(x => x !== id))
);
- if (apis && environment.isElectron) {
+ if (BUILD_CONFIG.isElectron && apis) {
await apis.workspace.delete(id);
}
diff --git a/packages/frontend/core/src/pages/auth/common.ts b/packages/frontend/core/src/pages/auth/common.ts
index bfde600e9..32b1a6979 100644
--- a/packages/frontend/core/src/pages/auth/common.ts
+++ b/packages/frontend/core/src/pages/auth/common.ts
@@ -5,5 +5,5 @@ export const supportedClient = z.enum([
'affine',
'affine-canary',
'affine-beta',
- ...(environment.isDebug ? ['affine-dev'] : []),
+ ...(BUILD_CONFIG.debug ? ['affine-dev'] : []),
]);
diff --git a/packages/frontend/core/src/pages/auth/sign-in.tsx b/packages/frontend/core/src/pages/auth/sign-in.tsx
index ae4b0c8f2..eff07bee8 100644
--- a/packages/frontend/core/src/pages/auth/sign-in.tsx
+++ b/packages/frontend/core/src/pages/auth/sign-in.tsx
@@ -1,7 +1,6 @@
import { AffineOtherPageLayout } from '@affine/component/affine-other-page-layout';
import { SignInPageContainer } from '@affine/component/auth-components';
import { AuthService } from '@affine/core/modules/cloud';
-import { appInfo } from '@affine/electron-api';
import { useLiveData, useService } from '@toeverything/infra';
import { useEffect } from 'react';
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
@@ -20,10 +19,6 @@ export const SignIn = () => {
const isLoggedIn = status === 'authenticated' && !isRevalidating;
useEffect(() => {
- if (environment.isElectron && appInfo?.windowName === 'hidden-window') {
- return;
- }
-
if (isLoggedIn) {
const redirectUri = searchParams.get('redirect_uri');
if (redirectUri) {
diff --git a/packages/frontend/core/src/pages/onboarding.tsx b/packages/frontend/core/src/pages/onboarding.tsx
index 1b3883201..bdb42c795 100644
--- a/packages/frontend/core/src/pages/onboarding.tsx
+++ b/packages/frontend/core/src/pages/onboarding.tsx
@@ -11,7 +11,7 @@ import {
import { RouteLogic, useNavigateHelper } from '../hooks/use-navigate-helper';
export const loader = () => {
- if (!environment.isElectron && !appConfigStorage.get('onBoarding')) {
+ if (!BUILD_CONFIG.isElectron && !appConfigStorage.get('onBoarding')) {
// onboarding is off, redirect to index
return redirect('/');
}
@@ -24,7 +24,7 @@ export const Component = () => {
const [, setOnboarding] = useAppConfigStorage('onBoarding');
const openApp = useCallback(() => {
- if (environment.isElectron) {
+ if (BUILD_CONFIG.isElectron) {
assertExists(apis);
apis.ui.handleOpenMainApp().catch(err => {
console.log('failed to open main app', err);
diff --git a/packages/frontend/core/src/pages/workspace/detail-page/detail-page.tsx b/packages/frontend/core/src/pages/workspace/detail-page/detail-page.tsx
index 3cda71e21..4f03ba004 100644
--- a/packages/frontend/core/src/pages/workspace/detail-page/detail-page.tsx
+++ b/packages/frontend/core/src/pages/workspace/detail-page/detail-page.tsx
@@ -204,7 +204,6 @@ const DetailPageImpl = memo(function DetailPageImpl() {
);
const [refCallback, hasScrollTop] = useHasScrollTop();
- const dynamicTopBorder = environment.isElectron;
const openOutlinePanel = useCallback(() => {
workbench.openSidebar();
@@ -219,7 +218,7 @@ const DetailPageImpl = memo(function DetailPageImpl() {
{/* Add a key to force rerender when page changed, to avoid error boundary persisting. */}
diff --git a/packages/frontend/core/src/pages/workspace/detail-page/use-header-responsive.ts b/packages/frontend/core/src/pages/workspace/detail-page/use-header-responsive.ts
index 8e6c6fdca..7cfea0182 100644
--- a/packages/frontend/core/src/pages/workspace/detail-page/use-header-responsive.ts
+++ b/packages/frontend/core/src/pages/workspace/detail-page/use-header-responsive.ts
@@ -20,10 +20,10 @@ export const useDetailPageHeaderResponsive = (availableWidth: number) => {
const hideToday = availableWidth < 300;
const showDivider =
+ !BUILD_CONFIG.isElectron &&
viewPosition.isLast &&
!rightSidebarOpen &&
- !(hidePresent && hideShare) &&
- !environment.isElectron;
+ !(hidePresent && hideShare);
return {
hideShare,
diff --git a/packages/frontend/core/src/pages/workspace/index.tsx b/packages/frontend/core/src/pages/workspace/index.tsx
index 0541a9470..f872c8dab 100644
--- a/packages/frontend/core/src/pages/workspace/index.tsx
+++ b/packages/frontend/core/src/pages/workspace/index.tsx
@@ -99,8 +99,8 @@ export const Component = (): ReactElement => {
if (workspaceNotFound) {
if (
- detailDocRoute /* */ &&
- !environment.isElectron /* only browser has share page */
+ !BUILD_CONFIG.isElectron /* only browser has share page */ &&
+ detailDocRoute
) {
return (
{
);
useEffect(() => {
- if (environment.isElectron) {
+ if (BUILD_CONFIG.isElectron) {
return events?.applicationMenu.openAboutPageInSettingModal(() =>
setOpenSettingModalAtom({
activeTab: 'about',
@@ -120,7 +120,7 @@ export function CurrentWorkspaceModals() {
)}
- {environment.isElectron && }
+ {BUILD_CONFIG.isElectron && }
= {
get stable() {
return {
+ debug: buildFlags.mode === 'development',
distribution: buildFlags.distribution,
+ isDesktopEdition: (
+ ['web', 'desktop', 'admin'] as BuildFlags['distribution'][]
+ ).includes(buildFlags.distribution),
+ isMobileEdition: (['mobile'] as BuildFlags['distribution'][]).includes(
+ buildFlags.distribution
+ ),
+ isElectron: buildFlags.distribution === 'desktop',
+ isWeb: buildFlags.distribution === 'web',
+ isMobileWeb: buildFlags.distribution === 'mobile',
+
+ isSelfHosted: process.env.SELF_HOSTED === 'true',
appBuildType: 'stable' as const,
serverUrlPrefix: 'https://app.affine.pro',
appVersion: packageJson.version,
@@ -87,7 +99,6 @@ export function getRuntimeConfig(buildFlags: BuildFlags): BUILD_CONFIG_TYPE {
}
return {
- isSelfHosted: process.env.SELF_HOSTED === 'true',
...currentBuildPreset,
// environment preset will overwrite current build preset
// this environment variable is for debug proposes only
diff --git a/tools/cli/src/webpack/webpack.config.ts b/tools/cli/src/webpack/webpack.config.ts
index 4ef523fee..01d7f0d1e 100644
--- a/tools/cli/src/webpack/webpack.config.ts
+++ b/tools/cli/src/webpack/webpack.config.ts
@@ -9,7 +9,7 @@ import webpack from 'webpack';
import { merge } from 'webpack-merge';
import { createConfiguration, rootPath, workspaceRoot } from './config.js';
-import { getRuntimeConfig } from './runtime-config.js';
+import { getBuildConfig } from './runtime-config.js';
const DESCRIPTION = `There can be more than Notion and Miro. AFFiNE is a next-gen knowledge base that brings planning, sorting and creating all together.`;
@@ -31,8 +31,8 @@ const gitShortHash = once(() => {
export function createWebpackConfig(cwd: string, flags: BuildFlags) {
console.log('build flags', flags);
- const runtimeConfig = getRuntimeConfig(flags);
- console.log('runtime config', runtimeConfig);
+ const runtimeConfig = getBuildConfig(flags);
+ console.log('BUILD_CONFIG', runtimeConfig);
const config = createConfiguration(cwd, flags, runtimeConfig);
const entry =
typeof flags.entry === 'string' || !flags.entry