@coze-arch/cli 0.0.1-alpha.b51c7a → 0.0.1-alpha.b6f2c1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/lib/__templates__/expo/.coze +7 -2
  2. package/lib/__templates__/expo/.cozeproj/scripts/dev_build.sh +46 -0
  3. package/lib/__templates__/expo/.cozeproj/scripts/dev_run.sh +220 -0
  4. package/lib/__templates__/expo/.cozeproj/scripts/prod_build.sh +47 -0
  5. package/lib/__templates__/expo/.cozeproj/scripts/prod_run.sh +34 -0
  6. package/lib/__templates__/expo/.cozeproj/scripts/server_dev_run.sh +27 -0
  7. package/lib/__templates__/expo/README.md +87 -7
  8. package/lib/__templates__/expo/_gitignore +1 -1
  9. package/lib/__templates__/expo/_npmrc +2 -4
  10. package/lib/__templates__/expo/client/app/_layout.tsx +14 -14
  11. package/lib/__templates__/expo/client/app/demo.tsx +1 -0
  12. package/lib/__templates__/expo/client/app/index.tsx +1 -0
  13. package/lib/__templates__/expo/client/app.config.ts +76 -0
  14. package/lib/__templates__/expo/client/components/ThemedText.tsx +33 -0
  15. package/lib/__templates__/expo/client/components/ThemedView.tsx +38 -0
  16. package/lib/__templates__/expo/client/constants/theme.ts +786 -50
  17. package/lib/__templates__/expo/client/hooks/useColorScheme.ts +34 -1
  18. package/lib/__templates__/expo/client/hooks/useTheme.ts +1 -1
  19. package/lib/__templates__/expo/client/metro.config.js +121 -0
  20. package/lib/__templates__/expo/client/package.json +93 -0
  21. package/lib/__templates__/expo/client/screens/demo/index.tsx +25 -0
  22. package/lib/__templates__/expo/client/screens/demo/styles.ts +28 -0
  23. package/lib/__templates__/expo/client/tsconfig.json +24 -0
  24. package/lib/__templates__/expo/package.json +13 -103
  25. package/lib/__templates__/expo/pnpm-lock.yaml +451 -867
  26. package/lib/__templates__/expo/pnpm-workspace.yaml +3 -0
  27. package/lib/__templates__/expo/server/package.json +32 -0
  28. package/lib/__templates__/expo/{src → server/src}/index.ts +8 -2
  29. package/lib/__templates__/expo/server/tsconfig.json +24 -0
  30. package/lib/__templates__/expo/template.config.js +1 -0
  31. package/lib/__templates__/expo/tsconfig.json +1 -24
  32. package/lib/__templates__/nextjs/.coze +1 -0
  33. package/lib/__templates__/nextjs/_npmrc +1 -0
  34. package/lib/__templates__/nextjs/next.config.ts +12 -0
  35. package/lib/__templates__/nextjs/package.json +3 -2
  36. package/lib/__templates__/nextjs/pnpm-lock.yaml +13 -5
  37. package/lib/__templates__/nextjs/scripts/prepare.sh +9 -0
  38. package/lib/__templates__/nextjs/src/app/globals.css +109 -89
  39. package/lib/__templates__/nextjs/src/app/layout.tsx +1 -12
  40. package/lib/__templates__/nextjs/src/app/page.tsx +33 -21
  41. package/lib/__templates__/nextjs/src/components/ui/resizable.tsx +29 -22
  42. package/lib/__templates__/nextjs/src/components/ui/sidebar.tsx +228 -230
  43. package/lib/__templates__/nextjs/template.config.js +30 -0
  44. package/lib/__templates__/templates.json +61 -43
  45. package/lib/__templates__/vite/.coze +1 -0
  46. package/lib/__templates__/vite/_npmrc +1 -0
  47. package/lib/__templates__/vite/eslint.config.mjs +9 -0
  48. package/lib/__templates__/vite/package.json +6 -2
  49. package/lib/__templates__/vite/pnpm-lock.yaml +3486 -19
  50. package/lib/__templates__/vite/scripts/prepare.sh +9 -0
  51. package/lib/__templates__/vite/template.config.js +28 -4
  52. package/lib/__templates__/vite/vite.config.ts +0 -3
  53. package/lib/cli.js +189 -52
  54. package/package.json +8 -3
  55. package/lib/__templates__/expo/.cozeproj/scripts/deploy_build.sh +0 -116
  56. package/lib/__templates__/expo/.cozeproj/scripts/deploy_run.sh +0 -239
  57. package/lib/__templates__/expo/app.json +0 -63
  58. package/lib/__templates__/expo/babel.config.js +0 -9
  59. package/lib/__templates__/expo/client/app/(tabs)/_layout.tsx +0 -43
  60. package/lib/__templates__/expo/client/app/(tabs)/home.tsx +0 -1
  61. package/lib/__templates__/expo/client/app/(tabs)/index.tsx +0 -7
  62. package/lib/__templates__/expo/client/app/+not-found.tsx +0 -79
  63. package/lib/__templates__/expo/client/index.js +0 -12
  64. package/lib/__templates__/expo/client/screens/home/index.tsx +0 -51
  65. package/lib/__templates__/expo/client/screens/home/styles.ts +0 -60
  66. package/lib/__templates__/expo/metro.config.js +0 -53
  67. package/lib/__templates__/nextjs/.vscode/settings.json +0 -121
  68. package/lib/__templates__/vite/.vscode/settings.json +0 -7
  69. /package/lib/__templates__/expo/{eslint-formatter-simple.mjs → client/eslint-formatter-simple.mjs} +0 -0
  70. /package/lib/__templates__/expo/{eslint.config.mjs → client/eslint.config.mjs} +0 -0
@@ -1,239 +0,0 @@
1
- ROOT_DIR="$(cd "$(dirname "$0")" && pwd)"
2
- LOG_DIR="${COZE_LOG_DIR:-$ROOT_DIR/logs}"
3
- LOG_FILE="$LOG_DIR/app.log"
4
- mkdir -p "$LOG_DIR"
5
-
6
- # ==================== 配置项 ====================
7
- # Server 服务配置
8
- SERVER_HOST="0.0.0.0"
9
- SERVER_PORT="9091"
10
- # Expo 项目配置
11
- EXPO_HOST="0.0.0.0"
12
- EXPO_DIR="expo"
13
- EXPO_PORT="9090"
14
- WEB_URL="${COZE_PROJECT_DOMAIN_DEFAULT:-http://127.0.0.1:${SERVER_PORT}}"
15
- ASSUME_YES="1"
16
- EXPO_PUBLIC_BACKEND_BASE_URL="${EXPO_PUBLIC_BACKEND_BASE_URL:-$WEB_URL}"
17
-
18
-
19
- EXPO_PACKAGER_PROXY_URL="${EXPO_PUBLIC_BACKEND_BASE_URL}"
20
- export EXPO_PUBLIC_BACKEND_BASE_URL EXPO_PACKAGER_PROXY_URL
21
- # 运行时变量(为避免 set -u 的未绑定错误,预置为空)
22
- SERVER_PID=""
23
- EXPO_PID=""
24
- # ==================== 工具函数 ====================
25
- info() {
26
- echo -e "\033[32m[INFO] $1\033[0m"
27
- }
28
- warn() {
29
- echo -e "\033[33m[WARN] $1\033[0m"
30
- }
31
- error() {
32
- echo -e "\033[31m[ERROR] $1\033[0m"
33
- exit 1
34
- }
35
- check_command() {
36
- if ! command -v "$1" &> /dev/null; then
37
- error "命令 $1 未找到,请先安装"
38
- fi
39
- }
40
- while [ $# -gt 0 ]; do
41
- case "$1" in
42
- -y|--yes)
43
- ASSUME_YES="1"
44
- shift
45
- ;;
46
- *)
47
- shift
48
- ;;
49
- esac
50
- done
51
- is_port_free() {
52
- ! lsof -iTCP:"$1" -sTCP:LISTEN >/dev/null 2>&1
53
- }
54
- choose_next_free_port() {
55
- local start=$1
56
- local p=$start
57
- while ! is_port_free "$p"; do
58
- p=$((p+1))
59
- done
60
- echo "$p"
61
- }
62
- ensure_port() {
63
- local var_name=$1
64
- local port_val=$2
65
- if is_port_free "$port_val"; then
66
- info "端口未占用:$port_val"
67
- eval "$var_name=$port_val"
68
- else
69
- warn "端口已占用:$port_val"
70
- local choice
71
- if [ "$ASSUME_YES" = "1" ]; then choice="Y"; else read -r -p "是否关闭该端口的进程?[Y/n] " choice || choice="Y"; fi
72
- if [ -z "$choice" ] || [ "$choice" = "y" ] || [ "$choice" = "Y" ]; then
73
- if command -v lsof &> /dev/null; then
74
- local pids
75
- pids=$(lsof -t -i tcp:"$port_val" -sTCP:LISTEN 2>/dev/null || true)
76
- if [ -n "$pids" ]; then
77
- info "正在关闭进程:$pids"
78
- kill -9 $pids 2>/dev/null || warn "关闭进程失败:$pids"
79
- eval "$var_name=$port_val"
80
- else
81
- warn "未获取到占用该端口的进程"
82
- eval "$var_name=$port_val"
83
- fi
84
- else
85
- warn "缺少 lsof,无法自动关闭进程"
86
- eval "$var_name=$port_val"
87
- fi
88
- else
89
- local new_port
90
- new_port=$(choose_next_free_port "$port_val")
91
- info "使用新的端口:$new_port"
92
- eval "$var_name=$new_port"
93
- fi
94
- fi
95
- }
96
-
97
- write_log() {
98
- local level="${1:-INFO}"
99
- local msg="${2:-}"
100
- node -e '
101
- const fs=require("fs");
102
- const path=process.argv[1];
103
- const level=(process.argv[2]||"").toUpperCase();
104
- let msg=String(process.argv[3]||"");
105
- const ts=Date.now();
106
- msg=msg.replace(/\\n/g,"\n");
107
- const dt=new Date();
108
- const parts=new Intl.DateTimeFormat("en-GB",{timeZone:"Asia/Shanghai",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:false}).formatToParts(dt);
109
- const o={};
110
- for(const p of parts){o[p.type]=p.value}
111
- const dt_str=`${o.year}-${o.month}-${o.day} ${o.hour}:${o.minute}:${o.second}`;
112
- msg=`${dt_str} [${level}] ${msg}`;
113
- const record=JSON.stringify({level, message: msg, timestamp: ts},null,0);
114
- const fd=fs.openSync(path,"a");
115
- fs.writeSync(fd, record+"\n", null, "utf8");
116
- fs.fsyncSync(fd);
117
- fs.closeSync(fd);
118
- ' "$LOG_FILE" "$level" "$msg"
119
- case "$level" in
120
- INFO) echo -e "\033[32m[INFO] $msg\033[0m" ;;
121
- WARN) echo -e "\033[33m[WARN] $msg\033[0m" ;;
122
- ERROR) echo -e "\033[31m[ERROR] $msg\033[0m" ;;
123
- *) echo -e "\033[32m[INFO] $msg\033[0m" ;;
124
- esac
125
- }
126
-
127
- wait_port_connectable() {
128
- local host=$1 port=$2 retries=${3:-10}
129
- for _ in $(seq 1 "$retries"); do
130
- nc -z "$host" "$port" && return 0
131
- sleep 1
132
- done
133
- return 1
134
- }
135
-
136
- start_expo() {
137
- local offline="${1:-0}"
138
- if [ "$offline" = "1" ]; then
139
- EXPO_OFFLINE=1 EXPO_NO_DOCTOR=1 EXPO_PUBLIC_BACKEND_BASE_URL="$EXPO_PUBLIC_BACKEND_BASE_URL" EXPO_PACKAGER_PROXY_URL="$EXPO_PACKAGER_PROXY_URL" nohup npx expo start --port "$EXPO_PORT" > logs/expo.log 2>&1 &
140
- else
141
- EXPO_NO_DOCTOR=1 EXPO_PUBLIC_BACKEND_BASE_URL="$EXPO_PUBLIC_BACKEND_BASE_URL" EXPO_PACKAGER_PROXY_URL="$EXPO_PACKAGER_PROXY_URL" nohup npx expo start --port "$EXPO_PORT" > logs/expo.log 2>&1 &
142
- fi
143
- EXPO_PID=$!
144
- echo "$EXPO_PID"
145
- }
146
-
147
- detect_expo_fetch_failed() {
148
- local timeout="${1:-8}"
149
- local waited=0
150
- local log_file="logs/expo.log"
151
- while [ "$waited" -lt "$timeout" ]; do
152
- if [ -f "$log_file" ] && grep -q "TypeError: fetch failed" "$log_file" 2>/dev/null; then
153
- return 0
154
- fi
155
- sleep 1
156
- waited=$((waited+1))
157
- done
158
- return 1
159
- }
160
-
161
- # ==================== 前置检查 ====================
162
- write_log "INFO" "==================== 开始启动 ===================="
163
- write_log "INFO" "开始执行服务启动脚本(start_dev.sh)..."
164
- write_log "INFO" "正在检查依赖命令和目录是否存在..."
165
- # 检查核心命令
166
- # check_command "python"
167
- check_command "npm"
168
- check_command "pnpm"
169
- check_command "lsof"
170
- check_command "bash"
171
-
172
- info "准备日志目录:logs"
173
- mkdir -p logs
174
- # 端口占用预检查与处理
175
- ensure_port SERVER_PORT "$SERVER_PORT"
176
- ensure_port EXPO_PORT "$EXPO_PORT"
177
-
178
- # ==================== 启动 Server 服务 ====================
179
- write_log "INFO" "检查 Nginx 端口 (5000)..."
180
- if is_port_free 5000; then
181
- write_log "INFO" "端口 5000 未被占用,正在启动 Nginx..."
182
- service nginx start
183
- else
184
- write_log "INFO" "端口 5000 已被占用,跳过 Nginx 启动"
185
- fi
186
-
187
- write_log "INFO" "==================== 启动 server 服务 ===================="
188
- write_log "INFO" "正在执行:npm run server"
189
- PORT="$SERVER_PORT" nohup npm run server > logs/app.log 2>&1 &
190
- SERVER_PID=$!
191
- if [ -z "${SERVER_PID}" ]; then
192
- write_log "ERROR" "无法获取 server 后台进程 PID"
193
- fi
194
- write_log "INFO" "server 服务已启动,进程 ID:${SERVER_PID:-unknown}"
195
-
196
- write_log "INFO" "==================== 启动 Expo 项目 ===================="
197
- write_log "INFO" "正在执行:npx expo start --port ${EXPO_PORT}"
198
- write_log "INFO" "开始启动 Expo 服务"
199
- EXPO_PID=$(start_expo 0)
200
- if detect_expo_fetch_failed 8; then
201
- write_log "WARN" "Expo 启动检测到网络错误:TypeError: fetch failed,启用离线模式重试"
202
- if [ -n "${EXPO_PID}" ]; then kill -9 "$EXPO_PID" 2>/dev/null || true; fi
203
- : > logs/expo.log
204
- EXPO_PID=$(start_expo 1)
205
- fi
206
- # 输出以下环境变量,确保 Expo 项目能正确连接到 Server 服务
207
- write_log "INFO" "Expo 环境变量配置:"
208
- write_log "INFO" "EXPO_PUBLIC_BACKEND_BASE_URL=${EXPO_PUBLIC_BACKEND_BASE_URL}"
209
- write_log "INFO" "EXPO_PACKAGER_PROXY_URL=${EXPO_PACKAGER_PROXY_URL}"
210
- if [ -z "${EXPO_PID}" ]; then
211
- write_log "ERROR" "无法获取 Expo 后台进程 PID"
212
- fi
213
-
214
- write_log "INFO" "所有服务已启动。Server PID: ${SERVER_PID}, Expo PID: ${EXPO_PID}"
215
-
216
- write_log "INFO" "检查 Server 服务端口:$SERVER_HOST:$SERVER_PORT"
217
- if wait_port_connectable "$SERVER_HOST" "$SERVER_PORT" 10 2; then
218
- write_log "INFO" "端口可连接:$SERVER_HOST:$SERVER_PORT"
219
- else
220
- write_log "WARN" "端口不可连接:$SERVER_HOST:$SERVER_PORT 10 次)"
221
- fi
222
-
223
- write_log "INFO" "检查 Expo 服务端口:$EXPO_HOST:$EXPO_PORT"
224
- if wait_port_connectable "$EXPO_HOST" "$EXPO_PORT" 10 2; then
225
- write_log "INFO" "端口可连接:$EXPO_HOST:$EXPO_PORT"
226
- else
227
- write_log "WARN" "端口不可连接:$EXPO_HOST:$EXPO_PORT(已尝试 10 次)"
228
- fi
229
-
230
- write_log "INFO" "服务端口检查完成"
231
-
232
- write_log "INFO" "检查根目录 post_run.py"
233
- if [ -f "$ROOT_DIR/post_run.py" ]; then
234
- write_log "INFO" "启动检查中"
235
- python "$ROOT_DIR/post_run.py" --port "$EXPO_PORT" || write_log "ERROR" "post_run.py 执行失败"
236
- write_log "INFO" "启动检查结束"
237
- fi
238
-
239
- write_log "INFO" "==================== 服务启动完成 ===================="
@@ -1,63 +0,0 @@
1
- {
2
- "expo": {
3
- "name": "${app_name}",
4
- "slug": "${slug}",
5
- "version": "1.0.0",
6
- "orientation": "portrait",
7
- "icon": "./client/assets/images/icon.png",
8
- "scheme": "myapp",
9
- "userInterfaceStyle": "automatic",
10
- "newArchEnabled": true,
11
- "ios": {
12
- "supportsTablet": true
13
- },
14
- "android": {
15
- "adaptiveIcon": {
16
- "foregroundImage": "./client/assets/images/adaptive-icon.png",
17
- "backgroundColor": "#ffffff"
18
- }
19
- },
20
- "web": {
21
- "bundler": "metro",
22
- "output": "single",
23
- "favicon": "./client/assets/images/favicon.png"
24
- },
25
- "plugins": [
26
- "expo-router",
27
- [
28
- "expo-splash-screen",
29
- {
30
- "image": "./client/assets/images/splash-icon.png",
31
- "imageWidth": 200,
32
- "resizeMode": "contain",
33
- "backgroundColor": "#ffffff"
34
- }
35
- ],
36
- [
37
- "expo-image-picker",
38
- {
39
- "photosPermission": "允许${app_name}访问您的相册,以便您上传或保存图片。",
40
- "cameraPermission": "允许${app_name}使用您的相机,以便您直接拍摄照片上传。",
41
- "microphonePermission": "允许${app_name}访问您的麦克风,以便您拍摄带有声音的视频。"
42
- }
43
- ],
44
- [
45
- "expo-location",
46
- {
47
- "locationWhenInUsePermission": "${app_name}需要访问您的位置以提供周边服务及导航功能。"
48
- }
49
- ],
50
- [
51
- "expo-camera",
52
- {
53
- "cameraPermission": "${app_name}需要访问相机以拍摄照片和视频。",
54
- "microphonePermission": "${app_name}需要访问麦克风以录制视频声音。",
55
- "recordAudioAndroid": true
56
- }
57
- ]
58
- ],
59
- "experiments": {
60
- "typedRoutes": true
61
- }
62
- }
63
- }
@@ -1,9 +0,0 @@
1
- module.exports = function (api) {
2
- api.cache(true);
3
- return {
4
- presets: ["babel-preset-expo"],
5
- plugins: [
6
- "react-native-reanimated/plugin",
7
- ],
8
- };
9
- };
@@ -1,43 +0,0 @@
1
- import { Tabs } from 'expo-router';
2
- import { FontAwesome6 } from '@expo/vector-icons';
3
- import { useSafeAreaInsets } from 'react-native-safe-area-context';
4
- import { useTheme } from '@/hooks/useTheme';
5
-
6
- export default function TabLayout() {
7
- const insets = useSafeAreaInsets();
8
- const { theme } = useTheme();
9
- const tabBarHeight = 56 + Math.max(insets.bottom, 8);
10
-
11
- return (
12
- <Tabs
13
- backBehavior='history'
14
- screenOptions={{
15
- headerShown: false,
16
- tabBarActiveTintColor: theme.tabIconSelected,
17
- tabBarInactiveTintColor: theme.tabIconDefault,
18
- tabBarStyle: {
19
- backgroundColor: theme.backgroundRoot,
20
- borderTopColor: theme.backgroundSecondary,
21
- borderTopWidth: 1,
22
- height: tabBarHeight,
23
- paddingBottom: Math.max(insets.bottom, 8),
24
- paddingTop: 6,
25
- },
26
- }}
27
- >
28
- <Tabs.Screen
29
- name='index'
30
- options={{ href: null }}
31
- />
32
- <Tabs.Screen
33
- name='home'
34
- options={{
35
- title: '首页',
36
- tabBarIcon: ({ color }) => (
37
- <FontAwesome6 name='house' size={20} color={color} />
38
- ),
39
- }}
40
- />
41
- </Tabs>
42
- );
43
- }
@@ -1 +0,0 @@
1
- export { default } from "@/screens/home";
@@ -1,7 +0,0 @@
1
- import { Redirect } from 'expo-router';
2
-
3
- const Index = () => {
4
- return <Redirect href="./home" relativeToDirectory />;
5
- };
6
-
7
- export default Index;
@@ -1,79 +0,0 @@
1
- import { useRouter } from 'expo-router';
2
- import { StyleSheet, View, Text, Pressable, Platform } from 'react-native';
3
-
4
- export default function NotFoundScreen() {
5
- const router = useRouter();
6
-
7
- const goBack = () => {
8
- if (router.canGoBack()) {
9
- router.back();
10
- }
11
- };
12
-
13
- return (
14
- <View style={styles.container}>
15
- <Text style={styles.heading}>404</Text>
16
- <Text style={styles.textStyle}>页面未找到</Text>
17
- <Text style={styles.subTextStyle}>
18
- 抱歉!您访问的页面不存在,当前页面功能待完善。
19
- </Text>
20
- <Pressable onPress={goBack} style={styles.button}>
21
- <Text style={styles.buttonText}>返回上一页</Text>
22
- </Pressable>
23
- </View>
24
- );
25
- }
26
-
27
- const styles = StyleSheet.create({
28
- container: {
29
- flex: 1,
30
- alignItems: 'center',
31
- justifyContent: 'center',
32
- backgroundColor: '#f3f5ff',
33
- padding: 16,
34
- },
35
- heading: {
36
- fontSize: 120,
37
- fontWeight: '900',
38
- color: '#4a5568',
39
- textShadowColor: 'rgba(0, 0, 0, 0.05)',
40
- textShadowOffset: { width: 0, height: 4 },
41
- textShadowRadius: 8,
42
- },
43
- textStyle: {
44
- fontSize: 24,
45
- fontWeight: '500',
46
- marginTop: -16,
47
- marginBottom: 16,
48
- color: '#4a5568',
49
- },
50
- subTextStyle: {
51
- fontSize: 16,
52
- color: '#718096',
53
- marginBottom: 32,
54
- maxWidth: 400,
55
- textAlign: 'center',
56
- },
57
- button: {
58
- paddingVertical: 12,
59
- paddingHorizontal: 24,
60
- backgroundColor: '#6366f1',
61
- borderRadius: 9999,
62
- ...Platform.select({
63
- ios: {
64
- shadowColor: 'rgba(0, 0, 0, 0.1)',
65
- shadowOffset: { width: 0, height: 10 },
66
- shadowOpacity: 1,
67
- shadowRadius: 15,
68
- },
69
- android: {
70
- elevation: 5,
71
- },
72
- }),
73
- },
74
- buttonText: {
75
- fontSize: 16,
76
- fontWeight: '600',
77
- color: '#ffffff',
78
- },
79
- });
@@ -1,12 +0,0 @@
1
- import '@expo/metro-runtime';
2
- import { registerRootComponent } from 'expo';
3
- import { ExpoRoot } from 'expo-router';
4
-
5
- // 显式定义 App 组件
6
- export function App() {
7
- // eslint-disable-next-line no-undef
8
- const ctx = require.context('./app');
9
- return <ExpoRoot context={ctx} />;
10
- }
11
-
12
- registerRootComponent(App);
@@ -1,51 +0,0 @@
1
- import React, { useState, useCallback } from 'react';
2
- import {
3
- View,
4
- Text,
5
- ScrollView,
6
- RefreshControl,
7
- } from 'react-native';
8
- import { useRouter, useFocusEffect } from 'expo-router';
9
- import { FontAwesome6 } from '@expo/vector-icons';
10
- import { useSafeAreaInsets } from 'react-native-safe-area-context';
11
- import { useTheme } from "@/hooks/useTheme";
12
-
13
- import { Screen } from '@/components/Screen';
14
-
15
- import { styles } from './styles';
16
-
17
-
18
- export default function HomeScreen() {
19
- const insets = useSafeAreaInsets();
20
- const { theme, isDark } = useTheme();
21
-
22
- const [isRefreshing, setIsRefreshing] = useState(false);
23
-
24
- const loadData = useCallback(async () => {
25
- }, []);
26
-
27
- useFocusEffect(
28
- useCallback(() => {
29
- loadData();
30
- }, [loadData])
31
- );
32
-
33
- const handleRefresh = useCallback(() => {
34
- setIsRefreshing(true);
35
- loadData();
36
- }, [loadData]);
37
- return (
38
- <Screen backgroundColor={theme.backgroundRoot} statusBarStyle={isDark ? 'light' : 'dark'}>
39
- <ScrollView
40
- showsVerticalScrollIndicator={false}
41
- contentContainerStyle={{}}
42
- refreshControl={
43
- <RefreshControl refreshing={isRefreshing} onRefresh={handleRefresh} colors={['#2563EB']} />
44
- }
45
- >
46
- <View style={[styles.header]}>
47
- </View>
48
- </ScrollView>
49
- </Screen>
50
- );
51
- }
@@ -1,60 +0,0 @@
1
- import { StyleSheet, Platform } from 'react-native';
2
-
3
- export const styles = StyleSheet.create({
4
- loadingContainer: {
5
- flex: 1,
6
- justifyContent: 'center',
7
- alignItems: 'center',
8
- },
9
- loadingText: {
10
- marginTop: 12,
11
- fontSize: 14,
12
- color: '#64748B',
13
- },
14
- errorContainer: {
15
- flex: 1,
16
- justifyContent: 'center',
17
- alignItems: 'center',
18
- paddingHorizontal: 24,
19
- },
20
- errorText: {
21
- marginTop: 16,
22
- fontSize: 16,
23
- color: '#64748B',
24
- },
25
- header: {
26
- flexDirection: 'row',
27
- justifyContent: 'space-between',
28
- alignItems: 'center',
29
- paddingHorizontal: 16,
30
- // paddingBottom: 16,
31
- backgroundColor: '#FFFFFF',
32
- // borderBottomWidth: 1,
33
- borderBottomColor: '#E2E8F0',
34
- },
35
- logoContainer: {
36
- width: 32,
37
- height: 32,
38
- backgroundColor: '#2563EB',
39
- borderRadius: 8,
40
- justifyContent: 'center',
41
- alignItems: 'center',
42
- ...Platform.select({
43
- ios: {
44
- shadowColor: '#000',
45
- shadowOffset: { width: 0, height: 1 },
46
- shadowOpacity: 0.1,
47
- shadowRadius: 2,
48
- },
49
- android: {
50
- elevation: 2,
51
- },
52
- }),
53
- },
54
- logoText: {
55
- fontSize: 18,
56
- fontWeight: '700',
57
- color: '#1E293B',
58
- letterSpacing: -0.5,
59
- },
60
- });
@@ -1,53 +0,0 @@
1
- const { getDefaultConfig } = require('expo/metro-config');
2
- // const { createProxyMiddleware } = require('http-proxy-middleware');
3
- const connect = require('connect');
4
-
5
- const config = getDefaultConfig(__dirname);
6
-
7
- // 安全地获取 Expo 的默认排除列表
8
- const existingBlockList = [].concat(config.resolver.blockList || []);
9
-
10
- config.resolver.blockList = [
11
- ...existingBlockList,
12
- /.*\/\.expo\/.*/, // Expo 的缓存和构建产物目录
13
-
14
- // 1. 原生代码 (Java/C++/Objective-C)
15
- /.*\/react-native\/ReactAndroid\/.*/,
16
- /.*\/react-native\/ReactCommon\/.*/,
17
-
18
- // 2. 纯开发和调试工具
19
- // 这些工具只在开发电脑上运行,不会被打包到应用中
20
- /.*\/@typescript-eslint\/eslint-plugin\/.*/,
21
-
22
- // 3. 构建时数据
23
- // 这个数据库只在打包过程中使用,应用运行时不需要
24
- /.*\/caniuse-lite\/data\/.*/,
25
-
26
- // 4. 通用规则
27
- /.*\/__tests__\/.*/, // 排除所有测试目录
28
- /.*\.git\/.*/, // 排除 Git 目录
29
- ];
30
-
31
- /*
32
- const apiProxy = createProxyMiddleware({
33
- target: 'http://localhost:5000',
34
- logLevel: 'debug',
35
- });
36
-
37
- config.server = {
38
- ...config.server,
39
- enhanceMiddleware: (metroMiddleware, metroServer) => {
40
- return connect()
41
- .use((req, res, next) => {
42
- if (req.url && req.url.startsWith('/api')) {
43
- console.log(`[Metro Proxy] Forwarding ${req.method} ${req.url}`);
44
- return apiProxy(req, res, next);
45
- }
46
- next();
47
- })
48
- .use(metroMiddleware);
49
- },
50
- }
51
- */
52
-
53
- module.exports = config;