Просмотр исходного кода

docs: 添加 Taro 小程序样式规范并修复组件布局问题

- 添加 Text 组件垂直排列规范到 CLAUDE.md
- 修复 EmploymentHistoryItem 组件中 Text 元素横向排列的问题
- 优化小程序发布脚本的构建配置逻辑

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
yourname 3 недель назад
Родитель
Сommit
63c4079205

+ 14 - 5
.claude/skills/weapp-publish/scripts/publish-weapp.js

@@ -30,14 +30,23 @@ const MINI_CONFIGS = {
 
 
 /**
 /**
  * 获取构建配置(根据 action 类型动态选择)
  * 获取构建配置(根据 action 类型动态选择)
+ *
+ * 说明:
+ * - dev (开发版预览): 使用 development 模式,跳过构建(使用 watch 模式的输出)
+ * - experience (体验版): 使用 development 模式,自动构建
+ * - production (正式版): 使用 production 模式,自动构建
+ *
+ * 目录结构:dist/weapp/{mode}/
  */
  */
 function getBuildConfig(config, action) {
 function getBuildConfig(config, action) {
-  const isDev = action === 'dev'
-  const mode = isDev ? 'development' : 'production'
+  // 体验版和开发版都使用 development 模式(连接开发环境)
+  // 只有正式版使用 production 模式
+  const mode = (action === 'experience' || action === 'dev') ? 'development' : 'production'
 
 
-  // 开发版和体验版都设置 NODE_ENV=development(使用 .env.development 配置)
-  // Taro build 默认不会进入 watch 模式(除非加 --watch 参数)
-  const buildCmd = `cd ${config.dir} && NODE_ENV=development pnpm taro build --type weapp`
+  // 根据模式设置对应的 NODE_ENV
+  // 这样构建输出目录和上传目录就能匹配了
+  const nodeEnv = mode === 'development' ? 'development' : 'production'
+  const buildCmd = `cd ${config.dir} && NODE_ENV=${nodeEnv} pnpm taro build --type weapp`
 
 
   return {
   return {
     ...config,
     ...config,

+ 26 - 0
CLAUDE.md

@@ -122,6 +122,32 @@
 - **表单调试**: 表单提交失败时,在表单form onsubmit=form.handleSubmit的第二个参数中加console.debug来看表单验证错误,例如:`form.handleSubmit(handleSubmit, (errors) => console.debug('表单验证错误:', errors))`
 - **表单调试**: 表单提交失败时,在表单form onsubmit=form.handleSubmit的第二个参数中加console.debug来看表单验证错误,例如:`form.handleSubmit(handleSubmit, (errors) => console.debug('表单验证错误:', errors))`
 - 类型检查 可以用 pnpm typecheck 加 grep来过滤要检查的 指定文件
 - 类型检查 可以用 pnpm typecheck 加 grep来过滤要检查的 指定文件
 - **长文档分段生成**: 如果文档(如 story 文档)太长一次生成不完,应该分段生成:
 - **长文档分段生成**: 如果文档(如 story 文档)太长一次生成不完,应该分段生成:
+
+### Taro 小程序样式规范
+
+由于 Tailwind `preflight: false` 禁用了基础样式重置,`Text` 组件默认是 **inline** 行内元素。
+
+**重要规则:当需要在 View 中垂直排列多个 Text 时,必须使用 `flex flex-col`**
+
+✅ 正确:
+```tsx
+<View className="flex flex-col">
+  <Text>公司名</Text>
+  <Text>岗位</Text>
+  <Text>日期</Text>
+</View>
+```
+
+❌ 错误(会横向排列):
+```tsx
+<View className="flex-1">
+  <Text>公司名</Text>
+  <Text>岗位</Text>
+  <Text>日期</Text>
+</View>
+```
+
+**注意**:`space-y-*` 等 Tailwind 工具类通过 `weapp-tailwindcss` 自动转换,在小程序环境中可以正常使用。
   1. 先使用 Write 工具创建文件的基础部分(header、requirements)
   1. 先使用 Write 工具创建文件的基础部分(header、requirements)
   2. 使用 Edit 工具逐步添加其他部分(dev notes、references、dev agent record 等)
   2. 使用 Edit 工具逐步添加其他部分(dev notes、references、dev agent record 等)
   3. 每次添加一个主要部分,确保不会超过单次生成的长度限制
   3. 每次添加一个主要部分,确保不会超过单次生成的长度限制

+ 2 - 2
mini-talent/src/components/EmploymentHistoryItem.tsx

@@ -4,7 +4,7 @@
  */
  */
 import React from 'react'
 import React from 'react'
 import { View, Text } from '@tarojs/components'
 import { View, Text } from '@tarojs/components'
-import { EmploymentHistoryItem, WorkStatus, isCurrentWork, formatDateRange } from '../types/employment'
+import { EmploymentHistoryItem, isCurrentWork, formatDateRange } from '../types/employment'
 
 
 interface EmploymentHistoryItemProps {
 interface EmploymentHistoryItemProps {
   item: EmploymentHistoryItem
   item: EmploymentHistoryItem
@@ -24,7 +24,7 @@ export const EmploymentHistoryItemComponent: React.FC<EmploymentHistoryItemProps
       </View>
       </View>
 
 
       {/* 内容 */}
       {/* 内容 */}
-      <View className="flex-1 pb-4">
+      <View className="flex flex-col flex-1 pb-4">
         <Text className="font-medium text-gray-800">{item.companyName || '未知企业'}</Text>
         <Text className="font-medium text-gray-800">{item.companyName || '未知企业'}</Text>
         <Text className="text-sm text-gray-500 mb-1">{item.orderName || item.positionName || '未知岗位'}</Text>
         <Text className="text-sm text-gray-500 mb-1">{item.orderName || item.positionName || '未知岗位'}</Text>
         <Text className="text-xs text-gray-500">{formatDateRange(item.joinDate, item.leaveDate)}</Text>
         <Text className="text-xs text-gray-500">{formatDateRange(item.joinDate, item.leaveDate)}</Text>