m8-codex-mcp 1.0.4 → 1.0.6

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 (110) hide show
  1. package/dist/index.js +1 -1
  2. package/dist/knowledge/index.js +1 -1
  3. package/dist/knowledge/standards-summary.js +1 -0
  4. package/dist/templates/vue2.js +1 -1
  5. package/dist/templates/vue3.js +1 -1
  6. package/dist/tools/generate_module_structure.js +1 -1
  7. package/package.json +3 -4
  8. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/000-/347/273/204/344/273/266/345/272/223/344/270/213/350/275/275/344/275/277/347/224/250.md +0 -188
  9. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/001-actionsheet/345/212/250/344/275/234/351/235/242/346/235/277.md +0 -460
  10. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/004-amap/345/234/260/345/233/276.md +0 -285
  11. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/005-button/346/214/211/351/222/256.md +0 -211
  12. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/008-cell/345/215/225/345/205/203/346/240/274.md +0 -213
  13. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/009-checkbox/345/244/215/351/200/211/346/241/206.md +0 -501
  14. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/010-circle/347/216/257/345/275/242/350/277/233/345/272/246/346/235/241.md +0 -168
  15. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/011-datepicker/346/227/245/346/234/237/351/200/211/346/213/251.md +0 -617
  16. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/013-field/350/276/223/345/205/245/346/241/206.md +0 -539
  17. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/015-form/350/241/250/345/215/225.md +0 -999
  18. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/018-header/345/244/264/351/203/250/345/257/274/350/210/252/346/240/217.md +0 -150
  19. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/019-icon/345/233/276/346/240/207.md +0 -133
  20. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/020-loading/345/212/240/350/275/275.md +0 -117
  21. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/021-noticebar/351/200/232/347/237/245/346/240/217.md +0 -152
  22. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/022-numberkeyboard/346/225/260/345/255/227/351/224/256/347/233/230.md +0 -427
  23. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/023-pagination/345/210/206/351/241/265.md +0 -212
  24. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/024-panel/351/235/242/346/235/277.md +0 -85
  25. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/025-passwordinput/345/257/206/347/240/201/350/276/223/345/205/245/346/241/206.md +0 -175
  26. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/026-picker/351/200/211/346/213/251/345/231/250.md +0 -519
  27. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/027-popup/345/274/271/345/207/272/345/261/202.md +0 -152
  28. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/028-progress/350/277/233/345/272/246/346/235/241.md +0 -103
  29. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/029-radio/345/215/225/351/200/211/346/241/206.md +0 -285
  30. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/030-rate/350/257/204/345/210/206.md +0 -189
  31. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/031-search/346/220/234/347/264/242.md +0 -217
  32. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/032-slider/346/273/221/345/235/227.md +0 -166
  33. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/033-stepper/346/255/245/350/277/233/345/231/250.md +0 -340
  34. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/035-swipecell/346/273/221/345/212/250/345/215/225/345/205/203/346/240/274.md +0 -265
  35. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/036-switch/345/274/200/345/205/263.md +0 -196
  36. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/037-switchcell/345/274/200/345/205/263/345/215/225/345/205/203/346/240/274.md +0 -115
  37. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/038-tag/346/240/207/350/256/260.md +0 -232
  38. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/039-treeselect/345/210/206/347/261/273/351/200/211/346/213/251.md +0 -631
  39. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/040-uploader/346/226/207/344/273/266/344/270/212/344/274/240.md +0 -531
  40. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/041-verifycode/351/252/214/350/257/201/347/240/201.md +0 -111
  41. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/042-minirefresh/344/270/213/346/213/211/345/210/267/346/226/260.md +0 -337
  42. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/043-layout/345/270/203/345/261/200.md +0 -150
  43. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/044-image/345/233/276/347/211/207.md +0 -144
  44. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/045-toast/350/275/273/346/217/220/347/244/272.md +0 -429
  45. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/046-calendar/346/227/245/345/216/206.md +0 -467
  46. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/047-area/347/234/201/345/270/202/345/214/272/351/200/211/346/213/251.md +0 -295
  47. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/048-tab/346/240/207/347/255/276/351/241/265.md +0 -577
  48. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/049-dialog/345/274/271/345/207/272/346/241/206.md +0 -491
  49. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/050-dropdownmenu/344/270/213/346/213/211/350/217/234/345/215/225.md +0 -265
  50. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/051-notify/346/266/210/346/201/257/351/200/232/347/237/245.md +0 -203
  51. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/052-overlay/351/201/256/347/275/251/345/261/202.md +0 -139
  52. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/053-collapse/346/212/230/345/217/240/351/235/242/346/235/277.md +0 -199
  53. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/054-grid/345/256/253/346/240/274.md +0 -183
  54. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/055-countdown/345/200/222/350/256/241/346/227/266.md +0 -289
  55. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/056-divider/345/210/206/345/211/262/347/272/277.md +0 -97
  56. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/057-empty/347/251/272/347/212/266/346/200/201.md +0 -146
  57. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/058-imagepreview/345/233/276/347/211/207/351/242/204/350/247/210.md +0 -292
  58. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/059-lazyload/346/207/222/345/212/240/350/275/275.md +0 -120
  59. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/060-skeleton/351/252/250/346/236/266/345/261/217.md +0 -114
  60. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/061-steps/346/255/245/351/252/244/346/235/241.md +0 -119
  61. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/062-sticky/347/262/230/346/200/247/345/270/203/345/261/200.md +0 -208
  62. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/063-indexbar/347/264/242/345/274/225/346/240/217.md +0 -161
  63. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/064-sidebar/344/276/247/350/276/271/345/257/274/350/210/252.md +0 -248
  64. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/065-tabbar/346/240/207/347/255/276/346/240/217.md +0 -314
  65. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/066-badge/345/276/275/346/240/207.md +0 -162
  66. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/067-popover/346/260/224/346/263/241/345/274/271/345/207/272/346/241/206.md +0 -325
  67. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/068-cascader/347/272/247/350/201/224/351/200/211/346/213/251.md +0 -360
  68. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/069-selectperson/351/200/211/344/272/272/347/273/204/344/273/266.md +0 -595
  69. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/070-swipe/350/275/256/346/222/255.md +0 -262
  70. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/071-/345/233/275/351/231/205/345/214/226.md +0 -51
  71. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/072-easycalendar/346/227/245/345/216/206.md +0 -132
  72. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/073-qrcode/344/272/214/347/273/264/347/240/201.md +0 -1538
  73. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/074-imagescale/345/233/276/347/211/207/350/243/201/345/211/252.md +0 -261
  74. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/075-dragsort/346/213/226/346/213/275/346/216/222/345/272/217.md +0 -161
  75. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/076-chart/345/233/276/350/241/250.md +0 -381
  76. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/077-rtc/351/237/263/350/247/206/351/242/221.md +0 -531
  77. package/data/m8mpdoc/UI/347/273/204/344/273/266/345/272/223/078-table/350/241/250/346/240/274.md +0 -849
  78. package/data/m8mpdoc//345/205/270/345/236/213/346/241/210/344/276/213/003-/345/210/227/350/241/250/350/257/246/346/203/205.md +0 -247
  79. package/data/m8mpdoc//345/205/270/345/236/213/346/241/210/344/276/213/003-/345/210/227/350/241/250/350/257/246/346/203/205vue3.md +0 -276
  80. package/data/m8mpdoc//345/205/270/345/236/213/346/241/210/344/276/213/003-/350/241/250/345/215/225/346/217/220/344/272/244.md +0 -130
  81. package/data/m8mpdoc//345/205/270/345/236/213/346/241/210/344/276/213/003-/350/241/250/345/215/225/346/217/220/344/272/244vue3.md +0 -115
  82. package/data/m8mpdoc//346/240/270/345/277/203/351/200/232/347/224/250Util/345/267/245/345/205/267/345/272/223/Ajax/344/270/216/346/226/207/344/273/266/344/270/212/344/274/240.md +0 -456
  83. package/data/m8mpdoc//346/240/270/345/277/203/351/200/232/347/224/250Util/345/267/245/345/205/267/345/272/223//345/267/245/345/205/267/345/207/275/346/225/260/345/272/223.md +0 -398
  84. package/data/standards/01-project/naming.md +0 -158
  85. package/data/standards/01-project/structure.md +0 -106
  86. package/data/standards/01-project/version-detection.md +0 -195
  87. package/data/standards/02-vue/basic.md +0 -242
  88. package/data/standards/02-vue/component.md +0 -299
  89. package/data/standards/02-vue/examples.md +0 -240
  90. package/data/standards/02-vue/performance.md +0 -74
  91. package/data/standards/02-vue/state-management.md +0 -293
  92. package/data/standards/03-css/index.md +0 -165
  93. package/data/standards/04-api/ajax.md +0 -178
  94. package/data/standards/04-api/ejs-api.md +0 -192
  95. package/data/standards/04-api/util.md +0 -166
  96. package/data/standards/05-typescript/index.md +0 -166
  97. package/data/standards/06-mock/index.md +0 -154
  98. package/data/standards/07-router/index.md +0 -141
  99. package/data/standards/README.md +0 -82
  100. package/data/standards/_index.md +0 -215
  101. package/dist/index.d.ts +0 -10
  102. package/dist/index.d.ts.map +0 -1
  103. package/dist/knowledge/index.d.ts +0 -47
  104. package/dist/knowledge/index.d.ts.map +0 -1
  105. package/dist/templates/vue2.d.ts +0 -41
  106. package/dist/templates/vue2.d.ts.map +0 -1
  107. package/dist/templates/vue3.d.ts +0 -41
  108. package/dist/templates/vue3.d.ts.map +0 -1
  109. package/dist/tools/generate_module_structure.d.ts +0 -22
  110. package/dist/tools/generate_module_structure.d.ts.map +0 -1
@@ -1,293 +0,0 @@
1
- # 状态管理规范
2
-
3
- > 定义 Vue 应用的状态管理规范,Vue2 使用 Vuex,Vue3 使用 Pinia。
4
-
5
- ## 📁 文件结构
6
-
7
- ```
8
- src/pages/[module_name]/
9
- ├── [module_name].vue
10
- ├── store.js # Vue2 Vuex 定义
11
- └── store.ts # Vue3 Pinia 定义
12
- ```
13
-
14
- ## 📦 Vue2 - Vuex
15
-
16
- ### store.js 文件结构
17
-
18
- ```javascript
19
- export default {
20
- // 模块名称:与目录名一致
21
- moduleName: "m8demo",
22
-
23
- // 使用独立命名空间
24
- namespaced: true,
25
-
26
- // 状态数据
27
- state: {
28
- count: 0, // 计数器
29
- userInfo: null, // 用户信息
30
- orderList: [], // 订单列表
31
- },
32
-
33
- // 同步修改状态
34
- mutations: {
35
- /**
36
- * 设置计数
37
- * @param {Object} state - 状态对象
38
- * @param {number} n - 增加的数量
39
- */
40
- increment(state, n) {
41
- state.count += n;
42
- },
43
-
44
- /**
45
- * 设置用户信息
46
- * @param {Object} state - 状态对象
47
- * @param {Object} userInfo - 用户信息
48
- */
49
- setUserInfo(state, userInfo) {
50
- state.userInfo = userInfo;
51
- },
52
- },
53
-
54
- // 异步操作
55
- actions: {
56
- /**
57
- * 异步获取用户信息
58
- * @param {Object} context - Vuex 上下文
59
- * @param {string} userId - 用户ID
60
- */
61
- async fetchUserInfo({ commit }, userId) {
62
- const result = await Util.ajax({
63
- url: `${Config.serverUrl}/api/user/${userId}`,
64
- });
65
- commit("setUserInfo", result.data);
66
- },
67
- },
68
-
69
- // 计算属性
70
- getters: {
71
- /**
72
- * 获取格式化的用户名
73
- */
74
- formattedName: (state) => {
75
- return state.userInfo ? `用户: ${state.userInfo.name}` : "未登录";
76
- },
77
- },
78
- };
79
- ```
80
-
81
- ### 组件中使用
82
-
83
- ```vue
84
- <template>
85
- <view>
86
- <text>Count: {{ count }}</text>
87
- <text>User: {{ formattedName }}</text>
88
- </view>
89
- </template>
90
-
91
- <script>
92
- export default {
93
- computed: {
94
- // 获取状态
95
- count() {
96
- return this.$store.state.m8demo.count;
97
- },
98
- // 获取 getter
99
- formattedName() {
100
- return this.$store.getters["m8demo/formattedName"];
101
- },
102
- },
103
- methods: {
104
- // 提交 mutation
105
- addCount() {
106
- this.$store.commit("m8demo/increment", 1);
107
- },
108
- // 派发 action
109
- loadUser(userId) {
110
- this.$store.dispatch("m8demo/fetchUserInfo", userId);
111
- },
112
- },
113
- };
114
- </script>
115
- ```
116
-
117
- ## 📦 Vue3 - Pinia
118
-
119
- ### store.ts 文件结构
120
-
121
- ```typescript
122
- import { defineStore } from "pinia";
123
-
124
- /**
125
- * 用户中心状态管理
126
- * 命名规则: use + 模块名 + Store
127
- */
128
- export const useUserCenterStore = defineStore(
129
- // Store 的唯一 ID
130
- "user_center",
131
- {
132
- // 状态数据
133
- state: () => ({
134
- count: 0, // 计数器
135
- userInfo: null as UserInfo | null, // 用户信息
136
- orderList: [] as Order[], // 订单列表
137
- }),
138
-
139
- // 计算属性
140
- getters: {
141
- /**
142
- * 格式化用户名
143
- */
144
- formattedName: (state) => {
145
- return state.userInfo ? `用户: ${state.userInfo.name}` : "未登录";
146
- },
147
-
148
- /**
149
- * 订单总数
150
- */
151
- orderCount: (state) => state.orderList.length,
152
- },
153
-
154
- // 方法(支持同步和异步)
155
- actions: {
156
- /**
157
- * 增加计数
158
- * @param n - 增加的数量
159
- */
160
- increment(n: number) {
161
- this.count += n;
162
- },
163
-
164
- /**
165
- * 获取用户信息
166
- * @param userId - 用户ID
167
- */
168
- async fetchUserInfo(userId: string) {
169
- const result = await Util.ajax({
170
- url: `${Config.serverUrl}/api/user/${userId}`,
171
- });
172
- this.userInfo = result.data;
173
- },
174
-
175
- /**
176
- * 重置状态
177
- */
178
- reset() {
179
- this.count = 0;
180
- this.userInfo = null;
181
- this.orderList = [];
182
- },
183
- },
184
- }
185
- );
186
-
187
- // 类型定义
188
- interface UserInfo {
189
- id: string;
190
- name: string;
191
- avatar: string;
192
- }
193
-
194
- interface Order {
195
- id: string;
196
- title: string;
197
- amount: number;
198
- }
199
- ```
200
-
201
- ### 组件中使用
202
-
203
- ```vue
204
- <template>
205
- <view>
206
- <text>Count: {{ store.count }}</text>
207
- <text>User: {{ store.formattedName }}</text>
208
- </view>
209
- </template>
210
-
211
- <script lang="ts" setup>
212
- import { useUserCenterStore } from "./store";
213
-
214
- // 获取 store 实例
215
- const store = useUserCenterStore();
216
-
217
- // 直接读取状态
218
- console.log(store.count);
219
-
220
- // 直接读取 getter
221
- console.log(store.formattedName);
222
-
223
- // 调用 action
224
- store.increment(1);
225
-
226
- // 异步 action
227
- store.fetchUserInfo("user123");
228
-
229
- // 重置状态
230
- store.reset();
231
- </script>
232
- ```
233
-
234
- ### 辅助函数(Options API 兼容)
235
-
236
- ```vue
237
- <script>
238
- import { useUserCenterStore } from "./store";
239
- import { mapState, mapActions } from "pinia";
240
-
241
- export default {
242
- computed: {
243
- // 映射 state 和 getters
244
- ...mapState(useUserCenterStore, ["count", "formattedName"]),
245
- },
246
- methods: {
247
- // 映射 actions
248
- ...mapActions(useUserCenterStore, ["increment", "fetchUserInfo"]),
249
- },
250
- };
251
- </script>
252
- ```
253
-
254
- ## 📋 使用原则
255
-
256
- ### 何时使用状态管理
257
-
258
- | 场景 | 推荐方案 |
259
- | -------------- | ---------------- |
260
- | 组件内部状态 | `ref` / `data` |
261
- | 父子组件通信 | `props` / `emit` |
262
- | 跨页面共享数据 | Vuex / Pinia |
263
- | 全局配置 | Vuex / Pinia |
264
-
265
- ### 最佳实践
266
-
267
- 1. **避免滥用全局状态**
268
-
269
- - 优先使用 `props` / `emit` 进行组件通信
270
- - 仅在确实需要跨页面共享时使用 Store
271
-
272
- 2. **使用 computed 获取派生状态**
273
-
274
- ```typescript
275
- // ✅ 使用 getter
276
- const userName = computed(() => store.userInfo?.name);
277
-
278
- // ❌ 避免在方法中直接计算
279
- const getUserName = () => store.userInfo?.name;
280
- ```
281
-
282
- 3. **模块化状态管理**
283
- - 每个模块维护自己的 Store
284
- - 避免将所有状态放在一个文件中
285
-
286
- ## ✅ 状态管理检查清单
287
-
288
- - [ ] Vue2 使用 Vuex,Vue3 使用 Pinia
289
- - [ ] Store 文件放在对应模块目录下
290
- - [ ] 使用独立命名空间
291
- - [ ] 变量和方法添加中文注释
292
- - [ ] 优先使用 props/emit,避免滥用全局状态
293
- - [ ] 使用 getter 获取派生状态
@@ -1,165 +0,0 @@
1
- # CSS 样式规范
2
-
3
- > 定义 M8 项目的 CSS/SCSS 编码规范与最佳实践。
4
-
5
- ## 📝 命名规范
6
-
7
- ### BEM 命名
8
-
9
- | 类型 | 格式 | 示例 |
10
- | ------------------ | ------------------ | --------------- |
11
- | 块(Block) | `.block` | `.card` |
12
- | 元素(Element) | `.block__element` | `.card__title` |
13
- | 修饰符(Modifier) | `.block--modifier` | `.card--active` |
14
-
15
- ```scss
16
- .user-card {
17
- &__avatar {
18
- }
19
- &__name {
20
- }
21
- &--vip {
22
- }
23
- }
24
- ```
25
-
26
- ### class/id 命名规则
27
-
28
- - ✅ 使用小写字母
29
- - ✅ 使用中划线连接
30
- - ❌ 禁止使用大写或驼峰
31
- - ❌ 避免过度简写
32
-
33
- ## 🎨 编码规范
34
-
35
- ### 基本规则
36
-
37
- | 规则 | 说明 |
38
- | ---------- | ------------------------ |
39
- | 预处理器 | 使用 SASS 编写 |
40
- | 颜色简写 | `#666666` → `#666` |
41
- | 避免单位 | 0 值不加单位 `margin: 0` |
42
- | 选择器换行 | 多选择器各占一行 |
43
-
44
- ### 样式穿透
45
-
46
- ```scss
47
- // Vue2
48
- ::v-deep .em-cell {
49
- color: red;
50
- }
51
-
52
- // Vue3
53
- :deep(.em-cell) {
54
- color: red;
55
- }
56
- ```
57
-
58
- **穿透后禁止使用 BEM 后缀选择器**,解决方案:
59
-
60
- ```scss
61
- // 方案1:分开写
62
- :deep(.em-cell) {
63
- }
64
- :deep(.em-cell__title) {
65
- }
66
-
67
- // 方案2:@at-root
68
- :deep(.em-cell) {
69
- @at-root {
70
- #{&}__title {
71
- }
72
- }
73
- }
74
- ```
75
-
76
- ### CSS 书写顺序
77
-
78
- 1. 位置属性:`position`, `top`, `z-index`, `display`, `float`
79
- 2. 大小属性:`width`, `height`, `padding`, `margin`
80
- 3. 文字属性:`font`, `line-height`, `color`, `text-align`
81
- 4. 背景边框:`background`, `border`
82
- 5. 其他属性:`animation`, `transition`
83
-
84
- ### 避免的写法
85
-
86
- ```scss
87
- // ❌ 深层嵌套(不超过3层)
88
- .a {
89
- .b {
90
- .c {
91
- .d {
92
- }
93
- }
94
- }
95
- }
96
-
97
- // ❌ 标签选择器
98
- div.container {
99
- }
100
-
101
- // ❌ 通配符选择器
102
- * {
103
- margin: 0;
104
- }
105
-
106
- // ❌ !important(除非覆盖第三方库)
107
- .text {
108
- color: red !important;
109
- }
110
- ```
111
-
112
- ## 📁 目录结构
113
-
114
- ```
115
- src/
116
- ├── pages/
117
- │ └── [module]/
118
- │ └── css/
119
- │ └── [module].scss # 模块样式
120
- └── common/
121
- └── css/
122
- └── common.extend # 拓展样式
123
- ```
124
-
125
- ### 引用方式
126
-
127
- ```vue
128
- <style lang="scss" scoped>
129
- @import "./css/login.scss";
130
- </style>
131
- ```
132
-
133
- ## 🎨 变量管理
134
-
135
- ```scss
136
- // variables.scss
137
- $primary-color: #1989fa;
138
- $text-color: #323233;
139
- $border-color: #ebedf0;
140
-
141
- $font-size-sm: 12px;
142
- $font-size-md: 14px;
143
- $font-size-lg: 16px;
144
-
145
- $spacing-xs: 4px;
146
- $spacing-sm: 8px;
147
- $spacing-md: 16px;
148
- ```
149
-
150
- ## ⚡ 性能优化
151
-
152
- - 避免深层嵌套(不超过 3 层)
153
- - 合理使用选择器
154
- - 压缩和合并样式文件
155
- - 删除冗余代码
156
-
157
- ## ✅ CSS 检查清单
158
-
159
- - [ ] 使用 BEM 命名规范
160
- - [ ] class 使用小写 + 中划线
161
- - [ ] 样式穿透语法与 Vue 版本匹配
162
- - [ ] 遵循 CSS 书写顺序
163
- - [ ] 避免使用 !important
164
- - [ ] 嵌套不超过 3 层
165
- - [ ] 删除冗余代码
@@ -1,178 +0,0 @@
1
- # Ajax 请求规范
2
-
3
- > 定义 M8 项目中 Ajax 请求的使用规范与示例。
4
-
5
- ## 📡 普通 Ajax 请求
6
-
7
- ### 基础用法
8
-
9
- ```javascript
10
- Util.ajax({
11
- url: Config.serverUrl + "/api/user/detail",
12
- data: {
13
- params: JSON.stringify({
14
- userId: "12345",
15
- }),
16
- },
17
- })
18
- .then((res) => {
19
- console.log("请求成功:", res);
20
-
21
- // 标准响应处理
22
- if (res?.status?.code === 1) {
23
- const data = res.custom;
24
- // 处理数据
25
- }
26
- })
27
- .catch((error) => {
28
- console.error("请求失败:", error);
29
- })
30
- .finally(() => {
31
- // 请求完成(无论成功失败)
32
- ejs.ui.closeWaiting();
33
- });
34
- ```
35
-
36
- ### 带加载提示
37
-
38
- ```javascript
39
- ejs.ui.showWaiting("加载中...");
40
-
41
- Util.ajax({
42
- url: `${Config.serverUrl}/api/data`,
43
- data: {
44
- params: JSON.stringify({ id: "123" }),
45
- },
46
- })
47
- .then((res) => {
48
- if (res?.status?.code === 1) {
49
- // 处理数据
50
- } else {
51
- ejs.ui.toast(res?.status?.message || "请求失败");
52
- }
53
- })
54
- .catch((error) => {
55
- ejs.ui.toast("网络请求失败");
56
- })
57
- .finally(() => {
58
- ejs.ui.closeWaiting();
59
- });
60
- ```
61
-
62
- ## 📤 文件上传
63
-
64
- ### 跨端上传(推荐)
65
-
66
- 支持 H5、微信小程序、支付宝小程序:
67
-
68
- ```javascript
69
- // afterRead 回调中处理上传
70
- const afterRead = (file) => {
71
- Util.upload({
72
- url: `${Config.serverUrl}/api/upload`,
73
- filePath: file.path, // 文件路径
74
- name: file.name, // 文件名
75
- formData: {
76
- userId: "user123",
77
- },
78
- success: (res) => {
79
- console.log("上传成功:", res);
80
- },
81
- fail: (error) => {
82
- console.error("上传失败:", error);
83
- },
84
- });
85
- };
86
- ```
87
-
88
- ### H5 专用上传
89
-
90
- ```javascript
91
- const afterRead = (file) => {
92
- Util.upload({
93
- url: `${Config.serverUrl}/api/upload`,
94
- files: [{ file: file }],
95
- formData: {
96
- userId: "user123",
97
- },
98
- success: (res) => {
99
- console.log("上传成功:", res);
100
- },
101
- });
102
- };
103
- ```
104
-
105
- ### 小程序文件名生成
106
-
107
- ```javascript
108
- const generateFileName = (path) => {
109
- const timestamp = new Date().getTime();
110
- const random = Math.floor(Math.random() * 10000);
111
- const extension = path.toLowerCase().split(".").pop();
112
- return `file_${timestamp}_${random}.${extension}`;
113
- };
114
- ```
115
-
116
- ## 📦 完整上传组件示例
117
-
118
- ```vue
119
- <template>
120
- <em-uploader :after-read="afterRead" />
121
- </template>
122
-
123
- <script>
124
- export default {
125
- methods: {
126
- afterRead(file) {
127
- // 判断是数组还是对象(多选/单选)
128
- const files = Array.isArray(file) ? file : [file];
129
-
130
- files.forEach((f) => {
131
- Util.upload({
132
- url: `${Config.serverUrl}/api/upload`,
133
- filePath: f.path,
134
- name: f.name || this.generateFileName(f.path),
135
- formData: { userId: "user123" },
136
- success: (res) => {
137
- console.log("上传成功:", res);
138
- },
139
- fail: (error) => {
140
- ejs.ui.toast("上传失败");
141
- },
142
- });
143
- });
144
- },
145
-
146
- generateFileName(path) {
147
- const timestamp = new Date().getTime();
148
- const random = Math.floor(Math.random() * 10000);
149
- const extension = path.toLowerCase().split(".").pop();
150
- return `file_${timestamp}_${random}.${extension}`;
151
- },
152
- },
153
- };
154
- </script>
155
- ```
156
-
157
- ## 📋 文件对象属性
158
-
159
- | 属性 | 说明 | 平台 |
160
- | ------ | -------- | ------ |
161
- | `path` | 文件路径 | 全平台 |
162
- | `file` | 文件对象 | 全平台 |
163
- | `name` | 文件名 | 仅 H5 |
164
- | `size` | 文件大小 | 仅 H5 |
165
-
166
- ## ⚠️ 注意事项
167
-
168
- 1. **跨端兼容**:小程序使用 `filePath` + `name`,H5 使用 `files`
169
- 2. **文件名获取**:小程序环境下需手动生成文件名
170
- 3. **多选处理**:`afterRead` 多选时返回数组,单选返回对象
171
-
172
- ## ✅ 检查清单
173
-
174
- - [ ] 使用 `Util.ajax` 发起请求
175
- - [ ] 请求参数使用 `JSON.stringify`
176
- - [ ] 正确处理响应状态码
177
- - [ ] 添加 loading 状态
178
- - [ ] 文件上传区分平台