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.
- package/.claude/hooks/skill-forced-eval.js +2 -0
- package/.claude/settings.json +3 -3
- package/.claude/skills/add-skill/SKILL.md +79 -32
- package/.claude/skills/api-development/SKILL.md +83 -377
- package/.claude/skills/architecture-design/SKILL.md +138 -632
- package/.claude/skills/backend-annotations/SKILL.md +134 -506
- package/.claude/skills/banana-image/SKILL.md +10 -3
- package/.claude/skills/brainstorm/SKILL.md +103 -535
- package/.claude/skills/bug-detective/SKILL.md +147 -1097
- package/.claude/skills/bug-detective/references/error-patterns.md +242 -0
- package/.claude/skills/code-patterns/SKILL.md +116 -426
- package/.claude/skills/code-patterns/references/leniu-code-patterns.md +87 -0
- package/.claude/skills/crud-development/SKILL.md +64 -304
- package/.claude/skills/data-permission/SKILL.md +105 -412
- package/.claude/skills/data-permission/references/custom-data-scope.md +90 -0
- package/.claude/skills/file-oss-management/SKILL.md +106 -714
- package/.claude/skills/file-oss-management/references/entities.md +105 -0
- package/.claude/skills/file-oss-management/references/service-impl.md +104 -0
- package/.claude/skills/leniu-api-development/SKILL.md +142 -626
- package/.claude/skills/leniu-api-development/references/real-examples.md +273 -0
- package/.claude/skills/leniu-architecture-design/SKILL.md +176 -391
- package/.claude/skills/leniu-backend-annotations/SKILL.md +132 -519
- package/.claude/skills/leniu-brainstorm/SKILL.md +132 -541
- package/.claude/skills/leniu-brainstorm/references/business-scenarios.md +162 -0
- package/.claude/skills/leniu-crud-development/SKILL.md +232 -938
- package/.claude/skills/leniu-crud-development/references/templates.md +597 -0
- package/.claude/skills/leniu-customization-location/SKILL.md +410 -0
- package/.claude/skills/leniu-data-permission/SKILL.md +70 -0
- package/.claude/skills/leniu-java-entity/SKILL.md +76 -590
- package/.claude/skills/leniu-java-entity/references/templates.md +237 -0
- package/.claude/skills/leniu-java-export/SKILL.md +94 -379
- package/.claude/skills/leniu-java-logging/SKILL.md +106 -709
- package/.claude/skills/leniu-java-logging/references/data-mask.md +46 -0
- package/.claude/skills/leniu-java-logging/references/logging-scenarios.md +113 -0
- package/.claude/skills/leniu-java-mybatis/SKILL.md +73 -446
- package/.claude/skills/leniu-java-mybatis/references/report-mapper.md +88 -0
- package/.claude/skills/leniu-report-customization/SKILL.md +111 -365
- package/.claude/skills/leniu-report-customization/references/table-fields.md +93 -0
- package/.claude/skills/leniu-report-standard-customization/SKILL.md +111 -334
- package/.claude/skills/leniu-report-standard-customization/references/analysis-module.md +64 -0
- package/.claude/skills/leniu-report-standard-customization/references/table-fields.md +113 -0
- package/.claude/skills/leniu-security-guard/SKILL.md +133 -347
- package/.claude/skills/mysql-debug/SKILL.md +364 -0
- package/.claude/skills/openspec-apply-change/SKILL.md +10 -1
- package/.claude/skills/openspec-archive-change/SKILL.md +9 -1
- package/.claude/skills/openspec-bulk-archive-change/SKILL.md +9 -1
- package/.claude/skills/openspec-continue-change/SKILL.md +9 -1
- package/.claude/skills/openspec-explore/SKILL.md +10 -1
- package/.claude/skills/openspec-ff-change/SKILL.md +9 -1
- package/.claude/skills/openspec-new-change/SKILL.md +9 -1
- package/.claude/skills/openspec-onboard/SKILL.md +15 -130
- package/.claude/skills/openspec-sync-specs/SKILL.md +9 -1
- package/.claude/skills/openspec-verify-change/SKILL.md +9 -1
- package/.claude/skills/performance-doctor/SKILL.md +110 -434
- package/.claude/skills/redis-cache/SKILL.md +89 -595
- package/.claude/skills/redis-cache/references/listeners.md +23 -0
- package/.claude/skills/scheduled-jobs/SKILL.md +88 -407
- package/.claude/skills/security-guard/SKILL.md +137 -532
- package/.claude/skills/security-guard/references/encrypt-config.md +103 -0
- package/.claude/skills/security-guard/references/sensitive-strategies.md +42 -0
- package/.claude/skills/sms-mail/SKILL.md +116 -574
- package/.claude/skills/sms-mail/references/mail-config.md +88 -0
- package/.claude/skills/sms-mail/references/sms-config.md +74 -0
- package/.claude/skills/social-login/SKILL.md +112 -514
- package/.claude/skills/social-login/references/provider-configs.md +118 -0
- package/.claude/skills/tenant-management/SKILL.md +129 -444
- package/.claude/skills/tenant-management/references/tenant-scenarios.md +91 -0
- package/.claude/skills/test-development/SKILL.md +86 -540
- package/.claude/skills/test-development/references/parameterized-examples.md +119 -0
- package/.claude/skills/utils-toolkit/SKILL.md +52 -305
- package/.claude/skills/utils-toolkit/references/redis-utils-api.md +56 -0
- package/.claude/skills/websocket-sse/SKILL.md +105 -550
- package/.claude/skills/workflow-engine/SKILL.md +147 -502
- package/.codex/skills/add-skill/SKILL.md +79 -32
- package/.codex/skills/api-development/SKILL.md +172 -599
- package/.codex/skills/architecture-design/SKILL.md +138 -504
- package/.codex/skills/backend-annotations/SKILL.md +134 -496
- package/.codex/skills/banana-image/SKILL.md +10 -3
- package/.codex/skills/brainstorm/SKILL.md +103 -535
- package/.codex/skills/bug-detective/SKILL.md +147 -1097
- package/.codex/skills/bug-detective/references/error-patterns.md +242 -0
- package/.codex/skills/code-patterns/SKILL.md +120 -282
- package/.codex/skills/code-patterns/references/leniu-code-patterns.md +87 -0
- package/.codex/skills/crud-development/SKILL.md +64 -292
- package/.codex/skills/data-permission/SKILL.md +108 -407
- package/.codex/skills/data-permission/references/custom-data-scope.md +90 -0
- package/.codex/skills/database-ops/SKILL.md +8 -154
- package/.codex/skills/error-handler/SKILL.md +10 -0
- package/.codex/skills/file-oss-management/SKILL.md +106 -714
- package/.codex/skills/file-oss-management/references/entities.md +105 -0
- package/.codex/skills/file-oss-management/references/service-impl.md +104 -0
- package/.codex/skills/git-workflow/SKILL.md +27 -5
- package/.codex/skills/leniu-api-development/SKILL.md +142 -626
- package/.codex/skills/leniu-api-development/references/real-examples.md +273 -0
- package/.codex/skills/leniu-architecture-design/SKILL.md +176 -391
- package/.codex/skills/leniu-backend-annotations/SKILL.md +132 -519
- package/.codex/skills/leniu-brainstorm/SKILL.md +132 -541
- package/.codex/skills/leniu-brainstorm/references/business-scenarios.md +162 -0
- package/.codex/skills/leniu-crud-development/SKILL.md +232 -938
- package/.codex/skills/leniu-crud-development/references/templates.md +597 -0
- package/.codex/skills/leniu-customization-location/SKILL.md +410 -0
- package/.codex/skills/leniu-data-permission/SKILL.md +70 -0
- package/.codex/skills/leniu-java-code-style/SKILL.md +510 -0
- package/.codex/skills/leniu-java-entity/SKILL.md +76 -590
- package/.codex/skills/leniu-java-entity/references/templates.md +237 -0
- package/.codex/skills/leniu-java-export/SKILL.md +94 -379
- package/.codex/skills/leniu-java-logging/SKILL.md +106 -709
- package/.codex/skills/leniu-java-logging/references/data-mask.md +46 -0
- package/.codex/skills/leniu-java-logging/references/logging-scenarios.md +113 -0
- package/.codex/skills/leniu-java-mybatis/SKILL.md +73 -446
- package/.codex/skills/leniu-java-mybatis/references/report-mapper.md +88 -0
- package/.codex/skills/leniu-report-customization/SKILL.md +111 -365
- package/.codex/skills/leniu-report-customization/references/table-fields.md +93 -0
- package/.codex/skills/leniu-report-standard-customization/SKILL.md +111 -334
- package/.codex/skills/leniu-report-standard-customization/references/analysis-module.md +64 -0
- package/.codex/skills/leniu-report-standard-customization/references/table-fields.md +113 -0
- package/.codex/skills/leniu-security-guard/SKILL.md +133 -347
- package/.codex/skills/mysql-debug/SKILL.md +364 -0
- package/.codex/skills/openspec-apply-change/SKILL.md +10 -1
- package/.codex/skills/openspec-archive-change/SKILL.md +9 -1
- package/.codex/skills/openspec-bulk-archive-change/SKILL.md +9 -1
- package/.codex/skills/openspec-continue-change/SKILL.md +9 -1
- package/.codex/skills/openspec-explore/SKILL.md +10 -1
- package/.codex/skills/openspec-ff-change/SKILL.md +9 -1
- package/.codex/skills/openspec-new-change/SKILL.md +9 -1
- package/.codex/skills/openspec-onboard/SKILL.md +15 -130
- package/.codex/skills/openspec-sync-specs/SKILL.md +9 -1
- package/.codex/skills/openspec-verify-change/SKILL.md +9 -1
- package/.codex/skills/performance-doctor/SKILL.md +110 -434
- package/.codex/skills/project-navigator/SKILL.md +20 -1
- package/.codex/skills/redis-cache/SKILL.md +93 -589
- package/.codex/skills/redis-cache/references/listeners.md +23 -0
- package/.codex/skills/scheduled-jobs/SKILL.md +88 -407
- package/.codex/skills/security-guard/SKILL.md +141 -527
- package/.codex/skills/security-guard/references/encrypt-config.md +103 -0
- package/.codex/skills/security-guard/references/sensitive-strategies.md +42 -0
- package/.codex/skills/sms-mail/SKILL.md +116 -574
- package/.codex/skills/sms-mail/references/mail-config.md +88 -0
- package/.codex/skills/sms-mail/references/sms-config.md +74 -0
- package/.codex/skills/social-login/SKILL.md +112 -514
- package/.codex/skills/social-login/references/provider-configs.md +118 -0
- package/.codex/skills/store-pc/SKILL.md +258 -383
- package/.codex/skills/tenant-management/SKILL.md +129 -444
- package/.codex/skills/tenant-management/references/tenant-scenarios.md +91 -0
- package/.codex/skills/test-development/SKILL.md +86 -540
- package/.codex/skills/test-development/references/parameterized-examples.md +119 -0
- package/.codex/skills/ui-pc/SKILL.md +350 -387
- package/.codex/skills/utils-toolkit/SKILL.md +52 -283
- package/.codex/skills/utils-toolkit/references/redis-utils-api.md +56 -0
- package/.codex/skills/websocket-sse/SKILL.md +105 -550
- package/.codex/skills/workflow-engine/SKILL.md +147 -502
- package/.cursor/hooks/cursor-skill-eval.js +53 -1
- package/.cursor/hooks.json +3 -3
- package/.cursor/skills/add-skill/SKILL.md +79 -32
- package/.cursor/skills/api-development/SKILL.md +83 -377
- package/.cursor/skills/architecture-design/SKILL.md +138 -632
- package/.cursor/skills/backend-annotations/SKILL.md +134 -506
- package/.cursor/skills/banana-image/SKILL.md +10 -3
- package/.cursor/skills/brainstorm/SKILL.md +103 -535
- package/.cursor/skills/bug-detective/SKILL.md +147 -1097
- package/.cursor/skills/bug-detective/references/error-patterns.md +242 -0
- package/.cursor/skills/code-patterns/SKILL.md +116 -426
- package/.cursor/skills/code-patterns/references/leniu-code-patterns.md +87 -0
- package/.cursor/skills/crud-development/SKILL.md +64 -304
- package/.cursor/skills/data-permission/SKILL.md +105 -412
- package/.cursor/skills/data-permission/references/custom-data-scope.md +90 -0
- package/.cursor/skills/file-oss-management/SKILL.md +106 -714
- package/.cursor/skills/file-oss-management/references/entities.md +105 -0
- package/.cursor/skills/file-oss-management/references/service-impl.md +104 -0
- package/.cursor/skills/git-workflow/SKILL.md +27 -5
- package/.cursor/skills/leniu-api-development/SKILL.md +142 -626
- package/.cursor/skills/leniu-api-development/references/real-examples.md +273 -0
- package/.cursor/skills/leniu-architecture-design/SKILL.md +176 -391
- package/.cursor/skills/leniu-backend-annotations/SKILL.md +132 -519
- package/.cursor/skills/leniu-brainstorm/SKILL.md +132 -541
- package/.cursor/skills/leniu-brainstorm/references/business-scenarios.md +162 -0
- package/.cursor/skills/leniu-crud-development/SKILL.md +232 -938
- package/.cursor/skills/leniu-crud-development/references/templates.md +597 -0
- package/.cursor/skills/leniu-customization-location/SKILL.md +410 -0
- package/.cursor/skills/leniu-data-permission/SKILL.md +70 -0
- package/.cursor/skills/leniu-java-code-style/SKILL.md +510 -0
- package/.cursor/skills/leniu-java-entity/SKILL.md +76 -590
- package/.cursor/skills/leniu-java-entity/references/templates.md +237 -0
- package/.cursor/skills/leniu-java-export/SKILL.md +94 -379
- package/.cursor/skills/leniu-java-logging/SKILL.md +106 -709
- package/.cursor/skills/leniu-java-logging/references/data-mask.md +46 -0
- package/.cursor/skills/leniu-java-logging/references/logging-scenarios.md +113 -0
- package/.cursor/skills/leniu-java-mybatis/SKILL.md +73 -446
- package/.cursor/skills/leniu-java-mybatis/references/report-mapper.md +88 -0
- package/.cursor/skills/leniu-report-customization/SKILL.md +111 -365
- package/.cursor/skills/leniu-report-customization/references/table-fields.md +93 -0
- package/.cursor/skills/leniu-report-standard-customization/SKILL.md +111 -334
- package/.cursor/skills/leniu-report-standard-customization/references/analysis-module.md +64 -0
- package/.cursor/skills/leniu-report-standard-customization/references/table-fields.md +113 -0
- package/.cursor/skills/leniu-security-guard/SKILL.md +133 -347
- package/.cursor/skills/mysql-debug/SKILL.md +364 -0
- package/.cursor/skills/openspec-apply-change/SKILL.md +10 -1
- package/.cursor/skills/openspec-archive-change/SKILL.md +9 -1
- package/.cursor/skills/openspec-bulk-archive-change/SKILL.md +9 -1
- package/.cursor/skills/openspec-continue-change/SKILL.md +9 -1
- package/.cursor/skills/openspec-explore/SKILL.md +10 -1
- package/.cursor/skills/openspec-ff-change/SKILL.md +9 -1
- package/.cursor/skills/openspec-new-change/SKILL.md +9 -1
- package/.cursor/skills/openspec-onboard/SKILL.md +15 -130
- package/.cursor/skills/openspec-sync-specs/SKILL.md +9 -1
- package/.cursor/skills/openspec-verify-change/SKILL.md +9 -1
- package/.cursor/skills/performance-doctor/SKILL.md +110 -434
- package/.cursor/skills/redis-cache/SKILL.md +89 -595
- package/.cursor/skills/redis-cache/references/listeners.md +23 -0
- package/.cursor/skills/scheduled-jobs/SKILL.md +88 -407
- package/.cursor/skills/security-guard/SKILL.md +137 -532
- package/.cursor/skills/security-guard/references/encrypt-config.md +103 -0
- package/.cursor/skills/security-guard/references/sensitive-strategies.md +42 -0
- package/.cursor/skills/sms-mail/SKILL.md +116 -574
- package/.cursor/skills/sms-mail/references/mail-config.md +88 -0
- package/.cursor/skills/sms-mail/references/sms-config.md +74 -0
- package/.cursor/skills/social-login/SKILL.md +112 -514
- package/.cursor/skills/social-login/references/provider-configs.md +118 -0
- package/.cursor/skills/tenant-management/SKILL.md +129 -444
- package/.cursor/skills/tenant-management/references/tenant-scenarios.md +91 -0
- package/.cursor/skills/test-development/SKILL.md +86 -540
- package/.cursor/skills/test-development/references/parameterized-examples.md +119 -0
- package/.cursor/skills/utils-toolkit/SKILL.md +52 -305
- package/.cursor/skills/utils-toolkit/references/redis-utils-api.md +56 -0
- package/.cursor/skills/websocket-sse/SKILL.md +105 -550
- package/.cursor/skills/workflow-engine/SKILL.md +147 -502
- package/package.json +1 -1
|
@@ -1,118 +1,71 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: store-pc
|
|
3
3
|
description: |
|
|
4
|
-
|
|
4
|
+
前端状态管理指南。包含 Vuex Store 的创建和使用规范。
|
|
5
5
|
|
|
6
6
|
触发场景:
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
- 权限判断
|
|
12
|
-
- 字典数据管理
|
|
7
|
+
- 创建/使用 Vuex Store
|
|
8
|
+
- Vuex 状态管理
|
|
9
|
+
- 跨组件数据共享
|
|
10
|
+
- 全局状态管理
|
|
13
11
|
|
|
14
|
-
触发词:
|
|
12
|
+
触发词:Vuex、store、mapState、mapActions、commit、dispatch、状态管理
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
适用目录:/Users/xujiajun/Developer/frontProj/web/src/store/**
|
|
17
15
|
---
|
|
18
16
|
|
|
19
|
-
#
|
|
17
|
+
# 前端状态管理指南
|
|
20
18
|
|
|
21
|
-
> **适用于**:
|
|
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
|
-
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
##
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
```
|
|
126
|
-
// store/modules/xxx.
|
|
127
|
-
|
|
78
|
+
```javascript
|
|
79
|
+
// src/store/modules/xxx.js
|
|
80
|
+
import { getList, getDetail } from '@/api/xxx'
|
|
128
81
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
|
-
|
|
146
|
-
|
|
108
|
+
async fetchList({ commit }, params) {
|
|
109
|
+
commit('SET_LOADING', true)
|
|
147
110
|
try {
|
|
148
|
-
const res = await
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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
|
-
|
|
119
|
+
commit('SET_LOADING', false)
|
|
154
120
|
}
|
|
155
|
-
}
|
|
121
|
+
},
|
|
156
122
|
|
|
157
123
|
/**
|
|
158
|
-
*
|
|
124
|
+
* 获取详情
|
|
159
125
|
*/
|
|
160
|
-
|
|
161
|
-
|
|
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
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
135
|
+
reset({ commit }) {
|
|
136
|
+
commit('SET_LIST', [])
|
|
137
|
+
commit('SET_CURRENT', null)
|
|
138
|
+
commit('SET_TOTAL', 0)
|
|
171
139
|
}
|
|
140
|
+
}
|
|
172
141
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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
|
-
|
|
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
|
-
|
|
242
|
-
|
|
160
|
+
```javascript
|
|
161
|
+
// src/store/index.js
|
|
162
|
+
import xxx from './modules/xxx'
|
|
243
163
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
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
|
-
|
|
269
|
-
|
|
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
|
-
###
|
|
273
|
-
|
|
274
|
-
```typescript
|
|
275
|
-
// 设置值(自动保存到 localStorage)
|
|
276
|
-
const token = useStorage('token', '')
|
|
277
|
-
token.value = 'new-token' // 自动保存
|
|
203
|
+
### 方式 2:mapState / mapGetters / mapActions
|
|
278
204
|
|
|
279
|
-
|
|
280
|
-
|
|
205
|
+
```javascript
|
|
206
|
+
import { mapState, mapGetters, mapActions, mapMutations } from 'vuex'
|
|
281
207
|
|
|
282
|
-
|
|
283
|
-
|
|
208
|
+
export default {
|
|
209
|
+
computed: {
|
|
210
|
+
// 模块内 state
|
|
211
|
+
...mapState('xxx', ['list', 'loading', 'total']),
|
|
284
212
|
|
|
285
|
-
//
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
213
|
+
// 全局 getters
|
|
214
|
+
...mapGetters(['token', 'userInfo', 'permissions', 'adminMerchant'])
|
|
215
|
+
},
|
|
216
|
+
methods: {
|
|
217
|
+
...mapActions('xxx', ['fetchList', 'fetchDetail', 'reset']),
|
|
289
218
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
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
|
-
|
|
229
|
+
---
|
|
327
230
|
|
|
328
|
-
|
|
329
|
-
// utils/auth.ts 示例
|
|
330
|
-
import { useStorage } from '@vueuse/core'
|
|
231
|
+
## 核心 Store 模块说明
|
|
331
232
|
|
|
332
|
-
|
|
333
|
-
const tokenStorage = useStorage<null | string>(TokenKey, null)
|
|
233
|
+
### user.js(用户状态)
|
|
334
234
|
|
|
335
|
-
|
|
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
|
-
|
|
242
|
+
```javascript
|
|
243
|
+
// 在路由守卫中获取用户信息
|
|
244
|
+
const userInfo = await store.dispatch('user/getInfo')
|
|
338
245
|
|
|
339
|
-
|
|
246
|
+
// 登出
|
|
247
|
+
await store.dispatch('user/resetToken')
|
|
248
|
+
localStorage.clear()
|
|
249
|
+
locationHref()
|
|
340
250
|
```
|
|
341
251
|
|
|
342
|
-
###
|
|
252
|
+
### permission.js(权限路由)
|
|
343
253
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
import { getToken, setToken, removeToken } from '@/utils/auth'
|
|
254
|
+
- 根据用户角色动态生成路由
|
|
255
|
+
- `state.routes` - 完整路由表(用于菜单渲染)
|
|
256
|
+
- `state.addRoutes` - 动态添加的路由
|
|
348
257
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
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
|
-
| 兄弟组件通信(简单) | ❌ 用
|
|
396
|
-
|
|
397
|
-
### 2. Store 命名规范
|
|
284
|
+
| 兄弟组件通信(简单) | ❌ 用 eventBus |
|
|
398
285
|
|
|
399
|
-
|
|
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
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
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
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
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
|
-
###
|
|
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
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
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
|
-
###
|
|
325
|
+
### 4. 分页数据格式
|
|
444
326
|
|
|
445
|
-
```
|
|
446
|
-
//
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
327
|
+
```javascript
|
|
328
|
+
// 后端返回的分页数据格式
|
|
329
|
+
{
|
|
330
|
+
records: [], // 数据列表(非 rows)
|
|
331
|
+
total: 100,
|
|
332
|
+
current: 1,
|
|
333
|
+
size: 20
|
|
334
|
+
}
|
|
452
335
|
|
|
453
|
-
//
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
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
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
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'`),可切换商户
|