mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-20 03:26:47 +08:00
refactor(core): adjust core struct (#8218)
packages/frontend/core/src hooks -> components/hooks atoms -> components/atoms layouts -> components/layouts providers -> components/providers mixpanel -> @affine/track ~~shared~~ ~~unexpected-application-state~~
This commit is contained in:
@@ -5,6 +5,7 @@ import { AffineContext } from '@affine/component/context';
|
||||
import { GlobalLoading } from '@affine/component/global-loading';
|
||||
import { AppFallback } from '@affine/core/components/affine/app-container';
|
||||
import { WindowsAppControls } from '@affine/core/components/pure/header/windows-app-controls';
|
||||
import { Telemetry } from '@affine/core/components/telemetry';
|
||||
import { configureCommonModules } from '@affine/core/modules';
|
||||
import { configureAppTabsHeaderModule } from '@affine/core/modules/app-tabs-header';
|
||||
import { configureElectronStateStorageImpls } from '@affine/core/modules/storage';
|
||||
@@ -16,11 +17,6 @@ import {
|
||||
configureSqliteWorkspaceEngineStorageProvider,
|
||||
} from '@affine/core/modules/workspace-engine';
|
||||
import { router } from '@affine/core/router';
|
||||
import {
|
||||
performanceLogger,
|
||||
performanceRenderLogger,
|
||||
} from '@affine/core/shared';
|
||||
import { Telemetry } from '@affine/core/telemetry';
|
||||
import createEmotionCache from '@affine/core/utils/create-emotion-cache';
|
||||
import { createI18n, setUpLanguage } from '@affine/i18n';
|
||||
import { CacheProvider } from '@emotion/react';
|
||||
@@ -51,7 +47,6 @@ if (
|
||||
throw new Error('Wrong distribution');
|
||||
}
|
||||
|
||||
const performanceI18nLogger = performanceLogger.namespace('i18n');
|
||||
const cache = createEmotionCache();
|
||||
|
||||
const future = {
|
||||
@@ -59,14 +54,10 @@ const future = {
|
||||
} as const;
|
||||
|
||||
async function loadLanguage() {
|
||||
performanceI18nLogger.info('start');
|
||||
|
||||
const i18n = createI18n();
|
||||
document.documentElement.lang = i18n.language;
|
||||
|
||||
performanceI18nLogger.info('set up');
|
||||
await setUpLanguage(i18n);
|
||||
performanceI18nLogger.info('done');
|
||||
}
|
||||
|
||||
let languageLoadingPromise: Promise<void> | null = null;
|
||||
@@ -88,8 +79,6 @@ window.addEventListener('focus', () => {
|
||||
frameworkProvider.get(LifecycleService).applicationStart();
|
||||
|
||||
export function App() {
|
||||
performanceRenderLogger.debug('App');
|
||||
|
||||
if (!languageLoadingPromise) {
|
||||
languageLoadingPromise = loadLanguage().catch(console.error);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import './setup';
|
||||
import './global.css';
|
||||
|
||||
import { appConfigProxy } from '@affine/core/hooks/use-app-config-storage';
|
||||
import { performanceLogger } from '@affine/core/shared';
|
||||
import { appConfigProxy } from '@affine/core/components/hooks/use-app-config-storage';
|
||||
import { apis, appInfo, events } from '@affine/electron-api';
|
||||
import {
|
||||
init,
|
||||
@@ -21,10 +20,7 @@ import {
|
||||
|
||||
import { App } from './app';
|
||||
|
||||
const performanceMainLogger = performanceLogger.namespace('main');
|
||||
function main() {
|
||||
performanceMainLogger.info('start');
|
||||
|
||||
// load persistent config for electron
|
||||
// TODO(@Peng): should be sync, but it's not necessary for now
|
||||
appConfigProxy
|
||||
@@ -33,12 +29,11 @@ function main() {
|
||||
|
||||
// skip bootstrap setup for desktop onboarding
|
||||
if (
|
||||
appInfo?.windowName === 'onboarding' ||
|
||||
appInfo?.windowName === 'theme-editor'
|
||||
!(
|
||||
appInfo?.windowName === 'onboarding' ||
|
||||
appInfo?.windowName === 'theme-editor'
|
||||
)
|
||||
) {
|
||||
performanceMainLogger.info('skip setup');
|
||||
} else {
|
||||
performanceMainLogger.info('setup start');
|
||||
if (BUILD_CONFIG.debug || window.SENTRY_RELEASE) {
|
||||
// https://docs.sentry.io/platforms/javascript/guides/electron/
|
||||
init({
|
||||
@@ -100,7 +95,6 @@ function main() {
|
||||
apis?.ui.handleWindowResize().catch(console.error);
|
||||
}, 50);
|
||||
window.addEventListener('resize', handleResize);
|
||||
performanceMainLogger.info('setup done');
|
||||
window.addEventListener('dragstart', () => {
|
||||
document.documentElement.dataset.dragging = 'true';
|
||||
});
|
||||
@@ -113,10 +107,8 @@ function main() {
|
||||
}
|
||||
|
||||
function mountApp() {
|
||||
performanceMainLogger.info('import app');
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const root = document.getElementById('app')!;
|
||||
performanceMainLogger.info('render app');
|
||||
createRoot(root).render(
|
||||
<StrictMode>
|
||||
<App />
|
||||
|
||||
@@ -6,7 +6,6 @@ import './setup';
|
||||
import { ThemeProvider } from '@affine/component/theme-provider';
|
||||
import { configureAppTabsHeaderModule } from '@affine/core/modules/app-tabs-header';
|
||||
import { configureElectronStateStorageImpls } from '@affine/core/modules/storage';
|
||||
import { performanceLogger } from '@affine/core/shared';
|
||||
import { apis, events } from '@affine/electron-api';
|
||||
import { createI18n, setUpLanguage } from '@affine/i18n';
|
||||
import {
|
||||
@@ -25,8 +24,6 @@ configureElectronStateStorageImpls(framework);
|
||||
configureAppTabsHeaderModule(framework);
|
||||
const frameworkProvider = framework.provider();
|
||||
|
||||
const logger = performanceLogger.namespace('shell');
|
||||
|
||||
async function loadLanguage() {
|
||||
const i18n = createI18n();
|
||||
document.documentElement.lang = i18n.language;
|
||||
@@ -60,7 +57,6 @@ function mountApp() {
|
||||
if (!root) {
|
||||
throw new Error('Root element not found');
|
||||
}
|
||||
logger.info('render app');
|
||||
createRoot(root).render(
|
||||
<StrictMode>
|
||||
<FrameworkRoot framework={frameworkProvider}>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ShellAppFallback } from '@affine/core/components/affine/app-container';
|
||||
import { useAppSettingHelper } from '@affine/core/hooks/affine/use-app-setting-helper';
|
||||
import { useAppSettingHelper } from '@affine/core/components/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';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user