mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-27 02:42:25 +08:00
fix(core): do not show open-in-app in mobile web browser (#8694)
This commit is contained in:
@@ -5,8 +5,10 @@ import { Telemetry } from '@affine/core/components/telemetry';
|
|||||||
import { router } from '@affine/core/desktop/router';
|
import { router } from '@affine/core/desktop/router';
|
||||||
import { configureCommonModules } from '@affine/core/modules';
|
import { configureCommonModules } from '@affine/core/modules';
|
||||||
import { I18nProvider } from '@affine/core/modules/i18n';
|
import { I18nProvider } from '@affine/core/modules/i18n';
|
||||||
import { configureOpenInApp } from '@affine/core/modules/open-in-app';
|
import {
|
||||||
import { WebOpenInAppGuard } from '@affine/core/modules/open-in-app/views/open-in-app-guard';
|
configureOpenInApp,
|
||||||
|
OpenInAppGuard,
|
||||||
|
} from '@affine/core/modules/open-in-app';
|
||||||
import { configureLocalStorageStateStorageImpls } from '@affine/core/modules/storage';
|
import { configureLocalStorageStateStorageImpls } from '@affine/core/modules/storage';
|
||||||
import { CustomThemeModifier } from '@affine/core/modules/theme-editor';
|
import { CustomThemeModifier } from '@affine/core/modules/theme-editor';
|
||||||
import { PopupWindowProvider } from '@affine/core/modules/url';
|
import { PopupWindowProvider } from '@affine/core/modules/url';
|
||||||
@@ -78,13 +80,13 @@ export function App() {
|
|||||||
<Telemetry />
|
<Telemetry />
|
||||||
<CustomThemeModifier />
|
<CustomThemeModifier />
|
||||||
<GlobalLoading />
|
<GlobalLoading />
|
||||||
<WebOpenInAppGuard>
|
<OpenInAppGuard>
|
||||||
<RouterProvider
|
<RouterProvider
|
||||||
fallbackElement={<AppFallback key="RouterFallback" />}
|
fallbackElement={<AppFallback key="RouterFallback" />}
|
||||||
router={router}
|
router={router}
|
||||||
future={future}
|
future={future}
|
||||||
/>
|
/>
|
||||||
</WebOpenInAppGuard>
|
</OpenInAppGuard>
|
||||||
</AffineContext>
|
</AffineContext>
|
||||||
</I18nProvider>
|
</I18nProvider>
|
||||||
</CacheProvider>
|
</CacheProvider>
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ export const AppearanceSettings = () => {
|
|||||||
{enableThemeEditor ? <ThemeEditorSetting /> : null}
|
{enableThemeEditor ? <ThemeEditorSetting /> : null}
|
||||||
</SettingWrapper>
|
</SettingWrapper>
|
||||||
|
|
||||||
{BUILD_CONFIG.isWeb ? (
|
{BUILD_CONFIG.isWeb && !environment.isMobile ? (
|
||||||
<SettingWrapper title={t['com.affine.setting.appearance.links']()}>
|
<SettingWrapper title={t['com.affine.setting.appearance.links']()}>
|
||||||
<SettingRow
|
<SettingRow
|
||||||
name={t['com.affine.setting.appearance.open-in-app']()}
|
name={t['com.affine.setting.appearance.open-in-app']()}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { OpenInAppService } from './services';
|
|||||||
|
|
||||||
export * from './services';
|
export * from './services';
|
||||||
export * from './utils';
|
export * from './utils';
|
||||||
|
export * from './views/open-in-app-guard';
|
||||||
|
|
||||||
export const configureOpenInApp = (framework: Framework) => {
|
export const configureOpenInApp = (framework: Framework) => {
|
||||||
framework.service(OpenInAppService, [GlobalState, WorkspacesService]);
|
framework.service(OpenInAppService, [GlobalState, WorkspacesService]);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { assertExists } from '@blocksuite/affine/global/utils';
|
import { assertExists } from '@blocksuite/affine/global/utils';
|
||||||
import { useLiveData, useService } from '@toeverything/infra';
|
import { useLiveData, useService } from '@toeverything/infra';
|
||||||
import { useCallback, useEffect } from 'react';
|
import { Fragment, useCallback, useEffect } from 'react';
|
||||||
|
|
||||||
import { OpenInAppService } from '../services';
|
import { OpenInAppService } from '../services';
|
||||||
import { OpenInAppPage } from './open-in-app-page';
|
import { OpenInAppPage } from './open-in-app-page';
|
||||||
@@ -8,11 +8,7 @@ import { OpenInAppPage } from './open-in-app-page';
|
|||||||
/**
|
/**
|
||||||
* Web only guard to open the URL in desktop app for different conditions
|
* Web only guard to open the URL in desktop app for different conditions
|
||||||
*/
|
*/
|
||||||
export const WebOpenInAppGuard = ({
|
const WebOpenInAppGuard = ({ children }: { children: React.ReactNode }) => {
|
||||||
children,
|
|
||||||
}: {
|
|
||||||
children: React.ReactNode;
|
|
||||||
}) => {
|
|
||||||
assertExists(
|
assertExists(
|
||||||
BUILD_CONFIG.isWeb,
|
BUILD_CONFIG.isWeb,
|
||||||
'WebOpenInAppGuard should only be used in web'
|
'WebOpenInAppGuard should only be used in web'
|
||||||
@@ -36,9 +32,13 @@ export const WebOpenInAppGuard = ({
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return shouldOpenInApp ? (
|
return shouldOpenInApp && !environment.isMobile ? (
|
||||||
<OpenInAppPage openHereClicked={onOpenHere} />
|
<OpenInAppPage openHereClicked={onOpenHere} />
|
||||||
) : (
|
) : (
|
||||||
children
|
children
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const OpenInAppGuard = environment.isMobile
|
||||||
|
? Fragment
|
||||||
|
: WebOpenInAppGuard;
|
||||||
|
|||||||
Reference in New Issue
Block a user