diff --git a/package.json b/package.json index 52776f4..15d0e76 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,8 @@ "version": "1.0.0", "scripts": { "start": "expo start", - "android": "expo start --android", - "ios": "expo start --ios", + "android": "concurrently \"npm run proxy\" \"expo start --ios\"", + "ios": "concurrently \"npm run proxy\" \"expo start --ios\"", "web": "expo start --web", "proxy": "node scripts/proxy-server.js", "dev": "concurrently \"npm run proxy\" \"npm run start\"", diff --git a/tsconfig.json b/tsconfig.json index ce27fee..f8557f5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,5 +6,5 @@ "@/*": ["./*"] } }, - "include": ["**/*.ts", "**/*.tsx", ".expo/types/**/*.ts", "expo-env.d.ts"] + "include": ["**/*.ts", "**/*.tsx", ".expo/types/**/*.ts", "expo-env.d.ts", "utils/config.ts.local"] } diff --git a/utils/config.ts b/utils/config.ts index e9ac4fd..c631ebd 100644 --- a/utils/config.ts +++ b/utils/config.ts @@ -51,9 +51,13 @@ export const getApiBaseUrl = (): string => { return 'http://localhost:8086/api'; } else { // iOS/Android 使用本机 IP - // 从环境变量读取,避免多人开发时地址冲突 - // 请在 .env.local 文件中配置 EXPO_PUBLIC_DEV_API_URL - return process.env.EXPO_PUBLIC_DEV_API_URL || 'http://192.168.1.100:8086/api'; + // ⚠️ 重要:需要替换为你的本机 IP 地址 + // 查看本机 IP: + // - Windows: ipconfig + // - Mac/Linux: ifconfig + // - 或者使用 Metro Bundler 显示的 IP + // process.env.APP_IP_ADDRESS 在 .env.development.local 中配置 自己本地创建,避免提交到代码库 + return process.env.APP_IP_ADDRESS || 'http://192.168.1.100:8086/api'; } case 'staging':