@qilitt-mickey/vue3-temp-skill 1.0.12 → 1.1.2
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/README.md +66 -214
- package/SKILL.md +165 -527
- package/package.json +2 -2
- package/references/api-check.md +187 -128
- package/references/base-code-dict.md +49 -48
- package/references/chart-echarts.md +61 -0
- package/references/code-quality.md +44 -15
- package/references/core-kernel.md +305 -0
- package/references/crud-pages.md +87 -261
- package/references/data-compare.md +502 -501
- package/references/data-mapping.md +218 -213
- package/references/data-screen.md +94 -79
- package/references/data-writeback.md +104 -104
- package/references/detail-page.md +100 -99
- package/references/directives-advanced.md +27 -4
- package/references/download-export.md +70 -68
- package/references/feedback-loading.md +62 -60
- package/references/feedback-ui.md +125 -111
- package/references/file-management.md +28 -7
- package/references/flowchart-g6.md +249 -244
- package/references/form-advanced.md +264 -26
- package/references/graph-relation.md +12 -7
- package/references/http-api.md +138 -103
- package/references/icons.md +326 -0
- package/references/layout-theme.md +1 -1
- package/references/mobile-h5.md +20 -0
- package/references/particles.md +143 -0
- package/references/permission-auth.md +8 -31
- package/references/project-inventory.md +175 -120
- package/references/qrcode-barcode.md +107 -92
- package/references/rich-text.md +85 -73
- package/references/seamless-scroll.md +40 -38
- package/references/table-vxe.md +114 -0
- package/references/tree-table.md +2 -1
- package/references/ui-components.md +5 -1
- package/references/verify-captcha.md +110 -96
- package/references/websocket-realtime.md +2 -1
- package/references/wechat-js.md +58 -0
- package/references/workflow-bpmn.md +207 -206
- package/references/advanced-ui.md +0 -302
- package/references/build-optim.md +0 -282
- package/references/vue-core.md +0 -209
package/references/vue-core.md
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
skill: vue-core
|
|
3
|
-
description: Vue 3 项目核心规范,涵盖技术栈、目录结构、组件开发标准、路由系统、状态管理和国际化。开发任何新功能或组件前必须参考此技能。
|
|
4
|
-
scope: project
|
|
5
|
-
tags: [vue3, typescript, vite, component, router, pinia, i18n, conventions]
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
# Vue 3 项目核心规范
|
|
9
|
-
|
|
10
|
-
## 技术栈
|
|
11
|
-
|
|
12
|
-
```typescript
|
|
13
|
-
const techStack = {
|
|
14
|
-
vue: "3.5.x",
|
|
15
|
-
typescript: "6.x",
|
|
16
|
-
vite: "8.x",
|
|
17
|
-
elementPlus: "2.14.x", // PC 端 UI
|
|
18
|
-
vant: "4.10.x", // 移动端 UI
|
|
19
|
-
pinia: "3.x",
|
|
20
|
-
vueRouter: "5.x",
|
|
21
|
-
unocss: "66.x",
|
|
22
|
-
axios: "1.18.x",
|
|
23
|
-
vueI18n: "11.x",
|
|
24
|
-
};
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## 目录结构
|
|
28
|
-
|
|
29
|
-
```
|
|
30
|
-
src/
|
|
31
|
-
├── api/ # API 接口(按业务模块分文件)
|
|
32
|
-
├── components/ # 可复用组件(Re* 前缀)
|
|
33
|
-
├── hooks/ # 组合式函数
|
|
34
|
-
├── store/ # Pinia 状态管理(模块化)
|
|
35
|
-
├── router/ # 路由配置(PC + 移动端)
|
|
36
|
-
├── utils/ # 工具函数
|
|
37
|
-
├── styles/ # 全局样式(SCSS + UnoCSS)
|
|
38
|
-
├── views/ # 页面组件
|
|
39
|
-
├── directives/ # 自定义指令
|
|
40
|
-
├── layout/ # 布局系统
|
|
41
|
-
└── locales/ # 国际化文件
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
## 组件开发规范
|
|
45
|
-
|
|
46
|
-
### 命名规则
|
|
47
|
-
|
|
48
|
-
- 全局自定义组件:`Re[ComponentName]`,如 `RePagination`、`ReDialog`。
|
|
49
|
-
- 页面组件:放在 `views/[module]/index.vue`,`name` 使用大驼峰,如 `BaseTable`、`LoginPage`。
|
|
50
|
-
- 组件 class 名:`re-[component-name]`,如 `.re-pagination`。
|
|
51
|
-
|
|
52
|
-
### 标准模板
|
|
53
|
-
|
|
54
|
-
```vue
|
|
55
|
-
<script setup lang="ts">
|
|
56
|
-
import type { ComponentNameProps, ComponentNameEmits } from "./type";
|
|
57
|
-
|
|
58
|
-
defineOptions({
|
|
59
|
-
name: "ReComponentName",
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
const props = withDefaults(defineProps<ComponentNameProps>(), {
|
|
63
|
-
// 默认值
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
const emit = defineEmits<ComponentNameEmits>();
|
|
67
|
-
|
|
68
|
-
// 组件逻辑
|
|
69
|
-
</script>
|
|
70
|
-
|
|
71
|
-
<template>
|
|
72
|
-
<div class="re-component-name">
|
|
73
|
-
<!-- 内容 -->
|
|
74
|
-
</div>
|
|
75
|
-
</template>
|
|
76
|
-
|
|
77
|
-
<style lang="scss" scoped>
|
|
78
|
-
.re-component-name {
|
|
79
|
-
/* 组件样式 */
|
|
80
|
-
}
|
|
81
|
-
</style>
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### 必须遵守
|
|
85
|
-
|
|
86
|
-
1. 始终使用 `<script setup lang="ts">` + Composition API,禁止 Options API。
|
|
87
|
-
2. `script` 标签第一行引入类型:`import type { ... } from "./type"`。
|
|
88
|
-
3. 使用 `defineOptions` 显式声明组件 `name`。
|
|
89
|
-
4. `props` 与 `emits` 的类型定义必须抽取到同目录 `type.ts` 文件。
|
|
90
|
-
5. 样式使用 `lang="scss" scoped`;UnoCSS 原子类可直接写在 template 中。
|
|
91
|
-
6. 系统常规组件(Element Plus / Vant)已自动引入,无需手动 `import`。
|
|
92
|
-
7. 自定义 Re 组件需显式引入:`import { RePagination } from "@/components/RePagination"`。
|
|
93
|
-
|
|
94
|
-
### 常见反例
|
|
95
|
-
|
|
96
|
-
- 使用 Options API(`export default { data(), methods }`)。
|
|
97
|
-
- `defineProps` 内直接写内联类型而不抽取到 `type.ts`。
|
|
98
|
-
- 在组件中硬编码中文文案(应使用 `$t()` 国际化)。
|
|
99
|
-
- 忘记写 `defineOptions({ name })` 导致 keep-alive 失效。
|
|
100
|
-
|
|
101
|
-
## 路由系统
|
|
102
|
-
|
|
103
|
-
### 静态路由模块格式
|
|
104
|
-
|
|
105
|
-
```typescript
|
|
106
|
-
export default {
|
|
107
|
-
path: "/system",
|
|
108
|
-
redirect: "/system/user",
|
|
109
|
-
meta: {
|
|
110
|
-
title: "系统管理",
|
|
111
|
-
icon: "ep:tools",
|
|
112
|
-
rank: 1,
|
|
113
|
-
},
|
|
114
|
-
children: [
|
|
115
|
-
{
|
|
116
|
-
path: "/system/user",
|
|
117
|
-
name: "SystemUser",
|
|
118
|
-
component: () => import("@/views/system/user/index.vue"),
|
|
119
|
-
meta: { title: "用户管理", roles: ["admin"] },
|
|
120
|
-
},
|
|
121
|
-
],
|
|
122
|
-
} satisfies RouteConfigsTable;
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### 路由约定
|
|
126
|
-
|
|
127
|
-
- 路由文件放在 `src/router/modules/` 下,按业务模块拆分。
|
|
128
|
-
- `meta.rank` 控制菜单排序,数值越小越靠前。
|
|
129
|
-
- `meta.roles` 控制页面级权限,不设置则表示无权限限制。
|
|
130
|
-
- 动态路由通过后端接口返回,前端使用 `addRoute()` 动态注册。
|
|
131
|
-
- 移动端路由放在 `src/router/mobile.ts`,与 PC 端隔离。
|
|
132
|
-
|
|
133
|
-
## Pinia 状态管理
|
|
134
|
-
|
|
135
|
-
### Store 模块格式
|
|
136
|
-
|
|
137
|
-
```typescript
|
|
138
|
-
import { defineStore } from "pinia";
|
|
139
|
-
|
|
140
|
-
export const useUserStore = defineStore("user", {
|
|
141
|
-
state: () => ({
|
|
142
|
-
token: "",
|
|
143
|
-
userInfo: null as UserInfo | null,
|
|
144
|
-
}),
|
|
145
|
-
|
|
146
|
-
actions: {
|
|
147
|
-
setToken(token: string) {
|
|
148
|
-
this.token = token;
|
|
149
|
-
},
|
|
150
|
-
async login(params: LoginParams) {
|
|
151
|
-
const { data } = await http.request<Result<LoginResult>>(
|
|
152
|
-
"post", "/api/login", { data: params }
|
|
153
|
-
);
|
|
154
|
-
this.token = data.token;
|
|
155
|
-
this.userInfo = data.userInfo;
|
|
156
|
-
},
|
|
157
|
-
logout() {
|
|
158
|
-
this.$reset();
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
|
|
162
|
-
persist: {
|
|
163
|
-
key: "user-store",
|
|
164
|
-
storage: localStorage,
|
|
165
|
-
paths: ["token"],
|
|
166
|
-
},
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
// 组件外部使用的 Hook(保证在 setup 外也能获取 store 实例)
|
|
170
|
-
export const useUserStoreHook = () => {
|
|
171
|
-
return useUserStore();
|
|
172
|
-
};
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
### Store 约定
|
|
176
|
-
|
|
177
|
-
- 文件名使用 `useXxxStore` 命名,如 `useUserStore.ts`。
|
|
178
|
-
- 必须导出 `useXxxStoreHook()` 函数,供组件外部(如工具函数、路由守卫)调用。
|
|
179
|
-
- 需要持久化的字段在 `persist.paths` 中声明。
|
|
180
|
-
- 不要在 store 中直接操作 DOM 或调用路由方法。
|
|
181
|
-
|
|
182
|
-
## 国际化 (i18n)
|
|
183
|
-
|
|
184
|
-
### 使用方式
|
|
185
|
-
|
|
186
|
-
```vue
|
|
187
|
-
<template>
|
|
188
|
-
<el-button>{{ $t("buttons.submit") }}</el-button>
|
|
189
|
-
</template>
|
|
190
|
-
|
|
191
|
-
<script setup lang="ts">
|
|
192
|
-
import { useI18n } from "vue-i18n";
|
|
193
|
-
const { t } = useI18n();
|
|
194
|
-
const label = t("system.title");
|
|
195
|
-
</script>
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
### 约定
|
|
199
|
-
|
|
200
|
-
- 所有用户可见文案必须通过 `$t()` 或 `t()` 引用。
|
|
201
|
-
- 语言包文件放在 `src/locales/` 下,按模块拆分。
|
|
202
|
-
- 开发阶段可先用中文 key 占位,后续替换为正式文案。
|
|
203
|
-
- 避免使用 `more`、`view details` 等无业务语义的占位文案。
|
|
204
|
-
|
|
205
|
-
## 通用原则
|
|
206
|
-
|
|
207
|
-
- 仅在系统边界(用户输入、外部 API)做校验,不添加无意义的防御代码。
|
|
208
|
-
- 新功能需同时考虑 PC 端与移动端兼容性。
|
|
209
|
-
- 用户可见文案优先通过 i18n 或后端配置化提供。
|