jimmiewang-skills-v2 1.0.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/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # jimmiewang-skills
2
+
3
+ A collection of skills and utilities.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install jimmiewang-skills
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```javascript
14
+ const { hello } = require('jimmiewang-skills');
15
+
16
+ console.log(hello('User'));
17
+ // Output: Hello, User from jimmiewang-skills!
18
+ ```
package/index.js ADDED
@@ -0,0 +1,7 @@
1
+ function hello(name = 'World') {
2
+ return `Hello, ${name} from jimmiewang-skills!`;
3
+ }
4
+
5
+ module.exports = {
6
+ hello
7
+ };
package/package.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "jimmiewang-skills-v2",
3
+ "version": "1.0.1",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "node test.js"
8
+ },
9
+ "keywords": [],
10
+ "author": "",
11
+ "license": "ISC",
12
+ "type": "commonjs"
13
+ }
@@ -0,0 +1,45 @@
1
+ # Create List Page Skill
2
+
3
+ 此 Skill 用于自动生成符合项目架构(Vue + Element UI + Vuex + TableList)的列表页面。
4
+
5
+ ## 什么是 create-list-page?
6
+
7
+ 它是一个自动化生成器,能够一次性为您创建以下所有文件:
8
+ 1. **View**: `src/views/<module>/<entity>/list.vue` (列表页面组件)
9
+ 2. **API**: `src/api/<module>.js` (后端接口定义)
10
+ 3. **Store**: `src/store/modules/<module>/<entity>.js` (Vuex 状态管理)
11
+ 4. **Router**: `src/router/modules/<module>.js` (路由配置)
12
+
13
+ ## 如何使用
14
+
15
+ 您可以直接使用自然语言描述需求,但为了保证生成的准确性,建议包含以下 4 个关键要素:
16
+ * **模块 (Module)**: 代码中的大模块名(如 `businessManagement`, `systemAdmin`)
17
+ * **实体 (Entity)**: 功能名称(如 `OrderList`, `UserLog`)
18
+ * **字段 (Fields)**: 列表需要展示的列
19
+ * **API**: 后端接口地址
20
+
21
+ ## 示例指令
22
+
23
+ 您可以复制以下格式发送给 Trae:
24
+
25
+ ```text
26
+ 使用 skills: create-list-page
27
+
28
+ - 模块 (Module): businessManagement
29
+ (说明: 这决定了文件将存放在 src/views/businessManagement/ 和 src/store/modules/businessManagement/)
30
+
31
+ - 实体 (Entity): OrderList
32
+ (说明: 这决定了组件名和文件名为 OrderList)
33
+
34
+ - 字段 (Fields): OrderId, CustomerName, Amount, Status
35
+ (说明: 这些字段将用于生成表格列)
36
+
37
+ - API: /api/business/orders/list
38
+ (说明: 用于生成 src/api/businessManagement.js 中的 fetchOrderList 函数)
39
+ ```
40
+
41
+ 或者更简单的自然语言描述:
42
+
43
+ > "请在 **systemAdmin** 模块下创建一个 **AuditLog**(审计日志)列表页。
44
+ > 表格需要包含:**LogID、Operator、Time、Action**。
45
+ > API 接口地址是 `/api/admin/audit/list`。"
@@ -0,0 +1,182 @@
1
+ ---
2
+ name: "create-list-page"
3
+ description: "Generates a Vue.js list page including View, API, Store, and Router updates based on requirements. Invoke when user wants to create a new list page or table view."
4
+ ---
5
+
6
+ # Create List Page
7
+
8
+ This skill generates a new list page following the project's architecture (Vue + Element UI + Vuex + TableList component).
9
+
10
+ ## Usage
11
+ Provide the requirement or data structure for the list page.
12
+ The skill will:
13
+ 1. Define the API function in `src/api/`.
14
+ 2. Create the Vuex Store module in `src/store/modules/<module>/<entity>.js`.
15
+ 3. Register the Store module in `src/store/modules/<module>/index.js` (converting file to folder if needed).
16
+ 4. Create the Vue component in `src/views/`.
17
+ 5. Add the route in `src/router/`.
18
+
19
+ ## Code Templates
20
+
21
+ ### 1. API (`src/api/<module>.js`)
22
+ Append this to the module's API file.
23
+ ```javascript
24
+ export const fetch<Entity>List = (params) => {
25
+ return service.get('/api/path/to/resource', { params: params })
26
+ }
27
+ ```
28
+
29
+ ### 2. Store (`src/store/modules/<module>/<entity>.js`)
30
+ Create this file.
31
+
32
+ ```javascript
33
+ import { fetch<Entity>List } from '@/api/<module>'
34
+
35
+ const <entity> = {
36
+ namespaced: true,
37
+ state: {
38
+ paging: {
39
+ total: 0,
40
+ currentPage: 1,
41
+ pageSize: 10
42
+ },
43
+ searchForm: {
44
+ // Define fields here
45
+ name: ''
46
+ },
47
+ selectedData: null
48
+ },
49
+ mutations: {
50
+ updatePaging(state, data) {
51
+ state.paging = { ...state.paging, ...data }
52
+ },
53
+ updateSearchForm(state, data) {
54
+ state.searchForm = { ...state.searchForm, ...data }
55
+ },
56
+ setSelectedData(state, data) {
57
+ state.selectedData = { ...state.selectedData, ...data }
58
+ }
59
+ },
60
+ actions: {
61
+ async get<Entity>List({ commit, state }, params) {
62
+ const searchParams = { ...state.searchForm, ...params.search }
63
+ const apiParams = {
64
+ ...searchParams,
65
+ page: state.paging.currentPage,
66
+ pageSize: state.paging.pageSize,
67
+ ...params
68
+ }
69
+
70
+ try {
71
+ const res = await fetch<Entity>List(apiParams)
72
+ if (!res.statusCode) {
73
+ commit('updatePaging', { total: res.total || 0 })
74
+ return res.list || res.data || []
75
+ }
76
+ return []
77
+ } catch (e) {
78
+ console.error(e)
79
+ return []
80
+ }
81
+ }
82
+ }
83
+ }
84
+
85
+ export default <entity>
86
+ ```
87
+
88
+ ### 3. View (`src/views/<module>/<entity>/list.vue`)
89
+ Use the `TableList` component pattern with Vuex.
90
+
91
+ ```vue
92
+ <template>
93
+ <div>
94
+ <CollapsePanel :panel-title="$t('<module>.searchTitle')">
95
+ <el-form ref="searchForm" :inline="true" :model="<module>.<entity>.searchForm">
96
+ <!-- Add search fields here, bind to store state -->
97
+ <el-form-item label="Name" prop="name">
98
+ <el-input v-model="<module>.<entity>.searchForm.name"/>
99
+ </el-form-item>
100
+ <div class="btn-area">
101
+ <el-button type="primary" @click="handleSearch">{{ $t('common.query') }}</el-button>
102
+ <el-button type="primary" plain @click="resetForm('searchForm')">{{ $t('common.clear') }}</el-button>
103
+ </div>
104
+ </el-form>
105
+ </CollapsePanel>
106
+
107
+ <TableList
108
+ ref="tableList"
109
+ :table-columns="tableColumns"
110
+ :search-form="<module>.<entity>.searchForm"
111
+ :page-obj="<module>.<entity>.paging"
112
+ :use-data-request="true"
113
+ :query-data-list="getTableData"
114
+ @addHandler="goToAdd"
115
+ />
116
+ </div>
117
+ </template>
118
+
119
+ <script>
120
+ import { mapState } from 'vuex'
121
+ import CollapsePanel from '@/components/CollapsePanel'
122
+ import TableList from '@/components/TableList'
123
+
124
+ export default {
125
+ name: '<Entity>List',
126
+ components: { CollapsePanel, TableList },
127
+ data() {
128
+ return {
129
+ tableColumns: [
130
+ { label: 'Name', prop: 'name', isShow: true, width: 200 },
131
+ { label: 'Status', prop: 'status', isShow: true, width: 150 }
132
+ // Add more columns based on requirements
133
+ ]
134
+ }
135
+ },
136
+ computed: {
137
+ ...mapState(['<module>'])
138
+ },
139
+ methods: {
140
+ async getTableData(params) {
141
+ this.$store.commit('<module>/<entity>/updatePaging', params.paging)
142
+ return await this.$store.dispatch('<module>/<entity>/get<Entity>List', params)
143
+ },
144
+ handleSearch() {
145
+ const searchData = this.<module>.<entity>.searchForm
146
+ this.$refs.tableList.searchData({ search: searchData })
147
+ },
148
+ resetForm(formName) {
149
+ this.$refs[formName].resetFields()
150
+ },
151
+ goToAdd() {
152
+ this.$router.push({ path: '/<module>/<entity>/add' })
153
+ }
154
+ }
155
+ }
156
+ </script>
157
+ ```
158
+
159
+ ### 4. Router (`src/router/modules/<module>.js`)
160
+ Add the new route to the children array.
161
+
162
+ ```javascript
163
+ {
164
+ path: '<entity>/list',
165
+ component: () => import('@/views/<module>/<entity>/list'),
166
+ name: '<Entity>List',
167
+ meta: { title: '<entity>.list' }
168
+ }
169
+ ```
170
+
171
+ ## Instructions for AI
172
+ 1. **Analyze the Request**: Identify the module, entity name, fields, and API endpoint.
173
+ 2. **Check Existing Files**: Check API, Router, and Store structure.
174
+ 3. **Store Handling**:
175
+ - If `src/store/modules/<module>.js` is a file, rename it to `src/store/modules/<module>/index.js` and ensure it exports the module with `modules` property.
176
+ - Create the new store file in `src/store/modules/<module>/<entity>.js`.
177
+ - Register `<entity>` in `src/store/modules/<module>/index.js`.
178
+ 4. **Generate Code**:
179
+ - Update API file.
180
+ - Create View file (referencing store state correctly).
181
+ - Update Router file.
182
+ 5. **Verify**: Ensure all paths and namespaced store calls are correct.
package/test.js ADDED
@@ -0,0 +1,12 @@
1
+ const { hello } = require('./index');
2
+
3
+ console.log('Testing jimmiewang-skills...');
4
+ const result = hello('Tester');
5
+ console.log(result);
6
+
7
+ if (result === 'Hello, Tester from jimmiewang-skills!') {
8
+ console.log('Test Passed!');
9
+ } else {
10
+ console.error('Test Failed!');
11
+ process.exit(1);
12
+ }