@coze-arch/cli 0.0.1-alpha.3002ee → 0.0.1-alpha.3ce8c6

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 (60) hide show
  1. package/lib/__templates__/expo/.coze +7 -2
  2. package/lib/__templates__/expo/.cozeproj/scripts/{deploy_build.sh → dev_build.sh} +4 -10
  3. package/lib/__templates__/expo/.cozeproj/scripts/{deploy_run.sh → dev_run.sh} +25 -57
  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/README.md +41 -12
  7. package/lib/__templates__/expo/_gitignore +1 -1
  8. package/lib/__templates__/expo/_npmrc +3 -5
  9. package/lib/__templates__/expo/client/app/_layout.tsx +1 -1
  10. package/lib/__templates__/expo/client/app/index.ts +1 -0
  11. package/lib/__templates__/expo/client/app.config.ts +71 -0
  12. package/lib/__templates__/expo/client/components/ThemedText.tsx +33 -0
  13. package/lib/__templates__/expo/client/components/ThemedView.tsx +38 -0
  14. package/lib/__templates__/expo/client/constants/theme.ts +779 -47
  15. package/lib/__templates__/expo/client/contexts/AuthContext.tsx +14 -107
  16. package/lib/__templates__/expo/client/hooks/useTheme.ts +1 -1
  17. package/lib/__templates__/expo/client/metro.config.js +121 -0
  18. package/lib/__templates__/expo/client/package.json +92 -0
  19. package/lib/__templates__/expo/client/screens/home/index.tsx +1 -5
  20. package/lib/__templates__/expo/client/screens/home/styles.ts +1 -273
  21. package/lib/__templates__/expo/client/tsconfig.json +24 -0
  22. package/lib/__templates__/expo/client/utils/index.ts +1 -2
  23. package/lib/__templates__/expo/package.json +16 -12
  24. package/lib/__templates__/expo/pnpm-lock.yaml +383 -516
  25. package/lib/__templates__/expo/pnpm-workspace.yaml +3 -0
  26. package/lib/__templates__/expo/server/package.json +17 -0
  27. package/lib/__templates__/expo/{src → server/src}/index.ts +2 -2
  28. package/lib/__templates__/expo/template.config.js +1 -1
  29. package/lib/__templates__/expo/tsconfig.json +1 -24
  30. package/lib/__templates__/nextjs/.coze +3 -3
  31. package/lib/__templates__/nextjs/_npmrc +1 -1
  32. package/lib/__templates__/nextjs/package.json +8 -3
  33. package/lib/__templates__/nextjs/pnpm-lock.yaml +2495 -1122
  34. package/lib/__templates__/nextjs/scripts/dev.sh +8 -27
  35. package/lib/__templates__/nextjs/src/app/globals.css +99 -87
  36. package/lib/__templates__/nextjs/src/app/layout.tsx +18 -22
  37. package/lib/__templates__/nextjs/template.config.js +1 -1
  38. package/lib/__templates__/templates.json +7 -0
  39. package/lib/__templates__/vite/.coze +3 -3
  40. package/lib/__templates__/vite/README.md +204 -26
  41. package/lib/__templates__/vite/_npmrc +1 -1
  42. package/lib/__templates__/vite/package.json +1 -1
  43. package/lib/__templates__/vite/pnpm-lock.yaml +120 -120
  44. package/lib/__templates__/vite/scripts/dev.sh +7 -26
  45. package/lib/__templates__/vite/template.config.js +10 -1
  46. package/lib/__templates__/vite/vite.config.ts +3 -3
  47. package/lib/cli.js +408 -248
  48. package/package.json +7 -3
  49. package/lib/__templates__/expo/app.json +0 -63
  50. package/lib/__templates__/expo/babel.config.js +0 -9
  51. package/lib/__templates__/expo/client/app/(tabs)/_layout.tsx +0 -43
  52. package/lib/__templates__/expo/client/app/(tabs)/home.tsx +0 -1
  53. package/lib/__templates__/expo/client/app/(tabs)/index.tsx +0 -7
  54. package/lib/__templates__/expo/client/app/+not-found.tsx +0 -79
  55. package/lib/__templates__/expo/client/index.js +0 -12
  56. package/lib/__templates__/expo/metro.config.js +0 -53
  57. package/lib/__templates__/nextjs/.babelrc +0 -15
  58. package/lib/__templates__/nextjs/server.mjs +0 -50
  59. /package/lib/__templates__/expo/{eslint-formatter-simple.mjs → client/eslint-formatter-simple.mjs} +0 -0
  60. /package/lib/__templates__/expo/{eslint.config.mjs → client/eslint.config.mjs} +0 -0
@@ -3,5 +3,10 @@ entrypoint = "server.js"
3
3
  requires = ["nodejs-24"]
4
4
 
5
5
  [dev]
6
- build = ["bash", ".cozeproj/scripts/deploy_build.sh"]
7
- run = ["bash", ".cozeproj/scripts/deploy_run.sh"]
6
+ build = ["bash", ".cozeproj/scripts/dev_build.sh"]
7
+ run = ["bash", ".cozeproj/scripts/dev_run.sh"]
8
+
9
+ [deploy]
10
+ build = ["bash", ".cozeproj/scripts/prod_build.sh"]
11
+ run = ["bash", ".cozeproj/scripts/prod_run.sh"]
12
+ build_app_dir = "."
@@ -2,6 +2,7 @@
2
2
  if [ -z "${BASH_VERSION:-}" ]; then exec /usr/bin/env bash "$0" "$@"; fi
3
3
  set -euo pipefail
4
4
  ROOT_DIR="$(pwd)"
5
+ PREVIEW_DIR="${COZE_PREVIEW_DIR:-$ROOT_DIR}"
5
6
  LOG_DIR="${COZE_LOG_DIR:-$ROOT_DIR/logs}"
6
7
  LOG_FILE="$LOG_DIR/app.log"
7
8
  mkdir -p "$LOG_DIR"
@@ -48,22 +49,15 @@ fs.writeSync(fd, record+"\n", null, "utf8");
48
49
  fs.fsyncSync(fd);
49
50
  fs.closeSync(fd);
50
51
  ' "$LOG_FILE" "$level" "$msg"
51
-
52
- case "$level" in
53
- INFO) info "$msg" ;;
54
- WARN) warn "$msg" ;;
55
- ERROR) echo -e "\033[31m[ERROR] $msg\033[0m" ;;
56
- *) info "$msg" ;;
57
- esac
58
52
  }
59
53
 
60
54
  # ==================== 前置检查 ====================
61
55
  write_log "INFO" "==================== 开始构建 ===================="
62
56
 
63
57
  write_log "INFO" "检查根目录 pre_install.py"
64
- if [ -f "$ROOT_DIR/pre_install.py" ]; then
65
- write_log "INFO" "执行:python $ROOT_DIR/pre_install.py"
66
- python "$ROOT_DIR/pre_install.py" || write_log "ERROR" "pre_install.py 执行失败"
58
+ if [ -f "$PREVIEW_DIR/pre_install.py" ]; then
59
+ write_log "INFO" "执行:python $PREVIEW_DIR/pre_install.py"
60
+ python "$PREVIEW_DIR/pre_install.py" || write_log "ERROR" "pre_install.py 执行失败"
67
61
  fi
68
62
 
69
63
  write_log "INFO" "开始执行构建脚本(build_dev.sh)..."
@@ -1,16 +1,17 @@
1
1
  ROOT_DIR="$(cd "$(dirname "$0")" && pwd)"
2
+ PREVIEW_DIR="${COZE_PREVIEW_DIR:-$ROOT_DIR}"
2
3
  LOG_DIR="${COZE_LOG_DIR:-$ROOT_DIR/logs}"
3
4
  LOG_FILE="$LOG_DIR/app.log"
4
5
  mkdir -p "$LOG_DIR"
5
6
 
6
7
  # ==================== 配置项 ====================
7
- # Python 服务配置
8
+ # Server 服务配置
8
9
  SERVER_HOST="0.0.0.0"
9
10
  SERVER_PORT="9091"
10
11
  # Expo 项目配置
11
12
  EXPO_HOST="0.0.0.0"
12
13
  EXPO_DIR="expo"
13
- EXPO_PORT="9090"
14
+ EXPO_PORT="5000"
14
15
  WEB_URL="${COZE_PROJECT_DOMAIN_DEFAULT:-http://127.0.0.1:${SERVER_PORT}}"
15
16
  ASSUME_YES="1"
16
17
  EXPO_PUBLIC_BACKEND_BASE_URL="${EXPO_PUBLIC_BACKEND_BASE_URL:-$WEB_URL}"
@@ -116,18 +117,12 @@ fs.writeSync(fd, record+"\n", null, "utf8");
116
117
  fs.fsyncSync(fd);
117
118
  fs.closeSync(fd);
118
119
  ' "$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
120
  }
126
121
 
127
122
  wait_port_connectable() {
128
123
  local host=$1 port=$2 retries=${3:-10}
129
124
  for _ in $(seq 1 "$retries"); do
130
- nc -z "$host" "$port" && return 0
125
+ nc -z -w 1 "$host" "$port" >/dev/null 2>&1 && return 0
131
126
  sleep 1
132
127
  done
133
128
  return 1
@@ -135,13 +130,18 @@ wait_port_connectable() {
135
130
 
136
131
  start_expo() {
137
132
  local offline="${1:-0}"
133
+
134
+ pushd ./client
135
+
138
136
  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 &
137
+ 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
138
  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 &
139
+ 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
140
  fi
143
141
  EXPO_PID=$!
144
142
  echo "$EXPO_PID"
143
+
144
+ popd
145
145
  }
146
146
 
147
147
  detect_expo_fetch_failed() {
@@ -159,6 +159,15 @@ detect_expo_fetch_failed() {
159
159
  }
160
160
 
161
161
  # ==================== 前置检查 ====================
162
+ # 关掉nginx进程
163
+ ps -ef | grep nginx | grep -v grep | awk '{print $2}' | xargs -r kill -9
164
+
165
+ write_log "INFO" "检查根目录 pre_install.py"
166
+ if [ -f "$PREVIEW_DIR/pre_install.py" ]; then
167
+ write_log "INFO" "执行:python $PREVIEW_DIR/pre_install.py"
168
+ python "$PREVIEW_DIR/pre_install.py" || write_log "ERROR" "pre_install.py 执行失败"
169
+ fi
170
+
162
171
  write_log "INFO" "==================== 开始启动 ===================="
163
172
  write_log "INFO" "开始执行服务启动脚本(start_dev.sh)..."
164
173
  write_log "INFO" "正在检查依赖命令和目录是否存在..."
@@ -175,42 +184,10 @@ mkdir -p logs
175
184
  ensure_port SERVER_PORT "$SERVER_PORT"
176
185
  ensure_port EXPO_PORT "$EXPO_PORT"
177
186
 
178
- # ==================== 步骤 1:启动 Python 服务 ====================
179
-
180
- # ------------环境变量----------------------
181
- export storage_type="s3"
182
- export project_platform="app"
183
-
184
- if [ -n "${COZE_WORKLOAD_IDENTITY_API_KEY:-}" ]; then
185
- export OPENAI_API_KEY="$COZE_WORKLOAD_IDENTITY_API_KEY"
186
- fi
187
- if [ -n "${OPENAI_API_KEY:-}" ]; then
188
- export ARK_API_KEY="$OPENAI_API_KEY"
189
- fi
190
-
191
- if [ -n "${COZE_INTEGRATION_BASE_URL:-}" ]; then
192
- _base="${COZE_INTEGRATION_BASE_URL%/}"
193
- export default_llm_base_url="${_base}/api/v3"
194
- else
195
- export default_llm_base_url="https://ark.cn-beijing.volces.com/api/v3"
196
- fi
197
-
198
- if [ -n "${PGDATABASE_URL:-}" ]; then
199
- _pg="${PGDATABASE_URL}"
200
- case "${_pg}" in
201
- postgresql://*)
202
- _pg="postgresql+asyncpg://${_pg#postgresql://}"
203
- ;;
204
- esac
205
- _pg="${_pg%%\?*}"
206
- export DATABASE_URL="${_pg}"
207
- fi
208
-
209
- # ------------环境变量----------------------
210
-
187
+ # ==================== 启动 Server 服务 ====================
211
188
  write_log "INFO" "==================== 启动 server 服务 ===================="
212
- write_log "INFO" "正在执行:npm run server"
213
- PORT="$SERVER_PORT" nohup npm run server > logs/app.log 2>&1 &
189
+ write_log "INFO" "正在执行:npm run dev"
190
+ PORT="$SERVER_PORT" nohup npm run dev --prefix ./server > logs/app.log 2>&1 &
214
191
  SERVER_PID=$!
215
192
  if [ -z "${SERVER_PID}" ]; then
216
193
  write_log "ERROR" "无法获取 server 后台进程 PID"
@@ -218,8 +195,7 @@ fi
218
195
  write_log "INFO" "server 服务已启动,进程 ID:${SERVER_PID:-unknown}"
219
196
 
220
197
  write_log "INFO" "==================== 启动 Expo 项目 ===================="
221
- write_log "INFO" "正在执行:npx expo start --port ${EXPO_PORT}"
222
- write_log "INFO" "开始启动 Expo 服务"
198
+ write_log "INFO" "开始启动 Expo 服务,端口 ${EXPO_PORT}"
223
199
  EXPO_PID=$(start_expo 0)
224
200
  if detect_expo_fetch_failed 8; then
225
201
  write_log "WARN" "Expo 启动检测到网络错误:TypeError: fetch failed,启用离线模式重试"
@@ -227,7 +203,7 @@ if detect_expo_fetch_failed 8; then
227
203
  : > logs/expo.log
228
204
  EXPO_PID=$(start_expo 1)
229
205
  fi
230
- # 输出以下环境变量,确保 Expo 项目能正确连接到 Python 服务
206
+ # 输出以下环境变量,确保 Expo 项目能正确连接到 Server 服务
231
207
  write_log "INFO" "Expo 环境变量配置:"
232
208
  write_log "INFO" "EXPO_PUBLIC_BACKEND_BASE_URL=${EXPO_PUBLIC_BACKEND_BASE_URL}"
233
209
  write_log "INFO" "EXPO_PACKAGER_PROXY_URL=${EXPO_PACKAGER_PROXY_URL}"
@@ -260,12 +236,4 @@ if [ -f "$ROOT_DIR/post_run.py" ]; then
260
236
  write_log "INFO" "启动检查结束"
261
237
  fi
262
238
 
263
- write_log "INFO" "检查 Nginx 端口 (5000)..."
264
- if is_port_free 5000; then
265
- write_log "INFO" "端口 5000 未被占用,正在启动 Nginx..."
266
- service nginx start
267
- else
268
- write_log "INFO" "端口 5000 已被占用,跳过 Nginx 启动"
269
- fi
270
-
271
239
  write_log "INFO" "==================== 服务启动完成 ===================="
@@ -0,0 +1,47 @@
1
+ #!/bin/bash
2
+ if [ -z "${BASH_VERSION:-}" ]; then exec /usr/bin/env bash "$0" "$@"; fi
3
+ set -euo pipefail
4
+ ROOT_DIR="$(pwd)"
5
+
6
+ # ==================== 工具函数 ====================
7
+ info() {
8
+ echo "[INFO] $1"
9
+ }
10
+ warn() {
11
+ echo "[WARN] $1"
12
+ }
13
+ error() {
14
+ echo "[ERROR] $1"
15
+ exit 1
16
+ }
17
+ check_command() {
18
+ if ! command -v "$1" &> /dev/null; then
19
+ error "命令 $1 未找到,请先安装"
20
+ fi
21
+ }
22
+
23
+ info "==================== 开始构建 ===================="
24
+ info "开始执行构建脚本(build_prod.sh)..."
25
+ info "正在检查依赖命令是否存在..."
26
+ # 检查核心命令
27
+ check_command "pnpm"
28
+ check_command "npm"
29
+
30
+ # ==================== 安装 Node 依赖 ====================
31
+ info "==================== 安装 Node 依赖 ===================="
32
+ info "开始安装 Node 依赖"
33
+ if [ -f "$ROOT_DIR/package.json" ]; then
34
+ info "进入目录:$ROOT_DIR"
35
+ info "正在执行:pnpm install"
36
+ (cd "$ROOT_DIR" && pnpm install --registry=https://registry.npmmirror.com) || error "Node 依赖安装失败"
37
+ else
38
+ warn "未找到 $ROOT_DIR/package.json 文件,请检查路径是否正确"
39
+ fi
40
+ info "==================== 依赖安装完成!====================\n"
41
+
42
+ info "==================== dist打包 ===================="
43
+ info "开始执行:npm run build --prefix server"
44
+ (cd "$ROOT_DIR" && npm run build --prefix ./server) || error "dist打包失败"
45
+ info "==================== dist打包完成!====================\n"
46
+
47
+ info "下一步:执行 ./prod_run.sh 启动服务"
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env bash
2
+ # 产物部署使用
3
+ set -euo pipefail
4
+
5
+ ROOT_DIR="$(pwd)"
6
+
7
+ HOST="${HOST:-0.0.0.0}"
8
+ PORT="${PORT:-5000}"
9
+
10
+ # ==================== 工具函数 ====================
11
+ info() {
12
+ echo "[INFO] $1"
13
+ }
14
+ warn() {
15
+ echo "[WARN] $1"
16
+ }
17
+ error() {
18
+ echo "[ERROR] $1"
19
+ exit 1
20
+ }
21
+ check_command() {
22
+ if ! command -v "$1" &> /dev/null; then
23
+ error "命令 $1 未找到,请先安装"
24
+ fi
25
+ }
26
+
27
+ # ============== 启动服务 ======================
28
+ # 检查核心命令
29
+ check_command "pnpm"
30
+ check_command "npm"
31
+
32
+ info "开始执行:npm run start"
33
+ (cd "$ROOT_DIR" && PORT="$PORT" npm run start --prefix ./server) || error "服务启动失败"
34
+ info "服务启动完成!\n"
@@ -1,13 +1,42 @@
1
- # Expo App Template
2
- ## 安装依赖
3
- ```bash
4
- pnpm install
5
- ```
6
- ## 启动 Metro 服务
7
- ```bash
8
- npx expo start
9
- ```
10
- ## 启动 Node 服务器
11
- ```bash
12
- npm run server
1
+ # Expo App + Express.js
2
+
3
+ ## 目录结构规范(严格遵循)
4
+
5
+ 当前仓库是一个 monorepo(基于 pnpm 的 workspace)
6
+ 其中 Expo 代码在 client 目录,Express.js 代码在 server 目录
7
+
8
+ 目录结构说明
9
+
10
+ ├── server/ # 服务端代码 (Express.js)
11
+ │ ├── index.ts # Express 入口文件
12
+ | └── package.json # 服务端 package.json
13
+ ├── client/ # React Native 前端代码
14
+ │ ├── app/ # Expo Router 路由目录(仅路由配置)
15
+ │ │ ├── _layout.tsx # 根布局文件(必需)
16
+ │ │ └── index.ts # 首页
17
+ │ ├── screens/ # 页面实现目录(与 app/ 路由对应)
18
+ │ │ └── home/
19
+ │ │ ├── index.tsx # 页面组件实现
20
+ │ │ └── styles.ts # 页面样式
21
+ │ ├── components/ # 可复用组件
22
+ │ │ └── Screen.tsx # 页面容器组件(必用)
23
+ │ ├── hooks/ # 自定义 Hooks
24
+ │ ├── contexts/ # React Context 代码
25
+ │ ├── assets/ # 静态资源
26
+ | └── package.json # Expo 应用 package.json
27
+ ├── package.json
28
+ ├── .cozeproj # 预置脚手架脚本(禁止修改)
29
+ └── .coze # 配置文件(禁止修改)
30
+
31
+ ## Expo 路径别名
32
+ Expo 配置了 `@/` 路径别名指向 `client/` 目录:
33
+
34
+ ```tsx
35
+ // 正确
36
+ import { Screen } from '@/components/Screen';
37
+
38
+ // 避免相对路径
39
+ import { Screen } from '../../../components/Screen';
13
40
  ```
41
+
42
+
@@ -8,4 +8,4 @@ expo/expo-env.d.ts
8
8
  expo-env.d.ts
9
9
  .DS_Store
10
10
  logs/
11
- tsconfig.tsbuildinfo
11
+ *.tsbuildinfo
@@ -1,4 +1,4 @@
1
- registry=https://registry.npmjs.org
1
+ registry=https://registry.npmmirror.com
2
2
 
3
3
  strictStorePkgContentCheck=false
4
4
  verifyStoreIntegrity=false
@@ -8,15 +8,13 @@ network-concurrency=16
8
8
  fetch-retries=3
9
9
  fetch-timeout=60000
10
10
 
11
- # 严格使用 peer dependencies
11
+ # peerDependencies
12
12
  strict-peer-dependencies=false
13
-
14
- # 自动生成 lockfile
15
13
  auto-install-peers=true
16
14
 
17
15
  # lockfile 配置
18
16
  lockfile=true
19
17
  prefer-frozen-lockfile=true
20
18
 
21
- # 如果 lockfile 存在但过期,更新而不是失败
19
+ # semver 选择最高版本
22
20
  resolution-mode=highest
@@ -24,7 +24,7 @@ export default function RootLayout() {
24
24
  // 隐藏自带的头部
25
25
  headerShown: false
26
26
  }}>
27
- <Stack.Screen name="(tabs)" options={{ title: "" }} />
27
+ <Stack.Screen name="index" options={{ title: "" }} />
28
28
  </Stack>
29
29
  <Toast />
30
30
  </GestureHandlerRootView>
@@ -0,0 +1 @@
1
+ export { default } from '@/screens/home'
@@ -0,0 +1,71 @@
1
+ import { ExpoConfig, ConfigContext } from 'expo/config';
2
+
3
+ export default ({ config }: ConfigContext): ExpoConfig => {
4
+ return {
5
+ ...config,
6
+ "name": "${app_name}",
7
+ "slug": "${slug}",
8
+ "version": "1.0.0",
9
+ "orientation": "portrait",
10
+ "icon": "./assets/images/icon.png",
11
+ "scheme": "myapp",
12
+ "userInterfaceStyle": "automatic",
13
+ "newArchEnabled": true,
14
+ "ios": {
15
+ "supportsTablet": true
16
+ },
17
+ "android": {
18
+ "adaptiveIcon": {
19
+ "foregroundImage": "./assets/images/adaptive-icon.png",
20
+ "backgroundColor": "#ffffff"
21
+ }
22
+ },
23
+ "web": {
24
+ "bundler": "metro",
25
+ "output": "single",
26
+ "favicon": "./assets/images/favicon.png"
27
+ },
28
+ "plugins": [
29
+ process.env.EXPO_PUBLIC_BACKEND_BASE_URL ? [
30
+ "expo-router",
31
+ {
32
+ "origin": process.env.EXPO_PUBLIC_BACKEND_BASE_URL
33
+ }
34
+ ] : 'expo-router',
35
+ [
36
+ "expo-splash-screen",
37
+ {
38
+ "image": "./assets/images/splash-icon.png",
39
+ "imageWidth": 200,
40
+ "resizeMode": "contain",
41
+ "backgroundColor": "#ffffff"
42
+ }
43
+ ],
44
+ [
45
+ "expo-image-picker",
46
+ {
47
+ "photosPermission": "允许${app_name}访问您的相册,以便您上传或保存图片。",
48
+ "cameraPermission": "允许${app_name}使用您的相机,以便您直接拍摄照片上传。",
49
+ "microphonePermission": "允许${app_name}访问您的麦克风,以便您拍摄带有声音的视频。"
50
+ }
51
+ ],
52
+ [
53
+ "expo-location",
54
+ {
55
+ "locationWhenInUsePermission": "${app_name}需要访问您的位置以提供周边服务及导航功能。"
56
+ }
57
+ ],
58
+ [
59
+ "expo-camera",
60
+ {
61
+ "cameraPermission": "${app_name}需要访问相机以拍摄照片和视频。",
62
+ "microphonePermission": "${app_name}需要访问麦克风以录制视频声音。",
63
+ "recordAudioAndroid": true
64
+ }
65
+ ]
66
+ ],
67
+ "experiments": {
68
+ "typedRoutes": true
69
+ }
70
+ }
71
+ }
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import { Text, TextProps, TextStyle } from 'react-native';
3
+ import { useTheme } from '@/hooks/useTheme';
4
+ import { Typography } from '@/constants/theme';
5
+
6
+ type TypographyVariant = keyof typeof Typography;
7
+
8
+ interface ThemedTextProps extends TextProps {
9
+ variant?: TypographyVariant;
10
+ color?: string;
11
+ }
12
+
13
+ export function ThemedText({
14
+ variant = 'body',
15
+ color,
16
+ style,
17
+ children,
18
+ ...props
19
+ }: ThemedTextProps) {
20
+ const { theme } = useTheme();
21
+ const typographyStyle = Typography[variant];
22
+
23
+ const textStyle: TextStyle = {
24
+ ...typographyStyle,
25
+ color: color ?? theme.textPrimary,
26
+ };
27
+
28
+ return (
29
+ <Text style={[textStyle, style]} {...props}>
30
+ {children}
31
+ </Text>
32
+ );
33
+ }
@@ -0,0 +1,38 @@
1
+ import React from 'react';
2
+ import { View, ViewProps, ViewStyle } from 'react-native';
3
+ import { useTheme } from '@/hooks/useTheme';
4
+
5
+ type BackgroundLevel = 'root' | 'default' | 'secondary' | 'tertiary';
6
+
7
+ interface ThemedViewProps extends ViewProps {
8
+ level?: BackgroundLevel;
9
+ backgroundColor?: string;
10
+ }
11
+
12
+ const backgroundMap: Record<BackgroundLevel, string> = {
13
+ root: 'backgroundRoot',
14
+ default: 'backgroundDefault',
15
+ secondary: 'backgroundSecondary',
16
+ tertiary: 'backgroundTertiary',
17
+ };
18
+
19
+ export function ThemedView({
20
+ level = 'root',
21
+ backgroundColor,
22
+ style,
23
+ children,
24
+ ...props
25
+ }: ThemedViewProps) {
26
+ const { theme } = useTheme();
27
+ const bgColor = backgroundColor ?? (theme as any)[backgroundMap[level]];
28
+
29
+ const viewStyle: ViewStyle = {
30
+ backgroundColor: bgColor,
31
+ };
32
+
33
+ return (
34
+ <View style={[viewStyle, style]} {...props}>
35
+ {children}
36
+ </View>
37
+ );
38
+ }