mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
refactor: improve code
This commit is contained in:
@@ -6,7 +6,7 @@ import './temporary.css';
|
||||
import { Logger } from '@toeverything/pathfinder-logger';
|
||||
import '@fontsource/space-mono';
|
||||
import '@fontsource/poppins';
|
||||
import { printBuildInfo } from '../utils/print-build-info';
|
||||
import '../utils/print-build-info';
|
||||
import ProviderComposer from '@/components/provider-composer';
|
||||
import type { PropsWithChildren, ReactElement, ReactNode } from 'react';
|
||||
import type { NextPage } from 'next';
|
||||
@@ -17,6 +17,7 @@ import { useRouter } from 'next/router';
|
||||
import { useEffect } from 'react';
|
||||
import { useAppState } from '@/providers/app-state-provider';
|
||||
import { PageLoading } from '@/components/loading';
|
||||
|
||||
const ThemeProvider = dynamic(() => import('@/providers/themeProvider'), {
|
||||
ssr: false,
|
||||
});
|
||||
@@ -34,9 +35,7 @@ type AppPropsWithLayout = AppProps & {
|
||||
|
||||
const App = ({ Component, pageProps }: AppPropsWithLayout) => {
|
||||
const getLayout = Component.getLayout || (page => page);
|
||||
useEffect(() => {
|
||||
printBuildInfo();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Logger />
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
declare global {
|
||||
interface Window {
|
||||
CLIENT_APP?: boolean;
|
||||
__editoVersion?: string;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,18 +12,7 @@ type Config = {
|
||||
|
||||
const nextConfig = getConfig();
|
||||
const publicRuntimeConfig: Config = nextConfig.publicRuntimeConfig;
|
||||
const setAffineAppProperties = () => {
|
||||
const input = document.createElement('input');
|
||||
const id = 'editor-version';
|
||||
if (document.getElementById(id)) {
|
||||
return;
|
||||
}
|
||||
input.value = publicRuntimeConfig.EDITOR_VERSION;
|
||||
input.type = 'hidden';
|
||||
input.id = id;
|
||||
input.setAttribute('data-testid', 'editor-version');
|
||||
document.body.appendChild(input);
|
||||
};
|
||||
|
||||
const printBuildInfo = () => {
|
||||
console.group('Build info');
|
||||
console.log('Project:', publicRuntimeConfig.PROJECT_NAME);
|
||||
@@ -47,8 +36,14 @@ const printBuildInfo = () => {
|
||||
`https://github.com/toeverything/AFFiNE/tree/${publicRuntimeConfig.COMMIT_HASH}`
|
||||
);
|
||||
console.groupEnd();
|
||||
|
||||
setAffineAppProperties();
|
||||
};
|
||||
|
||||
export { printBuildInfo };
|
||||
function setWindowEditorVersion() {
|
||||
// when it is not SSR
|
||||
if (typeof window !== 'undefined') {
|
||||
window.__editoVersion = publicRuntimeConfig.EDITOR_VERSION;
|
||||
}
|
||||
}
|
||||
printBuildInfo();
|
||||
setWindowEditorVersion();
|
||||
export {};
|
||||
|
||||
Reference in New Issue
Block a user