feat(core): build config for ios android (#8555)

This commit is contained in:
EYHN
2024-10-21 05:39:04 +00:00
parent d1783b6f8c
commit db374f7feb
10 changed files with 29 additions and 12 deletions

View File

@@ -2,7 +2,7 @@ import { UaHelper } from './ua-helper.js';
export type BUILD_CONFIG_TYPE = {
debug: boolean;
distribution: 'web' | 'desktop' | 'admin' | 'mobile';
distribution: 'web' | 'desktop' | 'admin' | 'mobile' | 'ios' | 'android';
/**
* 'web' | 'desktop' | 'admin'
*/
@@ -15,6 +15,8 @@ export type BUILD_CONFIG_TYPE = {
isElectron: boolean;
isWeb: boolean;
isMobileWeb: boolean;
isIOS: boolean;
isAndroid: boolean;
// this is for the electron app
/**

View File

@@ -30,7 +30,11 @@ export const SafeArea = forwardRef<HTMLDivElement, SafeAreaProps>(
<div
ref={ref}
className={clsx(safeArea, className)}
data-standalone={environment.isPwa ? '' : undefined}
data-standalone={
environment.isPwa || BUILD_CONFIG.isAndroid || BUILD_CONFIG.isIOS
? ''
: undefined
}
data-bottom={bottom ? '' : undefined}
data-top={top ? '' : undefined}
style={{

View File

@@ -50,8 +50,9 @@ function OAuthProvider({ provider }: { provider: OAuthProviderType }) {
const onClick = useCallback(() => {
let oauthUrl =
(BUILD_CONFIG.isElectron ? BUILD_CONFIG.serverUrlPrefix : '') +
`/oauth/login?provider=${provider}`;
(BUILD_CONFIG.isElectron || BUILD_CONFIG.isIOS || BUILD_CONFIG.isAndroid
? BUILD_CONFIG.serverUrlPrefix
: '') + `/oauth/login?provider=${provider}`;
if (BUILD_CONFIG.isElectron) {
oauthUrl += `&client=${appInfo?.schema}`;

View File

@@ -5,7 +5,7 @@ import { fromPromise, Service } from '@toeverything/infra';
import { BackendError, NetworkError } from '../error';
export function getAffineCloudBaseUrl(): string {
if (BUILD_CONFIG.isElectron) {
if (BUILD_CONFIG.isElectron || BUILD_CONFIG.isIOS || BUILD_CONFIG.isAndroid) {
return BUILD_CONFIG.serverUrlPrefix;
}
const { protocol, hostname, port } = window.location;

View File

@@ -3,9 +3,10 @@ import { apis } from '@affine/electron-api';
const logger = new DebugLogger('popup');
const origin = BUILD_CONFIG.isElectron
? BUILD_CONFIG.serverUrlPrefix
: location.origin;
const origin =
BUILD_CONFIG.isElectron || BUILD_CONFIG.isIOS || BUILD_CONFIG.isAndroid
? BUILD_CONFIG.serverUrlPrefix
: location.origin;
/**
* @deprecated need to be refactored as [UrlService] dependencies on [ServerConfigService]

View File

@@ -10,7 +10,7 @@ import { gqlFetcherFactory } from './fetcher';
setupGlobal();
export function getBaseUrl(): string {
if (BUILD_CONFIG.isElectron) {
if (BUILD_CONFIG.isElectron || BUILD_CONFIG.isIOS || BUILD_CONFIG.isAndroid) {
return BUILD_CONFIG.serverUrlPrefix;
}
if (typeof window === 'undefined') {