@coze-arch/cli 0.0.1-alpha.a17d4b → 0.0.1-alpha.a2a210

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.
@@ -43,4 +43,4 @@ kill_old_server
43
43
 
44
44
  echo "启动 server 服务..."
45
45
  cd "$SERVER_DIR"
46
- NODE_ENV=development PORT="$SERVER_PORT" npx tsx ./src/index.ts 2>&1 | pipe_to_log "SERVER" "$LOG_SERVER_FILE"
46
+ NODE_ENV=development PORT="$SERVER_PORT" npx tsx watch ./src/index.ts 2>&1 | pipe_to_log "SERVER" "$LOG_SERVER_FILE"
@@ -26,6 +26,9 @@ config.resolver.blockList = [
26
26
  // 4. 通用规则
27
27
  /.*\/__tests__\/.*/, // 排除所有测试目录
28
28
  /.*\.git\/.*/, // 排除 Git 目录
29
+
30
+ // 5. pnpm 临时目录(避免 ENOENT 错误)
31
+ /.*node_modules\/\.pnpm\/.*_tmp_\d+.*/,
29
32
  ];
30
33
 
31
34
  const BACKEND_TARGET = 'http://localhost:9091';
@@ -0,0 +1,11 @@
1
+ [project]
2
+ entrypoint = "index.html"
3
+ requires = ["python-3.12"]
4
+
5
+ [dev]
6
+ build = []
7
+ run = ["python", "-m", "http.server", "5000", "--bind", "0.0.0.0"]
8
+
9
+ [deploy]
10
+ build = []
11
+ run = ["python", "-m", "http.server", "5000", "--bind", "0.0.0.0"]
@@ -0,0 +1,33 @@
1
+ <!doctype html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <meta name="description" content="扣子编程,你的 AI 开发伙伴已就位" />
7
+ <title>扣子编程 - AI 开发伙伴</title>
8
+ <link rel="stylesheet" href="/styles/main.css" />
9
+ </head>
10
+ <body>
11
+ <div id="app">
12
+ <main class="main-wrapper">
13
+ <div class="content-container">
14
+ <img
15
+ src="https://lf-coze-web-cdn.coze.cn/obj/eden-cn/lm-lgvj/ljhwZthlaukjlkulzlp/coze-coding/icon/coze-coding.gif"
16
+ alt="扣子编程 Logo"
17
+ class="logo-image"
18
+ />
19
+ <div>
20
+ <div class="text-container">
21
+ <h1 class="heading">
22
+ 应用开发中
23
+ </h1>
24
+ <p class="description">
25
+ 请稍后,页面即将呈现
26
+ </p>
27
+ </div>
28
+ </div>
29
+ </div>
30
+ </main>
31
+ </div>
32
+ </body>
33
+ </html>
@@ -0,0 +1,136 @@
1
+ /* ABOUTME: Main stylesheet for native-static template */
2
+ /* ABOUTME: Provides layout, typography, and theme styles without external dependencies */
3
+
4
+ /* Reset and base styles */
5
+ * {
6
+ margin: 0;
7
+ padding: 0;
8
+ box-sizing: border-box;
9
+ }
10
+
11
+ :root {
12
+ /* Light theme colors */
13
+ --background: #ffffff;
14
+ --foreground: #171717;
15
+ --muted-foreground: #71717a;
16
+
17
+ /* Spacing */
18
+ --spacing-2: 0.5rem;
19
+ --spacing-4: 1rem;
20
+ --spacing-16: 4rem;
21
+ --spacing-32: 8rem;
22
+
23
+ /* Typography */
24
+ --font-size-base: 1rem;
25
+ --font-size-sm: 0.875rem;
26
+ --line-height-tight: 1.25;
27
+ --line-height-relaxed: 2;
28
+ --letter-spacing-tight: -0.025em;
29
+
30
+ /* Transitions */
31
+ --transition-duration: 300ms;
32
+ }
33
+
34
+ /* Dark theme */
35
+ @media (prefers-color-scheme: dark) {
36
+ :root {
37
+ --background: #0a0a0a;
38
+ --foreground: #ededed;
39
+ --muted-foreground: #a1a1aa;
40
+ }
41
+ }
42
+
43
+ body {
44
+ background: var(--background);
45
+ color: var(--foreground);
46
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
47
+ 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
48
+ sans-serif;
49
+ -webkit-font-smoothing: antialiased;
50
+ -moz-osx-font-smoothing: grayscale;
51
+ margin: 0;
52
+ padding: 0;
53
+ }
54
+
55
+ /* App container */
56
+ #app {
57
+ display: flex;
58
+ height: 100%;
59
+ min-height: 100vh;
60
+ align-items: center;
61
+ justify-content: center;
62
+ overflow: hidden;
63
+ }
64
+
65
+ /* Main content wrapper */
66
+ .main-wrapper {
67
+ display: flex;
68
+ width: 100%;
69
+ height: 100%;
70
+ max-width: 48rem;
71
+ flex-direction: column;
72
+ align-items: center;
73
+ justify-content: center;
74
+ padding-left: var(--spacing-16);
75
+ padding-right: var(--spacing-16);
76
+ padding-top: var(--spacing-32);
77
+ padding-bottom: var(--spacing-32);
78
+ }
79
+
80
+ /* Content container */
81
+ .content-container {
82
+ display: flex;
83
+ flex-direction: column;
84
+ align-items: center;
85
+ justify-content: space-between;
86
+ gap: var(--spacing-4);
87
+ }
88
+
89
+ /* Logo image */
90
+ .logo-image {
91
+ width: 156px;
92
+ height: 130px;
93
+ object-fit: contain;
94
+ }
95
+
96
+ /* Text container */
97
+ .text-container {
98
+ display: flex;
99
+ flex-direction: column;
100
+ align-items: center;
101
+ gap: var(--spacing-2);
102
+ text-align: center;
103
+ }
104
+
105
+ /* Heading */
106
+ .heading {
107
+ max-width: 36rem;
108
+ font-size: var(--font-size-base);
109
+ font-weight: 600;
110
+ line-height: var(--line-height-tight);
111
+ letter-spacing: var(--letter-spacing-tight);
112
+ color: var(--foreground);
113
+ }
114
+
115
+ /* Description text */
116
+ .description {
117
+ max-width: 42rem;
118
+ font-size: var(--font-size-sm);
119
+ line-height: var(--line-height-relaxed);
120
+ color: var(--muted-foreground);
121
+ }
122
+
123
+ /* Responsive design */
124
+ @media (max-width: 640px) {
125
+ .main-wrapper {
126
+ padding-left: 1rem;
127
+ padding-right: 1rem;
128
+ padding-top: 2rem;
129
+ padding-bottom: 2rem;
130
+ }
131
+
132
+ .logo-image {
133
+ width: 120px;
134
+ height: 100px;
135
+ }
136
+ }
@@ -0,0 +1,22 @@
1
+
2
+
3
+
4
+
5
+
6
+ // start_aigc
7
+ const config = {
8
+ description:
9
+ 'Native Static(纯静态):`coze init ${COZE_WORKSPACE_PATH} --template native-static`\n' +
10
+ '- 适用:纯静态 HTML/CSS/JS 项目、静态网站\n' +
11
+ '- 使用 Python http.server 作为开发服务器\n' +
12
+ '- 不需要 Node.js 环境,适合简单静态内容',
13
+ paramsSchema: {
14
+ type: 'object',
15
+ properties: {},
16
+ required: [],
17
+ additionalProperties: false,
18
+ },
19
+ };
20
+ // end_aigc
21
+
22
+ export default config;
@@ -8,5 +8,8 @@
8
8
  }
9
9
  }
10
10
  ]
11
+ ],
12
+ "plugins": [
13
+ "@react-dev-inspector/babel-plugin"
11
14
  ]
12
15
  }
@@ -1,81 +1,151 @@
1
1
  #!/bin/bash
2
-
3
2
  echo "⚙️ dev_run.sh 开始运行"
4
3
  set -Eeuo pipefail
5
4
 
6
5
  cd "${COZE_WORKSPACE_PATH}"
7
6
 
8
- echo "📦 Installing dependencies..."
9
- pnpm install
10
- echo "✅ Dependencies installed successfully!"
7
+ # ---------------------------------------------------------
8
+ # PID 文件,用于追踪上一次启动的进程树
9
+ # ---------------------------------------------------------
10
+ PID_FILE="/tmp/coze-dev-run.pid"
11
+
12
+ # ---------------------------------------------------------
13
+ # 工具函数
14
+ # ---------------------------------------------------------
15
+ kill_process_tree() {
16
+ local pid=$1
17
+ local children
18
+ children=$(pgrep -P "${pid}" 2>/dev/null || true)
19
+ for child in ${children}; do
20
+ kill_process_tree "${child}"
21
+ done
22
+ if kill -0 "${pid}" 2>/dev/null; then
23
+ echo "Killing PID ${pid}"
24
+ kill -9 "${pid}" 2>/dev/null || true
25
+ fi
26
+ }
11
27
 
12
28
  kill_port_if_listening() {
13
29
  local port=$1
14
30
  local pids
15
- pids=$(ss -H -lntp 2>/dev/null | awk -v port="${port}" '$4 ~ ":"port"$"' | grep -o 'pid=[0-9]*' | cut -d= -f2 | paste -sd' ' - || true)
31
+ pids=$(ss -H -lntp 2>/dev/null | awk -v port="${port}" '$4 ~ ":"port"$"' | grep -o 'pid=[0-9]*' | cut -d= -f2 | sort -u | paste -sd' ' - || true)
16
32
  if [[ -z "${pids}" ]]; then
17
- echo "Port ${port} is free."
18
- return
33
+ echo "Port ${port} is free."
34
+ return
19
35
  fi
20
36
  echo "Port ${port} in use by PIDs: ${pids}"
21
37
  for pid in ${pids}; do
22
- kill_process_group "${pid}"
38
+ kill_process_tree "${pid}"
23
39
  done
24
40
  sleep 1
25
- pids=$(ss -H -lntp 2>/dev/null | awk -v port="${port}" '$4 ~ ":"port"$"' | grep -o 'pid=[0-9]*' | cut -d= -f2 | paste -sd' ' - || true)
41
+ pids=$(ss -H -lntp 2>/dev/null | awk -v port="${port}" '$4 ~ ":"port"$"' | grep -o 'pid=[0-9]*' | cut -d= -f2 | sort -u | paste -sd' ' - || true)
26
42
  if [[ -n "${pids}" ]]; then
27
- echo "Warning: port ${port} still busy after cleanup, PIDs: ${pids}"
43
+ echo "Warning: port ${port} still busy after cleanup, PIDs: ${pids}"
28
44
  else
29
- echo "Port ${port} cleared."
45
+ echo "Port ${port} cleared."
30
46
  fi
31
47
  }
32
48
 
33
- kill_process_group() {
34
- local pid=$1
35
- local pgid
36
- pgid=$(ps -o pgid= -p "${pid}" 2>/dev/null | tr -d ' ' || true)
37
- if [[ -n "${pgid}" && "${pgid}" != "0" ]]; then
38
- echo "Killing process group ${pgid} (from PID ${pid})"
39
- kill -9 -"${pgid}" 2>/dev/null || true
40
- fi
41
- if kill -0 "${pid}" 2>/dev/null; then
42
- echo "Killing PID ${pid} directly"
43
- kill -9 "${pid}" 2>/dev/null || true
49
+ # ---------------------------------------------------------
50
+ # 1. 清理上一次运行残留的整棵进程树
51
+ # ---------------------------------------------------------
52
+ cleanup_previous_run() {
53
+ # 1a. 通过 PID 文件清理上次的进程树
54
+ if [[ -f "${PID_FILE}" ]]; then
55
+ local old_pid
56
+ old_pid=$(cat "${PID_FILE}" 2>/dev/null || true)
57
+ if [[ -n "${old_pid}" ]] && kill -0 "${old_pid}" 2>/dev/null; then
58
+ echo "🧹 Killing previous dev process tree (root PID: ${old_pid})..."
59
+ kill_process_tree "${old_pid}"
60
+ fi
61
+ rm -f "${PID_FILE}"
44
62
  fi
63
+
64
+ # 1b. 兜底:按特征匹配清理所有残留的相关进程(排除自身)
65
+ echo "🧹 Cleaning up any orphaned dev processes..."
66
+ local patterns=(
67
+ "pnpm dev"
68
+ "concurrently.*dev:web.*dev:server"
69
+ "nest start --watch"
70
+ "taro build --type h5 --watch"
71
+ "node --enable-source-maps.*/workspace/projects/server/dist/main"
72
+ "esbuild --service.*--ping"
73
+ )
74
+ for pattern in "${patterns[@]}"; do
75
+ local pids
76
+ pids=$(pgrep -f "${pattern}" 2>/dev/null || true)
77
+ for pid in ${pids}; do
78
+ # 不杀自己和自己的父进程链
79
+ if [[ "${pid}" != "$$" ]] && [[ "${pid}" != "${PPID}" ]]; then
80
+ echo " Killing orphan PID ${pid} matching '${pattern}'"
81
+ kill -9 "${pid}" 2>/dev/null || true
82
+ fi
83
+ done
84
+ done
85
+ sleep 1
86
+ }
87
+
88
+ # ---------------------------------------------------------
89
+ # 2. 安装依赖
90
+ # ---------------------------------------------------------
91
+ echo "📦 Installing dependencies..."
92
+ pnpm install
93
+ echo "✅ Dependencies installed successfully!"
94
+
95
+ # ---------------------------------------------------------
96
+ # 3. 清理旧进程 + 端口
97
+ # ---------------------------------------------------------
98
+ SERVER_PORT=3000
99
+
100
+ cleanup_previous_run
101
+
102
+ echo "Clearing port ${DEPLOY_RUN_PORT} (web) before start."
103
+ kill_port_if_listening "${DEPLOY_RUN_PORT}"
104
+ echo "Clearing port ${SERVER_PORT} (server) before start."
105
+ kill_port_if_listening "${SERVER_PORT}"
106
+
107
+ # ---------------------------------------------------------
108
+ # 4. 退出时自动清理子进程(信号 trap)
109
+ # ---------------------------------------------------------
110
+ cleanup_on_exit() {
111
+ echo "🛑 dev_run.sh exiting, cleaning up child processes..."
112
+ # 杀掉当前脚本的所有子进程
113
+ kill -- -$$ 2>/dev/null || true
114
+ rm -f "${PID_FILE}"
115
+ exit 0
45
116
  }
117
+ trap cleanup_on_exit EXIT INT TERM HUP
46
118
 
119
+ # ---------------------------------------------------------
120
+ # 5. 启动服务
121
+ # ---------------------------------------------------------
47
122
  start_service() {
48
123
  cd "${COZE_WORKSPACE_PATH}"
49
124
 
50
- # ---------------------------------------------------------
51
- # 0. 动态注入环境变量
52
- # ---------------------------------------------------------
53
- if [ -n "$COZE_PROJECT_DOMAIN_DEFAULT" ]; then
125
+ # 动态注入环境变量
126
+ if [ -n "${COZE_PROJECT_DOMAIN_DEFAULT:-}" ]; then
54
127
  export PROJECT_DOMAIN="$COZE_PROJECT_DOMAIN_DEFAULT"
55
128
  echo "✅ 环境变量已动态注入: PROJECT_DOMAIN=$PROJECT_DOMAIN"
56
129
  else
57
130
  echo "⚠️ 警告: COZE_PROJECT_DOMAIN_DEFAULT 未设置,使用 .env.local 中的配置"
58
131
  fi
59
132
 
60
- # ---------------------------------------------------------
61
133
  # 启动 Taro H5 和 NestJS Server
62
- # ---------------------------------------------------------
63
134
  echo "Starting Taro H5 Dev Server and NestJS Server..."
64
135
 
65
- # ⚠️ 重要:为了让 Taro 使用平台动态分配的端口
66
136
  export PORT=${DEPLOY_RUN_PORT}
67
-
68
137
  rm -f /tmp/coze-logs/dev.log
69
138
  mkdir -p /tmp/coze-logs
70
139
 
71
- exec pnpm dev 2>&1 | tee /tmp/coze-logs/dev.log
72
- }
140
+ # 后台启动并记录 PID
141
+ pnpm dev 2>&1 | tee /tmp/coze-logs/dev.log &
142
+ local dev_pid=$!
143
+ echo "${dev_pid}" > "${PID_FILE}"
144
+ echo "📝 Dev process started with PID: ${dev_pid} (saved to ${PID_FILE})"
73
145
 
74
- SERVER_PORT=<%= serverPort %>
146
+ # 前台等待,保证 trap 能正常捕获信号
147
+ wait "${dev_pid}" || true
148
+ }
75
149
 
76
- echo "Clearing port ${DEPLOY_RUN_PORT} (web) before start."
77
- kill_port_if_listening "${DEPLOY_RUN_PORT}"
78
- echo "Clearing port ${SERVER_PORT} (server) before start."
79
- kill_port_if_listening "${SERVER_PORT}"
80
150
  echo "Starting HTTP services on port ${DEPLOY_RUN_PORT} (web) and ${SERVER_PORT} (server)..."
81
151
  start_service
@@ -1 +1,24 @@
1
- pnpm build:weapp
1
+ # build_weapp.sh - 通过 PID 文件精确杀掉自己上次的构建进程
2
+ export OUTPUT_ROOT=dist
3
+ PID_FILE="/tmp/coze-build_weapp.pid"
4
+
5
+ # 杀掉上次的构建进程组
6
+ if [ -f "$PID_FILE" ]; then
7
+ OLD_PID=$(cat "$PID_FILE")
8
+ if kill -0 "$OLD_PID" 2>/dev/null; then
9
+ echo "正在终止上次的构建进程组 (PID: $OLD_PID)..."
10
+ # 关键:kill 负数 PID = 杀掉整个进程组
11
+ kill -9 -"$OLD_PID" 2>/dev/null
12
+ sleep 1
13
+ fi
14
+ rm -f "$PID_FILE"
15
+ fi
16
+
17
+ # 用 setsid 创建新的进程组,方便下次整组杀掉
18
+ setsid pnpm build:weapp &
19
+ echo $! > "$PID_FILE"
20
+
21
+ echo "构建已启动 (PID: $(cat $PID_FILE))"
22
+
23
+ wait $!
24
+ rm -f "$PID_FILE"
@@ -10,7 +10,7 @@
10
10
  - **样式**: TailwindCSS 4.1.18
11
11
  - **Tailwind 适配层**: weapp-tailwindcss 4.9.2
12
12
  - **状态管理**: Zustand 5.0.9
13
- - **图标库**: lucide-react 0.511.0
13
+ - **图标库**: lucide-react-taro latest
14
14
  - **工程化**: Vite 4.2.0
15
15
  - **包管理**: pnpm
16
16
  - **运行时**: Node.js >= 18
@@ -28,14 +28,16 @@
28
28
  │ ├── dev.ts # 开发环境配置
29
29
  │ └── prod.ts # 生产环境配置
30
30
  ├── server/ # NestJS 后端服务
31
- │ └── src/
31
+ │ └── src/
32
32
  │ ├── main.ts # 服务入口
33
33
  │ ├── app.module.ts # 根模块
34
34
  │ ├── app.controller.ts # 应用控制器
35
35
  │ └── app.service.ts # 应用服务
36
36
  ├── src/ # 前端源码
37
37
  │ ├── pages/ # 页面组件
38
+ │ ├── presets/ # 框架预置逻辑(无需读取,如无必要不改动)
38
39
  │ ├── utils/ # 工具函数
40
+ │ ├── network.ts # 封装好的网络请求工具
39
41
  │ ├── app.ts # 应用入口
40
42
  │ ├── app.config.ts # 应用配置
41
43
  │ └── app.css # 全局样式
@@ -237,8 +239,8 @@ Network 是对 Taro.request、Taro.uploadFile、Taro.downloadFile 的封装,
237
239
  import { Network } from '@/network'
238
240
 
239
241
  // GET 请求
240
- const data = await Network.request({
241
- url: '/api/hello'
242
+ const data = await Network.request({
243
+ url: '/api/hello'
242
244
  })
243
245
 
244
246
  // POST 请求
@@ -267,8 +269,8 @@ await Network.downloadFile({
267
269
  import Taro from '@tarojs/taro'
268
270
 
269
271
  // ❌ 会导致自动域名拼接无法生效,除非是特殊指定域名
270
- const data = await Network.request({
271
- url: 'http://localhost/api/hello'
272
+ const data = await Network.request({
273
+ url: 'http://localhost/api/hello'
272
274
  })
273
275
 
274
276
  // ❌ 不要直接使用 Taro.request
@@ -344,23 +346,29 @@ const router = useRouter()
344
346
  const { id } = router.params
345
347
  ```
346
348
 
347
- ### 图标使用 (lucide-react)
349
+ ### 图标使用 (lucide-react-taro)
350
+
351
+ **IMPORTANT: 禁止使用 lucide-react,必须使用 lucide-react-taro 替代。**
348
352
 
349
- 项目集成了 [lucide-react](https://lucide.dev/) 图标库,提供丰富的 SVG 图标:
353
+ lucide-react-taro Lucide 图标库的 Taro 适配版本,专为小程序环境优化,API 与 lucide-react 一致:
350
354
 
351
355
  ```tsx
352
356
  import { View } from '@tarojs/components'
353
- import { Home, Settings, User, Search, Heart, Star } from 'lucide-react'
357
+ import { House, Settings, User, Search, Camera, Zap } from 'lucide-react-taro'
354
358
 
355
359
  const IconDemo = () => {
356
360
  return (
357
361
  <View className="flex gap-4">
358
- <Home size={24} color="#333" />
359
- <Settings size={24} className="text-blue-500" />
360
- <User size={20} strokeWidth={1.5} />
361
- <Search size={24} />
362
- <Heart size={24} fill="red" color="red" />
363
- <Star size={24} className="text-yellow-500" />
362
+ {/* 基本用法 */}
363
+ <House />
364
+ {/* 自定义尺寸和颜色 */}
365
+ <Settings size={32} color="#1890ff" />
366
+ {/* 自定义描边宽度 */}
367
+ <User size={24} strokeWidth={1.5} />
368
+ {/* 绝对描边宽度(描边不随 size 缩放) */}
369
+ <Camera size={48} strokeWidth={2} absoluteStrokeWidth />
370
+ {/* 组合使用 */}
371
+ <Zap size={32} color="#ff6b00" strokeWidth={1.5} className="my-icon" />
364
372
  </View>
365
373
  )
366
374
  }
@@ -368,12 +376,66 @@ const IconDemo = () => {
368
376
 
369
377
  常用属性:
370
378
  - `size` - 图标大小(默认 24)
371
- - `color` - 图标颜色
379
+ - `color` - 图标颜色(默认 currentColor,小程序中建议显式设置)
372
380
  - `strokeWidth` - 线条粗细(默认 2)
373
- - `className` - 支持 Tailwind 类名
381
+ - `absoluteStrokeWidth` - 绝对描边宽度,启用后描边不随 size 缩放
382
+ - `className` / `style` - 自定义样式
374
383
 
375
384
  更多图标请访问:https://lucide.dev/icons
376
385
 
386
+ ### TabBar 图标生成 (CLI 工具)
387
+
388
+ **IMPORTANT: 微信小程序的 TabBar 不支持 base64 或 SVG 图片,必须使用本地 PNG 文件。**
389
+
390
+ lucide-react-taro 提供了 CLI 工具来生成 TabBar 所需的 PNG 图标:
391
+
392
+ ```bash
393
+ # 生成带选中状态的图标
394
+ npx taro-lucide-tabbar House Settings User -c "#999999" -a "#1890ff"
395
+
396
+ # 指定输出目录和尺寸
397
+ npx taro-lucide-tabbar House Settings User -c "#999999" -a "#1890ff" -o ./src/assets/tabbar -s 81
398
+ ```
399
+
400
+ CLI 参数:
401
+ - `--color, -c` (默认 #000000): 图标颜色
402
+ - `--active-color, -a`: 选中状态颜色
403
+ - `--size, -s` (默认 81): 图标尺寸
404
+ - `--output, -o` (默认 ./tabbar-icons): 输出目录
405
+ - `--stroke-width` (默认 2): 描边宽度
406
+
407
+ 在 `app.config.ts` 中使用生成的图标:
408
+
409
+ ```typescript
410
+ export default defineAppConfig({
411
+ tabBar: {
412
+ color: '#999999',
413
+ selectedColor: '#1890ff',
414
+ backgroundColor: '#ffffff',
415
+ borderStyle: 'black',
416
+ list: [
417
+ {
418
+ pagePath: 'pages/index/index',
419
+ text: '首页',
420
+ iconPath: './assets/tabbar/house.png',
421
+ selectedIconPath: './assets/tabbar/house-active.png',
422
+ },
423
+ {
424
+ pagePath: 'pages/settings/index',
425
+ text: '设置',
426
+ iconPath: './assets/tabbar/settings.png',
427
+ selectedIconPath: './assets/tabbar/settings-active.png',
428
+ },
429
+ {
430
+ pagePath: 'pages/user/index',
431
+ text: '用户',
432
+ iconPath: './assets/tabbar/user.png',
433
+ selectedIconPath: './assets/tabbar/user-active.png',
434
+ },
435
+ ],
436
+ },
437
+ })
438
+
377
439
  ### Tailwind CSS 样式开发
378
440
 
379
441
  IMPORTANT:必须使用 tailwindcss 实现样式,只有在必要情况下才能 fallback 到 css / less
@@ -16,7 +16,7 @@ import pkg from '../package.json';
16
16
  // https://taro-docs.jd.com/docs/next/config#defineconfig-辅助函数
17
17
  export default defineConfig<'vite'>(async (merge, _env) => {
18
18
  const isWeChatApp = process.env.TARO_ENV === 'weapp';
19
- const outputRoot = isWeChatApp ? 'dist' : 'dist-web';
19
+ const outputRoot = process.env.OUTPUT_ROOT || (isWeChatApp ? 'dist-weapp' : 'dist-web')
20
20
 
21
21
  const baseConfig: UserConfigExport<'vite'> = {
22
22
  projectName: '<%= appName %>',
@@ -30,23 +30,45 @@ export default [
30
30
  message:
31
31
  '请勿在 src 目录下直接使用 process.env\n如需获取 URL 请求前缀,请使用已经注入全局的 PROJECT_DOMAIN()',
32
32
  },
33
+ {
34
+ selector:
35
+ ":matches(ExportNamedDeclaration, ExportDefaultDeclaration) :matches([id.name='Network'], [declaration.id.name='Network'])",
36
+ message:
37
+ "禁止自行定义 Network,项目已提供 src/network.ts,请直接使用: import { Network } from '@/network'",
38
+ },
33
39
  ],
34
40
  'no-restricted-properties': [
35
41
  'error',
36
42
  {
37
43
  object: 'Taro',
38
44
  property: 'request',
39
- message: '请使用 Network.request 替代 Taro.request',
45
+ message:
46
+ "请使用 Network.request 替代 Taro.request,导入方式: import { Network } from '@/network'",
40
47
  },
41
48
  {
42
49
  object: 'Taro',
43
50
  property: 'uploadFile',
44
- message: '请使用 Network.uploadFile 替代 Taro.uploadFile',
51
+ message:
52
+ "请使用 Network.uploadFile 替代 Taro.uploadFile,导入方式: import { Network } from '@/network'",
45
53
  },
46
54
  {
47
55
  object: 'Taro',
48
56
  property: 'downloadFile',
49
- message: '请使用 Network.downloadFile 替代 Taro.downloadFile',
57
+ message:
58
+ "请使用 Network.downloadFile 替代 Taro.downloadFile,导入方式: import { Network } from '@/network'",
59
+ },
60
+ ],
61
+ },
62
+ },
63
+ {
64
+ files: ['src/pages/index/index.tsx'],
65
+ rules: {
66
+ 'no-restricted-syntax': [
67
+ 'error',
68
+ {
69
+ selector: 'JSXText[value=/应用开发中/]',
70
+ message:
71
+ '检测到首页 (src/pages/index/index) 仍为默认占位页面,这会导致用户无法进入新增页面,请根据用户需求开发实际的首页功能和界面。如果已经开发了新的首页,也需要删除旧首页,并更新 src/app.config.ts 文件',
50
72
  },
51
73
  ],
52
74
  },