mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 13:25:12 +00:00
fix: add platform selector to storybook (#4380)
This commit is contained in:
@@ -6,7 +6,6 @@ import {
|
||||
ModalHeader,
|
||||
} from '@affine/component/auth-components';
|
||||
import { pushNotificationAtom } from '@affine/component/notification-center';
|
||||
import { isDesktop } from '@affine/env/constant';
|
||||
import {
|
||||
sendChangeEmailMutation,
|
||||
sendChangePasswordEmailMutation,
|
||||
@@ -118,7 +117,7 @@ const useSendEmail = (emailType: AuthPanelProps['emailType']) => {
|
||||
return trigger({
|
||||
email,
|
||||
callbackUrl: `/auth/${callbackUrl}?isClient=${
|
||||
isDesktop ? 'true' : 'false'
|
||||
environment.isDesktop ? 'true' : 'false'
|
||||
}`,
|
||||
});
|
||||
},
|
||||
|
||||
@@ -3,7 +3,6 @@ import {
|
||||
appSidebarOpenAtom,
|
||||
SidebarSwitch,
|
||||
} from '@affine/component/app-sidebar';
|
||||
import { isDesktop } from '@affine/env/constant';
|
||||
import { useIsTinyScreen } from '@toeverything/hooks/use-is-tiny-screen';
|
||||
import clsx from 'clsx';
|
||||
import { type Atom, useAtomValue } from 'jotai';
|
||||
@@ -45,7 +44,7 @@ export const Header = forwardRef<HTMLDivElement, HeaderPros>(function Header(
|
||||
rightStatic: windowControlsRef,
|
||||
});
|
||||
|
||||
const isWindowsDesktop = globalThis.platform === 'win32' && isDesktop;
|
||||
const isWindowsDesktop = environment.isDesktop && environment.isWindows;
|
||||
const open = useAtomValue(appSidebarOpenAtom);
|
||||
const appSidebarFloating = useAtomValue(appSidebarFloatingAtom);
|
||||
return (
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { BrowserWarning } from '@affine/component/affine-banner';
|
||||
import { DownloadTips } from '@affine/component/affine-banner';
|
||||
import { isDesktop } from '@affine/env/constant';
|
||||
import { Trans } from '@affine/i18n';
|
||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
||||
import { useAtom } from 'jotai';
|
||||
@@ -11,7 +10,7 @@ import { guideDownloadClientTipAtom } from '../../../atoms/guide';
|
||||
const minimumChromeVersion = 102;
|
||||
|
||||
const shouldShowWarning = () => {
|
||||
if (isDesktop) {
|
||||
if (environment.isDesktop) {
|
||||
// even though desktop has compatibility issues,
|
||||
// we don't want to show the warning
|
||||
return false;
|
||||
@@ -64,7 +63,7 @@ export const TopTip = () => {
|
||||
setShowWarning(shouldShowWarning());
|
||||
}, []);
|
||||
|
||||
if (showDownloadTip && isDesktop) {
|
||||
if (showDownloadTip && environment.isDesktop) {
|
||||
return (
|
||||
<DownloadTips
|
||||
onClose={() => {
|
||||
|
||||
@@ -8,7 +8,7 @@ import * as style from './style.css';
|
||||
const maximizedAtom = atomWithObservable(() => {
|
||||
return new Observable<boolean>(subscriber => {
|
||||
subscriber.next(false);
|
||||
return window?.events.ui.onMaximized(maximized => {
|
||||
return window.events?.ui.onMaximized(maximized => {
|
||||
return subscriber.next(maximized);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
SidebarScrollableContainer,
|
||||
} from '@affine/component/app-sidebar';
|
||||
import { useCollectionManager } from '@affine/component/page-list';
|
||||
import { isDesktop } from '@affine/env/constant';
|
||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
||||
import {
|
||||
DeleteTemporarilyIcon,
|
||||
@@ -117,7 +116,7 @@ export const RootAppSidebar = ({
|
||||
|
||||
// Listen to the "New Page" action from the menu
|
||||
useEffect(() => {
|
||||
if (isDesktop) {
|
||||
if (environment.isDesktop) {
|
||||
return window.events?.applicationMenu.onNewPageAction(onClickNewPage);
|
||||
}
|
||||
return;
|
||||
@@ -125,7 +124,7 @@ export const RootAppSidebar = ({
|
||||
|
||||
const [sidebarOpen, setSidebarOpen] = useAtom(appSidebarOpenAtom);
|
||||
useEffect(() => {
|
||||
if (isDesktop) {
|
||||
if (environment.isDesktop) {
|
||||
window.apis?.ui.handleSidebarVisibilityChange(sidebarOpen).catch(err => {
|
||||
console.error(err);
|
||||
});
|
||||
@@ -252,7 +251,7 @@ export const RootAppSidebar = ({
|
||||
)}
|
||||
</SidebarScrollableContainer>
|
||||
<SidebarContainer>
|
||||
{isDesktop && <AppUpdaterButton />}
|
||||
{environment.isDesktop && <AppUpdaterButton />}
|
||||
<div style={{ height: '4px' }} />
|
||||
<AddPageButton onClick={onClickNewPage} />
|
||||
</SidebarContainer>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import '@toeverything/hooks/use-affine-ipc-renderer';
|
||||
|
||||
import { pushNotificationAtom } from '@affine/component/notification-center';
|
||||
import { isDesktop } from '@affine/env/constant';
|
||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
||||
import { refreshRootMetadataAtom } from '@affine/workspace/atom';
|
||||
import { useAtom, useSetAtom } from 'jotai';
|
||||
@@ -47,7 +46,7 @@ const SessionDefence = (props: PropsWithChildren) => {
|
||||
type: 'success',
|
||||
});
|
||||
|
||||
if (isDesktop) {
|
||||
if (environment.isDesktop) {
|
||||
window.affine.ipcRenderer.send('affine:login');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { isDesktop } from '@affine/env/constant';
|
||||
import {
|
||||
generateRandUTF16Chars,
|
||||
SPAN_ID_BYTES,
|
||||
@@ -48,7 +47,7 @@ function onRejectHandleTrace<T>(
|
||||
|
||||
export const signInCloud: typeof signIn = async (provider, ...rest) => {
|
||||
const traceParams = genTraceParams();
|
||||
if (isDesktop) {
|
||||
if (environment.isDesktop) {
|
||||
if (provider === 'google') {
|
||||
open(
|
||||
`${
|
||||
@@ -104,7 +103,7 @@ export const signOutCloud: typeof signOut = async options => {
|
||||
|
||||
export function buildCallbackUrl(callbackUrl: string) {
|
||||
const params: string[][] = [];
|
||||
if (isDesktop && window.appInfo.schema) {
|
||||
if (environment.isDesktop && window.appInfo.schema) {
|
||||
params.push(['schema', window.appInfo.schema]);
|
||||
}
|
||||
const query =
|
||||
|
||||
Reference in New Issue
Block a user