mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-11 22:18:54 +08:00
fix(env): is mobile flag (#8005)
only 'mobile' entry has isMobile = true flag
This commit is contained in:
@@ -16,7 +16,7 @@ export const AppContainer = (props: WorkspaceRootProps) => {
|
||||
useNoisyBackground={appSettings.enableNoisyBackground}
|
||||
useBlurBackground={
|
||||
appSettings.enableBlurBackground &&
|
||||
environment.isDesktop &&
|
||||
environment.isElectron &&
|
||||
environment.isMacOs
|
||||
}
|
||||
{...props}
|
||||
|
||||
@@ -57,7 +57,7 @@ function OAuthProvider({ provider }: { provider: OAuthProviderType }) {
|
||||
try {
|
||||
setIsConnecting(true);
|
||||
const url = await authService.oauthPreflight(provider);
|
||||
if (environment.isDesktop) {
|
||||
if (environment.isElectron) {
|
||||
await apis?.ui.openExternal(url);
|
||||
} else {
|
||||
popupWindow(url);
|
||||
|
||||
@@ -122,7 +122,7 @@ const useSendEmail = (emailType: AuthPanelProps<'sendEmail'>['emailType']) => {
|
||||
return trigger({
|
||||
email,
|
||||
callbackUrl: `/auth/${callbackUrl}?isClient=${
|
||||
environment.isDesktop ? 'true' : 'false'
|
||||
environment.isElectron ? 'true' : 'false'
|
||||
}`,
|
||||
});
|
||||
},
|
||||
|
||||
@@ -14,7 +14,7 @@ type Challenge = {
|
||||
};
|
||||
|
||||
const challengeFetcher = async (url: string) => {
|
||||
if (!environment.isDesktop) {
|
||||
if (!environment.isElectron) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ const challengeFetcher = async (url: string) => {
|
||||
};
|
||||
|
||||
const generateChallengeResponse = async (challenge: string) => {
|
||||
if (!environment.isDesktop) {
|
||||
if (!environment.isElectron) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ export const Captcha = () => {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (environment.isDesktop) {
|
||||
if (environment.isElectron) {
|
||||
if (response) {
|
||||
return <div className={style.captchaWrapper}>Making Challenge</div>;
|
||||
} else {
|
||||
@@ -87,7 +87,7 @@ export const useCaptcha = (): [string | undefined, string?] => {
|
||||
useEffect(() => {
|
||||
if (
|
||||
hasCaptchaFeature &&
|
||||
environment.isDesktop &&
|
||||
environment.isElectron &&
|
||||
challenge?.challenge &&
|
||||
prevChallenge.current !== challenge.challenge
|
||||
) {
|
||||
@@ -104,7 +104,7 @@ export const useCaptcha = (): [string | undefined, string?] => {
|
||||
return ['XXXX.DUMMY.TOKEN.XXXX'];
|
||||
}
|
||||
|
||||
if (environment.isDesktop) {
|
||||
if (environment.isElectron) {
|
||||
if (response) {
|
||||
return [response, challenge?.challenge];
|
||||
} else {
|
||||
|
||||
@@ -43,7 +43,7 @@ export const Onboarding = ({ onOpenApp }: OnboardingProps) => {
|
||||
return (
|
||||
<div
|
||||
className={styles.onboarding}
|
||||
data-is-desktop={environment.isDesktop}
|
||||
data-is-desktop={environment.isElectron}
|
||||
data-is-window={!!status.activeId || !!status.unfoldingId}
|
||||
>
|
||||
<div className={styles.offsetOrigin}>
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@ export const AboutAffine = () => {
|
||||
name={t['com.affine.aboutAFFiNE.version.editor.title']()}
|
||||
desc={runtimeConfig.editorVersion}
|
||||
/>
|
||||
{environment.isDesktop ? (
|
||||
{environment.isElectron ? (
|
||||
<>
|
||||
<UpdateCheckSection />
|
||||
<SettingRow
|
||||
|
||||
+3
-3
@@ -85,7 +85,7 @@ export const AppearanceSettings = () => {
|
||||
<LanguageMenu />
|
||||
</div>
|
||||
</SettingRow>
|
||||
{environment.isDesktop ? (
|
||||
{environment.isElectron ? (
|
||||
<SettingRow
|
||||
name={t['com.affine.appearanceSettings.clientBorder.title']()}
|
||||
desc={t['com.affine.appearanceSettings.clientBorder.description']()}
|
||||
@@ -97,7 +97,7 @@ export const AppearanceSettings = () => {
|
||||
/>
|
||||
</SettingRow>
|
||||
) : null}
|
||||
{runtimeConfig.enableNewSettingUnstableApi && environment.isDesktop ? (
|
||||
{runtimeConfig.enableNewSettingUnstableApi && environment.isElectron ? (
|
||||
<SettingRow
|
||||
name={t['com.affine.appearanceSettings.windowFrame.title']()}
|
||||
desc={t['com.affine.appearanceSettings.windowFrame.description']()}
|
||||
@@ -141,7 +141,7 @@ export const AppearanceSettings = () => {
|
||||
</SettingWrapper>
|
||||
) : null}
|
||||
|
||||
{environment.isDesktop ? (
|
||||
{environment.isElectron ? (
|
||||
<SettingWrapper
|
||||
title={t['com.affine.appearanceSettings.sidebar.title']()}
|
||||
>
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ export const ThemeEditorSetting = () => {
|
||||
const modified = useLiveData(themeEditor.modified$);
|
||||
|
||||
const open = useCallback(() => {
|
||||
if (environment.isDesktop) {
|
||||
if (environment.isElectron) {
|
||||
apis?.ui.openThemeEditor().catch(console.error);
|
||||
} else {
|
||||
popupWindow('/theme-editor');
|
||||
|
||||
+2
-2
@@ -85,7 +85,7 @@ const FontFamilySettings = () => {
|
||||
|
||||
const radioItems = useMemo(() => {
|
||||
const items = getBaseFontStyleOptions(t);
|
||||
if (!environment.isDesktop) return items;
|
||||
if (!environment.isElectron) return items;
|
||||
|
||||
// resolve custom fonts
|
||||
const customOption = fontStyleOptions.find(opt => opt.key === 'Custom');
|
||||
@@ -274,7 +274,7 @@ const CustomFontFamilySettings = () => {
|
||||
},
|
||||
[editorSettingService.editorSetting]
|
||||
);
|
||||
if (settings.fontFamily !== 'Custom' || !environment.isDesktop) {
|
||||
if (settings.fontFamily !== 'Custom' || !environment.isElectron) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ export const WorkspaceSettingDetail = ({
|
||||
<EnableCloudPanel />
|
||||
<MembersPanel />
|
||||
</SettingWrapper>
|
||||
{environment.isDesktop && (
|
||||
{environment.isElectron && (
|
||||
<SettingWrapper title={t['Storage and Export']()}>
|
||||
<ExportPanel
|
||||
workspace={workspace}
|
||||
|
||||
+1
-1
@@ -151,7 +151,7 @@ export const AFFiNESharePage = (props: ShareMenuProps) => {
|
||||
}
|
||||
}, [shareInfoService, t]);
|
||||
|
||||
const isMac = environment.isBrowser && environment.isMacOs;
|
||||
const isMac = environment.isMacOs;
|
||||
|
||||
const { onClickCopyLink } = useSharingUrl({
|
||||
workspaceId,
|
||||
|
||||
@@ -49,7 +49,7 @@ const SubscriptionChangedNotifyFooter = ({
|
||||
);
|
||||
};
|
||||
|
||||
const isDesktop = environment.isDesktop;
|
||||
const isDesktop = environment.isElectron;
|
||||
export const useUpgradeNotify = () => {
|
||||
const t = useI18n();
|
||||
const prevNotifyIdRef = useRef<string | number | null>(null);
|
||||
|
||||
@@ -2,7 +2,7 @@ import { atom } from 'jotai';
|
||||
import { atomWithStorage } from 'jotai/utils';
|
||||
|
||||
export const APP_SIDEBAR_OPEN = 'app-sidebar-open';
|
||||
export const isMobile = window.innerWidth < 768 && !environment.isDesktop;
|
||||
export const isMobile = window.innerWidth < 768 && !environment.isElectron;
|
||||
|
||||
export const appSidebarOpenAtom = atomWithStorage(APP_SIDEBAR_OPEN, !isMobile);
|
||||
export const appSidebarFloatingAtom = atom(isMobile);
|
||||
|
||||
@@ -49,7 +49,7 @@ export function AppSidebar({
|
||||
|
||||
useEffect(() => {
|
||||
// do not float app sidebar on desktop
|
||||
if (environment.isDesktop) {
|
||||
if (environment.isElectron) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -79,8 +79,8 @@ export function AppSidebar({
|
||||
};
|
||||
}, [open, setFloating, setOpen, width]);
|
||||
|
||||
const hasRightBorder = !environment.isDesktop && !clientBorder;
|
||||
const isMacosDesktop = environment.isDesktop && environment.isMacOs;
|
||||
const hasRightBorder = !environment.isElectron && !clientBorder;
|
||||
const isMacosDesktop = environment.isElectron && environment.isMacOs;
|
||||
return (
|
||||
<>
|
||||
<ResizePanel
|
||||
@@ -105,7 +105,7 @@ export function AppSidebar({
|
||||
data-client-border={clientBorder}
|
||||
>
|
||||
<nav className={navStyle} data-testid="app-sidebar">
|
||||
{!environment.isDesktop && <SidebarHeader />}
|
||||
{!environment.isElectron && <SidebarHeader />}
|
||||
<div className={navBodyStyle} data-testid="sliderBar-inner">
|
||||
{children}
|
||||
</div>
|
||||
|
||||
@@ -13,7 +13,7 @@ interface QuickSearchInputProps extends HTMLAttributes<HTMLDivElement> {
|
||||
// Although it is called an input, it is actually a button.
|
||||
export function QuickSearchInput({ onClick, ...props }: QuickSearchInputProps) {
|
||||
const t = useI18n();
|
||||
const isMac = environment.isBrowser && environment.isMacOs;
|
||||
const isMac = environment.isMacOs;
|
||||
|
||||
return (
|
||||
<div
|
||||
|
||||
@@ -206,7 +206,7 @@ export const PageHeaderMenuButton = ({
|
||||
setEditing(!isEditing);
|
||||
}, [isEditing, page.id, page.readonly, setDocReadonly]);
|
||||
|
||||
const isMobile = environment.isBrowser && environment.isMobile;
|
||||
const isMobile = environment.isMobileEdition;
|
||||
const mobileEditMenuItem = (
|
||||
<MenuItem
|
||||
prefixIcon={isEditing ? <SaveIcon /> : <EditIcon />}
|
||||
@@ -293,7 +293,7 @@ export const PageHeaderMenuButton = ({
|
||||
{t['com.affine.workbench.tab.page-menu-open']()}
|
||||
</MenuItem>
|
||||
|
||||
{environment.isDesktop && (
|
||||
{environment.isElectron && (
|
||||
<MenuItem
|
||||
prefixIcon={<SplitViewIcon />}
|
||||
data-testid="editor-option-menu-open-in-split-new"
|
||||
|
||||
@@ -182,7 +182,7 @@ export const PageOperationCell = ({
|
||||
{t['com.affine.workbench.tab.page-menu-open']()}
|
||||
</MenuItem>
|
||||
|
||||
{environment.isDesktop && enableSplitView ? (
|
||||
{environment.isElectron && enableSplitView ? (
|
||||
<MenuItem onClick={onOpenInSplitView} prefixIcon={<SplitViewIcon />}>
|
||||
{t['com.affine.workbench.split-view.page-menu-open']()}
|
||||
</MenuItem>
|
||||
|
||||
@@ -156,7 +156,7 @@ export const CollectionOperations = ({
|
||||
name: t['com.affine.workbench.tab.page-menu-open'](),
|
||||
click: openCollectionNewTab,
|
||||
},
|
||||
...(enableMultiView && environment.isDesktop
|
||||
...(enableMultiView && environment.isElectron
|
||||
? [
|
||||
{
|
||||
icon: <SplitViewIcon />,
|
||||
|
||||
@@ -29,7 +29,7 @@ const DEFAULT_SHOW_LIST: IslandItemNames[] = [
|
||||
const DESKTOP_SHOW_LIST: IslandItemNames[] = [...DEFAULT_SHOW_LIST];
|
||||
type IslandItemNames = 'whatNew' | 'contact' | 'shortcuts';
|
||||
|
||||
const showList = environment.isDesktop ? DESKTOP_SHOW_LIST : DEFAULT_SHOW_LIST;
|
||||
const showList = environment.isElectron ? DESKTOP_SHOW_LIST : DEFAULT_SHOW_LIST;
|
||||
|
||||
export const HelpIsland = () => {
|
||||
const { globalContextService } = useServices({
|
||||
|
||||
@@ -112,7 +112,7 @@ export const RootAppSidebar = (): ReactElement => {
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (environment.isDesktop) {
|
||||
if (environment.isElectron) {
|
||||
return events?.applicationMenu.onNewPageAction(() => {
|
||||
apis?.ui
|
||||
.isActiveTab()
|
||||
@@ -206,7 +206,7 @@ export const RootAppSidebar = (): ReactElement => {
|
||||
</div>
|
||||
</SidebarScrollableContainer>
|
||||
<SidebarContainer>
|
||||
{environment.isDesktop ? <UpdaterButton /> : <AppDownloadButton />}
|
||||
{environment.isElectron ? <UpdaterButton /> : <AppDownloadButton />}
|
||||
</SidebarContainer>
|
||||
</AppSidebar>
|
||||
);
|
||||
|
||||
@@ -12,19 +12,15 @@ import { AuthService } from '../modules/cloud';
|
||||
const minimumChromeVersion = 106;
|
||||
|
||||
const shouldShowWarning = (() => {
|
||||
if (environment.isDesktop) {
|
||||
if (environment.isElectron) {
|
||||
// even though desktop has compatibility issues,
|
||||
// we don't want to show the warning
|
||||
return false;
|
||||
}
|
||||
if (!environment.isBrowser) {
|
||||
// disable in SSR
|
||||
return false;
|
||||
}
|
||||
if (environment.isMobile) {
|
||||
return true;
|
||||
}
|
||||
if (environment.isChrome) {
|
||||
if (environment.isChrome && environment.chromeVersion) {
|
||||
return environment.chromeVersion < minimumChromeVersion;
|
||||
}
|
||||
return false;
|
||||
@@ -32,14 +28,14 @@ const shouldShowWarning = (() => {
|
||||
|
||||
const OSWarningMessage = () => {
|
||||
const t = useI18n();
|
||||
const notChrome = environment.isBrowser && !environment.isChrome;
|
||||
const notChrome = !environment.isChrome;
|
||||
const notGoodVersion =
|
||||
environment.isBrowser &&
|
||||
environment.isChrome &&
|
||||
environment.chromeVersion &&
|
||||
environment.chromeVersion < minimumChromeVersion;
|
||||
|
||||
// TODO(@L-Sun): remove this message when mobile version is able to edit.
|
||||
if ('isMobile' in environment && environment.isMobile) {
|
||||
if (environment.isMobile) {
|
||||
return <span>{t['com.affine.top-tip.mobile']()}</span>;
|
||||
}
|
||||
|
||||
@@ -80,7 +76,7 @@ export const TopTip = ({
|
||||
|
||||
if (
|
||||
showLocalDemoTips &&
|
||||
!environment.isDesktop &&
|
||||
!environment.isElectron &&
|
||||
workspace.flavour === WorkspaceFlavour.LOCAL
|
||||
) {
|
||||
return (
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ export const AddWorkspace = ({
|
||||
|
||||
return (
|
||||
<div>
|
||||
{environment.isDesktop ? (
|
||||
{environment.isElectron ? (
|
||||
<MenuItem
|
||||
block={true}
|
||||
prefixIcon={<ImportIcon />}
|
||||
|
||||
@@ -60,7 +60,7 @@ const UnSyncWorkspaceStatus = () => {
|
||||
const LocalWorkspaceStatus = () => {
|
||||
return (
|
||||
<>
|
||||
{!environment.isDesktop ? (
|
||||
{!environment.isElectron ? (
|
||||
<InformationFillDuotoneIcon style={{ color: cssVar('errorColor') }} />
|
||||
) : (
|
||||
<LocalWorkspaceIcon />
|
||||
@@ -98,7 +98,7 @@ const useSyncEngineSyncProgress = (meta: WorkspaceMetadata) => {
|
||||
let content;
|
||||
// TODO(@eyhn): add i18n
|
||||
if (workspace.flavour === WorkspaceFlavour.LOCAL) {
|
||||
if (!environment.isDesktop) {
|
||||
if (!environment.isElectron) {
|
||||
content = 'This is a local demo workspace.';
|
||||
} else {
|
||||
content = 'Saved locally';
|
||||
|
||||
@@ -26,8 +26,8 @@ export const AppContainer = ({
|
||||
children,
|
||||
...rest
|
||||
}: WorkspaceRootProps) => {
|
||||
const noisyBackground = useNoisyBackground && environment.isDesktop;
|
||||
const blurBackground = environment.isDesktop && useBlurBackground;
|
||||
const noisyBackground = useNoisyBackground && environment.isElectron;
|
||||
const blurBackground = environment.isElectron && useBlurBackground;
|
||||
return (
|
||||
<div
|
||||
{...rest}
|
||||
@@ -57,7 +57,7 @@ export const MainContainer = forwardRef<
|
||||
<div
|
||||
{...props}
|
||||
className={clsx(mainContainerStyle, className)}
|
||||
data-is-desktop={environment.isDesktop}
|
||||
data-is-desktop={environment.isElectron}
|
||||
data-transparent={false}
|
||||
data-client-border={appSettings.clientBorder}
|
||||
data-side-bar-open={appSideBarOpen}
|
||||
|
||||
Reference in New Issue
Block a user