From 32d2e292be458cdbb25ca2ab9db42a04da30a496 Mon Sep 17 00:00:00 2001 From: Tevin <tingquanren@163.com> Date: Tue, 18 Mar 2025 10:25:32 +0800 Subject: [PATCH] 知识库规则文档调整 --- _cursor.ai/rules/fit-base-pilot.mdc | 8 -- _cursor.ai/文档说明.md | 22 +++--- _cursor.ai/rules/fit-base-fetcher.mdc | 28 +++++--- _cursor.ai/rules/type-surface.mdc | 36 ++++++++++++ _cursor.ai/rules/type-pilot.mdc | 40 +++++++++++++ _cursor.ai/组件目录.md | 0 _cursor.ai/rules/type-fetchers.mdc | 31 ++++++++++ 7 files changed, 137 insertions(+), 28 deletions(-) diff --git a/_cursor.ai/rules/fit-base-fetcher.mdc b/_cursor.ai/rules/fit-base-fetcher.mdc index 766f648..20ee33f 100644 --- a/_cursor.ai/rules/fit-base-fetcher.mdc +++ b/_cursor.ai/rules/fit-base-fetcher.mdc @@ -14,9 +14,7 @@ ## 引用方法 ```js -import { - Fetcher -} from '@components/bases/Fetcher'; +import { Fetcher } from '@components/bases/Fetcher'; ``` ## 构造函数 @@ -263,7 +261,7 @@ } ``` -注意,为了保证接口数据的扩展性,data 只能接 Object 类型,禁止接其他类型 +注意,为了保证接口数据的扩展性,**data 只能接 Object 类型**,禁止接其他类型 ### 前端统一响应状态码 @@ -280,23 +278,31 @@ ```js import { Fetcher } from '@components/bases/Fetcher'; -class FCommon extends Fetcher {} +// 请求集 +class FCommon extends Fetcher { + + getUserInfo(user) { + const url = this.spellURL('getUserInfo', 'User/info'); + const send = {..user}; + return this.post(url, send); + } + +} // 全局单例 export const $fetchCommon = new FCommon(); ``` ```js -import { - $fetchCommon -} from '@fetchers/FCommon'; +import { $fetchCommon } from '@fetchers/FCommon'; -export class PPageName extends Pilot { +// 数据控制器 +export class PUserDetail extends Pilot { - // 在数据控制层中,发请求示例 onLoadUserInfo() { Taro.showLoading(); - $fetchCommon.getUserInfo(this.userId) + // 调用请求集发请求示例 + $fetchCommon.getUserInfo({uid: this.userId}) .then(res => { Taro.hideLoading(); if (!res) { diff --git a/_cursor.ai/rules/fit-base-pilot.mdc b/_cursor.ai/rules/fit-base-pilot.mdc index 61372cd..ef70d86 100644 --- a/_cursor.ai/rules/fit-base-pilot.mdc +++ b/_cursor.ai/rules/fit-base-pilot.mdc @@ -17,9 +17,7 @@ ## 引用方法 ```js -import { - Pilot -} from '@components/bases/Pilot'; +import { Pilot } from '@components/bases/Pilot'; ``` ## 主要方法 @@ -151,9 +149,7 @@ ```js // 引入界面层对应数据控制器 -import { - PPageName -} from '@pilots/pilotGroup/PPageName'; +import { PPageName } from '@pilots/pilotGroup/PPageName'; export default { name: 'PageName', diff --git a/_cursor.ai/rules/type-fetchers.mdc b/_cursor.ai/rules/type-fetchers.mdc index ec56ad1..babdf7e 100644 --- a/_cursor.ai/rules/type-fetchers.mdc +++ b/_cursor.ai/rules/type-fetchers.mdc @@ -5,3 +5,34 @@ --- # 请求集 + +## 请求集空白模板 + +```js +/** + * FCommon - 公用请求集 + * @author 作者 + */ + +import { Fetcher } from '@components/bases/Fetcher'; + +class FCommon extends Fetcher { + + constructor() { + super({ + // url前缀(本地路径, 服务器路径) + urlPrefix: ['/api/common/', '/serverPath/'], + }); + } + + // 读取页面详情 + getPageDetail() { + const url = this.spellURL('getPageDetail', 'page/Detail'); + const send = {}; + return this.post(url, send); + } + +} + +export const $fetchCommon = new FCommon(); +``` diff --git a/_cursor.ai/rules/type-pilot.mdc b/_cursor.ai/rules/type-pilot.mdc index a1f356c..96010c5 100644 --- a/_cursor.ai/rules/type-pilot.mdc +++ b/_cursor.ai/rules/type-pilot.mdc @@ -5,3 +5,43 @@ --- # 数据控制器 + +## 数据控制器空白模板 + +```js +/** + * PPageName - 页面名称 + * @author 作者 + */ + +import Taro from '@tarojs/taro'; +import { Pilot } from '@components/bases/Pilot'; +import { $fetchCommon } from '@fetchers/FCommon'; + +export class PPageName extends Pilot { + + $data() { + return {}; + } + + $mounted() { + this.onLoadDataResource(); + } + + // 加载用户详情 + onLoadDataResource() { + Taro.showLoading(); + $fetchCommon.getPageDetail() + .then(res => { + Taro.hideLoading(); + if (!res) { + return; + } + // do something + }); + } + +} +``` + +说明:请求异常由请求层的基类自动处理,数据控制层跳过错误的逻辑,只处理请求成功的后续业务 \ No newline at end of file diff --git a/_cursor.ai/rules/type-surface.mdc b/_cursor.ai/rules/type-surface.mdc index be88d50..be5de5f 100644 --- a/_cursor.ai/rules/type-surface.mdc +++ b/_cursor.ai/rules/type-surface.mdc @@ -5,3 +5,39 @@ --- # 界面 + +## 界面空白模板 + +```html +/** +* pageName - 页面名称 +* @author 作者 +*/ + +<template> + <CPage> + <CNavBar title="页面名称" /> + <CContent class="page-name"> + <!-- 页面内容 --> + </CContent> + </CPage> +</template> + +<script> +import Taro from '@tarojs/taro'; +import {} from 'taro-ui-vue'; +import { PPageName } from '@pilots/pilotGroup/PPageName'; +import { CPage, CContent, CNavBar } from '@components/layout/h5Page'; +import './pageName.scss'; + +export default { + name: 'PageName', + components: {}, + ...new PPageName().createOptions(), +}; +</script> +``` + +说明: +- H5 界面需要 CPage、CContent、CNavBar 这三个排版组件作为页面的基础布局 +- 在小程序中则不需要,删除即可 \ No newline at end of file diff --git a/_cursor.ai/readme.md "b/_cursor.ai/\346\226\207\346\241\243\350\257\264\346\230\216.md" similarity index 68% rename from _cursor.ai/readme.md rename to "_cursor.ai/\346\226\207\346\241\243\350\257\264\346\230\216.md" index 9814c62..d509456 100644 --- a/_cursor.ai/readme.md +++ "b/_cursor.ai/\346\226\207\346\241\243\350\257\264\346\230\216.md" @@ -2,15 +2,11 @@ ## rules 文件夹 -rules 是指编辑器根据一定条件自动读取的对 AI 的要求 - -> 注意:需要进行初始化 -> 请双击执行项目根目录 `link-rules.cmd` 命令文件,将公共资源目录中的 rules 链接到编辑器中 -> 然后在编辑器设置中查看是否链接成功(CursorSetting > Rules > ProjectRules) +rules 是指 AI 根据一定条件自动读取的工作环境设定,是我们控制项目代码生成质量的重要手段 ### 规则类型:全局使用 `Always` -所有的聊天(Agent、Ask、Edit)和 ctrl+k 编辑,都会参考此规则 +所有的聊天(Agent、Ask、Edit)和 ctrl+k 编辑,都会参考此规则生成代码 - [系统角色](/src/components/_cursor.ai/rules/all-system-role.mdc) - [项目介绍](/src/components/_cursor.ai/rules/all-project-info.mdc) @@ -18,7 +14,7 @@ ### 规则类型:按路径匹配 `Auto-Attached` -当路径规则匹配上时,会参考此规则 +当文件名称或路径匹配上时,会参考此规则生成代码 - [请求集](/src/components/_cursor.ai/rules/type-fetchers.mdc) - [数据控制器](/src/components/_cursor.ai/rules/type-pilot.mdc) @@ -28,17 +24,21 @@ ### 规则类型:自主决定 `Agent-Requested` -根据 Description 的文字描述,由 AI 自主决定是否需要参考此规则 -仅 Agent 模式生效,非 Agent 模式需要我们自己 @ 此规则 +在 Agent 模式下,由 AI 根据 Description 的文字描述,自主决定是否需要参考此规则生成代码 +非 Agent 模式需要我们自己 @ 此规则才能生效 - [请求集基类](/src/components/_cursor.ai/rules/fit-base-fetcher.mdc) - [数据控制器基类](/src/components/_cursor.ai/rules/fit-base-pilot.mdc) - 表单验证规则 +> 注意:rules 文件夹需要进行初始化 +> 请双击项目根目录文件 `link-rules.cmd` 执行命令,将公共资源目录中的 rules 链接到编辑器中 +> 然后在编辑器设置中查看是否链接成功(CursorSetting > Rules > ProjectRules) + ## prompts 文件夹 -prompts 是我们主动提问,和我们在聊天窗口叫 ai 干活一样 -区别是对于经常执行的有具体要求的操作,固定下来方便反复使用 +prompts 存放我们主动提出的指令 +和我们在聊天窗口要求 ai 完成工作一样,就是对需要经常执行的有具体要求的操作,存下来方便反复使用 ## 文档文件夹 diff --git "a/_cursor.ai/\347\273\204\344\273\266\347\233\256\345\275\225.md" "b/_cursor.ai/\347\273\204\344\273\266\347\233\256\345\275\225.md" new file mode 100644 index 0000000..e69de29 --- /dev/null +++ "b/_cursor.ai/\347\273\204\344\273\266\347\233\256\345\275\225.md" -- Gitblit v1.9.1