ai-engineering-init 1.1.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.
- package/.claude/agents/code-reviewer.md +139 -0
- package/.claude/agents/project-manager.md +159 -0
- package/.claude/audio/completed.wav +0 -0
- package/.claude/commands/add-todo.md +255 -0
- package/.claude/commands/check.md +210 -0
- package/.claude/commands/crud.md +454 -0
- package/.claude/commands/dev.md +503 -0
- package/.claude/commands/init-docs.md +681 -0
- package/.claude/commands/next.md +251 -0
- package/.claude/commands/progress.md +242 -0
- package/.claude/commands/start.md +199 -0
- package/.claude/commands/sync.md +307 -0
- package/.claude/commands/update-status.md +428 -0
- package/.claude/docs/Mixin/344/275/277/347/224/250/346/214/207/345/215/227.md +299 -0
- package/.claude/docs/README.md +167 -0
- package/.claude/docs//345/211/215/347/253/257/345/274/200/345/217/221/346/214/207/345/215/227.md +599 -0
- package/.claude/docs//345/220/216/347/253/257/345/274/200/345/217/221/346/214/207/345/215/227.md +726 -0
- package/.claude/docs//345/267/245/344/275/234/346/265/201/345/274/200/345/217/221/346/214/207/345/215/227.md +714 -0
- package/.claude/docs//345/267/245/345/205/267/347/261/273/344/275/277/347/224/250/346/214/207/345/215/227.md +463 -0
- package/.claude/docs//346/225/260/346/215/256/345/272/223/350/256/276/350/256/241/350/247/204/350/214/203.md +390 -0
- package/.claude/docs//346/226/260/345/212/237/350/203/275/345/274/200/345/217/221/346/265/201/347/250/213/350/247/204/350/214/203.md +688 -0
- package/.claude/docs//346/226/260/351/241/271/347/233/256/345/274/200/345/217/221/346/265/201/347/250/213.md +365 -0
- package/.claude/docs//346/241/206/346/236/266/350/257/264/346/230/216.md +393 -0
- package/.claude/docs//350/267/257/347/224/261/351/205/215/347/275/256/346/214/207/345/215/227.md +246 -0
- package/.claude/framework-config.json +73 -0
- package/.claude/hooks/pre-tool-use.js +117 -0
- package/.claude/hooks/skill-forced-eval.js +167 -0
- package/.claude/hooks/stop.js +58 -0
- package/.claude/settings.json +41 -0
- package/.claude/skills/add-skill/SKILL.md +352 -0
- package/.claude/skills/api-development/SKILL.md +560 -0
- package/.claude/skills/architecture-design/SKILL.md +756 -0
- package/.claude/skills/backend-annotations/SKILL.md +674 -0
- package/.claude/skills/banana-image/CHANGELOG.md +37 -0
- package/.claude/skills/banana-image/README.md +146 -0
- package/.claude/skills/banana-image/SKILL.md +164 -0
- package/.claude/skills/banana-image/assets/logo.png +0 -0
- package/.claude/skills/banana-image/references/advanced-usage.md +189 -0
- package/.claude/skills/banana-image/scripts/apply_template.py +125 -0
- package/.claude/skills/banana-image/scripts/banana_image_exec.ts +412 -0
- package/.claude/skills/banana-image/scripts/batch_prep.py +82 -0
- package/.claude/skills/banana-image/scripts/package-lock.json +1437 -0
- package/.claude/skills/banana-image/scripts/package.json +18 -0
- package/.claude/skills/banana-image/scripts/requirements.txt +10 -0
- package/.claude/skills/banana-image/templates/poster.json +22 -0
- package/.claude/skills/banana-image/templates/product.json +17 -0
- package/.claude/skills/banana-image/templates/social.json +22 -0
- package/.claude/skills/banana-image/templates/thumbnail.json +17 -0
- package/.claude/skills/brainstorm/SKILL.md +648 -0
- package/.claude/skills/bug-detective/SKILL.md +1206 -0
- package/.claude/skills/code-patterns/SKILL.md +590 -0
- package/.claude/skills/collaborating-with-codex/SKILL.md +174 -0
- package/.claude/skills/collaborating-with-codex/scripts/codex_bridge.py +275 -0
- package/.claude/skills/collaborating-with-gemini/SKILL.md +194 -0
- package/.claude/skills/collaborating-with-gemini/scripts/gemini_bridge.py +275 -0
- package/.claude/skills/crud-development/SKILL.md +649 -0
- package/.claude/skills/data-permission/SKILL.md +599 -0
- package/.claude/skills/database-ops/SKILL.md +407 -0
- package/.claude/skills/error-handler/SKILL.md +371 -0
- package/.claude/skills/file-oss-management/SKILL.md +863 -0
- package/.claude/skills/git-workflow/SKILL.md +375 -0
- package/.claude/skills/json-serialization/SKILL.md +357 -0
- package/.claude/skills/leniu-api-development/SKILL.md +803 -0
- package/.claude/skills/leniu-architecture-design/SKILL.md +598 -0
- package/.claude/skills/leniu-backend-annotations/SKILL.md +664 -0
- package/.claude/skills/leniu-code-patterns/SKILL.md +365 -0
- package/.claude/skills/leniu-crud-development/SKILL.md +1110 -0
- package/.claude/skills/leniu-data-permission/SKILL.md +256 -0
- package/.claude/skills/leniu-database-ops/SKILL.md +426 -0
- package/.claude/skills/leniu-error-handler/SKILL.md +462 -0
- package/.claude/skills/leniu-java-amount-handling/SKILL.md +461 -0
- package/.claude/skills/leniu-java-code-style/SKILL.md +510 -0
- package/.claude/skills/leniu-java-concurrent/SKILL.md +400 -0
- package/.claude/skills/leniu-java-entity/SKILL.md +751 -0
- package/.claude/skills/leniu-java-export/SKILL.md +560 -0
- package/.claude/skills/leniu-java-logging/SKILL.md +832 -0
- package/.claude/skills/leniu-java-mq/SKILL.md +338 -0
- package/.claude/skills/leniu-java-mybatis/SKILL.md +640 -0
- package/.claude/skills/leniu-java-report-query-param/SKILL.md +291 -0
- package/.claude/skills/leniu-java-task/SKILL.md +367 -0
- package/.claude/skills/leniu-java-total-line/SKILL.md +195 -0
- package/.claude/skills/leniu-marketing-price-rule-customizer/SKILL.md +301 -0
- package/.claude/skills/leniu-marketing-recharge-rule-customizer/SKILL.md +285 -0
- package/.claude/skills/leniu-mealtime/SKILL.md +215 -0
- package/.claude/skills/leniu-redis-cache/SKILL.md +316 -0
- package/.claude/skills/leniu-security-guard/SKILL.md +520 -0
- package/.claude/skills/leniu-utils-toolkit/SKILL.md +380 -0
- package/.claude/skills/openspec-apply-change/SKILL.md +156 -0
- package/.claude/skills/openspec-archive-change/SKILL.md +114 -0
- package/.claude/skills/openspec-bulk-archive-change/SKILL.md +246 -0
- package/.claude/skills/openspec-continue-change/SKILL.md +118 -0
- package/.claude/skills/openspec-explore/SKILL.md +290 -0
- package/.claude/skills/openspec-ff-change/SKILL.md +101 -0
- package/.claude/skills/openspec-new-change/SKILL.md +74 -0
- package/.claude/skills/openspec-onboard/SKILL.md +529 -0
- package/.claude/skills/openspec-sync-specs/SKILL.md +138 -0
- package/.claude/skills/openspec-verify-change/SKILL.md +168 -0
- package/.claude/skills/performance-doctor/SKILL.md +627 -0
- package/.claude/skills/project-navigator/SKILL.md +305 -0
- package/.claude/skills/redis-cache/SKILL.md +839 -0
- package/.claude/skills/scheduled-jobs/SKILL.md +633 -0
- package/.claude/skills/security-guard/SKILL.md +748 -0
- package/.claude/skills/sms-mail/SKILL.md +766 -0
- package/.claude/skills/social-login/SKILL.md +668 -0
- package/.claude/skills/store-pc/SKILL.md +366 -0
- package/.claude/skills/task-tracker/SKILL.md +307 -0
- package/.claude/skills/tech-decision/SKILL.md +393 -0
- package/.claude/skills/tenant-management/SKILL.md +603 -0
- package/.claude/skills/test-development/SKILL.md +755 -0
- package/.claude/skills/ui-pc/SKILL.md +438 -0
- package/.claude/skills/utils-toolkit/SKILL.md +615 -0
- package/.claude/skills/websocket-sse/SKILL.md +716 -0
- package/.claude/skills/workflow-engine/SKILL.md +676 -0
- package/.claude/templates//345/276/205/345/212/236/346/270/205/345/215/225/346/250/241/346/235/277.md +56 -0
- package/.claude/templates//351/234/200/346/261/202/346/226/207/346/241/243/346/250/241/346/235/277.md +85 -0
- package/.claude/templates//351/241/271/347/233/256/347/212/266/346/200/201/346/250/241/346/235/277.md +43 -0
- package/.codex/skills/add-skill/SKILL.md +352 -0
- package/.codex/skills/add-todo/SKILL.md +269 -0
- package/.codex/skills/api-development/SKILL.md +693 -0
- package/.codex/skills/architecture-design/SKILL.md +628 -0
- package/.codex/skills/backend-annotations/SKILL.md +664 -0
- package/.codex/skills/banana-image/CHANGELOG.md +37 -0
- package/.codex/skills/banana-image/README.md +146 -0
- package/.codex/skills/banana-image/SKILL.md +164 -0
- package/.codex/skills/banana-image/assets/logo.png +0 -0
- package/.codex/skills/banana-image/references/advanced-usage.md +189 -0
- package/.codex/skills/banana-image/scripts/apply_template.py +125 -0
- package/.codex/skills/banana-image/scripts/banana_image_exec.ts +412 -0
- package/.codex/skills/banana-image/scripts/batch_prep.py +82 -0
- package/.codex/skills/banana-image/scripts/package-lock.json +1437 -0
- package/.codex/skills/banana-image/scripts/package.json +18 -0
- package/.codex/skills/banana-image/scripts/requirements.txt +10 -0
- package/.codex/skills/banana-image/templates/poster.json +22 -0
- package/.codex/skills/banana-image/templates/product.json +17 -0
- package/.codex/skills/banana-image/templates/social.json +22 -0
- package/.codex/skills/banana-image/templates/thumbnail.json +17 -0
- package/.codex/skills/brainstorm/SKILL.md +648 -0
- package/.codex/skills/bug-detective/SKILL.md +1206 -0
- package/.codex/skills/check/SKILL.md +367 -0
- package/.codex/skills/code-patterns/SKILL.md +442 -0
- package/.codex/skills/collaborating-with-codex/SKILL.md +174 -0
- package/.codex/skills/collaborating-with-codex/scripts/codex_bridge.py +275 -0
- package/.codex/skills/collaborating-with-gemini/SKILL.md +194 -0
- package/.codex/skills/collaborating-with-gemini/scripts/gemini_bridge.py +275 -0
- package/.codex/skills/crud/SKILL.md +265 -0
- package/.codex/skills/crud-development/SKILL.md +637 -0
- package/.codex/skills/data-permission/SKILL.md +591 -0
- package/.codex/skills/database-ops/SKILL.md +553 -0
- package/.codex/skills/dev/SKILL.md +187 -0
- package/.codex/skills/error-handler/SKILL.md +361 -0
- package/.codex/skills/file-oss-management/SKILL.md +863 -0
- package/.codex/skills/git-workflow/SKILL.md +375 -0
- package/.codex/skills/init-docs/SKILL.md +194 -0
- package/.codex/skills/json-serialization/SKILL.md +357 -0
- package/.codex/skills/leniu-api-development/SKILL.md +803 -0
- package/.codex/skills/leniu-architecture-design/SKILL.md +594 -0
- package/.codex/skills/leniu-backend-annotations/SKILL.md +662 -0
- package/.codex/skills/leniu-code-patterns/SKILL.md +365 -0
- package/.codex/skills/leniu-crud-development/SKILL.md +1110 -0
- package/.codex/skills/leniu-data-permission/SKILL.md +256 -0
- package/.codex/skills/leniu-database-ops/SKILL.md +426 -0
- package/.codex/skills/leniu-error-handler/SKILL.md +462 -0
- package/.codex/skills/leniu-java-amount-handling/SKILL.md +461 -0
- package/.codex/skills/leniu-java-code-style/SKILL.md +510 -0
- package/.codex/skills/leniu-java-concurrent/SKILL.md +400 -0
- package/.codex/skills/leniu-java-entity/SKILL.md +751 -0
- package/.codex/skills/leniu-java-export/SKILL.md +560 -0
- package/.codex/skills/leniu-java-logging/SKILL.md +832 -0
- package/.codex/skills/leniu-java-mq/SKILL.md +338 -0
- package/.codex/skills/leniu-java-mybatis/SKILL.md +640 -0
- package/.codex/skills/leniu-java-report-query-param/SKILL.md +291 -0
- package/.codex/skills/leniu-java-task/SKILL.md +367 -0
- package/.codex/skills/leniu-java-total-line/SKILL.md +195 -0
- package/.codex/skills/leniu-marketing-price-rule-customizer/SKILL.md +301 -0
- package/.codex/skills/leniu-marketing-recharge-rule-customizer/SKILL.md +285 -0
- package/.codex/skills/leniu-mealtime/SKILL.md +215 -0
- package/.codex/skills/leniu-redis-cache/SKILL.md +316 -0
- package/.codex/skills/leniu-security-guard/SKILL.md +520 -0
- package/.codex/skills/leniu-utils-toolkit/SKILL.md +378 -0
- package/.codex/skills/next/SKILL.md +137 -0
- package/.codex/skills/openspec-apply-change/SKILL.md +156 -0
- package/.codex/skills/openspec-archive-change/SKILL.md +114 -0
- package/.codex/skills/openspec-bulk-archive-change/SKILL.md +246 -0
- package/.codex/skills/openspec-continue-change/SKILL.md +118 -0
- package/.codex/skills/openspec-explore/SKILL.md +290 -0
- package/.codex/skills/openspec-ff-change/SKILL.md +101 -0
- package/.codex/skills/openspec-new-change/SKILL.md +74 -0
- package/.codex/skills/openspec-onboard/SKILL.md +529 -0
- package/.codex/skills/openspec-sync-specs/SKILL.md +138 -0
- package/.codex/skills/openspec-verify-change/SKILL.md +168 -0
- package/.codex/skills/performance-doctor/SKILL.md +627 -0
- package/.codex/skills/progress/SKILL.md +193 -0
- package/.codex/skills/project-navigator/SKILL.md +286 -0
- package/.codex/skills/redis-cache/SKILL.md +829 -0
- package/.codex/skills/scheduled-jobs/SKILL.md +633 -0
- package/.codex/skills/security-guard/SKILL.md +739 -0
- package/.codex/skills/sms-mail/SKILL.md +766 -0
- package/.codex/skills/social-login/SKILL.md +668 -0
- package/.codex/skills/start/SKILL.md +154 -0
- package/.codex/skills/store-pc/SKILL.md +491 -0
- package/.codex/skills/sync/SKILL.md +149 -0
- package/.codex/skills/task-tracker/SKILL.md +307 -0
- package/.codex/skills/tech-decision/SKILL.md +393 -0
- package/.codex/skills/tenant-management/SKILL.md +603 -0
- package/.codex/skills/test-development/SKILL.md +755 -0
- package/.codex/skills/ui-pc/SKILL.md +475 -0
- package/.codex/skills/update-status/SKILL.md +159 -0
- package/.codex/skills/utils-toolkit/SKILL.md +593 -0
- package/.codex/skills/websocket-sse/SKILL.md +716 -0
- package/.codex/skills/workflow-engine/SKILL.md +676 -0
- package/.cursor/agents/code-reviewer.md +139 -0
- package/.cursor/agents/project-manager.md +159 -0
- package/.cursor/commands/opsx-apply.md +152 -0
- package/.cursor/commands/opsx-archive.md +157 -0
- package/.cursor/commands/opsx-bulk-archive.md +242 -0
- package/.cursor/commands/opsx-continue.md +114 -0
- package/.cursor/commands/opsx-explore.md +174 -0
- package/.cursor/commands/opsx-ff.md +94 -0
- package/.cursor/commands/opsx-new.md +69 -0
- package/.cursor/commands/opsx-onboard.md +525 -0
- package/.cursor/commands/opsx-sync.md +134 -0
- package/.cursor/commands/opsx-verify.md +164 -0
- package/.cursor/mcp.json +22 -0
- package/.cursor/skills/add-skill/SKILL.md +352 -0
- package/.cursor/skills/api-development/SKILL.md +560 -0
- package/.cursor/skills/architecture-design/SKILL.md +756 -0
- package/.cursor/skills/backend-annotations/SKILL.md +674 -0
- package/.cursor/skills/banana-image/CHANGELOG.md +37 -0
- package/.cursor/skills/banana-image/README.md +146 -0
- package/.cursor/skills/banana-image/SKILL.md +164 -0
- package/.cursor/skills/banana-image/assets/logo.png +0 -0
- package/.cursor/skills/banana-image/references/advanced-usage.md +189 -0
- package/.cursor/skills/banana-image/scripts/apply_template.py +125 -0
- package/.cursor/skills/banana-image/scripts/banana_image_exec.ts +412 -0
- package/.cursor/skills/banana-image/scripts/batch_prep.py +82 -0
- package/.cursor/skills/banana-image/scripts/package-lock.json +1437 -0
- package/.cursor/skills/banana-image/scripts/package.json +18 -0
- package/.cursor/skills/banana-image/scripts/requirements.txt +10 -0
- package/.cursor/skills/banana-image/templates/poster.json +22 -0
- package/.cursor/skills/banana-image/templates/product.json +17 -0
- package/.cursor/skills/banana-image/templates/social.json +22 -0
- package/.cursor/skills/banana-image/templates/thumbnail.json +17 -0
- package/.cursor/skills/brainstorm/SKILL.md +648 -0
- package/.cursor/skills/bug-detective/SKILL.md +1206 -0
- package/.cursor/skills/code-patterns/SKILL.md +590 -0
- package/.cursor/skills/collaborating-with-codex/SKILL.md +174 -0
- package/.cursor/skills/collaborating-with-codex/scripts/codex_bridge.py +275 -0
- package/.cursor/skills/collaborating-with-gemini/SKILL.md +194 -0
- package/.cursor/skills/collaborating-with-gemini/scripts/gemini_bridge.py +275 -0
- package/.cursor/skills/crud-development/SKILL.md +649 -0
- package/.cursor/skills/data-permission/SKILL.md +599 -0
- package/.cursor/skills/database-ops/SKILL.md +407 -0
- package/.cursor/skills/error-handler/SKILL.md +371 -0
- package/.cursor/skills/file-oss-management/SKILL.md +863 -0
- package/.cursor/skills/git-workflow/SKILL.md +375 -0
- package/.cursor/skills/json-serialization/SKILL.md +357 -0
- package/.cursor/skills/leniu-api-development/SKILL.md +803 -0
- package/.cursor/skills/leniu-architecture-design/SKILL.md +598 -0
- package/.cursor/skills/leniu-backend-annotations/SKILL.md +664 -0
- package/.cursor/skills/leniu-code-patterns/SKILL.md +365 -0
- package/.cursor/skills/leniu-crud-development/SKILL.md +1110 -0
- package/.cursor/skills/leniu-data-permission/SKILL.md +256 -0
- package/.cursor/skills/leniu-database-ops/SKILL.md +426 -0
- package/.cursor/skills/leniu-error-handler/SKILL.md +462 -0
- package/.cursor/skills/leniu-java-amount-handling/SKILL.md +461 -0
- package/.cursor/skills/leniu-java-code-style/SKILL.md +510 -0
- package/.cursor/skills/leniu-java-concurrent/SKILL.md +400 -0
- package/.cursor/skills/leniu-java-entity/SKILL.md +751 -0
- package/.cursor/skills/leniu-java-export/SKILL.md +560 -0
- package/.cursor/skills/leniu-java-logging/SKILL.md +832 -0
- package/.cursor/skills/leniu-java-mq/SKILL.md +338 -0
- package/.cursor/skills/leniu-java-mybatis/SKILL.md +640 -0
- package/.cursor/skills/leniu-java-report-query-param/SKILL.md +291 -0
- package/.cursor/skills/leniu-java-task/SKILL.md +367 -0
- package/.cursor/skills/leniu-java-total-line/SKILL.md +195 -0
- package/.cursor/skills/leniu-marketing-price-rule-customizer/SKILL.md +301 -0
- package/.cursor/skills/leniu-marketing-recharge-rule-customizer/SKILL.md +285 -0
- package/.cursor/skills/leniu-mealtime/SKILL.md +215 -0
- package/.cursor/skills/leniu-redis-cache/SKILL.md +316 -0
- package/.cursor/skills/leniu-security-guard/SKILL.md +520 -0
- package/.cursor/skills/leniu-utils-toolkit/SKILL.md +380 -0
- package/.cursor/skills/openspec-apply-change/SKILL.md +156 -0
- package/.cursor/skills/openspec-archive-change/SKILL.md +114 -0
- package/.cursor/skills/openspec-bulk-archive-change/SKILL.md +246 -0
- package/.cursor/skills/openspec-continue-change/SKILL.md +118 -0
- package/.cursor/skills/openspec-explore/SKILL.md +290 -0
- package/.cursor/skills/openspec-ff-change/SKILL.md +101 -0
- package/.cursor/skills/openspec-new-change/SKILL.md +74 -0
- package/.cursor/skills/openspec-onboard/SKILL.md +529 -0
- package/.cursor/skills/openspec-sync-specs/SKILL.md +138 -0
- package/.cursor/skills/openspec-verify-change/SKILL.md +168 -0
- package/.cursor/skills/performance-doctor/SKILL.md +627 -0
- package/.cursor/skills/project-navigator/SKILL.md +305 -0
- package/.cursor/skills/redis-cache/SKILL.md +839 -0
- package/.cursor/skills/scheduled-jobs/SKILL.md +633 -0
- package/.cursor/skills/security-guard/SKILL.md +748 -0
- package/.cursor/skills/sms-mail/SKILL.md +766 -0
- package/.cursor/skills/social-login/SKILL.md +668 -0
- package/.cursor/skills/store-pc/SKILL.md +366 -0
- package/.cursor/skills/task-tracker/SKILL.md +307 -0
- package/.cursor/skills/tech-decision/SKILL.md +393 -0
- package/.cursor/skills/tenant-management/SKILL.md +603 -0
- package/.cursor/skills/test-development/SKILL.md +755 -0
- package/.cursor/skills/ui-pc/SKILL.md +438 -0
- package/.cursor/skills/utils-toolkit/SKILL.md +615 -0
- package/.cursor/skills/websocket-sse/SKILL.md +716 -0
- package/.cursor/skills/workflow-engine/SKILL.md +676 -0
- package/AGENTS.md +669 -0
- package/CLAUDE.md +205 -0
- package/README.md +205 -0
- package/bin/index.js +179 -0
- package/init.sh +178 -0
- package/package.json +27 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: start
|
|
3
|
+
description: |
|
|
4
|
+
当需要快速了解项目、新成员入门时自动使用此 Skill。
|
|
5
|
+
|
|
6
|
+
触发场景:
|
|
7
|
+
- 新成员第一次接触项目
|
|
8
|
+
- 接手他人的项目需要快速了解
|
|
9
|
+
- 距上次熟悉项目已久需要快速回顾
|
|
10
|
+
- 在新的会话中快速了解项目
|
|
11
|
+
|
|
12
|
+
触发词:了解项目、start、项目介绍、项目概览、快速入门、新手入门、项目了解
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# /start - 项目快速了解
|
|
16
|
+
|
|
17
|
+
新成员快速了解项目的必看命令。自动检测项目类型、扫描业务模块、生成项目概览。
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 🎯 适用场景
|
|
22
|
+
|
|
23
|
+
| 场景 | 说明 |
|
|
24
|
+
|------|------|
|
|
25
|
+
| **初次接触** | 新成员第一次接触项目 |
|
|
26
|
+
| **项目交接** | 接手他人的项目 |
|
|
27
|
+
| **重新梳理** | 距上次熟悉项目已久,需要快速回顾 |
|
|
28
|
+
| **窗口切换** | 在新的会话中快速了解项目 |
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## 🚀 执行流程
|
|
33
|
+
|
|
34
|
+
### 第一步:识别项目类型和框架(强制执行)
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# 扫描项目结构
|
|
38
|
+
Glob pattern: "ruoyi-modules/ruoyi-*/src/main/java/**/controller/*Controller.java"
|
|
39
|
+
|
|
40
|
+
# 查看最近 3 条 Git 提交
|
|
41
|
+
git log -3 --oneline --format="%h %s (%ar)"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**识别框架模块(不统计进度)**:
|
|
45
|
+
- ✅ `ruoyi-system` - 系统管理模块
|
|
46
|
+
- ✅ `ruoyi-generator` - 代码生成器
|
|
47
|
+
- ✅ `ruoyi-common` - 通用工具库
|
|
48
|
+
|
|
49
|
+
**识别业务模块(需统计进度)**:
|
|
50
|
+
- 排除上述框架模块后的所有 `ruoyi-*` 模块
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
### 第二步:判断项目开发阶段
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
业务模块数量 = 0 → 🟢 全新项目(仅有框架)
|
|
58
|
+
业务模块数量 1-5 → 🟡 初期开发(刚开始业务)
|
|
59
|
+
业务模块数量 6+ → 🔴 成熟项目(业务较多)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
### 第三步:生成项目概览报告
|
|
65
|
+
|
|
66
|
+
#### 情况 1:全新项目(业务模块数 = 0)
|
|
67
|
+
|
|
68
|
+
```markdown
|
|
69
|
+
# 👋 欢迎使用 RuoYi-Vue-Plus 框架
|
|
70
|
+
|
|
71
|
+
**项目类型**:Spring Boot 3 + MyBatis-Plus 纯后端项目
|
|
72
|
+
**框架版本**:5.5.3+
|
|
73
|
+
|
|
74
|
+
## 📦 框架现状
|
|
75
|
+
|
|
76
|
+
### ✅ 已就绪的框架模块
|
|
77
|
+
|
|
78
|
+
| 模块 | 说明 | 状态 |
|
|
79
|
+
|------|------|------|
|
|
80
|
+
| ruoyi-system | 系统管理(用户、角色、菜单、字典等) | ✅ 完整 |
|
|
81
|
+
| ruoyi-generator | 动态代码生成器 | ✅ 完整 |
|
|
82
|
+
| ruoyi-common | 通用工具库 | ✅ 完整 |
|
|
83
|
+
|
|
84
|
+
## 🎯 快速开始
|
|
85
|
+
|
|
86
|
+
### 方式 1:使用 /dev 命令(推荐)
|
|
87
|
+
\`/dev\`
|
|
88
|
+
|
|
89
|
+
### 方式 2:使用 /crud 命令(表已存在)
|
|
90
|
+
\`/crud\`
|
|
91
|
+
|
|
92
|
+
## 💡 推荐操作
|
|
93
|
+
|
|
94
|
+
**第一步**:了解项目规范
|
|
95
|
+
查看项目根目录的 CLAUDE.md 文件
|
|
96
|
+
|
|
97
|
+
**第二步**:初始化项目文档
|
|
98
|
+
\`/init-docs\`
|
|
99
|
+
|
|
100
|
+
**第三步**:开发第一个功能
|
|
101
|
+
\`/dev\` 或 \`/crud\`
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
#### 情况 2:初期开发项目(业务模块数 1-5)
|
|
105
|
+
|
|
106
|
+
```markdown
|
|
107
|
+
# 👋 欢迎回到项目
|
|
108
|
+
|
|
109
|
+
**技术栈**:Spring Boot 3 + MyBatis-Plus + Sa-Token
|
|
110
|
+
**项目阶段**:🟡 初期开发
|
|
111
|
+
|
|
112
|
+
## 📊 项目概况
|
|
113
|
+
|
|
114
|
+
### 业务进度
|
|
115
|
+
- **业务模块**:X 个
|
|
116
|
+
- **已完成功能**:X 个
|
|
117
|
+
- **进行中功能**:X 个
|
|
118
|
+
- **总体进度**:X%
|
|
119
|
+
|
|
120
|
+
## 🎯 当前工作建议
|
|
121
|
+
|
|
122
|
+
### 快速查看进度
|
|
123
|
+
\`/progress\`
|
|
124
|
+
|
|
125
|
+
### 检查代码规范
|
|
126
|
+
\`/check\`
|
|
127
|
+
|
|
128
|
+
### 获取开发建议
|
|
129
|
+
\`/next\`
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## 📚 相关命令
|
|
135
|
+
|
|
136
|
+
| 命令 | 说明 | 用途 |
|
|
137
|
+
|------|------|------|
|
|
138
|
+
| `/progress` | 详细进度报告 | 了解各模块完成情况 |
|
|
139
|
+
| `/check` | 代码规范检查 | 确保代码质量 |
|
|
140
|
+
| `/next` | 下一步建议 | 获取开发方向 |
|
|
141
|
+
| `/sync` | 全量同步 | 定期整理文档 |
|
|
142
|
+
| `/dev` | 开发新功能 | 完整开发流程 |
|
|
143
|
+
| `/crud` | 快速生成 | 表已存在时 |
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## 🎓 新成员入门清单
|
|
148
|
+
|
|
149
|
+
- [ ] 阅读项目根目录的 `CLAUDE.md` 了解开发规范
|
|
150
|
+
- [ ] 运行 `/start` 了解项目现状
|
|
151
|
+
- [ ] 运行 `/progress` 查看详细进度
|
|
152
|
+
- [ ] 查看 `/docs/ARCHITECTURE.md` 了解架构
|
|
153
|
+
- [ ] 根据 `/next` 建议选择任务
|
|
154
|
+
- [ ] 使用 `/dev` 或 `/crud` 开始开发
|
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: store-pc
|
|
3
|
+
description: |
|
|
4
|
+
PC 端(plus-ui)状态管理与 Hooks 指南。包含 Pinia Store、Hooks 组合式函数的创建和使用规范。
|
|
5
|
+
|
|
6
|
+
触发场景:
|
|
7
|
+
- 在 PC 后台创建/使用 Store
|
|
8
|
+
- Pinia 状态管理
|
|
9
|
+
- 跨组件数据共享(PC端)
|
|
10
|
+
- 持久化存储(useStorage)
|
|
11
|
+
- 权限判断
|
|
12
|
+
- 字典数据管理
|
|
13
|
+
|
|
14
|
+
触发词:PC Store、Pinia、defineStore、useUserStore、useDictStore、PC状态管理、useStorage、持久化、状态管理
|
|
15
|
+
|
|
16
|
+
适用目录:plus-ui/**
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
# PC 端状态管理指南
|
|
20
|
+
|
|
21
|
+
> **适用于**: `plus-ui/` 目录下的 PC 后台管理系统
|
|
22
|
+
|
|
23
|
+
## 自动导入说明
|
|
24
|
+
|
|
25
|
+
以下内容**无需手动 import**(通过 unplugin-auto-import 自动导入):
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
// Vue APIs
|
|
29
|
+
ref, reactive, computed, watch, watchEffect, watchPostEffect, watchSyncEffect
|
|
30
|
+
onMounted, onUnmounted, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onUpdated
|
|
31
|
+
onActivated, onDeactivated, onErrorCaptured, onRenderTracked, onRenderTriggered
|
|
32
|
+
onServerPrefetch
|
|
33
|
+
nextTick, toRefs, toRef, unref, isRef, isReactive, isReadonly, isProxy
|
|
34
|
+
provide, inject, defineProps, defineEmits, defineExpose, defineOptions, defineSlots
|
|
35
|
+
withDefaults, useSlots, useAttrs, useCssModule, useCssVars
|
|
36
|
+
shallowRef, shallowReactive, shallowReadonly, triggerRef, customRef, toRaw, markRaw
|
|
37
|
+
effectScope, getCurrentScope, onScopeDispose
|
|
38
|
+
|
|
39
|
+
// Pinia
|
|
40
|
+
defineStore, storeToRefs, acceptHMRUpdate, createPinia, setActivePinia, getActivePinia
|
|
41
|
+
mapStores, mapState, mapWritableState, mapActions
|
|
42
|
+
|
|
43
|
+
// Vue Router
|
|
44
|
+
useRouter, useRoute, useLink, onBeforeRouteLeave, onBeforeRouteUpdate
|
|
45
|
+
|
|
46
|
+
// @vueuse/core
|
|
47
|
+
useStorage, useLocalStorage, useSessionStorage, useMouse, useWindowSize
|
|
48
|
+
// ... 以及其他 @vueuse/core 导出的函数
|
|
49
|
+
|
|
50
|
+
// Element Plus
|
|
51
|
+
ElMessage, ElMessageBox, ElNotification, ElLoading
|
|
52
|
+
// ... 以及其他 Element Plus 组件和函数
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**需要手动 import 的**:
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
// Stores(需要手动导入)
|
|
59
|
+
import { useUserStore } from '@/store/modules/user'
|
|
60
|
+
import { useDictStore } from '@/store/modules/dict'
|
|
61
|
+
import { usePermissionStore } from '@/store/modules/permission'
|
|
62
|
+
import { useAppStore } from '@/store/modules/app'
|
|
63
|
+
import { useSettingsStore } from '@/store/modules/settings'
|
|
64
|
+
import { useTagsViewStore } from '@/store/modules/tagsView'
|
|
65
|
+
import { useNoticeStore } from '@/store/modules/notice'
|
|
66
|
+
|
|
67
|
+
// Hooks(需要手动导入)
|
|
68
|
+
import useDialog from '@/hooks/useDialog'
|
|
69
|
+
|
|
70
|
+
// 工具函数(需要手动导入)
|
|
71
|
+
import { getToken, setToken, removeToken } from '@/utils/auth'
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## 已有 Store 清单
|
|
77
|
+
|
|
78
|
+
| Store | 文件 | 用途 | 关键方法 |
|
|
79
|
+
|-------|------|------|---------|
|
|
80
|
+
| `useUserStore` | `store/modules/user.ts` | 用户认证、权限 | login, logout, getInfo, setAvatar |
|
|
81
|
+
| `useDictStore` | `store/modules/dict.ts` | 字典数据缓存 | getDict, setDict, removeDict, cleanDict |
|
|
82
|
+
| `usePermissionStore` | `store/modules/permission.ts` | 路由权限 | generateRoutes, setRoutes, setSidebarRouters |
|
|
83
|
+
| `useAppStore` | `store/modules/app.ts` | 应用配置(侧边栏、语言、尺寸) | toggleSideBar, closeSideBar, changeLanguage, setSize |
|
|
84
|
+
| `useSettingsStore` | `store/modules/settings.ts` | 布局设置 | setTitle |
|
|
85
|
+
| `useTagsViewStore` | `store/modules/tagsView.ts` | 标签页管理 | addView, delView, delAllViews, delOthersViews |
|
|
86
|
+
| `useNoticeStore` | `store/modules/notice.ts` | 通知消息 | addNotice, removeNotice, readAll, clearNotice |
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Hooks 清单
|
|
91
|
+
|
|
92
|
+
> Hooks 是可复用的组合式函数,封装了特定业务逻辑。
|
|
93
|
+
|
|
94
|
+
### 已有 Hooks
|
|
95
|
+
|
|
96
|
+
| Hook | 文件 | 用途 | 关键方法/属性 |
|
|
97
|
+
|------|------|------|--------------|
|
|
98
|
+
| `useDialog` | `hooks/useDialog.ts` | 弹窗控制 | visible, title, openDialog, closeDialog |
|
|
99
|
+
|
|
100
|
+
### useDialog 使用示例
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
import useDialog from '@/hooks/useDialog'
|
|
104
|
+
|
|
105
|
+
// 在组件中使用
|
|
106
|
+
const { visible, title, openDialog, closeDialog } = useDialog({ title: '编辑用户' })
|
|
107
|
+
|
|
108
|
+
// 打开弹窗
|
|
109
|
+
const handleEdit = () => {
|
|
110
|
+
openDialog()
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// 关闭弹窗
|
|
114
|
+
const handleClose = () => {
|
|
115
|
+
closeDialog()
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## 创建新 Store
|
|
122
|
+
|
|
123
|
+
### 标准模板
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
// store/modules/xxx.ts
|
|
127
|
+
// ✅ defineStore、ref、computed 已自动导入,无需手动 import
|
|
128
|
+
|
|
129
|
+
export const useXxxStore = defineStore('xxx', () => {
|
|
130
|
+
// ========== 状态 ==========
|
|
131
|
+
const list = ref<XxxVo[]>([])
|
|
132
|
+
const loading = ref(false)
|
|
133
|
+
const current = ref<XxxVo | null>(null)
|
|
134
|
+
|
|
135
|
+
// ========== 计算属性 ==========
|
|
136
|
+
const count = computed(() => list.value.length)
|
|
137
|
+
const isEmpty = computed(() => list.value.length === 0)
|
|
138
|
+
const hasSelected = computed(() => current.value !== null)
|
|
139
|
+
|
|
140
|
+
// ========== 方法 ==========
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* 获取列表
|
|
144
|
+
*/
|
|
145
|
+
const fetchList = async (params?: XxxQuery) => {
|
|
146
|
+
loading.value = true
|
|
147
|
+
try {
|
|
148
|
+
const res = await pageXxxs(params)
|
|
149
|
+
list.value = res.data.records
|
|
150
|
+
} catch (error) {
|
|
151
|
+
console.error('获取列表失败:', error)
|
|
152
|
+
} finally {
|
|
153
|
+
loading.value = false
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* 设置当前选中项
|
|
159
|
+
*/
|
|
160
|
+
const setCurrent = (item: XxxVo | null) => {
|
|
161
|
+
current.value = item
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* 重置状态
|
|
166
|
+
*/
|
|
167
|
+
const reset = () => {
|
|
168
|
+
list.value = []
|
|
169
|
+
current.value = null
|
|
170
|
+
loading.value = false
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// ========== 返回 ==========
|
|
174
|
+
return {
|
|
175
|
+
// 状态
|
|
176
|
+
list,
|
|
177
|
+
loading,
|
|
178
|
+
current,
|
|
179
|
+
// 计算属性
|
|
180
|
+
count,
|
|
181
|
+
isEmpty,
|
|
182
|
+
hasSelected,
|
|
183
|
+
// 方法
|
|
184
|
+
fetchList,
|
|
185
|
+
setCurrent,
|
|
186
|
+
reset
|
|
187
|
+
}
|
|
188
|
+
})
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## 使用 Store
|
|
194
|
+
|
|
195
|
+
### 基本用法
|
|
196
|
+
|
|
197
|
+
```typescript
|
|
198
|
+
import { useXxxStore } from '@/store/modules/xxx'
|
|
199
|
+
|
|
200
|
+
const xxxStore = useXxxStore()
|
|
201
|
+
|
|
202
|
+
// 访问状态(非响应式)
|
|
203
|
+
console.log(xxxStore.list)
|
|
204
|
+
console.log(xxxStore.count)
|
|
205
|
+
|
|
206
|
+
// 调用方法
|
|
207
|
+
await xxxStore.fetchList()
|
|
208
|
+
xxxStore.setCurrent(item)
|
|
209
|
+
xxxStore.reset()
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### 响应式解构
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
import { useXxxStore } from '@/store/modules/xxx'
|
|
216
|
+
|
|
217
|
+
const xxxStore = useXxxStore()
|
|
218
|
+
|
|
219
|
+
// ✅ 正确:使用 storeToRefs 解构状态
|
|
220
|
+
const { list, loading, current } = storeToRefs(xxxStore)
|
|
221
|
+
|
|
222
|
+
// ✅ 正确:方法直接解构(方法不需要响应式)
|
|
223
|
+
const { fetchList, setCurrent, reset } = xxxStore
|
|
224
|
+
|
|
225
|
+
// ❌ 错误:直接解构状态会丢失响应式
|
|
226
|
+
// const { list, loading } = xxxStore
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### 在模板中使用
|
|
230
|
+
|
|
231
|
+
```vue
|
|
232
|
+
<template>
|
|
233
|
+
<div v-loading="xxxStore.loading">
|
|
234
|
+
<div v-for="item in xxxStore.list" :key="item.id">
|
|
235
|
+
{{ item.name }}
|
|
236
|
+
</div>
|
|
237
|
+
<div v-if="xxxStore.isEmpty">暂无数据</div>
|
|
238
|
+
</div>
|
|
239
|
+
</template>
|
|
240
|
+
|
|
241
|
+
<script setup lang="ts">
|
|
242
|
+
import { useXxxStore } from '@/store/modules/xxx'
|
|
243
|
+
|
|
244
|
+
const xxxStore = useXxxStore()
|
|
245
|
+
|
|
246
|
+
onMounted(() => {
|
|
247
|
+
xxxStore.fetchList()
|
|
248
|
+
})
|
|
249
|
+
</script>
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## 持久化存储
|
|
255
|
+
|
|
256
|
+
> ⚠️ **重要**:本项目使用 `@vueuse/core` 的 `useStorage` 实现持久化存储,而不是 pinia-plugin-persist 插件。
|
|
257
|
+
|
|
258
|
+
### useStorage 说明
|
|
259
|
+
|
|
260
|
+
```typescript
|
|
261
|
+
// useStorage 已自动导入,无需手动 import
|
|
262
|
+
// 基于 localStorage
|
|
263
|
+
const data = useStorage('key', defaultValue)
|
|
264
|
+
|
|
265
|
+
// 基于 sessionStorage
|
|
266
|
+
const data = useSessionStorage('key', defaultValue)
|
|
267
|
+
|
|
268
|
+
// 基于 localStorage(显式指定)
|
|
269
|
+
const data = useLocalStorage('key', defaultValue)
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### useStorage API
|
|
273
|
+
|
|
274
|
+
```typescript
|
|
275
|
+
// 设置值(自动保存到 localStorage)
|
|
276
|
+
const token = useStorage('token', '')
|
|
277
|
+
token.value = 'new-token' // 自动保存
|
|
278
|
+
|
|
279
|
+
// 获取值
|
|
280
|
+
console.log(token.value)
|
|
281
|
+
|
|
282
|
+
// 删除值
|
|
283
|
+
token.value = null
|
|
284
|
+
|
|
285
|
+
// 带类型的存储
|
|
286
|
+
const user = useStorage<UserInfo>('user', null)
|
|
287
|
+
user.value = { name: 'admin', age: 18 }
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### 在 Store 中使用 useStorage
|
|
291
|
+
|
|
292
|
+
```typescript
|
|
293
|
+
// store/modules/app.ts 示例
|
|
294
|
+
import { defineStore } from 'pinia'
|
|
295
|
+
import { useStorage } from '@vueuse/core'
|
|
296
|
+
|
|
297
|
+
export const useAppStore = defineStore('app', () => {
|
|
298
|
+
// ✅ 使用 useStorage 实现持久化
|
|
299
|
+
const sidebarStatus = useStorage('sidebarStatus', '1')
|
|
300
|
+
const size = useStorage<'large' | 'default' | 'small'>('size', 'default')
|
|
301
|
+
const language = useStorage('language', 'zh_CN')
|
|
302
|
+
|
|
303
|
+
// 状态会自动持久化到 localStorage
|
|
304
|
+
const sidebar = reactive({
|
|
305
|
+
opened: sidebarStatus.value ? !!+sidebarStatus.value : true,
|
|
306
|
+
withoutAnimation: false,
|
|
307
|
+
hide: false
|
|
308
|
+
})
|
|
309
|
+
|
|
310
|
+
const toggleSideBar = (withoutAnimation: boolean) => {
|
|
311
|
+
sidebar.opened = !sidebar.opened
|
|
312
|
+
sidebar.withoutAnimation = withoutAnimation
|
|
313
|
+
// ✅ 修改 sidebarStatus 会自动保存到 localStorage
|
|
314
|
+
sidebarStatus.value = sidebar.opened ? '1' : '0'
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
return {
|
|
318
|
+
sidebar,
|
|
319
|
+
size,
|
|
320
|
+
language,
|
|
321
|
+
toggleSideBar
|
|
322
|
+
}
|
|
323
|
+
})
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
### Token 管理示例
|
|
327
|
+
|
|
328
|
+
```typescript
|
|
329
|
+
// utils/auth.ts 示例
|
|
330
|
+
import { useStorage } from '@vueuse/core'
|
|
331
|
+
|
|
332
|
+
const TokenKey = 'Admin-Token'
|
|
333
|
+
const tokenStorage = useStorage<null | string>(TokenKey, null)
|
|
334
|
+
|
|
335
|
+
export const getToken = () => tokenStorage.value
|
|
336
|
+
|
|
337
|
+
export const setToken = (access_token: string) => (tokenStorage.value = access_token)
|
|
338
|
+
|
|
339
|
+
export const removeToken = () => (tokenStorage.value = null)
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
### 在 useUserStore 中使用
|
|
343
|
+
|
|
344
|
+
```typescript
|
|
345
|
+
// store/modules/user.ts 示例
|
|
346
|
+
import { defineStore } from 'pinia'
|
|
347
|
+
import { getToken, setToken, removeToken } from '@/utils/auth'
|
|
348
|
+
|
|
349
|
+
export const useUserStore = defineStore('user', () => {
|
|
350
|
+
// ✅ token 通过 utils/auth.ts 中的 useStorage 持久化
|
|
351
|
+
const token = ref(getToken())
|
|
352
|
+
const roles = ref<Array<string>>([])
|
|
353
|
+
const permissions = ref<Array<string>>([])
|
|
354
|
+
|
|
355
|
+
const login = async (userInfo: LoginData): Promise<void> => {
|
|
356
|
+
const res = await loginApi(userInfo)
|
|
357
|
+
const data = res.data
|
|
358
|
+
setToken(data.access_token) // ✅ 自动保存到 localStorage
|
|
359
|
+
token.value = data.access_token
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
const logout = async (): Promise<void> => {
|
|
363
|
+
await logoutApi()
|
|
364
|
+
token.value = ''
|
|
365
|
+
roles.value = []
|
|
366
|
+
permissions.value = []
|
|
367
|
+
removeToken() // ✅ 自动从 localStorage 删除
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
return {
|
|
371
|
+
token,
|
|
372
|
+
roles,
|
|
373
|
+
permissions,
|
|
374
|
+
login,
|
|
375
|
+
logout
|
|
376
|
+
}
|
|
377
|
+
})
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
---
|
|
381
|
+
|
|
382
|
+
## 最佳实践
|
|
383
|
+
|
|
384
|
+
### 1. 何时使用 Store
|
|
385
|
+
|
|
386
|
+
| 场景 | 是否使用 Store |
|
|
387
|
+
|------|---------------|
|
|
388
|
+
| 多个页面/组件共享的数据 | ✅ 使用 |
|
|
389
|
+
| 用户登录状态、权限 | ✅ 使用 |
|
|
390
|
+
| 全局配置、主题设置 | ✅ 使用 |
|
|
391
|
+
| 字典数据缓存 | ✅ 使用 |
|
|
392
|
+
| 页面内部状态 | ❌ 用 ref/reactive |
|
|
393
|
+
| 组件内部状态 | ❌ 用 ref/reactive |
|
|
394
|
+
| 父子组件传值 | ❌ 用 props/emit |
|
|
395
|
+
| 兄弟组件通信(简单) | ❌ 用 provide/inject |
|
|
396
|
+
|
|
397
|
+
### 2. Store 命名规范
|
|
398
|
+
|
|
399
|
+
```typescript
|
|
400
|
+
// ✅ 正确:use + 业务名 + Store
|
|
401
|
+
export const useUserStore = defineStore('user', ...)
|
|
402
|
+
export const useCartStore = defineStore('cart', ...)
|
|
403
|
+
export const useDictStore = defineStore('dict', ...)
|
|
404
|
+
|
|
405
|
+
// ❌ 错误:不规范的命名
|
|
406
|
+
export const userStore = defineStore('user', ...)
|
|
407
|
+
export const useUser = defineStore('user', ...)
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
### 3. 避免循环依赖
|
|
411
|
+
|
|
412
|
+
```typescript
|
|
413
|
+
// ❌ 避免 Store 之间循环引用
|
|
414
|
+
// userStore.ts
|
|
415
|
+
import { useOrderStore } from './order' // orderStore 又引用 userStore
|
|
416
|
+
|
|
417
|
+
// ✅ 正确做法:在组件层协调,或使用事件
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
### 4. 重置 Store(登出时)
|
|
421
|
+
|
|
422
|
+
```typescript
|
|
423
|
+
// 在 useUserStore 中
|
|
424
|
+
const logout = async () => {
|
|
425
|
+
// 重置所有相关 Store
|
|
426
|
+
const dictStore = useDictStore()
|
|
427
|
+
const permissionStore = usePermissionStore()
|
|
428
|
+
|
|
429
|
+
// 重置当前 Store
|
|
430
|
+
token.value = ''
|
|
431
|
+
roles.value = []
|
|
432
|
+
permissions.value = []
|
|
433
|
+
removeToken()
|
|
434
|
+
|
|
435
|
+
// 重置其他 Store
|
|
436
|
+
dictStore.cleanDict()
|
|
437
|
+
|
|
438
|
+
// 跳转登录页
|
|
439
|
+
router.push('/login')
|
|
440
|
+
}
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
### 5. 使用 Setup Syntax
|
|
444
|
+
|
|
445
|
+
```typescript
|
|
446
|
+
// ✅ 推荐:使用 Setup 语法(Composition API)
|
|
447
|
+
export const useXxxStore = defineStore('xxx', () => {
|
|
448
|
+
const state = ref(0)
|
|
449
|
+
const increment = () => state.value++
|
|
450
|
+
return { state, increment }
|
|
451
|
+
})
|
|
452
|
+
|
|
453
|
+
// ❌ 不推荐:使用 Options API
|
|
454
|
+
export const useXxxStore = defineStore('xxx', {
|
|
455
|
+
state: () => ({ count: 0 }),
|
|
456
|
+
actions: {
|
|
457
|
+
increment() { this.count++ }
|
|
458
|
+
}
|
|
459
|
+
})
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
---
|
|
463
|
+
|
|
464
|
+
## 参考文件
|
|
465
|
+
|
|
466
|
+
### Stores
|
|
467
|
+
|
|
468
|
+
- Store 目录:`plus-ui/src/store/modules/`
|
|
469
|
+
- 用户 Store:`plus-ui/src/store/modules/user.ts`
|
|
470
|
+
- 字典 Store:`plus-ui/src/store/modules/dict.ts`
|
|
471
|
+
- 权限 Store:`plus-ui/src/store/modules/permission.ts`
|
|
472
|
+
- 应用 Store:`plus-ui/src/store/modules/app.ts`
|
|
473
|
+
- 设置 Store:`plus-ui/src/store/modules/settings.ts`
|
|
474
|
+
- 标签页 Store:`plus-ui/src/store/modules/tagsView.ts`
|
|
475
|
+
- 通知 Store:`plus-ui/src/store/modules/notice.ts`
|
|
476
|
+
|
|
477
|
+
### Hooks
|
|
478
|
+
|
|
479
|
+
- Hooks 目录:`plus-ui/src/hooks/`
|
|
480
|
+
- 弹窗控制:`plus-ui/src/hooks/useDialog.ts`
|
|
481
|
+
|
|
482
|
+
### 工具类
|
|
483
|
+
|
|
484
|
+
- Token 管理:`plus-ui/src/utils/auth.ts`(使用 useStorage)
|
|
485
|
+
|
|
486
|
+
### 配置文件
|
|
487
|
+
|
|
488
|
+
- 自动导入配置:`plus-ui/vite/plugins/auto-import.ts`
|
|
489
|
+
- Vite 配置:`plus-ui/vite.config.ts`
|
|
490
|
+
---
|
|
491
|
+
|