refactor: avoid runtime config object (#8202)

This commit is contained in:
forehalo
2024-09-13 07:27:11 +00:00
parent c76b4d70b0
commit 25969a34e8
45 changed files with 117 additions and 156 deletions
@@ -6,7 +6,7 @@ import { BackendError, NetworkError } from '../error';
export function getAffineCloudBaseUrl(): string {
if (environment.isElectron) {
return runtimeConfig.serverUrlPrefix;
return BUILD_CONFIG.serverUrlPrefix;
}
const { protocol, hostname, port } = window.location;
return `${protocol}//${hostname}${port ? `:${port}` : ''}`;
@@ -35,7 +35,7 @@ interface NameWorkspaceContentProps extends ConfirmModalProps {
) => void;
}
const shouldEnableCloud = !runtimeConfig.allowLocalWorkspace;
const shouldEnableCloud = !BUILD_CONFIG.allowLocalWorkspace;
const NameWorkspaceContent = ({
loading,
@@ -146,7 +146,7 @@ const NameWorkspaceContent = ({
{shouldEnableCloud ? (
<a
className={styles.cloudTips}
href={runtimeConfig.downloadUrl}
href={BUILD_CONFIG.downloadUrl}
target="_blank"
rel="noreferrer"
>
@@ -213,7 +213,7 @@ const CreateWorkspaceDialog = () => {
// this will be the last step for web for now
// fix me later
if (runtimeConfig.enablePreloading) {
if (BUILD_CONFIG.enablePreloading) {
const { meta, defaultDocId } = await buildShowcaseWorkspace(
workspacesService,
workspaceFlavour,
@@ -154,21 +154,17 @@ export const useExplorerDocNodeOperations = (
/>
),
},
...(runtimeConfig.enableInfoModal
? [
{
index: 50,
view: (
<MenuItem
prefixIcon={<InformationIcon />}
onClick={handleOpenInfoModal}
>
{t['com.affine.page-properties.page-info.view']()}
</MenuItem>
),
},
]
: []),
{
index: 50,
view: (
<MenuItem
prefixIcon={<InformationIcon />}
onClick={handleOpenInfoModal}
>
{t['com.affine.page-properties.page-info.view']()}
</MenuItem>
),
},
{
index: 99,
view: (
@@ -11,7 +11,7 @@ export const useCustomTheme = (target: HTMLElement) => {
const { resolvedTheme } = useTheme();
useEffect(() => {
if (!runtimeConfig.enableThemeEditor) return;
if (!BUILD_CONFIG.enableThemeEditor) return;
if (_provided) return;
_provided = true;
@@ -36,7 +36,7 @@ export class UserDBDocServer implements DocServer {
await this.socket.emitWithAck('space:join', {
spaceType: 'userspace',
spaceId: this.userId,
clientVersion: runtimeConfig.appVersion,
clientVersion: BUILD_CONFIG.appVersion,
});
}
@@ -166,7 +166,7 @@ export class CloudAwarenessConnection implements AwarenessConnection {
spaceType: 'workspace',
spaceId: this.workspaceId,
docId: this.workspaceId,
clientVersion: runtimeConfig.appVersion,
clientVersion: BUILD_CONFIG.appVersion,
},
(res: any) => {
logger.debug('awareness handshake finished', res);
@@ -37,7 +37,7 @@ export class CloudDocEngineServer implements DocServer {
await this.socket.emitWithAck('space:join', {
spaceType: 'workspace',
spaceId: this.workspaceId,
clientVersion: runtimeConfig.appVersion,
clientVersion: BUILD_CONFIG.appVersion,
});
}