cmpt-huitu-cli 1.0.12 → 1.0.14
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.
- package/package.json +1 -1
- package/src/versions.js +2 -2
- package/templates/default/.lingma/rules/project-rules.md +78 -255
- package/templates/default/.qoder/rules/project-rules.md +78 -255
- package/templates/default/.trae/rules/project-rules.md +78 -255
- package/templates/default/package.json +0 -1
- package/templates/default/src/app.vue +16 -39
- package/templates/default/src/main.js +8 -0
- package/templates/default/src/routers/modules/example.js +1 -1
- package/templates/default/src/services/login.js +9 -0
- package/templates/default/src/styles/index.scss +15 -0
- package/templates/default/src/styles/theme/variables.scss +6 -0
- package/templates/default/src/utils/theme.js +14 -1
- package/templates/default/src/views/home.vue +177 -18
- package/templates/default/ESM/347/216/257/345/242/203/350/257/264/346/230/216.md +0 -164
package/package.json
CHANGED
package/src/versions.js
CHANGED
|
@@ -49,16 +49,16 @@
|
|
|
49
49
|
|
|
50
50
|
- **Element Plus**: `^2.11.1`
|
|
51
51
|
- **@element-plus/icons-vue**: `^2.3.2`
|
|
52
|
+
- **ECharts**: `^5.5.0` (通过 `cmpt-huitu-ui` 集成)
|
|
52
53
|
|
|
53
54
|
### 共享包
|
|
54
55
|
|
|
55
|
-
- **cmpt-huitu-ui**:
|
|
56
|
-
- **cmpt-huitu-utils**:
|
|
56
|
+
- **cmpt-huitu-ui**: `workspace:*` - UI 组件库
|
|
57
|
+
- **cmpt-huitu-utils**: `workspace:*` - 工具函数库
|
|
57
58
|
|
|
58
59
|
### 工具库
|
|
59
60
|
|
|
60
61
|
- **axios**: `^1.11.0` - HTTP 客户端
|
|
61
|
-
- **dayjs**: `^1.11.18` - 时间处理
|
|
62
62
|
- **lodash-es**: `^4.17.21` - 工具函数
|
|
63
63
|
- **nprogress**: `^0.2.0` - 进度条
|
|
64
64
|
|
|
@@ -162,24 +162,25 @@
|
|
|
162
162
|
|
|
163
163
|
- **会被 Vite 处理**,支持导入和路径别名
|
|
164
164
|
- 存放会被代码引用的资源(图片、字体等)
|
|
165
|
-
- 支持动态导入和路径别名
|
|
165
|
+
- 支持动态导入和路径别名 `@assets/...`
|
|
166
166
|
|
|
167
167
|
#### `src/routers/modules/` - 路由模块
|
|
168
168
|
|
|
169
169
|
- **自动导入**:Vite 会自动扫描并合并所有 `.js` 文件
|
|
170
|
-
-
|
|
170
|
+
- 每个模块导出一个路由对象数组 `export default [...]`
|
|
171
171
|
- 文件名建议使用 `模块名.js` 格式
|
|
172
172
|
|
|
173
173
|
#### `src/stores/` - 状态管理
|
|
174
174
|
|
|
175
175
|
- 使用 Pinia,按模块组织
|
|
176
176
|
- 每个模块一个文件,文件名即 store id
|
|
177
|
+
- 推荐使用 Options API 风格定义 Store (与模板保持一致),但也支持 Composition API
|
|
177
178
|
|
|
178
179
|
#### `src/services/` - API 服务
|
|
179
180
|
|
|
180
181
|
- 按功能模块组织 API 请求
|
|
181
182
|
- 每个文件对应一个业务模块
|
|
182
|
-
- 统一使用
|
|
183
|
+
- 统一使用 `@utils/requestAxios.js` 封装的 axios 实例
|
|
183
184
|
|
|
184
185
|
---
|
|
185
186
|
|
|
@@ -203,31 +204,10 @@
|
|
|
203
204
|
</script>
|
|
204
205
|
```
|
|
205
206
|
|
|
206
|
-
####
|
|
207
|
+
#### 2. 组件命名
|
|
207
208
|
|
|
208
209
|
- **组件文件名**:使用 **camelCase(小驼峰)**,如 `userProfile.vue`、`home.vue`
|
|
209
|
-
-
|
|
210
|
-
|
|
211
|
-
#### 2. 编译器宏无需导入
|
|
212
|
-
|
|
213
|
-
```vue
|
|
214
|
-
<script setup>
|
|
215
|
-
// ✅ 正确:defineProps、defineEmits 是编译器宏,无需导入
|
|
216
|
-
const props = defineProps({
|
|
217
|
-
title: String,
|
|
218
|
-
})
|
|
219
|
-
|
|
220
|
-
const emit = defineEmits(['update'])
|
|
221
|
-
|
|
222
|
-
// ❌ 错误:不要导入编译器宏
|
|
223
|
-
// import { defineProps, defineEmits } from 'vue'
|
|
224
|
-
</script>
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
#### 3. 组件命名
|
|
228
|
-
|
|
229
|
-
- **组件文件名**:使用 **camelCase(小驼峰)**,如 `userProfile.vue`、`home.vue`
|
|
230
|
-
- **组件注册名**:在模板中使用时,Vue 会自动处理大小写转换(camelCase ↔ PascalCase)
|
|
210
|
+
- **组件注册名**:在模板中使用时,Vue 会自动处理大小写转换
|
|
231
211
|
- **Props 定义**:使用对象形式,提供类型和默认值
|
|
232
212
|
|
|
233
213
|
```vue
|
|
@@ -246,7 +226,7 @@
|
|
|
246
226
|
</script>
|
|
247
227
|
```
|
|
248
228
|
|
|
249
|
-
####
|
|
229
|
+
#### 3. 样式规范
|
|
250
230
|
|
|
251
231
|
- **使用 Scoped 样式**:避免样式污染
|
|
252
232
|
- **使用 CSS 变量**:利用主题系统
|
|
@@ -266,34 +246,31 @@
|
|
|
266
246
|
|
|
267
247
|
#### 1. 路由模块化
|
|
268
248
|
|
|
269
|
-
在 `src/routers/modules/`
|
|
249
|
+
在 `src/routers/modules/` 下创建路由模块,**必须导出数组**:
|
|
270
250
|
|
|
271
251
|
```javascript
|
|
272
252
|
// src/routers/modules/user.js
|
|
273
|
-
export default
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
children: [
|
|
282
|
-
{
|
|
283
|
-
path: 'list',
|
|
284
|
-
name: 'UserList',
|
|
285
|
-
component: () => import('@/views/user/list.vue'),
|
|
253
|
+
export default [
|
|
254
|
+
{
|
|
255
|
+
path: '/user',
|
|
256
|
+
name: 'User',
|
|
257
|
+
component: () => import('@views/user/index.vue'),
|
|
258
|
+
meta: {
|
|
259
|
+
title: '用户管理',
|
|
260
|
+
requiresAuth: true, // 需要登录
|
|
286
261
|
},
|
|
287
|
-
|
|
288
|
-
|
|
262
|
+
children: [
|
|
263
|
+
{
|
|
264
|
+
path: 'list',
|
|
265
|
+
name: 'UserList',
|
|
266
|
+
component: () => import('@views/user/list.vue'),
|
|
267
|
+
},
|
|
268
|
+
],
|
|
269
|
+
},
|
|
270
|
+
]
|
|
289
271
|
```
|
|
290
272
|
|
|
291
|
-
#### 2.
|
|
292
|
-
|
|
293
|
-
- **路由 name**:使用 PascalCase,与组件名对应
|
|
294
|
-
- **路由 path**:使用 kebab-case,与菜单路径对应
|
|
295
|
-
|
|
296
|
-
#### 3. 路由元信息
|
|
273
|
+
#### 2. 路由元信息
|
|
297
274
|
|
|
298
275
|
使用 `meta` 字段存储路由元信息:
|
|
299
276
|
|
|
@@ -302,7 +279,6 @@ export default {
|
|
|
302
279
|
meta: {
|
|
303
280
|
title: '页面标题', // 页面标题
|
|
304
281
|
requiresAuth: true, // 是否需要登录
|
|
305
|
-
roles: ['admin'], // 权限角色
|
|
306
282
|
keepAlive: true, // 是否缓存
|
|
307
283
|
hidden: false, // 是否在菜单中隐藏
|
|
308
284
|
},
|
|
@@ -313,38 +289,26 @@ export default {
|
|
|
313
289
|
|
|
314
290
|
#### 1. Store 定义
|
|
315
291
|
|
|
316
|
-
使用 `defineStore` 定义 store
|
|
292
|
+
使用 `defineStore` 定义 store,模板默认使用 Options API 风格:
|
|
317
293
|
|
|
318
294
|
```javascript
|
|
319
|
-
// src/stores/
|
|
295
|
+
// src/stores/index/global.js
|
|
320
296
|
import { defineStore } from 'pinia'
|
|
321
|
-
import { ref, computed } from 'vue'
|
|
322
|
-
|
|
323
|
-
export const useUserStore = defineStore('user', () => {
|
|
324
|
-
// State
|
|
325
|
-
const userInfo = ref(null)
|
|
326
|
-
const token = ref('')
|
|
327
297
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
userInfo.value = info
|
|
334
|
-
}
|
|
298
|
+
export const globalStore = defineStore('global', {
|
|
299
|
+
state: () => ({
|
|
300
|
+
themeVal: 'light',
|
|
301
|
+
isLoading: false,
|
|
302
|
+
}),
|
|
335
303
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
isLoggedIn,
|
|
345
|
-
setUserInfo,
|
|
346
|
-
logout,
|
|
347
|
-
}
|
|
304
|
+
actions: {
|
|
305
|
+
changeGlobalTheme(theme) {
|
|
306
|
+
this.themeVal = theme
|
|
307
|
+
},
|
|
308
|
+
setIsLoadingStore(status) {
|
|
309
|
+
this.isLoading = status
|
|
310
|
+
},
|
|
311
|
+
},
|
|
348
312
|
})
|
|
349
313
|
```
|
|
350
314
|
|
|
@@ -354,20 +318,17 @@ export const useUserStore = defineStore('user', () => {
|
|
|
354
318
|
|
|
355
319
|
```vue
|
|
356
320
|
<script setup>
|
|
357
|
-
import {
|
|
321
|
+
import { globalStore } from '@/stores/index/global'
|
|
322
|
+
import { storeToRefs } from 'pinia'
|
|
358
323
|
|
|
359
|
-
|
|
324
|
+
// 1. 实例化 Store
|
|
325
|
+
const store = globalStore()
|
|
360
326
|
|
|
361
|
-
//
|
|
362
|
-
|
|
327
|
+
// 2. 解构 state 需要使用 storeToRefs 保持响应式
|
|
328
|
+
const { themeVal } = storeToRefs(store)
|
|
363
329
|
|
|
364
|
-
//
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
// 使用 getter
|
|
368
|
-
if (userStore.isLoggedIn) {
|
|
369
|
-
// ...
|
|
370
|
-
}
|
|
330
|
+
// 3. 解构 actions 可以直接使用
|
|
331
|
+
const { changeGlobalTheme } = store
|
|
371
332
|
</script>
|
|
372
333
|
```
|
|
373
334
|
|
|
@@ -377,7 +338,7 @@ export const useUserStore = defineStore('user', () => {
|
|
|
377
338
|
|
|
378
339
|
```javascript
|
|
379
340
|
// src/services/user.js
|
|
380
|
-
import request from '@/utils/requestAxios'
|
|
341
|
+
import { axiosInstance as request } from '@/utils/requestAxios'
|
|
381
342
|
|
|
382
343
|
// ✅ 推荐:统一使用封装的 request
|
|
383
344
|
export function getUserList(params) {
|
|
@@ -397,24 +358,15 @@ export function createUser(data) {
|
|
|
397
358
|
}
|
|
398
359
|
```
|
|
399
360
|
|
|
400
|
-
#### 2.
|
|
361
|
+
#### 2. 依赖注入 (可选)
|
|
401
362
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
onMounted(async () => {
|
|
410
|
-
try {
|
|
411
|
-
const res = await getUserList({ page: 1 })
|
|
412
|
-
list.value = res.data
|
|
413
|
-
} catch (error) {
|
|
414
|
-
console.error('获取用户列表失败', error)
|
|
415
|
-
}
|
|
416
|
-
})
|
|
417
|
-
</script>
|
|
363
|
+
在某些场景(如通用组件库)中,可以使用依赖注入获取 request 实例:
|
|
364
|
+
|
|
365
|
+
```javascript
|
|
366
|
+
import { getCurrentInstance } from 'vue'
|
|
367
|
+
|
|
368
|
+
const { proxy } = getCurrentInstance()
|
|
369
|
+
// proxy.$request 也是可用的
|
|
418
370
|
```
|
|
419
371
|
|
|
420
372
|
---
|
|
@@ -431,19 +383,13 @@ export function createUser(data) {
|
|
|
431
383
|
| **工具函数** | camelCase | `formatDate.js` |
|
|
432
384
|
| **常量文件** | UPPER_SNAKE_CASE | `ERROR_CODE.js` |
|
|
433
385
|
|
|
434
|
-
### 变量命名
|
|
435
|
-
|
|
436
|
-
- **变量/函数**:camelCase - `userName`, `getUserInfo()`
|
|
437
|
-
- **常量**:UPPER_SNAKE_CASE - `API_BASE_URL`, `MAX_COUNT`
|
|
438
|
-
- **组件名**:PascalCase - `UserProfile`, `DataTable`
|
|
439
|
-
- **CSS 类名**:kebab-case - `.user-profile`, `.data-table`
|
|
440
|
-
|
|
441
386
|
### 路径别名
|
|
442
387
|
|
|
443
|
-
使用 `
|
|
388
|
+
使用 `vite.config.js` 中定义的路径别名:
|
|
444
389
|
|
|
445
390
|
| 别名 | 对应路径 | 用途 |
|
|
446
391
|
| -------------- | ----------------- | ------------ |
|
|
392
|
+
| `~/` | `./` | 项目根目录 |
|
|
447
393
|
| `@/` | `src/` | 源代码根目录 |
|
|
448
394
|
| `@public/` | `public/` | 静态资源目录 |
|
|
449
395
|
| `@components/` | `src/components/` | 全局组件 |
|
|
@@ -454,16 +400,7 @@ export function createUser(data) {
|
|
|
454
400
|
| `@utils/` | `src/utils/` | 工具函数 |
|
|
455
401
|
| `@assets/` | `src/assets/` | 资源文件 |
|
|
456
402
|
| `@services/` | `src/services/` | API 服务 |
|
|
457
|
-
|
|
458
|
-
```javascript
|
|
459
|
-
// ✅ 推荐:使用路径别名(组件文件名使用 camelCase)
|
|
460
|
-
import { parseTime } from '@/utils'
|
|
461
|
-
import UserList from '@/views/user/list.vue'
|
|
462
|
-
import { useUserStore } from '@/stores/user'
|
|
463
|
-
|
|
464
|
-
// ❌ 不推荐:使用相对路径
|
|
465
|
-
import { parseTime } from '../../utils'
|
|
466
|
-
```
|
|
403
|
+
| `@plugins/` | `src/plugins/` | 插件配置 |
|
|
467
404
|
|
|
468
405
|
---
|
|
469
406
|
|
|
@@ -486,7 +423,6 @@ const config = {
|
|
|
486
423
|
|
|
487
424
|
// 文件服务配置
|
|
488
425
|
uploadUrl: origin + '/upload',
|
|
489
|
-
downloadUrl: origin + '/download',
|
|
490
426
|
|
|
491
427
|
// ... 其他配置
|
|
492
428
|
}
|
|
@@ -501,85 +437,17 @@ const config = {
|
|
|
501
437
|
VITE_PORT=3001
|
|
502
438
|
VITE_PATH=/
|
|
503
439
|
VITE_MOCK=true
|
|
504
|
-
|
|
505
|
-
# .env.production
|
|
506
|
-
VITE_PATH=/production-path/
|
|
507
|
-
VITE_MOCK=false
|
|
508
|
-
```
|
|
509
|
-
|
|
510
|
-
在代码中使用:
|
|
511
|
-
|
|
512
|
-
```javascript
|
|
513
|
-
// ✅ 正确:使用 import.meta.env
|
|
514
|
-
const apiUrl = import.meta.env.VITE_API_URL
|
|
515
|
-
|
|
516
|
-
// ❌ 错误:不要使用 process.env(Vite 不支持)
|
|
517
|
-
// const apiUrl = process.env.VITE_API_URL
|
|
518
|
-
```
|
|
519
|
-
|
|
520
|
-
### Vite 配置
|
|
521
|
-
|
|
522
|
-
主要配置在 `vite.config.js`,已预配置:
|
|
523
|
-
|
|
524
|
-
- **路径别名**:`@/`、`@public/` 等
|
|
525
|
-
- **自动导入**:Vue API、组件、Element Plus 组件
|
|
526
|
-
- **SCSS 全局变量**:自动注入 `cmpt-huitu-ui` 样式变量
|
|
527
|
-
- **代理配置**:开发环境 API 代理
|
|
528
|
-
- **构建优化**:代码分割、压缩等
|
|
529
|
-
|
|
530
|
-
---
|
|
531
|
-
|
|
532
|
-
## 💻 开发规范
|
|
533
|
-
|
|
534
|
-
### 1. 开发流程
|
|
535
|
-
|
|
536
|
-
```bash
|
|
537
|
-
# 1. 安装依赖
|
|
538
|
-
pnpm install
|
|
539
|
-
|
|
540
|
-
# 2. 启动开发服务器
|
|
541
|
-
pnpm dev
|
|
542
|
-
|
|
543
|
-
# 3. 代码检查
|
|
544
|
-
pnpm lint
|
|
545
|
-
|
|
546
|
-
# 4. 构建生产版本
|
|
547
|
-
pnpm build
|
|
548
|
-
|
|
549
|
-
# 5. 预览构建结果
|
|
550
|
-
pnpm preview
|
|
551
440
|
```
|
|
552
441
|
|
|
553
|
-
###
|
|
442
|
+
### ECharts 引入规范
|
|
554
443
|
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
```bash
|
|
558
|
-
# 功能新增
|
|
559
|
-
git commit -m "feat: 添加用户管理页面"
|
|
444
|
+
**允许全量引入**:为了避免构建时的 `install` 导出警告,并简化开发,本项目允许直接全量引入 ECharts。
|
|
560
445
|
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
# 文档更新
|
|
565
|
-
git commit -m "docs: 更新 README"
|
|
566
|
-
|
|
567
|
-
# 代码重构
|
|
568
|
-
git commit -m "refactor: 重构用户服务代码"
|
|
569
|
-
|
|
570
|
-
# 样式调整
|
|
571
|
-
git commit -m "style: 调整页面布局"
|
|
446
|
+
```javascript
|
|
447
|
+
// packages/ui/index.js
|
|
448
|
+
import * as echarts from 'echarts'
|
|
572
449
|
```
|
|
573
450
|
|
|
574
|
-
### 3. 代码审查要点
|
|
575
|
-
|
|
576
|
-
- ✅ 是否遵循命名规范
|
|
577
|
-
- ✅ 是否使用路径别名而非相对路径
|
|
578
|
-
- ✅ 是否正确处理异步操作(try-catch)
|
|
579
|
-
- ✅ 是否使用共享包而非重复实现
|
|
580
|
-
- ✅ 样式是否使用 scoped 或 CSS 变量
|
|
581
|
-
- ✅ 是否移除未使用的导入和代码
|
|
582
|
-
|
|
583
451
|
---
|
|
584
452
|
|
|
585
453
|
## ✨ 最佳实践
|
|
@@ -590,13 +458,10 @@ git commit -m "style: 调整页面布局"
|
|
|
590
458
|
|
|
591
459
|
```javascript
|
|
592
460
|
// ✅ 推荐:使用共享工具函数
|
|
593
|
-
import {
|
|
461
|
+
import { cache } from 'cmpt-huitu-utils'
|
|
594
462
|
|
|
595
463
|
// ✅ 推荐:使用共享 UI 组件
|
|
596
|
-
import { HTable, VexTable
|
|
597
|
-
|
|
598
|
-
// ❌ 不推荐:重复实现已有功能
|
|
599
|
-
// function formatTime(time) { ... } // 已有 parseTime
|
|
464
|
+
import { HTable, VexTable } from 'cmpt-huitu-ui'
|
|
600
465
|
```
|
|
601
466
|
|
|
602
467
|
### 2. 组件复用
|
|
@@ -610,40 +475,20 @@ import { HTable, VexTable, HtDialog } from 'cmpt-huitu-ui'
|
|
|
610
475
|
- 使用路由懒加载
|
|
611
476
|
- 大组件使用异步组件
|
|
612
477
|
- 合理使用 `v-memo` 和 `v-once`
|
|
613
|
-
- 图片使用懒加载
|
|
614
|
-
|
|
615
|
-
```javascript
|
|
616
|
-
// ✅ 路由懒加载(文件名使用 camelCase)
|
|
617
|
-
component: () => import('@/views/user/index.vue')
|
|
618
|
-
|
|
619
|
-
// ✅ 异步组件(文件名使用 camelCase)
|
|
620
|
-
const AsyncComponent = defineAsyncComponent(() => import('@/components/heavyComponent.vue'))
|
|
621
|
-
```
|
|
622
478
|
|
|
623
479
|
### 4. 错误处理
|
|
624
480
|
|
|
625
481
|
统一错误处理:
|
|
626
482
|
|
|
627
483
|
```javascript
|
|
628
|
-
// ✅ 推荐:统一错误处理
|
|
629
484
|
try {
|
|
630
485
|
const res = await getUserList()
|
|
631
|
-
// 处理成功
|
|
632
486
|
} catch (error) {
|
|
633
487
|
console.error('获取用户列表失败', error)
|
|
634
|
-
|
|
488
|
+
// requestAxios 已有统一的错误拦截提示,通常无需再次弹窗
|
|
635
489
|
}
|
|
636
490
|
```
|
|
637
491
|
|
|
638
|
-
### 5. 类型安全
|
|
639
|
-
|
|
640
|
-
利用自动生成的类型文件:
|
|
641
|
-
|
|
642
|
-
```typescript
|
|
643
|
-
// components.d.ts 和 imports.d.ts 由插件自动生成
|
|
644
|
-
// 提供完整的类型提示
|
|
645
|
-
```
|
|
646
|
-
|
|
647
492
|
---
|
|
648
493
|
|
|
649
494
|
## ⚠️ 注意事项
|
|
@@ -653,37 +498,26 @@ try {
|
|
|
653
498
|
- ✅ **`public/config/envCfg.js`** - 环境配置(API 地址、登录配置等)
|
|
654
499
|
- ✅ **`index.html`** - 页面标题、项目名称
|
|
655
500
|
- ✅ **`package.json`** - 项目名称、描述(CLI 会自动修改)
|
|
656
|
-
- ✅ **`vite.config.js`** - 如需自定义构建配置
|
|
657
501
|
|
|
658
502
|
### 2. 共享包依赖
|
|
659
503
|
|
|
660
504
|
- ✅ 使用 `workspace:*` 在 Monorepo 中开发
|
|
661
|
-
- ✅ CLI
|
|
505
|
+
- ✅ CLI 创建项目时自动转换为版本号
|
|
662
506
|
- ✅ 不要手动修改 `package.json` 中的共享包版本
|
|
663
507
|
|
|
664
508
|
### 3. 样式变量
|
|
665
509
|
|
|
666
|
-
- ✅
|
|
510
|
+
- ✅ 自动注入了 `cmpt-huitu-ui` 的全局 SCSS 变量(在 vite.config.js 中配置)
|
|
667
511
|
- ✅ 自定义主题变量放在 `src/styles/theme/variables.scss`
|
|
668
|
-
- ✅ 使用 `@use` 替代 `@import`(避免弃用警告)
|
|
669
512
|
|
|
670
513
|
### 4. 路由模块
|
|
671
514
|
|
|
672
|
-
- ✅
|
|
515
|
+
- ✅ 路由模块自动导入,**必需导出数组**
|
|
673
516
|
- ✅ 404 路由会自动添加到最后
|
|
674
|
-
- ✅ 路由守卫在 `src/routers/guard.js` 中统一处理
|
|
675
|
-
|
|
676
|
-
### 5. 环境变量
|
|
677
517
|
|
|
678
|
-
|
|
679
|
-
- ✅ 使用 `VITE_` 前缀
|
|
680
|
-
- ✅ 在代码中使用 `import.meta.env.VITE_XXX`
|
|
518
|
+
### 5. 跨平台兼容性
|
|
681
519
|
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
- ✅ 生产构建会自动压缩和优化
|
|
685
|
-
- ✅ 使用 `pnpm preview` 预览生产构建结果
|
|
686
|
-
- ✅ 构建产物在 `dist/` 目录
|
|
520
|
+
- ✅ **禁止**在 `package.json` 的 `dependencies` 中硬编码平台特定依赖(如 `@esbuild/darwin-arm64`),这会导致 Windows 环境安装失败。
|
|
687
521
|
|
|
688
522
|
---
|
|
689
523
|
|
|
@@ -697,15 +531,4 @@ try {
|
|
|
697
531
|
|
|
698
532
|
---
|
|
699
533
|
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
- **v1.0.0** (2026-01-04)
|
|
703
|
-
- 初始版本
|
|
704
|
-
- 集成 Vue 3 + Vite + Element Plus
|
|
705
|
-
- 集成 cmpt-huitu-ui 和 cmpt-huitu-utils
|
|
706
|
-
- 完整的开发规范和最佳实践
|
|
707
|
-
|
|
708
|
-
---
|
|
709
|
-
|
|
710
|
-
**维护者**: 慧图前端团队
|
|
711
|
-
**最后更新**: 2026-01-04
|
|
534
|
+
**最后更新**: 2026-01-14
|