ai-engineering-init 1.3.4 → 1.4.1

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 (227) hide show
  1. package/.claude/hooks/skill-forced-eval.js +2 -0
  2. package/.claude/settings.json +3 -3
  3. package/.claude/skills/add-skill/SKILL.md +79 -32
  4. package/.claude/skills/api-development/SKILL.md +83 -377
  5. package/.claude/skills/architecture-design/SKILL.md +138 -632
  6. package/.claude/skills/backend-annotations/SKILL.md +134 -506
  7. package/.claude/skills/banana-image/SKILL.md +10 -3
  8. package/.claude/skills/brainstorm/SKILL.md +103 -535
  9. package/.claude/skills/bug-detective/SKILL.md +147 -1097
  10. package/.claude/skills/bug-detective/references/error-patterns.md +242 -0
  11. package/.claude/skills/code-patterns/SKILL.md +116 -426
  12. package/.claude/skills/code-patterns/references/leniu-code-patterns.md +87 -0
  13. package/.claude/skills/crud-development/SKILL.md +64 -304
  14. package/.claude/skills/data-permission/SKILL.md +105 -412
  15. package/.claude/skills/data-permission/references/custom-data-scope.md +90 -0
  16. package/.claude/skills/file-oss-management/SKILL.md +106 -714
  17. package/.claude/skills/file-oss-management/references/entities.md +105 -0
  18. package/.claude/skills/file-oss-management/references/service-impl.md +104 -0
  19. package/.claude/skills/leniu-api-development/SKILL.md +142 -626
  20. package/.claude/skills/leniu-api-development/references/real-examples.md +273 -0
  21. package/.claude/skills/leniu-architecture-design/SKILL.md +176 -391
  22. package/.claude/skills/leniu-backend-annotations/SKILL.md +132 -519
  23. package/.claude/skills/leniu-brainstorm/SKILL.md +132 -541
  24. package/.claude/skills/leniu-brainstorm/references/business-scenarios.md +162 -0
  25. package/.claude/skills/leniu-crud-development/SKILL.md +232 -938
  26. package/.claude/skills/leniu-crud-development/references/templates.md +597 -0
  27. package/.claude/skills/leniu-customization-location/SKILL.md +410 -0
  28. package/.claude/skills/leniu-data-permission/SKILL.md +70 -0
  29. package/.claude/skills/leniu-java-entity/SKILL.md +76 -590
  30. package/.claude/skills/leniu-java-entity/references/templates.md +237 -0
  31. package/.claude/skills/leniu-java-export/SKILL.md +94 -379
  32. package/.claude/skills/leniu-java-logging/SKILL.md +106 -709
  33. package/.claude/skills/leniu-java-logging/references/data-mask.md +46 -0
  34. package/.claude/skills/leniu-java-logging/references/logging-scenarios.md +113 -0
  35. package/.claude/skills/leniu-java-mybatis/SKILL.md +73 -446
  36. package/.claude/skills/leniu-java-mybatis/references/report-mapper.md +88 -0
  37. package/.claude/skills/leniu-report-customization/SKILL.md +111 -365
  38. package/.claude/skills/leniu-report-customization/references/table-fields.md +93 -0
  39. package/.claude/skills/leniu-report-standard-customization/SKILL.md +111 -334
  40. package/.claude/skills/leniu-report-standard-customization/references/analysis-module.md +64 -0
  41. package/.claude/skills/leniu-report-standard-customization/references/table-fields.md +113 -0
  42. package/.claude/skills/leniu-security-guard/SKILL.md +133 -347
  43. package/.claude/skills/mysql-debug/SKILL.md +364 -0
  44. package/.claude/skills/openspec-apply-change/SKILL.md +10 -1
  45. package/.claude/skills/openspec-archive-change/SKILL.md +9 -1
  46. package/.claude/skills/openspec-bulk-archive-change/SKILL.md +9 -1
  47. package/.claude/skills/openspec-continue-change/SKILL.md +9 -1
  48. package/.claude/skills/openspec-explore/SKILL.md +10 -1
  49. package/.claude/skills/openspec-ff-change/SKILL.md +9 -1
  50. package/.claude/skills/openspec-new-change/SKILL.md +9 -1
  51. package/.claude/skills/openspec-onboard/SKILL.md +15 -130
  52. package/.claude/skills/openspec-sync-specs/SKILL.md +9 -1
  53. package/.claude/skills/openspec-verify-change/SKILL.md +9 -1
  54. package/.claude/skills/performance-doctor/SKILL.md +110 -434
  55. package/.claude/skills/redis-cache/SKILL.md +89 -595
  56. package/.claude/skills/redis-cache/references/listeners.md +23 -0
  57. package/.claude/skills/scheduled-jobs/SKILL.md +88 -407
  58. package/.claude/skills/security-guard/SKILL.md +137 -532
  59. package/.claude/skills/security-guard/references/encrypt-config.md +103 -0
  60. package/.claude/skills/security-guard/references/sensitive-strategies.md +42 -0
  61. package/.claude/skills/sms-mail/SKILL.md +116 -574
  62. package/.claude/skills/sms-mail/references/mail-config.md +88 -0
  63. package/.claude/skills/sms-mail/references/sms-config.md +74 -0
  64. package/.claude/skills/social-login/SKILL.md +112 -514
  65. package/.claude/skills/social-login/references/provider-configs.md +118 -0
  66. package/.claude/skills/tenant-management/SKILL.md +129 -444
  67. package/.claude/skills/tenant-management/references/tenant-scenarios.md +91 -0
  68. package/.claude/skills/test-development/SKILL.md +86 -540
  69. package/.claude/skills/test-development/references/parameterized-examples.md +119 -0
  70. package/.claude/skills/utils-toolkit/SKILL.md +52 -305
  71. package/.claude/skills/utils-toolkit/references/redis-utils-api.md +56 -0
  72. package/.claude/skills/websocket-sse/SKILL.md +105 -550
  73. package/.claude/skills/workflow-engine/SKILL.md +147 -502
  74. package/.codex/skills/add-skill/SKILL.md +79 -32
  75. package/.codex/skills/api-development/SKILL.md +172 -599
  76. package/.codex/skills/architecture-design/SKILL.md +138 -504
  77. package/.codex/skills/backend-annotations/SKILL.md +134 -496
  78. package/.codex/skills/banana-image/SKILL.md +10 -3
  79. package/.codex/skills/brainstorm/SKILL.md +103 -535
  80. package/.codex/skills/bug-detective/SKILL.md +147 -1097
  81. package/.codex/skills/bug-detective/references/error-patterns.md +242 -0
  82. package/.codex/skills/code-patterns/SKILL.md +120 -282
  83. package/.codex/skills/code-patterns/references/leniu-code-patterns.md +87 -0
  84. package/.codex/skills/crud-development/SKILL.md +64 -292
  85. package/.codex/skills/data-permission/SKILL.md +108 -407
  86. package/.codex/skills/data-permission/references/custom-data-scope.md +90 -0
  87. package/.codex/skills/database-ops/SKILL.md +8 -154
  88. package/.codex/skills/error-handler/SKILL.md +10 -0
  89. package/.codex/skills/file-oss-management/SKILL.md +106 -714
  90. package/.codex/skills/file-oss-management/references/entities.md +105 -0
  91. package/.codex/skills/file-oss-management/references/service-impl.md +104 -0
  92. package/.codex/skills/git-workflow/SKILL.md +27 -5
  93. package/.codex/skills/leniu-api-development/SKILL.md +142 -626
  94. package/.codex/skills/leniu-api-development/references/real-examples.md +273 -0
  95. package/.codex/skills/leniu-architecture-design/SKILL.md +176 -391
  96. package/.codex/skills/leniu-backend-annotations/SKILL.md +132 -519
  97. package/.codex/skills/leniu-brainstorm/SKILL.md +132 -541
  98. package/.codex/skills/leniu-brainstorm/references/business-scenarios.md +162 -0
  99. package/.codex/skills/leniu-crud-development/SKILL.md +232 -938
  100. package/.codex/skills/leniu-crud-development/references/templates.md +597 -0
  101. package/.codex/skills/leniu-customization-location/SKILL.md +410 -0
  102. package/.codex/skills/leniu-data-permission/SKILL.md +70 -0
  103. package/.codex/skills/leniu-java-code-style/SKILL.md +510 -0
  104. package/.codex/skills/leniu-java-entity/SKILL.md +76 -590
  105. package/.codex/skills/leniu-java-entity/references/templates.md +237 -0
  106. package/.codex/skills/leniu-java-export/SKILL.md +94 -379
  107. package/.codex/skills/leniu-java-logging/SKILL.md +106 -709
  108. package/.codex/skills/leniu-java-logging/references/data-mask.md +46 -0
  109. package/.codex/skills/leniu-java-logging/references/logging-scenarios.md +113 -0
  110. package/.codex/skills/leniu-java-mybatis/SKILL.md +73 -446
  111. package/.codex/skills/leniu-java-mybatis/references/report-mapper.md +88 -0
  112. package/.codex/skills/leniu-report-customization/SKILL.md +111 -365
  113. package/.codex/skills/leniu-report-customization/references/table-fields.md +93 -0
  114. package/.codex/skills/leniu-report-standard-customization/SKILL.md +111 -334
  115. package/.codex/skills/leniu-report-standard-customization/references/analysis-module.md +64 -0
  116. package/.codex/skills/leniu-report-standard-customization/references/table-fields.md +113 -0
  117. package/.codex/skills/leniu-security-guard/SKILL.md +133 -347
  118. package/.codex/skills/mysql-debug/SKILL.md +364 -0
  119. package/.codex/skills/openspec-apply-change/SKILL.md +10 -1
  120. package/.codex/skills/openspec-archive-change/SKILL.md +9 -1
  121. package/.codex/skills/openspec-bulk-archive-change/SKILL.md +9 -1
  122. package/.codex/skills/openspec-continue-change/SKILL.md +9 -1
  123. package/.codex/skills/openspec-explore/SKILL.md +10 -1
  124. package/.codex/skills/openspec-ff-change/SKILL.md +9 -1
  125. package/.codex/skills/openspec-new-change/SKILL.md +9 -1
  126. package/.codex/skills/openspec-onboard/SKILL.md +15 -130
  127. package/.codex/skills/openspec-sync-specs/SKILL.md +9 -1
  128. package/.codex/skills/openspec-verify-change/SKILL.md +9 -1
  129. package/.codex/skills/performance-doctor/SKILL.md +110 -434
  130. package/.codex/skills/project-navigator/SKILL.md +20 -1
  131. package/.codex/skills/redis-cache/SKILL.md +93 -589
  132. package/.codex/skills/redis-cache/references/listeners.md +23 -0
  133. package/.codex/skills/scheduled-jobs/SKILL.md +88 -407
  134. package/.codex/skills/security-guard/SKILL.md +141 -527
  135. package/.codex/skills/security-guard/references/encrypt-config.md +103 -0
  136. package/.codex/skills/security-guard/references/sensitive-strategies.md +42 -0
  137. package/.codex/skills/sms-mail/SKILL.md +116 -574
  138. package/.codex/skills/sms-mail/references/mail-config.md +88 -0
  139. package/.codex/skills/sms-mail/references/sms-config.md +74 -0
  140. package/.codex/skills/social-login/SKILL.md +112 -514
  141. package/.codex/skills/social-login/references/provider-configs.md +118 -0
  142. package/.codex/skills/store-pc/SKILL.md +258 -383
  143. package/.codex/skills/tenant-management/SKILL.md +129 -444
  144. package/.codex/skills/tenant-management/references/tenant-scenarios.md +91 -0
  145. package/.codex/skills/test-development/SKILL.md +86 -540
  146. package/.codex/skills/test-development/references/parameterized-examples.md +119 -0
  147. package/.codex/skills/ui-pc/SKILL.md +350 -387
  148. package/.codex/skills/utils-toolkit/SKILL.md +52 -283
  149. package/.codex/skills/utils-toolkit/references/redis-utils-api.md +56 -0
  150. package/.codex/skills/websocket-sse/SKILL.md +105 -550
  151. package/.codex/skills/workflow-engine/SKILL.md +147 -502
  152. package/.cursor/hooks/cursor-skill-eval.js +53 -1
  153. package/.cursor/hooks.json +3 -3
  154. package/.cursor/skills/add-skill/SKILL.md +79 -32
  155. package/.cursor/skills/api-development/SKILL.md +83 -377
  156. package/.cursor/skills/architecture-design/SKILL.md +138 -632
  157. package/.cursor/skills/backend-annotations/SKILL.md +134 -506
  158. package/.cursor/skills/banana-image/SKILL.md +10 -3
  159. package/.cursor/skills/brainstorm/SKILL.md +103 -535
  160. package/.cursor/skills/bug-detective/SKILL.md +147 -1097
  161. package/.cursor/skills/bug-detective/references/error-patterns.md +242 -0
  162. package/.cursor/skills/code-patterns/SKILL.md +116 -426
  163. package/.cursor/skills/code-patterns/references/leniu-code-patterns.md +87 -0
  164. package/.cursor/skills/crud-development/SKILL.md +64 -304
  165. package/.cursor/skills/data-permission/SKILL.md +105 -412
  166. package/.cursor/skills/data-permission/references/custom-data-scope.md +90 -0
  167. package/.cursor/skills/file-oss-management/SKILL.md +106 -714
  168. package/.cursor/skills/file-oss-management/references/entities.md +105 -0
  169. package/.cursor/skills/file-oss-management/references/service-impl.md +104 -0
  170. package/.cursor/skills/git-workflow/SKILL.md +27 -5
  171. package/.cursor/skills/leniu-api-development/SKILL.md +142 -626
  172. package/.cursor/skills/leniu-api-development/references/real-examples.md +273 -0
  173. package/.cursor/skills/leniu-architecture-design/SKILL.md +176 -391
  174. package/.cursor/skills/leniu-backend-annotations/SKILL.md +132 -519
  175. package/.cursor/skills/leniu-brainstorm/SKILL.md +132 -541
  176. package/.cursor/skills/leniu-brainstorm/references/business-scenarios.md +162 -0
  177. package/.cursor/skills/leniu-crud-development/SKILL.md +232 -938
  178. package/.cursor/skills/leniu-crud-development/references/templates.md +597 -0
  179. package/.cursor/skills/leniu-customization-location/SKILL.md +410 -0
  180. package/.cursor/skills/leniu-data-permission/SKILL.md +70 -0
  181. package/.cursor/skills/leniu-java-code-style/SKILL.md +510 -0
  182. package/.cursor/skills/leniu-java-entity/SKILL.md +76 -590
  183. package/.cursor/skills/leniu-java-entity/references/templates.md +237 -0
  184. package/.cursor/skills/leniu-java-export/SKILL.md +94 -379
  185. package/.cursor/skills/leniu-java-logging/SKILL.md +106 -709
  186. package/.cursor/skills/leniu-java-logging/references/data-mask.md +46 -0
  187. package/.cursor/skills/leniu-java-logging/references/logging-scenarios.md +113 -0
  188. package/.cursor/skills/leniu-java-mybatis/SKILL.md +73 -446
  189. package/.cursor/skills/leniu-java-mybatis/references/report-mapper.md +88 -0
  190. package/.cursor/skills/leniu-report-customization/SKILL.md +111 -365
  191. package/.cursor/skills/leniu-report-customization/references/table-fields.md +93 -0
  192. package/.cursor/skills/leniu-report-standard-customization/SKILL.md +111 -334
  193. package/.cursor/skills/leniu-report-standard-customization/references/analysis-module.md +64 -0
  194. package/.cursor/skills/leniu-report-standard-customization/references/table-fields.md +113 -0
  195. package/.cursor/skills/leniu-security-guard/SKILL.md +133 -347
  196. package/.cursor/skills/mysql-debug/SKILL.md +364 -0
  197. package/.cursor/skills/openspec-apply-change/SKILL.md +10 -1
  198. package/.cursor/skills/openspec-archive-change/SKILL.md +9 -1
  199. package/.cursor/skills/openspec-bulk-archive-change/SKILL.md +9 -1
  200. package/.cursor/skills/openspec-continue-change/SKILL.md +9 -1
  201. package/.cursor/skills/openspec-explore/SKILL.md +10 -1
  202. package/.cursor/skills/openspec-ff-change/SKILL.md +9 -1
  203. package/.cursor/skills/openspec-new-change/SKILL.md +9 -1
  204. package/.cursor/skills/openspec-onboard/SKILL.md +15 -130
  205. package/.cursor/skills/openspec-sync-specs/SKILL.md +9 -1
  206. package/.cursor/skills/openspec-verify-change/SKILL.md +9 -1
  207. package/.cursor/skills/performance-doctor/SKILL.md +110 -434
  208. package/.cursor/skills/redis-cache/SKILL.md +89 -595
  209. package/.cursor/skills/redis-cache/references/listeners.md +23 -0
  210. package/.cursor/skills/scheduled-jobs/SKILL.md +88 -407
  211. package/.cursor/skills/security-guard/SKILL.md +137 -532
  212. package/.cursor/skills/security-guard/references/encrypt-config.md +103 -0
  213. package/.cursor/skills/security-guard/references/sensitive-strategies.md +42 -0
  214. package/.cursor/skills/sms-mail/SKILL.md +116 -574
  215. package/.cursor/skills/sms-mail/references/mail-config.md +88 -0
  216. package/.cursor/skills/sms-mail/references/sms-config.md +74 -0
  217. package/.cursor/skills/social-login/SKILL.md +112 -514
  218. package/.cursor/skills/social-login/references/provider-configs.md +118 -0
  219. package/.cursor/skills/tenant-management/SKILL.md +129 -444
  220. package/.cursor/skills/tenant-management/references/tenant-scenarios.md +91 -0
  221. package/.cursor/skills/test-development/SKILL.md +86 -540
  222. package/.cursor/skills/test-development/references/parameterized-examples.md +119 -0
  223. package/.cursor/skills/utils-toolkit/SKILL.md +52 -305
  224. package/.cursor/skills/utils-toolkit/references/redis-utils-api.md +56 -0
  225. package/.cursor/skills/websocket-sse/SKILL.md +105 -550
  226. package/.cursor/skills/workflow-engine/SKILL.md +147 -502
  227. package/package.json +1 -1
@@ -1,118 +1,71 @@
1
1
  ---
2
2
  name: store-pc
3
3
  description: |
4
- PC 端(plus-ui)状态管理与 Hooks 指南。包含 Pinia Store、Hooks 组合式函数的创建和使用规范。
4
+ 前端状态管理指南。包含 Vuex Store 的创建和使用规范。
5
5
 
6
6
  触发场景:
7
- - PC 后台创建/使用 Store
8
- - Pinia 状态管理
9
- - 跨组件数据共享(PC端)
10
- - 持久化存储(useStorage)
11
- - 权限判断
12
- - 字典数据管理
7
+ - 创建/使用 Vuex Store
8
+ - Vuex 状态管理
9
+ - 跨组件数据共享
10
+ - 全局状态管理
13
11
 
14
- 触发词:PC StorePiniadefineStoreuseUserStoreuseDictStorePC状态管理、useStorage、持久化、状态管理
12
+ 触发词:VuexstoremapStatemapActionscommitdispatch、状态管理
15
13
 
16
- 适用目录:plus-ui/**
14
+ 适用目录:/Users/xujiajun/Developer/frontProj/web/src/store/**
17
15
  ---
18
16
 
19
- # PC 端状态管理指南
17
+ # 前端状态管理指南
20
18
 
21
- > **适用于**: `plus-ui/` 目录下的 PC 后台管理系统
19
+ > **适用于**: 腾云智慧食堂管理系统前端项目(Vue 2.7.16 + Vuex 3.4.0)
20
+ >
21
+ > **Store 目录**: `/Users/xujiajun/Developer/frontProj/web/src/store/`
22
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
23
+ ---
45
24
 
46
- // @vueuse/core
47
- useStorage, useLocalStorage, useSessionStorage, useMouse, useWindowSize
48
- // ... 以及其他 @vueuse/core 导出的函数
25
+ ## 目录结构
49
26
 
50
- // Element Plus
51
- ElMessage, ElMessageBox, ElNotification, ElLoading
52
- // ... 以及其他 Element Plus 组件和函数
53
27
  ```
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'
28
+ src/store/
29
+ ├── index.js # Store 入口(Vuex 初始化)
30
+ ├── getters.js # 全局 getters
31
+ └── modules/ # Store 模块(28个)
32
+ ├── user.js # 用户状态(最核心)
33
+ ├── app.js # 应用状态(语言/尺寸)
34
+ ├── permission.js # 权限路由管理
35
+ ├── tagsView.js # 标签页管理
36
+ ├── settings.js # 系统设置
37
+ ├── marketing.js # 营销状态
38
+ ├── order.js # 订单状态
39
+ ├── stock.js # 库存状态
40
+ ├── reportcenter.js # 报表状态
41
+ ├── account.js # 账户状态
42
+ ├── purchase.js # 采购状态
43
+ ├── chart.js # 图表状态
44
+ ├── notice.js # 通知状态
45
+ ├── upload.js # 上传状态
46
+ ├── menudish.js # 菜品状态
47
+ ├── supplyChain.js # 供应链状态
48
+ └── ... # 其他业务模块
72
49
  ```
73
50
 
74
51
  ---
75
52
 
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()
53
+ ## 全局 Getters(getters.js)
54
+
55
+ ```javascript
56
+ // 常用全局 getters(可直接用 mapGetters 访问)
57
+ {
58
+ token, // 登录 token
59
+ name, // 用户名
60
+ userInfo, // 完整用户信息对象
61
+ permissions, // 权限列表
62
+ hasRoles, // 是否已加载角色(用于路由守卫)
63
+ permission_routes, // 已生成的权限路由
64
+ adminMerchant, // 是否为超级管理员商户
65
+ url, // API base URL
66
+ language, // 当前语言(zh/en)
67
+ size, // Element UI 组件尺寸
68
+ areaOptions, // 区域选项(来自 supplyChain)
116
69
  }
117
70
  ```
118
71
 
@@ -122,261 +75,199 @@ const handleClose = () => {
122
75
 
123
76
  ### 标准模板
124
77
 
125
- ```typescript
126
- // store/modules/xxx.ts
127
- // defineStore、ref、computed 已自动导入,无需手动 import
78
+ ```javascript
79
+ // src/store/modules/xxx.js
80
+ import { getList, getDetail } from '@/api/xxx'
128
81
 
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)
82
+ const state = {
83
+ list: [],
84
+ current: null,
85
+ loading: false,
86
+ total: 0
87
+ }
139
88
 
140
- // ========== 方法 ==========
89
+ const mutations = {
90
+ SET_LIST: (state, list) => {
91
+ state.list = list
92
+ },
93
+ SET_CURRENT: (state, current) => {
94
+ state.current = current
95
+ },
96
+ SET_LOADING: (state, loading) => {
97
+ state.loading = loading
98
+ },
99
+ SET_TOTAL: (state, total) => {
100
+ state.total = total
101
+ }
102
+ }
141
103
 
104
+ const actions = {
142
105
  /**
143
106
  * 获取列表
144
107
  */
145
- const fetchList = async (params?: XxxQuery) => {
146
- loading.value = true
108
+ async fetchList({ commit }, params) {
109
+ commit('SET_LOADING', true)
147
110
  try {
148
- const res = await pageXxxs(params)
149
- list.value = res.data.records
150
- } catch (error) {
151
- console.error('获取列表失败:', error)
111
+ const res = await getList({
112
+ page: { current: params.current || 1, size: params.size || 20 },
113
+ object: params
114
+ })
115
+ commit('SET_LIST', res.records || [])
116
+ commit('SET_TOTAL', res.total || 0)
117
+ return res
152
118
  } finally {
153
- loading.value = false
119
+ commit('SET_LOADING', false)
154
120
  }
155
- }
121
+ },
156
122
 
157
123
  /**
158
- * 设置当前选中项
124
+ * 获取详情
159
125
  */
160
- const setCurrent = (item: XxxVo | null) => {
161
- current.value = item
162
- }
126
+ async fetchDetail({ commit }, id) {
127
+ const res = await getDetail({ id })
128
+ commit('SET_CURRENT', res)
129
+ return res
130
+ },
163
131
 
164
132
  /**
165
133
  * 重置状态
166
134
  */
167
- const reset = () => {
168
- list.value = []
169
- current.value = null
170
- loading.value = false
135
+ reset({ commit }) {
136
+ commit('SET_LIST', [])
137
+ commit('SET_CURRENT', null)
138
+ commit('SET_TOTAL', 0)
171
139
  }
140
+ }
172
141
 
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
142
+ const getters = {
143
+ list: state => state.list,
144
+ current: state => state.current,
145
+ loading: state => state.loading,
146
+ total: state => state.total
147
+ }
224
148
 
225
- // 错误:直接解构状态会丢失响应式
226
- // const { list, loading } = xxxStore
149
+ export default {
150
+ namespaced: true,
151
+ state,
152
+ mutations,
153
+ actions,
154
+ getters
155
+ }
227
156
  ```
228
157
 
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>
158
+ ### 在 index.js 中注册
240
159
 
241
- <script setup lang="ts">
242
- import { useXxxStore } from '@/store/modules/xxx'
160
+ ```javascript
161
+ // src/store/index.js
162
+ import xxx from './modules/xxx'
243
163
 
244
- const xxxStore = useXxxStore()
245
-
246
- onMounted(() => {
247
- xxxStore.fetchList()
164
+ export default new Vuex.Store({
165
+ modules: {
166
+ // ... 其他模块
167
+ xxx
168
+ }
248
169
  })
249
- </script>
250
170
  ```
251
171
 
252
172
  ---
253
173
 
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)
174
+ ## 使用 Store
267
175
 
268
- // 基于 localStorage(显式指定)
269
- const data = useLocalStorage('key', defaultValue)
176
+ ### 方式 1:直接访问
177
+
178
+ ```javascript
179
+ export default {
180
+ computed: {
181
+ list() {
182
+ return this.$store.state.xxx.list
183
+ },
184
+ loading() {
185
+ return this.$store.state.xxx.loading
186
+ },
187
+ // 使用全局 getter
188
+ token() {
189
+ return this.$store.getters.token
190
+ },
191
+ userInfo() {
192
+ return this.$store.getters.userInfo
193
+ }
194
+ },
195
+ methods: {
196
+ getData() {
197
+ this.$store.dispatch('xxx/fetchList', this.queryParams)
198
+ }
199
+ }
200
+ }
270
201
  ```
271
202
 
272
- ### useStorage API
273
-
274
- ```typescript
275
- // 设置值(自动保存到 localStorage)
276
- const token = useStorage('token', '')
277
- token.value = 'new-token' // 自动保存
203
+ ### 方式 2:mapState / mapGetters / mapActions
278
204
 
279
- // 获取值
280
- console.log(token.value)
205
+ ```javascript
206
+ import { mapState, mapGetters, mapActions, mapMutations } from 'vuex'
281
207
 
282
- // 删除值
283
- token.value = null
208
+ export default {
209
+ computed: {
210
+ // 模块内 state
211
+ ...mapState('xxx', ['list', 'loading', 'total']),
284
212
 
285
- // 带类型的存储
286
- const user = useStorage<UserInfo>('user', null)
287
- user.value = { name: 'admin', age: 18 }
288
- ```
213
+ // 全局 getters
214
+ ...mapGetters(['token', 'userInfo', 'permissions', 'adminMerchant'])
215
+ },
216
+ methods: {
217
+ ...mapActions('xxx', ['fetchList', 'fetchDetail', 'reset']),
289
218
 
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
219
+ async getData() {
220
+ await this.fetchList({ ...this.queryParams, ...this.page })
221
+ }
222
+ },
223
+ mounted() {
224
+ this.getData()
322
225
  }
323
- })
226
+ }
324
227
  ```
325
228
 
326
- ### Token 管理示例
229
+ ---
327
230
 
328
- ```typescript
329
- // utils/auth.ts 示例
330
- import { useStorage } from '@vueuse/core'
231
+ ## 核心 Store 模块说明
331
232
 
332
- const TokenKey = 'Admin-Token'
333
- const tokenStorage = useStorage<null | string>(TokenKey, null)
233
+ ### user.js(用户状态)
334
234
 
335
- export const getToken = () => tokenStorage.value
235
+ 最重要的模块,包含:
236
+ - `state.token` - 登录 token
237
+ - `state.userInfo` - 完整用户信息(userId、roles、roleCode、merchantId 等)
238
+ - `state.hasRoles` - 是否已加载角色信息
239
+ - `state.adminMerchant` - 是否为超级管理员(`roleCode === 'ROLE_ADMIN'`)
240
+ - `state.merchantList` - 商户列表(管理员可切换商户)
336
241
 
337
- export const setToken = (access_token: string) => (tokenStorage.value = access_token)
242
+ ```javascript
243
+ // 在路由守卫中获取用户信息
244
+ const userInfo = await store.dispatch('user/getInfo')
338
245
 
339
- export const removeToken = () => (tokenStorage.value = null)
246
+ // 登出
247
+ await store.dispatch('user/resetToken')
248
+ localStorage.clear()
249
+ locationHref()
340
250
  ```
341
251
 
342
- ### 在 useUserStore 中使用
252
+ ### permission.js(权限路由)
343
253
 
344
- ```typescript
345
- // store/modules/user.ts 示例
346
- import { defineStore } from 'pinia'
347
- import { getToken, setToken, removeToken } from '@/utils/auth'
254
+ - 根据用户角色动态生成路由
255
+ - `state.routes` - 完整路由表(用于菜单渲染)
256
+ - `state.addRoutes` - 动态添加的路由
348
257
 
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
- }
258
+ ```javascript
259
+ // 在路由守卫中生成权限路由
260
+ const accessRoutes = await store.dispatch('permission/generateRoutes')
261
+ accessRoutes.forEach(route => {
262
+ router.addRoute(route)
377
263
  })
378
264
  ```
379
265
 
266
+ ### app.js(应用状态)
267
+
268
+ - `state.language` - 当前语言(zh/en)
269
+ - `state.size` - Element UI 组件尺寸
270
+
380
271
  ---
381
272
 
382
273
  ## 最佳实践
@@ -386,106 +277,90 @@ export const useUserStore = defineStore('user', () => {
386
277
  | 场景 | 是否使用 Store |
387
278
  |------|---------------|
388
279
  | 多个页面/组件共享的数据 | ✅ 使用 |
389
- | 用户登录状态、权限 | ✅ 使用 |
390
- | 全局配置、主题设置 | ✅ 使用 |
391
- | 字典数据缓存 | 使用 |
392
- | 页面内部状态 | ❌ 用 ref/reactive |
393
- | 组件内部状态 | ❌ 用 ref/reactive |
280
+ | 用户登录状态、权限 | ✅ 使用(user 模块) |
281
+ | 全局配置(语言、尺寸) | ✅ 使用(app 模块) |
282
+ | 页面内部状态(表单数据)| data |
394
283
  | 父子组件传值 | ❌ 用 props/emit |
395
- | 兄弟组件通信(简单) | ❌ 用 provide/inject |
396
-
397
- ### 2. Store 命名规范
284
+ | 兄弟组件通信(简单) | ❌ 用 eventBus |
398
285
 
399
- ```typescript
400
- // ✅ 正确:use + 业务名 + Store
401
- export const useUserStore = defineStore('user', ...)
402
- export const useCartStore = defineStore('cart', ...)
403
- export const useDictStore = defineStore('dict', ...)
286
+ ### 2. 命名规范
404
287
 
405
- // ❌ 错误:不规范的命名
406
- export const userStore = defineStore('user', ...)
407
- export const useUser = defineStore('user', ...)
408
- ```
409
-
410
- ### 3. 避免循环依赖
288
+ ```javascript
289
+ // 正确:Mutation 大写字母+下划线
290
+ const mutations = {
291
+ SET_LIST: (state, list) => { state.list = list },
292
+ SET_LOADING: (state, v) => { state.loading = v }
293
+ }
411
294
 
412
- ```typescript
413
- // 避免 Store 之间循环引用
414
- // userStore.ts
415
- import { useOrderStore } from './order' // orderStore 又引用 userStore
295
+ // ✅ 正确:Action 小驼峰
296
+ const actions = {
297
+ fetchList: async ({ commit }, params) => { },
298
+ fetchDetail: async ({ commit }, id) => { }
299
+ }
416
300
 
417
- // ✅ 正确做法:在组件层协调,或使用事件
301
+ // ✅ 正确:模块文件名小写,匹配业务名
302
+ // store/modules/marketing.js
303
+ // store/modules/order.js
418
304
  ```
419
305
 
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()
306
+ ### 3. 登出时重置 Store
434
307
 
435
- // 重置其他 Store
436
- dictStore.cleanDict()
437
-
438
- // 跳转登录页
439
- router.push('/login')
308
+ ```javascript
309
+ // 在 user store 中
310
+ const actions = {
311
+ async resetToken({ commit }) {
312
+ commit('SET_TOKEN', '')
313
+ commit('SET_HAS_ROLES', false)
314
+ removeToken()
315
+ removeTenant()
316
+ }
440
317
  }
318
+
319
+ // 登出时(permission.js 路由守卫中)
320
+ await store.dispatch('user/resetToken')
321
+ localStorage.clear()
322
+ locationHref() // 使用全局 locationHref 跳转(不用 router.push)
441
323
  ```
442
324
 
443
- ### 5. 使用 Setup Syntax
325
+ ### 4. 分页数据格式
444
326
 
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
- })
327
+ ```javascript
328
+ // 后端返回的分页数据格式
329
+ {
330
+ records: [], // 数据列表(非 rows)
331
+ total: 100,
332
+ current: 1,
333
+ size: 20
334
+ }
452
335
 
453
- // ❌ 不推荐:使用 Options API
454
- export const useXxxStore = defineStore('xxx', {
455
- state: () => ({ count: 0 }),
456
- actions: {
457
- increment() { this.count++ }
458
- }
459
- })
336
+ // 请求分页参数格式
337
+ {
338
+ page: { current: 1, size: 20 },
339
+ object: { ...queryParams } // 查询条件
340
+ }
460
341
  ```
461
342
 
462
343
  ---
463
344
 
464
345
  ## 参考文件
465
346
 
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`
347
+ | Store | 路径 |
348
+ |-------|------|
349
+ | Store 入口 | `/Users/xujiajun/Developer/frontProj/web/src/store/index.js` |
350
+ | 全局 Getters | `/Users/xujiajun/Developer/frontProj/web/src/store/getters.js` |
351
+ | 用户 Store | `/Users/xujiajun/Developer/frontProj/web/src/store/modules/user.js` |
352
+ | 权限 Store | `/Users/xujiajun/Developer/frontProj/web/src/store/modules/permission.js` |
353
+ | 应用 Store | `/Users/xujiajun/Developer/frontProj/web/src/store/modules/app.js` |
354
+ | 设置 Store | `/Users/xujiajun/Developer/frontProj/web/src/store/modules/settings.js` |
355
+ | 标签页 Store | `/Users/xujiajun/Developer/frontProj/web/src/store/modules/tagsView.js` |
476
356
 
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
357
  ---
491
358
 
359
+ ## 注意事项
360
+
361
+ 1. **本项目使用 Vuex 3.x**(非 Pinia),与 Vue 2 配套
362
+ 2. **Store 模块必须设置 `namespaced: true`**
363
+ 3. **异步操作放在 Actions 中**,同步操作放在 Mutations 中
364
+ 4. **分页数据用 `records`**,不是 `rows`(与 RuoYi 后端框架不同)
365
+ 5. **登出使用 `locationHref()`** 而非 `router.push('/login')`,目的是清除内存中的数据
366
+ 6. **`adminMerchant` 为 true 时**,用户是超级管理员(`roleCode === 'ROLE_ADMIN'`),可切换商户