create-dwy 0.5.1 → 0.6.0

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 (156) hide show
  1. package/bin/index.js +1 -1
  2. package/package.json +2 -2
  3. package/src/create.js +61 -37
  4. package/src/sync.js +212 -61
  5. package/templates/claude-global/CLAUDE.md +92 -0
  6. package/templates/claude-global/rules/dwy-android-core.md +610 -0
  7. package/templates/claude-global/rules/dwy-api-design.md +110 -0
  8. package/templates/claude-global/rules/dwy-db-migration.md +46 -0
  9. package/templates/claude-global/rules/dwy-flutter-core.md +564 -0
  10. package/templates/claude-global/rules/dwy-flutter-network.md +222 -0
  11. package/templates/claude-global/rules/dwy-flutter-router.md +97 -0
  12. package/templates/claude-global/rules/dwy-flutter-testing.md +94 -0
  13. package/templates/claude-global/rules/dwy-git-commit-convention.md +82 -0
  14. package/templates/claude-global/rules/dwy-git-security.md +53 -0
  15. package/templates/claude-global/rules/dwy-payload-limits.md +178 -0
  16. package/templates/claude-global/rules/{prefer-open-source.md → dwy-prefer-open-source.md} +4 -0
  17. package/templates/claude-global/rules/dwy-project-structure.md +181 -0
  18. package/templates/claude-global/rules/{python-code-style.md → dwy-python-core.md} +292 -358
  19. package/templates/claude-global/rules/dwy-python-fastapi.md +272 -0
  20. package/templates/claude-global/rules/dwy-python-orm.md +61 -0
  21. package/templates/claude-global/rules/{backend-security.md → dwy-python-security.md} +99 -72
  22. package/templates/claude-global/rules/dwy-python-testing.md +53 -0
  23. package/templates/claude-global/rules/{server-security.md → dwy-server-security.md} +1 -2
  24. package/templates/claude-global/rules/dwy-tdd-development.md +70 -0
  25. package/templates/claude-global/rules/dwy-tech-stack.md +60 -0
  26. package/templates/claude-global/rules/dwy-vue-api.md +146 -0
  27. package/templates/claude-global/rules/{vue-code-style.md → dwy-vue-core.md} +338 -152
  28. package/templates/claude-global/rules/dwy-vue-pinia.md +75 -0
  29. package/templates/claude-global/rules/dwy-vue-testing.md +102 -0
  30. package/templates/claude-global/skills/dwy-deploy-audit/SKILL.md +481 -0
  31. package/templates/claude-global/skills/dwy-deploy-audit/references/checks-data.md +117 -0
  32. package/templates/claude-global/skills/dwy-deploy-audit/references/checks-network.md +74 -0
  33. package/templates/claude-global/skills/dwy-deploy-audit/references/checks-runtime.md +184 -0
  34. package/templates/claude-global/skills/dwy-deploy-audit/scripts/check_base.sh +39 -0
  35. package/templates/claude-global/skills/dwy-deploy-audit/scripts/check_capacity.sh +278 -0
  36. package/templates/claude-global/skills/dwy-deploy-audit/scripts/check_db.sh +122 -0
  37. package/templates/claude-global/skills/dwy-deploy-audit/scripts/check_docker.sh +249 -0
  38. package/templates/claude-global/skills/dwy-deploy-audit/scripts/check_env.sh +64 -0
  39. package/templates/claude-global/skills/dwy-deploy-audit/scripts/check_https.sh +60 -0
  40. package/templates/claude-global/skills/dwy-deploy-audit/scripts/check_logs.sh +209 -0
  41. package/templates/claude-global/skills/dwy-deploy-audit/scripts/check_nginx.sh +92 -0
  42. package/templates/claude-global/skills/dwy-deploy-audit/scripts/check_resilience.sh +157 -0
  43. package/templates/claude-global/skills/dwy-deploy-audit/scripts/check_secrets.sh +327 -0
  44. package/templates/claude-global/skills/dwy-deploy-audit/scripts/check_services.sh +77 -0
  45. package/templates/claude-global/skills/dwy-deploy-audit/scripts/check_ssh.sh +56 -0
  46. package/templates/claude-global/skills/dwy-deploy-audit/scripts/run_all.sh +105 -0
  47. package/templates/claude-global/skills/dwy-docker/SKILL.md +187 -0
  48. package/templates/claude-global/skills/dwy-docker/references/ask-templates.md +142 -0
  49. package/templates/claude-global/skills/dwy-docker/references/templates.md +479 -0
  50. package/templates/claude-global/skills/dwy-docker/references/version-rules.md +76 -0
  51. package/templates/claude-global/skills/dwy-docker/scripts/query_dockerhub.py +204 -0
  52. package/templates/claude-global/skills/dwy-docker/scripts/scan_images.sh +185 -0
  53. package/templates/claude-global/skills/dwy-eapi/SKILL.md +433 -0
  54. package/templates/claude-global/skills/dwy-eapi/references/tasks-integration-guide.md +387 -0
  55. package/templates/claude-global/skills/dwy-ekit/SKILL.md +85 -0
  56. package/templates/claude-global/skills/dwy-ekit/references/data.md +135 -0
  57. package/templates/claude-global/skills/dwy-ekit/references/form.md +68 -0
  58. package/templates/claude-global/skills/dwy-ekit/references/request.md +183 -0
  59. package/templates/claude-global/skills/dwy-ekit/references/ui.md +109 -0
  60. package/templates/claude-global/skills/{dwy-frontend-eui → dwy-eui}/SKILL.md +129 -15
  61. package/templates/claude-global/skills/dwy-eui/references/eui-design-guide.md +257 -0
  62. package/templates/claude-global/skills/dwy-eui/references/eui-integration-guide.md +302 -0
  63. package/templates/claude-global/skills/dwy-eui/references/eui-landing-design-guide.md +437 -0
  64. package/templates/claude-global/skills/dwy-fullstack-scaffold/SKILL.md +214 -0
  65. package/templates/claude-global/skills/dwy-mirror-source/SKILL.md +275 -0
  66. package/templates/claude-global/skills/dwy-mirror-source/references/dockerfile-snippets.md +228 -0
  67. package/templates/claude-global/skills/dwy-mirror-source/references/mirror-providers.md +150 -0
  68. package/templates/claude-global/skills/dwy-mirror-source/scripts/__pycache__/check_mirrors.cpython-313.pyc +0 -0
  69. package/templates/claude-global/skills/dwy-mirror-source/scripts/apply_mirrors.py +666 -0
  70. package/templates/claude-global/skills/dwy-mirror-source/scripts/check_mirrors.py +868 -0
  71. package/templates/claude-global/skills/dwy-pentest/SKILL.md +344 -0
  72. package/templates/claude-global/skills/dwy-pentest/scripts/lib/__init__.py +1 -0
  73. package/templates/claude-global/skills/dwy-pentest/scripts/lib/__pycache__/__init__.cpython-311.pyc +0 -0
  74. package/templates/claude-global/skills/dwy-pentest/scripts/lib/__pycache__/config.cpython-311.pyc +0 -0
  75. package/templates/claude-global/skills/dwy-pentest/scripts/lib/__pycache__/executor.cpython-311.pyc +0 -0
  76. package/templates/claude-global/skills/dwy-pentest/scripts/lib/__pycache__/severity.cpython-311.pyc +0 -0
  77. package/templates/claude-global/skills/dwy-pentest/scripts/lib/__pycache__/validator.cpython-311.pyc +0 -0
  78. package/templates/claude-global/skills/dwy-pentest/scripts/lib/config.py +109 -0
  79. package/templates/claude-global/skills/dwy-pentest/scripts/lib/executor.py +157 -0
  80. package/templates/claude-global/skills/dwy-pentest/scripts/lib/severity.py +96 -0
  81. package/templates/claude-global/skills/dwy-pentest/scripts/lib/validator.py +113 -0
  82. package/templates/claude-global/skills/dwy-pentest/scripts/pentest_auth.py +289 -0
  83. package/templates/claude-global/skills/dwy-pentest/scripts/pentest_recon.py +217 -0
  84. package/templates/claude-global/skills/dwy-pentest/scripts/pentest_report.py +343 -0
  85. package/templates/claude-global/skills/dwy-pentest/scripts/pentest_scan.py +205 -0
  86. package/templates/claude-global/skills/dwy-pentest/scripts/pentest_ssl.py +208 -0
  87. package/templates/claude-global/skills/dwy-pentest/scripts/pentest_vuln.py +205 -0
  88. package/templates/claude-global/skills/dwy-pentest/scripts/pentest_web.py +330 -0
  89. package/templates/claude-global/skills/dwy-pentest/scripts/pyproject.toml +14 -0
  90. package/templates/claude-global/skills/dwy-pentest/scripts/setup_tools.sh +97 -0
  91. package/templates/claude-global/skills/dwy-pentest/scripts/uv.lock +415 -0
  92. package/templates/claude-global/skills/{dwy-release → dwy-publish}/SKILL.md +42 -18
  93. package/templates/claude-global/skills/dwy-vue-core/SKILL.md +890 -0
  94. package/templates/project/backend/.dwy.hbs +5 -0
  95. package/templates/project/backend/.python-version +1 -0
  96. package/templates/project/backend/CLAUDE.md.hbs +40 -0
  97. package/templates/project/{web/backend → backend}/alembic/script.py.mako +2 -0
  98. package/templates/project/{web/backend → backend}/alembic.ini.hbs +0 -1
  99. package/templates/project/backend/deploy.sh.hbs +18 -0
  100. package/templates/project/{web → backend}/docker-compose.prod.yml.hbs +1 -1
  101. package/templates/project/{web/backend → backend}/pyproject.toml.hbs +4 -5
  102. package/templates/project/{web/backend → backend}/src/app/config.py.hbs +1 -1
  103. package/templates/project/backend/src/app/database.py +10 -0
  104. package/templates/project/backend/src/app/dependencies.py +5 -0
  105. package/templates/project/{web/backend → backend}/src/app/main.py.hbs +3 -3
  106. package/templates/project/backend/src/app/models/base.py +5 -0
  107. package/templates/project/web/CLAUDE.md.hbs +29 -36
  108. package/templates/project/web/{frontend → apps/web}/index.html.hbs +1 -0
  109. package/templates/project/web/{frontend → apps/web}/package.json.hbs +4 -3
  110. package/templates/project/web/apps/web/src/App.vue +9 -0
  111. package/templates/project/web/apps/web/src/api/client.ts +5 -0
  112. package/templates/project/web/apps/web/src/composables/.gitkeep +0 -0
  113. package/templates/project/web/apps/web/src/layouts/DefaultLayout.vue +8 -0
  114. package/templates/project/web/{frontend → apps/web}/src/router/index.ts +1 -1
  115. package/templates/project/web/{frontend → apps/web}/src/stores/auth.ts +4 -2
  116. package/templates/project/web/apps/web/src/style.css +2 -0
  117. package/templates/project/web/apps/web/src/types/router.d.ts +8 -0
  118. package/templates/project/web/apps/web/src/views/HomeView.vue +8 -0
  119. package/templates/project/web/apps/web/tsconfig.app.json +18 -0
  120. package/templates/project/web/apps/web/tsconfig.json +6 -0
  121. package/templates/project/web/{frontend → apps/web}/vite.config.ts.hbs +7 -1
  122. package/templates/project/web/package.json.hbs +16 -0
  123. package/templates/project/web/packages/.gitkeep +0 -0
  124. package/templates/project/web/pnpm-workspace.yaml +3 -0
  125. package/templates/claude-global/hooks/post-sync-claude-global.sh +0 -72
  126. package/templates/claude-global/rules/agent-team-execution.md +0 -138
  127. package/templates/claude-global/rules/agent-team-patterns.md +0 -157
  128. package/templates/claude-global/rules/git-commit-convention.md +0 -106
  129. package/templates/claude-global/rules/git-security.md +0 -144
  130. package/templates/claude-global/skills/dwy-backend-base/SKILL.md +0 -279
  131. package/templates/claude-global/skills/dwy-frontend-core/SKILL.md +0 -181
  132. package/templates/project/web/.claude/commands/deploy.md +0 -4
  133. package/templates/project/web/backend/src/app/models/base.py +0 -5
  134. package/templates/project/web/deploy.sh.hbs +0 -113
  135. package/templates/project/web/frontend/src/App.vue +0 -3
  136. package/templates/project/web/frontend/src/api/client.ts +0 -13
  137. package/templates/project/web/frontend/src/style.css +0 -1
  138. package/templates/project/web/frontend/src/views/HomeView.vue +0 -5
  139. package/templates/project/web/frontend/tsconfig.app.json +0 -14
  140. package/templates/project/web/frontend/tsconfig.json +0 -4
  141. /package/templates/{project/web/backend → claude-global/skills/dwy-pentest/scripts}/.python-version +0 -0
  142. /package/templates/project/{web/backend → backend}/Dockerfile +0 -0
  143. /package/templates/project/{web/backend → backend}/alembic/env.py.hbs +0 -0
  144. /package/templates/{claude-global/skills → project/backend/alembic/versions}/.gitkeep +0 -0
  145. /package/templates/project/{web → backend}/docker-compose.dev.yml.hbs +0 -0
  146. /package/templates/project/{web/backend → backend}/src/app/__init__.py +0 -0
  147. /package/templates/project/{web/backend → backend}/src/app/models/__init__.py +0 -0
  148. /package/templates/project/{web/backend → backend}/src/app/routers/__init__.py +0 -0
  149. /package/templates/project/{web/backend → backend}/src/app/routers/health.py +0 -0
  150. /package/templates/project/{web/backend → backend}/src/app/schemas/__init__.py +0 -0
  151. /package/templates/project/{web/backend → backend}/src/app/services/__init__.py +0 -0
  152. /package/templates/project/{web/backend → backend}/tests/__init__.py +0 -0
  153. /package/templates/project/{web/backend → backend}/tests/conftest.py.hbs +0 -0
  154. /package/templates/project/{web/backend/alembic/versions → mobile}/.gitkeep +0 -0
  155. /package/templates/project/web/{frontend → apps/web}/src/components/.gitkeep +0 -0
  156. /package/templates/project/web/{frontend → apps/web}/src/main.ts +0 -0
@@ -0,0 +1,257 @@
1
+ # EUI 页面设计风格规范
2
+
3
+ > AI 使用 @dwydev/eui 编写 UI 页面时必须遵循此规范。
4
+
5
+ ## 一、设计风格定位
6
+
7
+ **shadcn 风格 + 中后台场景**:干净、克制、功能优先。不追求视觉冲击力,追求信息密度和操作效率。
8
+
9
+ | 维度 | 规范 |
10
+ |------|------|
11
+ | 风格 | 扁平、无装饰、留白适度 |
12
+ | 色彩 | 中性灰为主,主色点缀,不超过 3 种颜色 |
13
+ | 圆角 | 统一 `rounded-md`(0.625rem),不混用不同圆角 |
14
+ | 阴影 | 仅 `shadow-xs` / `shadow-sm`,不用 `shadow-lg` 及以上 |
15
+ | 边框 | 1px `border-border`,不用粗边框 |
16
+ | 图标 | 只用 `lucide-vue-next`,不用 emoji、不用其他图标库 |
17
+ | 字体 | 系统字体栈(不引入额外字体),依赖 Tailwind 默认 |
18
+
19
+ ## 二、颜色系统
20
+
21
+ ### 语义色(直接使用,不写具体色值)
22
+
23
+ | 用途 | Tailwind class | 说明 |
24
+ |------|---------------|------|
25
+ | 页面背景 | `bg-background` | 浅色/深色自动切换 |
26
+ | 主文本 | `text-foreground` | 最高对比度 |
27
+ | 次要文本 | `text-muted-foreground` | 描述、辅助信息 |
28
+ | 主色按钮/强调 | `bg-primary text-primary-foreground` | 主操作 |
29
+ | 次要按钮 | `bg-secondary text-secondary-foreground` | 次要操作 |
30
+ | 卡片背景 | `bg-card text-card-foreground` | 卡片容器 |
31
+ | 危险/错误 | `text-destructive` / `bg-destructive` | 删除、错误 |
32
+ | 边框 | `border-border` | 统一边框色 |
33
+ | 输入框边框 | `border-input` | 表单控件 |
34
+ | 聚焦环 | `ring-ring` | focus 状态 |
35
+
36
+ ### 禁止
37
+
38
+ - **禁止**写死色值(如 `bg-[#3B82F6]`),必须用语义 token
39
+ - **禁止**用 `bg-blue-500` 等 Tailwind 原始色(除了 chart 场景)
40
+ - **禁止**超过 3 种颜色混用
41
+
42
+ ### 主题色
43
+
44
+ EUI 支持 7 种主题色,通过 `<html class="theme-blue">` 切换,代码中不需要关心具体色值:
45
+
46
+ neutral(默认)| blue | green | rose | orange | violet | slate
47
+
48
+ ## 三、暗色模式
49
+
50
+ - 所有页面必须同时支持亮色和暗色
51
+ - 使用语义色 token 自动适配,不需要手写 `dark:` 前缀
52
+ - 特殊场景需要区分时使用 `dark:` 变体
53
+ - 背景层级:`bg-background` > `bg-card` > `bg-muted`
54
+ - 暗色模式下避免纯白文字,用 `text-foreground` 自动适配
55
+
56
+ ## 四、布局规范
57
+
58
+ ### 页面结构
59
+
60
+ ```vue
61
+ <!-- 标准中后台页面 -->
62
+ <div class="flex flex-col gap-6 p-6">
63
+ <!-- 页头:标题 + 操作 -->
64
+ <div class="flex items-center justify-between">
65
+ <div>
66
+ <h1 class="text-2xl font-semibold">页面标题</h1>
67
+ <p class="text-sm text-muted-foreground">页面描述</p>
68
+ </div>
69
+ <div class="flex gap-2">
70
+ <EButton variant="outline">次要操作</EButton>
71
+ <EButton>主操作</EButton>
72
+ </div>
73
+ </div>
74
+
75
+ <!-- 内容区 -->
76
+ <div>...</div>
77
+ </div>
78
+ ```
79
+
80
+ ### 间距规则
81
+
82
+ | 场景 | 间距 | 说明 |
83
+ |------|------|------|
84
+ | 页面内边距 | `p-6` | 24px |
85
+ | 区块间距 | `gap-6` | 24px |
86
+ | 卡片内边距 | `p-4` 或 `p-6` | 16px 或 24px |
87
+ | 表单项间距 | `space-y-4` | 16px |
88
+ | 按钮间距 | `gap-2` | 8px |
89
+ | 紧凑元素间距 | `gap-1` | 4px |
90
+
91
+ ### 按钮放置
92
+
93
+ - 表单/弹窗的操作按钮**右对齐**:`flex justify-end gap-2`
94
+ - 次要操作在前(左),主操作在后(右)
95
+ - 危险操作用 `variant="destructive"`,放最右
96
+
97
+ ## 五、组件使用规范
98
+
99
+ ### 优先级
100
+
101
+ 使用 EUI 组件的优先级:**EUI 组件 > 组合组件 > 原生 HTML**
102
+
103
+ | 需求 | 使用 | 不使用 |
104
+ |------|------|--------|
105
+ | 按钮 | `<EButton>` | `<button>` |
106
+ | 输入框 | `<EInput>` | `<input>` |
107
+ | 下拉选择 | `<ESelect>` | `<select>` |
108
+ | 开关 | `<ESwitch>` | `<input type="checkbox">` |
109
+ | 表格 | `<ETable>` | `<table>` |
110
+ | 弹窗 | `<EDialog>` | 自定义 modal |
111
+ | 轻提示 | `useMessage()` / `toast()` | `alert()` |
112
+ | 表单 | `<EForm>` | `<form>` |
113
+ | 确认框 | `<EConfirmDialog>` | `confirm()` |
114
+
115
+ ### 表单
116
+
117
+ > **禁止使用原生 `<form>` 标签。** 所有表单必须使用 `<EForm>` 组件,EForm 内置 vee-validate 校验、provide/inject 上下文传递、统一的 label 布局和 reset/validate API,原生 `<form>` 无法与 EUI 表单体系集成。
118
+
119
+ ```vue
120
+ <!-- 标准表单 -->
121
+ <EForm ref="formRef" :model="model" :rules="rules" label-width="80px">
122
+ <EFormItem label="名称" prop="name">
123
+ <EInput v-model="model.name" placeholder="请输入" />
124
+ </EFormItem>
125
+ <EFormItem>
126
+ <div class="flex justify-end gap-2">
127
+ <EButton variant="outline" @click="handleReset">重置</EButton>
128
+ <EButton @click="handleSubmit">提交</EButton>
129
+ </div>
130
+ </EFormItem>
131
+ </EForm>
132
+ ```
133
+
134
+ ### 表格页
135
+
136
+ ```vue
137
+ <!-- 标准 CRUD 列表页 -->
138
+ <div class="flex flex-col gap-6 p-6">
139
+ <!-- 筛选栏 -->
140
+ <EForm inline :model="filters">
141
+ <EFormItem label="关键词">
142
+ <EInput v-model="filters.keyword" placeholder="搜索..." />
143
+ </EFormItem>
144
+ <EFormItem>
145
+ <EButton @click="search">搜索</EButton>
146
+ </EFormItem>
147
+ </EForm>
148
+
149
+ <!-- 表格 -->
150
+ <ETable :data="list" :columns="columns" :loading="loading" />
151
+
152
+ <!-- 分页 -->
153
+ <EPagination
154
+ v-model="page"
155
+ :total="total"
156
+ v-model:pageSize="pageSize"
157
+ showSizeChanger
158
+ showTotal
159
+ />
160
+ </div>
161
+ ```
162
+
163
+ ### 弹窗
164
+
165
+ - 表单弹窗用 `<EFormDialog>` 或 `<EDialog>` + 表单
166
+ - 确认操作用 `<EConfirmDialog>`
167
+ - Dialog 内容超长时自动滚动(body 区域),header/footer 固定
168
+ - `maxWidth` 控制宽度:表单弹窗 `500px`,详情弹窗 `600px`
169
+
170
+ ## 六、排版规范
171
+
172
+ | 元素 | class | 场景 |
173
+ |------|-------|------|
174
+ | 页面标题 | `text-2xl font-semibold` | h1 |
175
+ | 区块标题 | `text-lg font-semibold` | h2 |
176
+ | 卡片标题 | `text-base font-medium` | h3 |
177
+ | 正文 | `text-sm` | 默认文本 |
178
+ | 辅助文字 | `text-sm text-muted-foreground` | 描述、提示 |
179
+ | 小字 | `text-xs text-muted-foreground` | 时间戳、标签 |
180
+
181
+ ### 禁止
182
+
183
+ - **禁止**超过 `text-3xl` 的字号(中后台不需要)
184
+ - **禁止**用 `font-bold`(用 `font-semibold` 或 `font-medium`)
185
+ - **禁止**正文用 `text-xs`(太小)
186
+
187
+ ## 七、交互规范
188
+
189
+ ### 状态反馈
190
+
191
+ | 操作 | 反馈方式 |
192
+ |------|---------|
193
+ | 表单提交成功 | `toast.success('保存成功')` 或 `useMessage().success()` |
194
+ | 表单提交失败 | 字段级错误提示(EForm 自动处理) |
195
+ | 删除确认 | `<EConfirmDialog type="warning">` |
196
+ | 异步加载 | `<ETable :loading="true">` 或 `<ESkeleton>` |
197
+ | 空数据 | `<EEmpty>` |
198
+
199
+ ### 过渡动画
200
+
201
+ - 弹窗/抽屉:EUI 组件内置,不需要额外处理
202
+ - 列表切换:`<Transition>` + `duration-200`
203
+ - 加载态:`<ESkeleton>` 占位,不用空白闪烁
204
+ - **禁止**花哨动画(弹跳、旋转入场等)
205
+
206
+ ### 响应式
207
+
208
+ | 断点 | 宽度 | 场景 |
209
+ |------|------|------|
210
+ | sm | 640px | 手机横屏 |
211
+ | md | 768px | 平板 |
212
+ | lg | 1024px | 小桌面 |
213
+ | xl | 1280px | 标准桌面 |
214
+
215
+ 中后台页面最小支持 `md`(768px),不强求手机适配。
216
+
217
+ ## 八、ESelect 特殊约束
218
+
219
+ - `option.value` **不能为空字符串**(reka-ui 不支持)
220
+ - 需要"全部"选项时 value 用 `'all'`,不用 `''`
221
+
222
+ ## 九、卡片/面板规范
223
+
224
+ ```vue
225
+ <!-- 标准卡片 -->
226
+ <div class="rounded-lg border bg-card p-6">
227
+ <h3 class="text-base font-medium mb-4">卡片标题</h3>
228
+ <!-- 内容 -->
229
+ </div>
230
+
231
+ <!-- 统计卡片 -->
232
+ <div class="rounded-lg border bg-card p-4">
233
+ <p class="text-sm text-muted-foreground">指标名称</p>
234
+ <p class="text-2xl font-semibold mt-1">1,234</p>
235
+ </div>
236
+ ```
237
+
238
+ - 卡片用 `rounded-lg border bg-card`,不加阴影
239
+ - 卡片标题和内容间距 `mb-4`
240
+ - 统计卡片用紧凑内边距 `p-4`
241
+
242
+ ## 十、代码自检清单
243
+
244
+ AI 生成页面代码后,逐条验证:
245
+
246
+ | # | 检查项 |
247
+ |---|--------|
248
+ | 1 | 颜色只用语义 token(bg-primary/text-foreground 等),不写死色值 |
249
+ | 2 | 图标只用 lucide-vue-next,无 emoji |
250
+ | 3 | 表单必须用 EForm,表单控件用 EUI 组件,禁止原生 `<form>` 和原生 HTML 控件 |
251
+ | 4 | 按钮操作区右对齐,次要在前主要在后 |
252
+ | 5 | 弹窗指定 maxWidth,不让内容无限撑开 |
253
+ | 6 | 可交互元素有 hover 反馈和 cursor-pointer |
254
+ | 7 | 文本层级清晰:标题 semibold、正文 sm、辅助 muted-foreground |
255
+ | 8 | 暗色模式下所有元素可见可读 |
256
+ | 9 | 空状态用 EEmpty,加载态用 loading prop 或 ESkeleton |
257
+ | 10 | ESelect 选项 value 不为空字符串 |
@@ -0,0 +1,302 @@
1
+ # @dwydev/eui 集成指南
2
+
3
+ 在你的 Vue 3 项目中集成 @dwydev/eui 组件库。
4
+
5
+ ## 1. 安装依赖
6
+
7
+ ### 安装组件库
8
+
9
+ ```bash
10
+ pnpm add @dwydev/eui
11
+ ```
12
+
13
+ ### 安装 Peer Dependencies
14
+
15
+ ```bash
16
+ pnpm add -D tailwindcss @tailwindcss/vite tw-animate-css
17
+ ```
18
+
19
+ | 包名 | 版本要求 | 说明 |
20
+ |------|---------|------|
21
+ | `tailwindcss` | `^4.0.0` | CSS 框架 |
22
+ | `@tailwindcss/vite` | `^4.0.0` | Vite 插件 |
23
+ | `tw-animate-css` | `^1.0.0` | 动画工具类 |
24
+
25
+ ### 已知问题:vue-sonner 需手动安装
26
+
27
+ `vue-sonner` 已声明在 EUI 的 `dependencies` 中,但 pnpm 的严格依赖提升策略可能导致它无法被项目正确解析。如果使用 Toast 组件时遇到模块找不到的错误,需手动安装:
28
+
29
+ ```bash
30
+ pnpm add vue-sonner
31
+ ```
32
+
33
+ ## 2. 配置 Vite
34
+
35
+ ```ts
36
+ // vite.config.ts
37
+ import tailwindcss from '@tailwindcss/vite'
38
+ import vue from '@vitejs/plugin-vue'
39
+ import { defineConfig } from 'vite'
40
+
41
+ export default defineConfig({
42
+ plugins: [vue(), tailwindcss()],
43
+ })
44
+ ```
45
+
46
+ ## 3. 引入样式
47
+
48
+ ```css
49
+ /* src/style.css */
50
+ @import "@dwydev/eui/theme";
51
+ ```
52
+
53
+ > 主题 CSS 已内置 `@source` 指令,Tailwind 会自动扫描组件使用的工具类,无需手动配置。
54
+
55
+ ### 可选:按需引入主题
56
+
57
+ ```css
58
+ /* 完整主题(推荐) */
59
+ @import "@dwydev/eui/theme";
60
+
61
+ /* 或分别引入 */
62
+ @import "@dwydev/eui/theme/tokens"; /* 基础变量 + Tailwind */
63
+ @import "@dwydev/eui/theme/dark"; /* 暗色模式 */
64
+ ```
65
+
66
+ ## 4. 注册组件
67
+
68
+ ### 全局注册(推荐)
69
+
70
+ ```ts
71
+ // main.ts
72
+ import './style.css'
73
+ import { createApp } from 'vue'
74
+ import EUI from '@dwydev/eui'
75
+ import App from './App.vue'
76
+
77
+ const app = createApp(App)
78
+ app.use(EUI)
79
+ app.mount('#app')
80
+ ```
81
+
82
+ 注册后所有组件全局可用,无需逐个导入。
83
+
84
+ ### 按需导入
85
+
86
+ ```ts
87
+ // 在组件中按需导入
88
+ import { EButton, EInput, ETable } from '@dwydev/eui'
89
+ ```
90
+
91
+ 适合对打包体积敏感的场景,支持 Tree-shaking。
92
+
93
+ ## 5. 全局配置 EConfigProvider(必须)
94
+
95
+ **EConfigProvider 是使用 EUI 的前置条件。** 必须在 App 根组件用 `<EConfigProvider>` 包裹整个应用,否则以下功能不生效:
96
+
97
+ - **国际化** — 日期选择器、日历等组件将显示英文而非中文
98
+ - **全局尺寸** — 无法统一控制所有组件的尺寸
99
+ - **弹层层级** — Dialog/Drawer/Popover 等弹层 z-index 无法统一管理
100
+ - **UI 文案** — 确定/取消/暂无数据等通用文案无法全局配置
101
+
102
+ ### 基础用法
103
+
104
+ ```vue
105
+ <!-- App.vue -->
106
+ <script setup lang="ts">
107
+ import { EConfigProvider } from '@dwydev/eui'
108
+ </script>
109
+
110
+ <template>
111
+ <EConfigProvider>
112
+ <RouterView />
113
+ </EConfigProvider>
114
+ </template>
115
+ ```
116
+
117
+ 使用默认配置即可满足中文项目需求,无需传任何 props。
118
+
119
+ ### Props
120
+
121
+ | Prop | 类型 | 默认值 | 说明 |
122
+ |------|------|--------|------|
123
+ | size | `'sm' \| 'default' \| 'lg'` | `'default'` | 所有组件的全局尺寸 |
124
+ | zIndex | `number` | `2000` | 弹层组件的基准 z-index |
125
+ | locale | `Record<string, string>` | 见下方 | 国际化配置 |
126
+
127
+ ### locale 配置
128
+
129
+ locale 是一个扁平的键值对象,`name` 字段为 BCP 47 语言标签,控制日期类组件的本地化显示;其余字段为 UI 通用文案。
130
+
131
+ | 字段 | 默认值 | 说明 |
132
+ |------|--------|------|
133
+ | name | `'zh-CN'` | BCP 47 语言标签,控制 EDatePicker、ECalendar 等组件的月份名、星期名、年份格式 |
134
+ | confirm | `'确定'` | 确认按钮文案 |
135
+ | cancel | `'取消'` | 取消按钮文案 |
136
+ | close | `'关闭'` | 关闭按钮文案 |
137
+ | loading | `'加载中...'` | 加载状态文案 |
138
+ | empty | `'暂无数据'` | 空状态文案 |
139
+ | search | `'搜索'` | 搜索占位文案 |
140
+ | selectPlaceholder | `'请选择'` | 选择器默认占位文案 |
141
+ | inputPlaceholder | `'请输入'` | 输入框默认占位文案 |
142
+
143
+ ### 自定义配置示例
144
+
145
+ ```vue
146
+ <EConfigProvider
147
+ size="sm"
148
+ :z-index="3000"
149
+ :locale="{
150
+ name: 'en-US',
151
+ confirm: 'OK',
152
+ cancel: 'Cancel',
153
+ close: 'Close',
154
+ loading: 'Loading...',
155
+ empty: 'No data',
156
+ search: 'Search',
157
+ selectPlaceholder: 'Please select',
158
+ inputPlaceholder: 'Please input',
159
+ }"
160
+ >
161
+ <RouterView />
162
+ </EConfigProvider>
163
+ ```
164
+
165
+ ### 嵌套覆盖
166
+
167
+ EConfigProvider 支持嵌套,内层配置覆盖外层,适用于局部区域需要不同配置的场景:
168
+
169
+ ```vue
170
+ <EConfigProvider> <!-- 全局中文 -->
171
+ <EConfigProvider :locale="{ name: 'en-US', ... }"> <!-- 局部英文 -->
172
+ <EDatePicker type="month" /> <!-- 显示英文月份 -->
173
+ </EConfigProvider>
174
+ </EConfigProvider>
175
+ ```
176
+
177
+ ## 6. 主题配置(可选)
178
+
179
+ ### 暗色模式 + 主题切换
180
+
181
+ ```vue
182
+ <script setup lang="ts">
183
+ import { useTheme } from '@dwydev/eui'
184
+
185
+ const { isDark, toggleDark, colorTheme, setColorTheme } = useTheme()
186
+ </script>
187
+
188
+ <template>
189
+ <EButton @click="toggleDark">
190
+ {{ isDark ? '切换亮色' : '切换暗色' }}
191
+ </EButton>
192
+
193
+ <EButton @click="setColorTheme('blue')">
194
+ 蓝色主题
195
+ </EButton>
196
+ </template>
197
+ ```
198
+
199
+ ### 内置 7 种颜色主题
200
+
201
+ | 主题名 | 说明 |
202
+ |--------|------|
203
+ | `neutral` | 默认主题 |
204
+ | `blue` | 蓝色 |
205
+ | `green` | 绿色 |
206
+ | `rose` | 玫红 |
207
+ | `orange` | 橙色 |
208
+ | `violet` | 紫色 |
209
+ | `slate` | 石板灰 |
210
+
211
+ ## 7. Composables
212
+
213
+ ### useToast
214
+
215
+ 轻量 toast 通知。需要在根组件挂载 `<EToast />` 容器:
216
+
217
+ ```vue
218
+ <!-- App.vue -->
219
+ <template>
220
+ <router-view />
221
+ <EToast rich-colors />
222
+ </template>
223
+ ```
224
+
225
+ 使用:
226
+
227
+ ```ts
228
+ import { useToast } from '@dwydev/eui'
229
+
230
+ const toast = useToast()
231
+
232
+ toast.success('操作成功')
233
+ toast.error('操作失败')
234
+ toast.warning('警告信息')
235
+ toast.info('提示信息')
236
+
237
+ // 带描述
238
+ toast.success('保存成功', { description: '数据已持久化' })
239
+
240
+ // 自定义时长(毫秒)
241
+ toast.info('处理中...', { duration: 5000 })
242
+ ```
243
+
244
+ ### useMessage
245
+
246
+ ```ts
247
+ import { useMessage } from '@dwydev/eui'
248
+
249
+ const message = useMessage()
250
+
251
+ message.success('操作成功')
252
+ message.error('操作失败')
253
+ message.warning('警告信息')
254
+ message.info('提示信息')
255
+ ```
256
+
257
+ ### useNotification
258
+
259
+ ```ts
260
+ import { useNotification } from '@dwydev/eui'
261
+
262
+ const notification = useNotification()
263
+
264
+ notification.success({
265
+ title: '操作成功',
266
+ message: '数据已保存',
267
+ })
268
+ ```
269
+
270
+ ## 完整示例
271
+
272
+ ### 最小项目结构
273
+
274
+ ```
275
+ my-app/
276
+ ├── src/
277
+ │ ├── style.css # @import "@dwydev/eui/theme"
278
+ │ ├── main.ts # app.use(EUI)
279
+ │ └── App.vue
280
+ ├── index.html
281
+ ├── vite.config.ts # tailwindcss 插件
282
+ ├── tsconfig.json
283
+ └── package.json
284
+ ```
285
+
286
+ ### package.json 依赖
287
+
288
+ ```json
289
+ {
290
+ "dependencies": {
291
+ "@dwydev/eui": "^1.2.0",
292
+ "vue": "^3.5.0"
293
+ },
294
+ "devDependencies": {
295
+ "@tailwindcss/vite": "^4.0.0",
296
+ "@vitejs/plugin-vue": "^6.0.0",
297
+ "tailwindcss": "^4.0.0",
298
+ "tw-animate-css": "^1.0.0",
299
+ "vite": "^8.0.0"
300
+ }
301
+ }
302
+ ```