fix:修复
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
EXPO_PUBLIC_API_BASE_URL=http://localhost:8000
|
||||
EXPO_PUBLIC_ENV=dev
|
||||
EXPO_PUBLIC_DEFAULT_LANGUAGE=auto
|
||||
#
|
||||
# Expo/EAS 项目 ID(UUID)。用于真机获取 Expo Push Token(expo-notifications)。
|
||||
# 获取方式:在 client 目录执行 `eas project:init` 或 `eas project:info` 查看。
|
||||
EXPO_PUBLIC_EAS_PROJECT_ID=c519f016-e5c8-426c-868f-5545dce8beef
|
||||
|
||||
1
client/.npmrc
Normal file
1
client/.npmrc
Normal file
@@ -0,0 +1 @@
|
||||
registry=https://registry.npmmirror.com
|
||||
30
client/app.config.ts
Normal file
30
client/app.config.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import type { ConfigContext, ExpoConfig } from 'expo/config';
|
||||
|
||||
/**
|
||||
* 运行时获取 Push Token(expo-notifications)在真机/Dev Client 场景下通常需要 projectId。
|
||||
*
|
||||
* 这里把 projectId 注入到 `extra.eas.projectId`:
|
||||
* - 开发/本地:从 `.env.local`(EXPO_PUBLIC_EAS_PROJECT_ID)读取并写入配置
|
||||
* - CI/EAS:也可通过环境变量注入(EXPO_PUBLIC_EAS_PROJECT_ID 或 EAS_PROJECT_ID)
|
||||
*/
|
||||
export default ({ config }: ConfigContext): ExpoConfig => {
|
||||
const projectId =
|
||||
process.env.EXPO_PUBLIC_EAS_PROJECT_ID ||
|
||||
// 兼容部分 CI/EAS 注入的变量名
|
||||
process.env.EAS_PROJECT_ID ||
|
||||
undefined;
|
||||
|
||||
return {
|
||||
...config,
|
||||
extra: {
|
||||
...(config.extra ?? {}),
|
||||
eas: {
|
||||
// 保留已有配置,再覆盖 projectId
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
...(((config.extra as any) ?? {}).eas ?? {}),
|
||||
projectId: projectId ?? (config.extra as any)?.eas?.projectId,
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -36,6 +36,13 @@
|
||||
],
|
||||
"experiments": {
|
||||
"typedRoutes": true
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"eas": {
|
||||
"projectId": "c519f016-e5c8-426c-868f-5545dce8beef"
|
||||
},
|
||||
"router": {}
|
||||
},
|
||||
"owner": "damersu"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import { useTranslation } from 'react-i18next';
|
||||
import { SafeAreaView } from 'react-native-safe-area-context';
|
||||
import { setConsentAccepted, getConsentAccepted } from '../../src/storage/appStorage';
|
||||
import { fetchLegalLinks } from '@/src/services/legalApi';
|
||||
import { getOnboardingCompleted } from '@/src/storage/appStorage';
|
||||
|
||||
// 导入 SVG 组件
|
||||
import FlowersBg from '../../assets/images/index/flowers_endbg.svg';
|
||||
@@ -27,7 +28,13 @@ export default function SplashScreen() {
|
||||
const accepted = await getConsentAccepted();
|
||||
setShowConsent(!accepted);
|
||||
if (accepted) {
|
||||
router.replace('/');
|
||||
// 已同意协议则直接分发到目标页,避免先回到 /(index)再二次跳转导致“闪一下”
|
||||
const completed = await getOnboardingCompleted();
|
||||
if (completed) {
|
||||
router.replace('/(app)/home');
|
||||
} else {
|
||||
router.replace('/(onboarding)/onboarding');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -32,7 +32,8 @@ export {
|
||||
|
||||
export const unstable_settings = {
|
||||
// Ensure that reloading on `/modal` keeps a back button present.
|
||||
initialRouteName: 'index',
|
||||
// 让首次启动(未同意协议)直接进入协议页,避免先渲染 index 再跳转导致“闪一下”
|
||||
initialRouteName: '(splash)/splash',
|
||||
};
|
||||
|
||||
// Prevent the splash screen from auto-hiding before asset loading is complete.
|
||||
@@ -144,6 +145,9 @@ function RootLayoutNav() {
|
||||
return (
|
||||
<ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>
|
||||
<Stack screenOptions={{ headerShown: false }}>
|
||||
{/* 协议页分组(首次启动优先进入) */}
|
||||
<Stack.Screen name="(splash)" />
|
||||
|
||||
{/* 启动分发页:根据 onboarding 状态跳转 */}
|
||||
<Stack.Screen name="index" />
|
||||
|
||||
@@ -173,7 +177,8 @@ const styles = StyleSheet.create({
|
||||
backgroundColor: '#EAD2BA',
|
||||
},
|
||||
splashImage: {
|
||||
width: '80%',
|
||||
height: '80%',
|
||||
// 覆盖层图片尺寸需与系统原生 Splash 的视觉一致,避免出现“缩小一下”的错觉
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -81,7 +81,12 @@ function ThemeCard({
|
||||
{children}
|
||||
{/* 文案展示在图片中心 */}
|
||||
<View style={styles.textOverlay}>
|
||||
<Text style={[styles.overlayTitle, selected && styles.selectedOverlayTitle]}>
|
||||
<Text
|
||||
style={[styles.overlayTitle, selected && styles.selectedOverlayTitle]}
|
||||
numberOfLines={1}
|
||||
adjustsFontSizeToFit
|
||||
minimumFontScale={0.85}
|
||||
>
|
||||
{title}
|
||||
</Text>
|
||||
</View>
|
||||
@@ -94,20 +99,21 @@ function ThemeCard({
|
||||
const styles = StyleSheet.create({
|
||||
row: {
|
||||
flexDirection: 'row',
|
||||
flexWrap: 'wrap',
|
||||
flexWrap: 'nowrap',
|
||||
gap: 12,
|
||||
paddingHorizontal: 0,
|
||||
paddingHorizontal: 4,
|
||||
paddingBottom: 50,
|
||||
paddingTop: 20,
|
||||
justifyContent: 'center',
|
||||
justifyContent: 'space-between',
|
||||
},
|
||||
cardContainer: {
|
||||
alignItems: 'center',
|
||||
width: 112,
|
||||
flex: 1,
|
||||
minWidth: 0,
|
||||
alignItems: 'stretch',
|
||||
},
|
||||
previewWrapper: {
|
||||
width: 110,
|
||||
height: 178,
|
||||
width: '100%',
|
||||
aspectRatio: 110 / 178,
|
||||
borderRadius: 26,
|
||||
padding: 6.5,
|
||||
justifyContent: 'center',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import { View, StyleSheet, TextInput, Platform, Animated, TouchableOpacity, Text } from 'react-native';
|
||||
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { View, StyleSheet, TextInput, Platform, Animated, TouchableOpacity, Text, Keyboard, Pressable } from 'react-native';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
||||
import { OnboardingColors } from '@/constants/OnboardingTheme';
|
||||
@@ -17,9 +17,27 @@ export function NameInputStep({ value, onChangeText, onNext }: NameInputStepProp
|
||||
const { t } = useTranslation();
|
||||
const insets = useSafeAreaInsets();
|
||||
const [isFocused, setIsFocused] = useState(false);
|
||||
const [keyboardHeight, setKeyboardHeight] = useState(0);
|
||||
const blinkAnim = useRef(new Animated.Value(1)).current;
|
||||
const hasInput = value.trim().length > 0;
|
||||
|
||||
useEffect(() => {
|
||||
const showEvent = Platform.OS === 'ios' ? 'keyboardWillShow' : 'keyboardDidShow';
|
||||
const hideEvent = Platform.OS === 'ios' ? 'keyboardWillHide' : 'keyboardDidHide';
|
||||
|
||||
const subShow = Keyboard.addListener(showEvent, (e) => {
|
||||
setKeyboardHeight(e.endCoordinates?.height ?? 0);
|
||||
});
|
||||
const subHide = Keyboard.addListener(hideEvent, () => {
|
||||
setKeyboardHeight(0);
|
||||
});
|
||||
|
||||
return () => {
|
||||
subShow.remove();
|
||||
subHide.remove();
|
||||
};
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const animation = Animated.loop(
|
||||
Animated.sequence([
|
||||
@@ -36,8 +54,14 @@ export function NameInputStep({ value, onChangeText, onNext }: NameInputStepProp
|
||||
return () => animation.stop();
|
||||
}, [blinkAnim, isFocused]);
|
||||
|
||||
const footerBottom = useMemo(() => {
|
||||
// iOS 的 keyboard height 通常已包含底部安全区,避免重复叠加
|
||||
const keyboardOffset = Math.max(0, keyboardHeight - insets.bottom);
|
||||
return 16 + insets.bottom + keyboardOffset;
|
||||
}, [insets.bottom, keyboardHeight]);
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Pressable style={styles.container} onPress={Keyboard.dismiss} accessible={false}>
|
||||
<View style={styles.inputCard}>
|
||||
<View style={styles.inputWrapper}>
|
||||
{/* 显示层:文案 + 跟随的光标 */}
|
||||
@@ -67,20 +91,30 @@ export function NameInputStep({ value, onChangeText, onNext }: NameInputStepProp
|
||||
caretHidden={true}
|
||||
autoCorrect={false}
|
||||
spellCheck={false}
|
||||
returnKeyType="done"
|
||||
blurOnSubmit={true}
|
||||
onSubmitEditing={() => {
|
||||
Keyboard.dismiss();
|
||||
// 有输入时,“完成”直接进入下一步,避免真机卡在键盘上
|
||||
if (value.trim().length > 0) onNext();
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
<View style={[styles.footer, { bottom: insets.bottom + 16 }]}>
|
||||
<View style={[styles.footer, { bottom: footerBottom }]}>
|
||||
<TouchableOpacity
|
||||
onPress={onNext}
|
||||
onPress={() => {
|
||||
Keyboard.dismiss();
|
||||
onNext();
|
||||
}}
|
||||
disabled={!hasInput}
|
||||
activeOpacity={0.8}
|
||||
>
|
||||
{hasInput ? <BtnClicked width={87} height={57} /> : <BtnNotClicked width={87} height={57} />}
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</View>
|
||||
</Pressable>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,8 @@
|
||||
<string>12.0</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>NSLocalNetworkUsageDescription</key>
|
||||
<string>用于连接局域网服务以获取内容与同步数据(仅在需要访问内网地址时使用)。</string>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
|
||||
@@ -5,6 +5,11 @@ set -euo pipefail
|
||||
# - 某些情况下 xcodebuild 生成的 .xcarchive/Info.plist 缺少 ApplicationProperties
|
||||
# - Organizer 无法识别归档中的主 App(即使 Products/Applications/*.app 存在)
|
||||
#
|
||||
# 说明:
|
||||
# - 该脚本的核心作用是让 Organizer 能识别归档里的主 App,从而出现“分发/上传 TestFlight”入口。
|
||||
# - 这类问题通常发生在命令行/CI 归档(xcodebuild archive)或某些自定义归档流程中,
|
||||
# 导致 .xcarchive/Info.plist 缺少/不完整。
|
||||
#
|
||||
# 用法:
|
||||
# ./scripts/fix-xcarchive-header.sh "/path/to/xxx.xcarchive"
|
||||
|
||||
@@ -25,6 +30,10 @@ if [[ ! -f "$ARCHIVE_INFO_PLIST" ]]; then
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# 归档名:尽量从路径推导,避免依赖 Xcode 环境变量
|
||||
archive_basename="$(/usr/bin/basename "$ARCHIVE_PATH")"
|
||||
archive_name="${archive_basename%.xcarchive}"
|
||||
|
||||
# 取第一个 App(归档里通常只有一个主 App)
|
||||
APP_PLIST="$(/usr/bin/find "$ARCHIVE_PATH/Products/Applications" -maxdepth 2 -name Info.plist -path "*.app/Info.plist" 2>/dev/null | /usr/bin/head -n 1 || true)"
|
||||
if [[ -z "$APP_PLIST" ]]; then
|
||||
@@ -39,6 +48,14 @@ APP_REL_PATH="Applications/$APP_NAME"
|
||||
bundle_id="$(/usr/bin/plutil -extract CFBundleIdentifier raw -o - "$APP_PLIST" 2>/dev/null || true)"
|
||||
short_version="$(/usr/bin/plutil -extract CFBundleShortVersionString raw -o - "$APP_PLIST" 2>/dev/null || true)"
|
||||
build_version="$(/usr/bin/plutil -extract CFBundleVersion raw -o - "$APP_PLIST" 2>/dev/null || true)"
|
||||
display_name="$(/usr/bin/plutil -extract CFBundleDisplayName raw -o - "$APP_PLIST" 2>/dev/null || true)"
|
||||
bundle_name="$(/usr/bin/plutil -extract CFBundleName raw -o - "$APP_PLIST" 2>/dev/null || true)"
|
||||
|
||||
# SchemeName 在 Organizer 中会用到,但在某些归档流程里会缺失
|
||||
scheme_name="${SCHEME_NAME:-}"
|
||||
if [[ -z "$scheme_name" ]]; then
|
||||
scheme_name="${archive_name:-}"
|
||||
fi
|
||||
|
||||
if [[ -z "$bundle_id" || -z "$short_version" || -z "$build_version" ]]; then
|
||||
echo "错误:无法从 App Info.plist 读取 bundle/version/build:$APP_PLIST" >&2
|
||||
@@ -63,6 +80,16 @@ fi
|
||||
# 备份一份,防止误操作
|
||||
cp -f "$ARCHIVE_INFO_PLIST" "$ARCHIVE_INFO_PLIST.bak"
|
||||
|
||||
# 修复归档根字段,避免 Organizer 仍然把它当 Generic Archive
|
||||
# 参考:标准 .xcarchive/Info.plist 通常包含 Name / SchemeName / ArchiveVersion / CreationDate 等。
|
||||
# 我们只在缺失时补齐,尽量不改动归档的其他内容。
|
||||
if ! /usr/bin/plutil -extract Name xml1 -o - "$ARCHIVE_INFO_PLIST" >/dev/null 2>&1; then
|
||||
/usr/bin/plutil -insert Name -string "${archive_name:-${display_name:-${bundle_name:-}}}" "$ARCHIVE_INFO_PLIST" 2>/dev/null || true
|
||||
fi
|
||||
if ! /usr/bin/plutil -extract SchemeName xml1 -o - "$ARCHIVE_INFO_PLIST" >/dev/null 2>&1; then
|
||||
/usr/bin/plutil -insert SchemeName -string "${scheme_name:-${archive_name:-}}" "$ARCHIVE_INFO_PLIST" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# 如果已有 ApplicationProperties,直接更新关键字段即可
|
||||
if /usr/bin/plutil -extract ApplicationProperties xml1 -o - "$ARCHIVE_INFO_PLIST" >/dev/null 2>&1; then
|
||||
/usr/bin/plutil -replace ApplicationProperties.ApplicationPath -string "$APP_REL_PATH" "$ARCHIVE_INFO_PLIST"
|
||||
@@ -98,3 +125,9 @@ echo "已修复归档 header:$ARCHIVE_INFO_PLIST"
|
||||
echo "主 App:$APP_REL_PATH"
|
||||
echo "Bundle:$bundle_id"
|
||||
echo "Version/Build:$short_version/$build_version"
|
||||
echo "Name/SchemeName:${archive_name:-} / ${scheme_name:-}"
|
||||
|
||||
# 轻量自检:确保关键字段存在(不强制失败,避免中断归档)
|
||||
if ! /usr/bin/plutil -extract ApplicationProperties.ApplicationPath xml1 -o - "$ARCHIVE_INFO_PLIST" >/dev/null 2>&1; then
|
||||
echo "警告:归档 Info.plist 仍缺少 ApplicationProperties.ApplicationPath,Organizer 可能仍显示 Generic Archive" >&2
|
||||
fi
|
||||
|
||||
@@ -22,7 +22,14 @@ function getOptionalEnv(name: string, fallback: string): string {
|
||||
|
||||
export type AppRuntimeEnv = 'local' | 'dev' | 'prod';
|
||||
|
||||
export const APP_ENV = (getOptionalEnv('EXPO_PUBLIC_ENV', 'local') as AppRuntimeEnv) ?? 'local';
|
||||
/**
|
||||
* Release/TestFlight 场景下如果未注入 EXPO_PUBLIC_ENV,
|
||||
* 默认回退到 prod(避免误打到 localhost 导致真机“无法发起网络请求”)。
|
||||
*/
|
||||
const DEFAULT_RUNTIME_ENV: AppRuntimeEnv =
|
||||
typeof __DEV__ !== 'undefined' && __DEV__ ? 'local' : 'prod';
|
||||
|
||||
export const APP_ENV = (getOptionalEnv('EXPO_PUBLIC_ENV', DEFAULT_RUNTIME_ENV) as AppRuntimeEnv) ?? DEFAULT_RUNTIME_ENV;
|
||||
|
||||
function getApiBaseUrl(env: AppRuntimeEnv): string {
|
||||
// 向后兼容:若直接提供了 EXPO_PUBLIC_API_BASE_URL,则优先使用(不再强制要求 *_DEV/_PROD)
|
||||
|
||||
@@ -100,6 +100,8 @@ function getExpoProjectId(): string | undefined {
|
||||
// 兼容 app.json / app.config.ts 的 extra.eas.projectId
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(Constants.expoConfig as any)?.extra?.eas?.projectId ||
|
||||
// 兜底:某些运行时环境仍可直接读到 EXPO_PUBLIC_ 注入
|
||||
process.env.EXPO_PUBLIC_EAS_PROJECT_ID ||
|
||||
undefined
|
||||
);
|
||||
}
|
||||
@@ -115,7 +117,7 @@ export async function getExpoPushTokenOrThrow(): Promise<string> {
|
||||
const msg = e instanceof Error ? e.message : String(e);
|
||||
const hint = projectId
|
||||
? ''
|
||||
: '(可能缺少 EAS projectId,建议在 app.json 的 extra.eas.projectId 配置后重试)';
|
||||
: '(可能缺少 EAS projectId:请在 .env.local 配置 EXPO_PUBLIC_EAS_PROJECT_ID,或在 app.json/app.config.ts 的 extra.eas.projectId 写入后重试)';
|
||||
throw new Error(`获取 Expo Push Token 失败:${msg}${hint}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,7 +122,8 @@ export async function httpJson<T>(opts: HttpJsonOptions): Promise<T> {
|
||||
} catch (e) {
|
||||
// RN 下 AbortError 文案不完全一致,这里统一对外语义
|
||||
const msg = e instanceof Error ? e.message : String(e);
|
||||
throw new Error(`网络请求失败:${msg}`);
|
||||
// 带上 URL,便于在 TestFlight/Release 排查实际打到哪个地址(例如误打到 localhost)
|
||||
throw new Error(`网络请求失败:${msg}(${url})`);
|
||||
}
|
||||
|
||||
if (!res.ok) {
|
||||
|
||||
Reference in New Issue
Block a user