mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-18 10:36:22 +08:00
refactor: avoid runtime config object (#8202)
This commit is contained in:
@@ -50,7 +50,7 @@ function OAuthProvider({ provider }: { provider: OAuthProviderType }) {
|
||||
|
||||
const onClick = useCallback(() => {
|
||||
let oauthUrl =
|
||||
(environment.isElectron ? runtimeConfig.serverUrlPrefix : '') +
|
||||
(environment.isElectron ? BUILD_CONFIG.serverUrlPrefix : '') +
|
||||
`/oauth/login?provider=${provider}`;
|
||||
|
||||
if (environment.isElectron) {
|
||||
|
||||
@@ -48,7 +48,7 @@ interface NameWorkspaceContentProps extends ConfirmModalProps {
|
||||
) => void;
|
||||
}
|
||||
|
||||
const shouldEnableCloud = !runtimeConfig.allowLocalWorkspace;
|
||||
const shouldEnableCloud = !BUILD_CONFIG.allowLocalWorkspace;
|
||||
|
||||
const NameWorkspaceContent = ({
|
||||
loading,
|
||||
@@ -159,7 +159,7 @@ const NameWorkspaceContent = ({
|
||||
{shouldEnableCloud ? (
|
||||
<a
|
||||
className={styles.cloudTips}
|
||||
href={runtimeConfig.downloadUrl}
|
||||
href={BUILD_CONFIG.downloadUrl}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
@@ -229,7 +229,7 @@ export const CreateWorkspaceModal = ({
|
||||
|
||||
// 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,
|
||||
|
||||
@@ -24,7 +24,7 @@ export const IssueFeedbackModal = () => {
|
||||
onOpenChange={setOpen}
|
||||
description={t['com.affine.issue-feedback.description']()}
|
||||
cancelText={t['com.affine.issue-feedback.cancel']()}
|
||||
to={`${runtimeConfig.githubUrl}/issues/new/choose`}
|
||||
to={`${BUILD_CONFIG.githubUrl}/issues/new/choose`}
|
||||
confirmText={t['com.affine.issue-feedback.confirm']()}
|
||||
confirmButtonOptions={{
|
||||
variant: 'primary',
|
||||
|
||||
+4
-4
@@ -21,7 +21,7 @@ export const AboutAffine = () => {
|
||||
const t = useI18n();
|
||||
const { appSettings, updateSettings } = useAppSettingHelper();
|
||||
const { toggleAutoCheck, toggleAutoDownload } = useAppUpdater();
|
||||
const channel = runtimeConfig.appBuildType;
|
||||
const channel = BUILD_CONFIG.appBuildType;
|
||||
const appIcon = appIconMap[channel];
|
||||
const appName = appNames[channel];
|
||||
|
||||
@@ -63,14 +63,14 @@ export const AboutAffine = () => {
|
||||
<SettingWrapper title={t['com.affine.aboutAFFiNE.version.title']()}>
|
||||
<SettingRow
|
||||
name={appName}
|
||||
desc={runtimeConfig.appVersion}
|
||||
desc={BUILD_CONFIG.appVersion}
|
||||
className={styles.appImageRow}
|
||||
>
|
||||
<img src={appIcon} alt={appName} width={56} height={56} />
|
||||
</SettingRow>
|
||||
<SettingRow
|
||||
name={t['com.affine.aboutAFFiNE.version.editor.title']()}
|
||||
desc={runtimeConfig.editorVersion}
|
||||
desc={BUILD_CONFIG.editorVersion}
|
||||
/>
|
||||
{environment.isElectron ? (
|
||||
<>
|
||||
@@ -100,7 +100,7 @@ export const AboutAffine = () => {
|
||||
desc={t['com.affine.aboutAFFiNE.changelog.description']()}
|
||||
style={{ cursor: 'pointer' }}
|
||||
onClick={() => {
|
||||
popupWindow(runtimeConfig.changelogUrl);
|
||||
popupWindow(BUILD_CONFIG.changelogUrl);
|
||||
}}
|
||||
>
|
||||
<ArrowRightSmallIcon />
|
||||
|
||||
+3
-3
@@ -98,7 +98,7 @@ export const AppearanceSettings = () => {
|
||||
/>
|
||||
</SettingRow>
|
||||
) : null}
|
||||
{runtimeConfig.enableNewSettingUnstableApi && environment.isElectron ? (
|
||||
{BUILD_CONFIG.enableNewSettingUnstableApi && environment.isElectron ? (
|
||||
<SettingRow
|
||||
name={t['com.affine.appearanceSettings.windowFrame.title']()}
|
||||
desc={t['com.affine.appearanceSettings.windowFrame.description']()}
|
||||
@@ -118,11 +118,11 @@ export const AppearanceSettings = () => {
|
||||
/>
|
||||
</SettingRow>
|
||||
) : null}
|
||||
{runtimeConfig.enableThemeEditor ? <ThemeEditorSetting /> : null}
|
||||
{BUILD_CONFIG.enableThemeEditor ? <ThemeEditorSetting /> : null}
|
||||
</SettingWrapper>
|
||||
{/* // TODO(@JimmFly): remove Page component when stable release */}
|
||||
<Page />
|
||||
{runtimeConfig.enableNewSettingUnstableApi ? (
|
||||
{BUILD_CONFIG.enableNewSettingUnstableApi ? (
|
||||
<SettingWrapper title={t['com.affine.appearanceSettings.date.title']()}>
|
||||
<SettingRow
|
||||
name={t['com.affine.appearanceSettings.dateFormat.title']()}
|
||||
|
||||
+1
-1
@@ -107,7 +107,7 @@ export const useGeneralSettingList = (): GeneralSettingList => {
|
||||
}
|
||||
}
|
||||
|
||||
if (runtimeConfig.enableExperimentalFeature) {
|
||||
if (BUILD_CONFIG.enableExperimentalFeature) {
|
||||
settings.push({
|
||||
key: 'experimental-features',
|
||||
title: t['com.affine.settings.workspace.experimental-features'](),
|
||||
|
||||
@@ -24,7 +24,7 @@ export const StarAFFiNEModal = () => {
|
||||
onOpenChange={setOpen}
|
||||
description={t['com.affine.star-affine.description']()}
|
||||
cancelText={t['com.affine.star-affine.cancel']()}
|
||||
to={runtimeConfig.githubUrl}
|
||||
to={BUILD_CONFIG.githubUrl}
|
||||
confirmButtonOptions={{
|
||||
variant: 'primary',
|
||||
}}
|
||||
|
||||
+6
-6
@@ -89,22 +89,22 @@ const BlockSuiteEditorImpl = ({
|
||||
|
||||
// provide image proxy endpoint to blocksuite
|
||||
editor.host?.std.clipboard.use(
|
||||
customImageProxyMiddleware(runtimeConfig.imageProxyUrl)
|
||||
customImageProxyMiddleware(BUILD_CONFIG.imageProxyUrl)
|
||||
);
|
||||
ImageBlockService.setImageProxyURL(runtimeConfig.imageProxyUrl);
|
||||
ImageBlockService.setImageProxyURL(BUILD_CONFIG.imageProxyUrl);
|
||||
|
||||
// provide link preview endpoint to blocksuite
|
||||
BookmarkBlockService.setLinkPreviewEndpoint(
|
||||
runtimeConfig.linkPreviewUrl
|
||||
BUILD_CONFIG.linkPreviewUrl
|
||||
);
|
||||
EmbedGithubBlockService.setLinkPreviewEndpoint(
|
||||
runtimeConfig.linkPreviewUrl
|
||||
BUILD_CONFIG.linkPreviewUrl
|
||||
);
|
||||
EmbedYoutubeBlockService.setLinkPreviewEndpoint(
|
||||
runtimeConfig.linkPreviewUrl
|
||||
BUILD_CONFIG.linkPreviewUrl
|
||||
);
|
||||
EmbedLoomBlockService.setLinkPreviewEndpoint(
|
||||
runtimeConfig.linkPreviewUrl
|
||||
BUILD_CONFIG.linkPreviewUrl
|
||||
);
|
||||
|
||||
return editor.host?.updateComplete;
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import { AffineCanvasTextFonts, FontConfigExtension } from '@blocksuite/blocks';
|
||||
|
||||
export function getFontConfigExtension() {
|
||||
return FontConfigExtension(
|
||||
runtimeConfig.isSelfHosted
|
||||
BUILD_CONFIG.isSelfHosted
|
||||
? AffineCanvasTextFonts.map(font => ({
|
||||
...font,
|
||||
// self-hosted fonts are served from /assets
|
||||
|
||||
@@ -304,16 +304,13 @@ export const PageHeaderMenuButton = ({
|
||||
)}
|
||||
|
||||
<MenuSeparator />
|
||||
|
||||
{runtimeConfig.enableInfoModal && (
|
||||
<MenuItem
|
||||
prefixIcon={<InformationIcon />}
|
||||
data-testid="editor-option-menu-info"
|
||||
onSelect={openInfoModal}
|
||||
>
|
||||
{t['com.affine.page-properties.page-info.view']()}
|
||||
</MenuItem>
|
||||
)}
|
||||
<MenuItem
|
||||
prefixIcon={<InformationIcon />}
|
||||
data-testid="editor-option-menu-info"
|
||||
onSelect={openInfoModal}
|
||||
>
|
||||
{t['com.affine.page-properties.page-info.view']()}
|
||||
</MenuItem>
|
||||
{currentMode === 'page' ? (
|
||||
<MenuItem
|
||||
prefixIcon={<TocIcon />}
|
||||
|
||||
@@ -173,11 +173,9 @@ export const PageOperationCell = ({
|
||||
? t['com.affine.favoritePageOperation.remove']()
|
||||
: t['com.affine.favoritePageOperation.add']()}
|
||||
</MenuItem>
|
||||
{runtimeConfig.enableInfoModal ? (
|
||||
<MenuItem onClick={onOpenInfoModal} prefixIcon={<InformationIcon />}>
|
||||
{t['com.affine.page-properties.page-info.view']()}
|
||||
</MenuItem>
|
||||
) : null}
|
||||
<MenuItem onClick={onOpenInfoModal} prefixIcon={<InformationIcon />}>
|
||||
{t['com.affine.page-properties.page-info.view']()}
|
||||
</MenuItem>
|
||||
|
||||
<MenuItem onClick={onOpenInNewTab} prefixIcon={<OpenInNewIcon />}>
|
||||
{t['com.affine.workbench.tab.page-menu-open']()}
|
||||
|
||||
@@ -77,7 +77,7 @@ export const HelpIsland = () => {
|
||||
<StyledIconWrapper
|
||||
data-testid="right-bottom-change-log-icon"
|
||||
onClick={() => {
|
||||
popupWindow(runtimeConfig.changelogUrl);
|
||||
popupWindow(BUILD_CONFIG.changelogUrl);
|
||||
}}
|
||||
>
|
||||
<NewIcon />
|
||||
|
||||
@@ -176,7 +176,7 @@ export const RootAppSidebar = (): ReactElement => {
|
||||
</SidebarContainer>
|
||||
<SidebarScrollableContainer>
|
||||
<ExplorerFavorites />
|
||||
{runtimeConfig.enableOrganize && <ExplorerOrganize />}
|
||||
<ExplorerOrganize />
|
||||
<ExplorerMigrationFavorites />
|
||||
<ExplorerCollections />
|
||||
<ExplorerTags />
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ export const AddWorkspace = ({
|
||||
className={styles.ItemContainer}
|
||||
>
|
||||
<div className={styles.ItemText}>
|
||||
{runtimeConfig.allowLocalWorkspace
|
||||
{BUILD_CONFIG.allowLocalWorkspace
|
||||
? t['com.affine.workspaceList.addWorkspace.create']()
|
||||
: t['com.affine.workspaceList.addWorkspace.create-cloud']()}
|
||||
</div>
|
||||
|
||||
+1
-1
@@ -88,7 +88,7 @@ const UserWithWorkspaceListInner = ({
|
||||
}, [setOpenSignIn]);
|
||||
|
||||
const onNewWorkspace = useCallback(() => {
|
||||
if (!isAuthenticated && !runtimeConfig.allowLocalWorkspace) {
|
||||
if (!isAuthenticated && !BUILD_CONFIG.allowLocalWorkspace) {
|
||||
return openSignInModal();
|
||||
}
|
||||
track.$.navigationPanel.workspaceList.createWorkspace();
|
||||
|
||||
Reference in New Issue
Block a user