mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 18:26:05 +08:00
feat(core): build config for ios android (#8555)
This commit is contained in:
4
packages/common/env/src/global.ts
vendored
4
packages/common/env/src/global.ts
vendored
@@ -2,7 +2,7 @@ import { UaHelper } from './ua-helper.js';
|
|||||||
|
|
||||||
export type BUILD_CONFIG_TYPE = {
|
export type BUILD_CONFIG_TYPE = {
|
||||||
debug: boolean;
|
debug: boolean;
|
||||||
distribution: 'web' | 'desktop' | 'admin' | 'mobile';
|
distribution: 'web' | 'desktop' | 'admin' | 'mobile' | 'ios' | 'android';
|
||||||
/**
|
/**
|
||||||
* 'web' | 'desktop' | 'admin'
|
* 'web' | 'desktop' | 'admin'
|
||||||
*/
|
*/
|
||||||
@@ -15,6 +15,8 @@ export type BUILD_CONFIG_TYPE = {
|
|||||||
isElectron: boolean;
|
isElectron: boolean;
|
||||||
isWeb: boolean;
|
isWeb: boolean;
|
||||||
isMobileWeb: boolean;
|
isMobileWeb: boolean;
|
||||||
|
isIOS: boolean;
|
||||||
|
isAndroid: boolean;
|
||||||
|
|
||||||
// this is for the electron app
|
// this is for the electron app
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -30,7 +30,11 @@ export const SafeArea = forwardRef<HTMLDivElement, SafeAreaProps>(
|
|||||||
<div
|
<div
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={clsx(safeArea, className)}
|
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-bottom={bottom ? '' : undefined}
|
||||||
data-top={top ? '' : undefined}
|
data-top={top ? '' : undefined}
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
@@ -50,8 +50,9 @@ function OAuthProvider({ provider }: { provider: OAuthProviderType }) {
|
|||||||
|
|
||||||
const onClick = useCallback(() => {
|
const onClick = useCallback(() => {
|
||||||
let oauthUrl =
|
let oauthUrl =
|
||||||
(BUILD_CONFIG.isElectron ? BUILD_CONFIG.serverUrlPrefix : '') +
|
(BUILD_CONFIG.isElectron || BUILD_CONFIG.isIOS || BUILD_CONFIG.isAndroid
|
||||||
`/oauth/login?provider=${provider}`;
|
? BUILD_CONFIG.serverUrlPrefix
|
||||||
|
: '') + `/oauth/login?provider=${provider}`;
|
||||||
|
|
||||||
if (BUILD_CONFIG.isElectron) {
|
if (BUILD_CONFIG.isElectron) {
|
||||||
oauthUrl += `&client=${appInfo?.schema}`;
|
oauthUrl += `&client=${appInfo?.schema}`;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { fromPromise, Service } from '@toeverything/infra';
|
|||||||
import { BackendError, NetworkError } from '../error';
|
import { BackendError, NetworkError } from '../error';
|
||||||
|
|
||||||
export function getAffineCloudBaseUrl(): string {
|
export function getAffineCloudBaseUrl(): string {
|
||||||
if (BUILD_CONFIG.isElectron) {
|
if (BUILD_CONFIG.isElectron || BUILD_CONFIG.isIOS || BUILD_CONFIG.isAndroid) {
|
||||||
return BUILD_CONFIG.serverUrlPrefix;
|
return BUILD_CONFIG.serverUrlPrefix;
|
||||||
}
|
}
|
||||||
const { protocol, hostname, port } = window.location;
|
const { protocol, hostname, port } = window.location;
|
||||||
|
|||||||
@@ -3,9 +3,10 @@ import { apis } from '@affine/electron-api';
|
|||||||
|
|
||||||
const logger = new DebugLogger('popup');
|
const logger = new DebugLogger('popup');
|
||||||
|
|
||||||
const origin = BUILD_CONFIG.isElectron
|
const origin =
|
||||||
? BUILD_CONFIG.serverUrlPrefix
|
BUILD_CONFIG.isElectron || BUILD_CONFIG.isIOS || BUILD_CONFIG.isAndroid
|
||||||
: location.origin;
|
? BUILD_CONFIG.serverUrlPrefix
|
||||||
|
: location.origin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated need to be refactored as [UrlService] dependencies on [ServerConfigService]
|
* @deprecated need to be refactored as [UrlService] dependencies on [ServerConfigService]
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { gqlFetcherFactory } from './fetcher';
|
|||||||
setupGlobal();
|
setupGlobal();
|
||||||
|
|
||||||
export function getBaseUrl(): string {
|
export function getBaseUrl(): string {
|
||||||
if (BUILD_CONFIG.isElectron) {
|
if (BUILD_CONFIG.isElectron || BUILD_CONFIG.isIOS || BUILD_CONFIG.isAndroid) {
|
||||||
return BUILD_CONFIG.serverUrlPrefix;
|
return BUILD_CONFIG.serverUrlPrefix;
|
||||||
}
|
}
|
||||||
if (typeof window === 'undefined') {
|
if (typeof window === 'undefined') {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
export type BuildFlags = {
|
export type BuildFlags = {
|
||||||
distribution: 'web' | 'desktop' | 'admin' | 'mobile';
|
distribution: 'web' | 'desktop' | 'admin' | 'mobile' | 'ios' | 'android';
|
||||||
mode: 'development' | 'production';
|
mode: 'development' | 'production';
|
||||||
channel: 'stable' | 'beta' | 'canary' | 'internal';
|
channel: 'stable' | 'beta' | 'canary' | 'internal';
|
||||||
static: boolean;
|
static: boolean;
|
||||||
|
|||||||
@@ -69,7 +69,9 @@ export const getPublicPath = (buildFlags: BuildFlags) => {
|
|||||||
if (
|
if (
|
||||||
buildFlags.mode === 'development' ||
|
buildFlags.mode === 'development' ||
|
||||||
process.env.COVERAGE ||
|
process.env.COVERAGE ||
|
||||||
buildFlags.distribution === 'desktop'
|
buildFlags.distribution === 'desktop' ||
|
||||||
|
buildFlags.distribution === 'ios' ||
|
||||||
|
buildFlags.distribution === 'android'
|
||||||
) {
|
) {
|
||||||
return '/';
|
return '/';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ export function getBuildConfig(buildFlags: BuildFlags): BUILD_CONFIG_TYPE {
|
|||||||
isElectron: buildFlags.distribution === 'desktop',
|
isElectron: buildFlags.distribution === 'desktop',
|
||||||
isWeb: buildFlags.distribution === 'web',
|
isWeb: buildFlags.distribution === 'web',
|
||||||
isMobileWeb: buildFlags.distribution === 'mobile',
|
isMobileWeb: buildFlags.distribution === 'mobile',
|
||||||
|
isIOS: buildFlags.distribution === 'ios',
|
||||||
|
isAndroid: buildFlags.distribution === 'android',
|
||||||
|
|
||||||
isSelfHosted: process.env.SELF_HOSTED === 'true',
|
isSelfHosted: process.env.SELF_HOSTED === 'true',
|
||||||
appBuildType: 'stable' as const,
|
appBuildType: 'stable' as const,
|
||||||
|
|||||||
@@ -58,7 +58,12 @@ export function createWebpackConfig(cwd: string, flags: BuildFlags) {
|
|||||||
PRECONNECT: cdnOrigin
|
PRECONNECT: cdnOrigin
|
||||||
? `<link rel="preconnect" href="${cdnOrigin}" />`
|
? `<link rel="preconnect" href="${cdnOrigin}" />`
|
||||||
: '',
|
: '',
|
||||||
VIEWPORT_FIT: flags.distribution === 'mobile' ? 'cover' : 'auto',
|
VIEWPORT_FIT:
|
||||||
|
flags.distribution === 'mobile' ||
|
||||||
|
flags.distribution === 'ios' ||
|
||||||
|
flags.distribution === 'android'
|
||||||
|
? 'cover'
|
||||||
|
: 'auto',
|
||||||
};
|
};
|
||||||
|
|
||||||
const createHTMLPlugins = (entryName: string) => {
|
const createHTMLPlugins = (entryName: string) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user