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 f087da0..c631ebd 100644 --- a/utils/config.ts +++ b/utils/config.ts @@ -56,7 +56,8 @@ export const getApiBaseUrl = (): string => { // - Windows: ipconfig // - Mac/Linux: ifconfig // - 或者使用 Metro Bundler 显示的 IP - return 'http://192.168.1.100:8086/api'; + // process.env.APP_IP_ADDRESS 在 .env.development.local 中配置 自己本地创建,避免提交到代码库 + return process.env.APP_IP_ADDRESS || 'http://192.168.1.100:8086/api'; } case 'staging':