m8-framework-mcp 1.0.1 → 1.0.4
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 +55 -2
- package/build/index.js +507 -122
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,10 +8,12 @@ M8 框架文档助手是一个基于 Model Context Protocol (MCP) 的智能开
|
|
|
8
8
|
|
|
9
9
|
- 🔍 **组件搜索**: 按名称或功能描述搜索 M8 框架 UI 组件
|
|
10
10
|
- 📚 **API 查询**: 搜索 EJS 原生 API,支持按模块或功能描述搜索
|
|
11
|
-
-
|
|
11
|
+
- 🔧 **Util 工具搜索**: 搜索 M8 框架 Util 工具方法(如 Util.ajax、Util.upload)
|
|
12
|
+
- 💡 **智能推荐**: 根据需求描述智能推荐合适的组件、API 和 Util 方法
|
|
12
13
|
- 🛠️ **代码生成**: 生成符合 M8 框架规范的 Vue 代码(支持 M8.3/Vue2 和 M8.4/Vue3)
|
|
13
14
|
- ✅ **兼容性检查**: 检查组件或 API 在目标平台的兼容性
|
|
14
15
|
- 📋 **典型模式**: 获取常见场景的实现模式(列表详情、表单提交等)
|
|
16
|
+
- 📖 **编码规范**: 查询和管理编码规范文档(CSS、Vue、JavaScript 等)
|
|
15
17
|
|
|
16
18
|
## 快速开始
|
|
17
19
|
|
|
@@ -101,18 +103,69 @@ M8 框架文档助手是一个基于 Model Context Protocol (MCP) 的智能开
|
|
|
101
103
|
获取列表详情页的实现模式
|
|
102
104
|
```
|
|
103
105
|
|
|
106
|
+
### 搜索 Util 方法
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
搜索 M8 框架的 ajax 方法
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### 获取编码规范
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
获取 Vue 组件编码规范
|
|
116
|
+
列出所有可用的编码规范
|
|
117
|
+
```
|
|
118
|
+
|
|
104
119
|
## 可用工具列表
|
|
105
120
|
|
|
106
121
|
| 工具名 | 说明 |
|
|
107
122
|
|--------|------|
|
|
108
123
|
| `search_component` | 搜索 M8 框架 UI 组件 |
|
|
109
124
|
| `search_ejs_api` | 搜索 EJS 原生 API |
|
|
125
|
+
| `search_util` | 搜索 Util 工具方法(如 ajax、upload) |
|
|
110
126
|
| `get_component_detail` | 获取组件完整文档 |
|
|
111
127
|
| `get_api_detail` | 获取 API 完整文档 |
|
|
112
|
-
| `
|
|
128
|
+
| `get_util_detail` | 获取 Util 方法完整文档 |
|
|
129
|
+
| `recommend` | 根据需求智能推荐(优先推荐 Util 方法) |
|
|
113
130
|
| `generate_code` | 生成符合规范的代码 |
|
|
114
131
|
| `check_compatibility` | 检查平台兼容性 |
|
|
115
132
|
| `get_pattern` | 获取典型实现模式 |
|
|
133
|
+
| `get_standard` | 获取编码规范文档 |
|
|
134
|
+
| `list_standards` | 列出所有可用的编码规范 |
|
|
135
|
+
|
|
136
|
+
## 重要说明
|
|
137
|
+
|
|
138
|
+
### HTTP 请求推荐使用 Util.ajax
|
|
139
|
+
|
|
140
|
+
当你询问关于 HTTP 请求、ajax、接口调用等问题时,MCP 会优先推荐 `Util.ajax` 而不是 EJS API:
|
|
141
|
+
|
|
142
|
+
```javascript
|
|
143
|
+
// ✅ 推荐使用 Util.ajax
|
|
144
|
+
Util.ajax({
|
|
145
|
+
url: Config.serverUrl + '/api/data',
|
|
146
|
+
type: 'POST',
|
|
147
|
+
data: { params: JSON.stringify(params) },
|
|
148
|
+
dataPath: 'data',
|
|
149
|
+
success: (result) => {
|
|
150
|
+
console.log('成功:', result);
|
|
151
|
+
},
|
|
152
|
+
error: (err) => {
|
|
153
|
+
console.error('失败:', err);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
// ❌ 不存在的 API
|
|
158
|
+
ejs.http.post('/api/data'); // 这个 API 不存在!
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### 编码规范
|
|
162
|
+
|
|
163
|
+
MCP 内置了多种编码规范,可以通过 `list_standards` 查看所有规范,通过 `get_standard` 获取详细内容:
|
|
164
|
+
|
|
165
|
+
- **vue-style**: Vue 组件编码规范
|
|
166
|
+
- **css-style**: CSS/SCSS 编码规范
|
|
167
|
+
- **js-style**: JavaScript/TypeScript 编码规范
|
|
168
|
+
- **project-structure**: 项目结构规范
|
|
116
169
|
|
|
117
170
|
## 高级配置
|
|
118
171
|
|
package/build/index.js
CHANGED
|
@@ -1,130 +1,188 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{McpServer as
|
|
3
|
-
`),
|
|
4
|
-
`),language:
|
|
5
|
-
`),rows:
|
|
6
|
-
`)});continue}if(a.trim()){let
|
|
7
|
-
`)});continue}
|
|
8
|
-
`)[0];break}let
|
|
9
|
-
`)[0]));o&&o.name&&(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
`)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
2
|
+
import{McpServer as It}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as Lt}from"@modelcontextprotocol/sdk/server/stdio.js";import{z as h}from"zod";import{fileURLToPath as Dt}from"url";import{dirname as Ut,join as Te}from"path";import{existsSync as Tt}from"fs";import*as A from"path";import*as j from"fs";import*as z from"path";function Ve(t){try{return j.readFileSync(t,"utf-8")}catch(e){return console.error(`[Parser] \u8BFB\u53D6\u6587\u4EF6\u5931\u8D25: ${t}`,e),""}}function v(t){let e=[];try{if(!j.existsSync(t))return console.error(`[Parser] \u76EE\u5F55\u4E0D\u5B58\u5728: ${t}`),e;let s=j.readdirSync(t,{withFileTypes:!0});for(let r of s){let o=z.join(t,r.name);r.isDirectory()?e.push(...v(o)):r.isFile()&&r.name.endsWith(".md")&&e.push(o)}}catch(s){console.error(`[Parser] \u626B\u63CF\u76EE\u5F55\u5931\u8D25: ${t}`,s)}return e}function Ee(t){let e=[];for(let s of t){if(/^\|[\s\-:]+\|$/.test(s.trim()))continue;let r=s.split("|").map(o=>o.trim()).filter(o=>o!=="");r.length>0&&e.push(r)}return e}function M(t){let e=Ve(t),s=[],r="",o=e.split(`
|
|
3
|
+
`),n=0;for(;n<o.length;){let a=o[n],l=a.match(/^(#{1,6})\s+(.+)$/);if(l){let i=l[1].length,c=l[2].trim();i===1&&!r&&(r=c),s.push({type:"heading",level:i,content:c}),n++;continue}if(a.startsWith("```")){let i=a.slice(3).trim(),c=[];for(n++;n<o.length&&!o[n].startsWith("```");)c.push(o[n]),n++;s.push({type:"code",content:c.join(`
|
|
4
|
+
`),language:i||"text"}),n++;continue}if(a.startsWith("|")){let i=[a];for(n++;n<o.length&&o[n].startsWith("|");)i.push(o[n]),n++;let c=Ee(i);s.push({type:"table",content:i.join(`
|
|
5
|
+
`),rows:c});continue}if(/^[\-\*\+]\s/.test(a)||/^\d+\.\s/.test(a)){let i=[a];for(n++;n<o.length&&(/^[\-\*\+]\s/.test(o[n])||/^\d+\.\s/.test(o[n])||/^\s+/.test(o[n]));)i.push(o[n]),n++;s.push({type:"list",content:i.join(`
|
|
6
|
+
`)});continue}if(a.trim()){let i=[a];for(n++;n<o.length&&o[n].trim()&&!o[n].startsWith("#")&&!o[n].startsWith("```")&&!o[n].startsWith("|");)i.push(o[n]),n++;s.push({type:"paragraph",content:i.join(`
|
|
7
|
+
`)});continue}n++}return{filePath:t,title:r,nodes:s,rawContent:e}}function P(t,e,s){let r=[],o=!1,n=0;for(let a of t){if(a.type==="heading"){if(a.content.toLowerCase().includes(e.toLowerCase())){if(!s||a.level===s){o=!0,n=a.level;continue}}else if(o&&a.level<=n)break}o&&r.push(a)}return r}function B(){return{ejsH5:!1,ejsMiniProgram:!1,h5:!1,dingtalk:!1,wechat:!1,alipay:!1}}function _e(t){let e=t.replace(".md","").replace(/^\d+-/,""),s=e.match(/^([a-zA-Z\-]+)(.*)$/);return s?{name:s[1].toLowerCase(),displayName:s[2]||s[1]}:{name:e.toLowerCase(),displayName:e}}function Re(t){let e=t.split(A.sep);for(let s of e)if(s.includes("\u7EC4\u4EF6")||s.includes("UI"))return s.replace(/^\d+-/,"");return"\u5176\u4ED6"}function J(t){let e=[];if(t.length<2)return e;let s=t[0].map(l=>l.toLowerCase()),r=s.findIndex(l=>l.includes("\u53C2\u6570")||l.includes("name")||l.includes("\u5C5E\u6027")),o=s.findIndex(l=>l.includes("\u7C7B\u578B")||l.includes("type")),n=s.findIndex(l=>l.includes("\u9ED8\u8BA4")||l.includes("default")),a=s.findIndex(l=>l.includes("\u8BF4\u660E")||l.includes("\u63CF\u8FF0")||l.includes("description"));for(let l=1;l<t.length;l++){let i=t[l],c={name:r>=0&&i[r]?i[r].trim():"",type:o>=0&&i[o]?i[o].trim():"any",description:a>=0&&i[a]?i[a].trim():""};n>=0&&i[n]&&(c.default=i[n].trim()),c.name&&e.push(c)}return e}function Fe(t){let e=[];if(t.length<2)return e;let s=t[0].map(a=>a.toLowerCase()),r=s.findIndex(a=>a.includes("\u4E8B\u4EF6")||a.includes("name")||a.includes("\u540D")),o=s.findIndex(a=>a.includes("\u8BF4\u660E")||a.includes("\u63CF\u8FF0")),n=s.findIndex(a=>a.includes("\u53C2\u6570")||a.includes("\u56DE\u8C03"));for(let a=1;a<t.length;a++){let l=t[a],i={name:r>=0&&l[r]?l[r].trim():"",description:o>=0&&l[o]?l[o].trim():""};n>=0&&l[n]&&(i.params=l[n].trim()),i.name&&e.push(i)}return e}function He(t){let e=B();if(t.length<2)return e;let s=t[0].map(n=>n.toLowerCase()),r=t[1],o=[{keywords:["ejs","h5 \u5E94\u7528","h5\u5E94\u7528"],key:"ejsH5"},{keywords:["\u65B0\u70B9\u5C0F\u7A0B\u5E8F","ejs\u5C0F\u7A0B\u5E8F"],key:"ejsMiniProgram"},{keywords:["h5"],key:"h5"},{keywords:["\u9489\u9489"],key:"dingtalk"},{keywords:["\u5FAE\u4FE1"],key:"wechat"},{keywords:["\u652F\u4ED8\u5B9D"],key:"alipay"},{keywords:["weex"],key:"weex"}];for(let n=0;n<s.length&&n<r.length;n++){let a=s[n],l=r[n].trim().toLowerCase();for(let{keywords:i,key:c}of o)if(i.some(p=>a.includes(p))){l==="\u652F\u6301"||l==="\u662F"||l==="true"||l==="yes"?e[c]=!0:l==="\u4E0D\u652F\u6301"||l==="\u5426"||l==="false"||l==="no"?e[c]=!1:l&&(e[c]=r[n].trim());break}}return e}function We(t){let e=[],s="",r;for(let o of t)o.type==="heading"&&(s=o.content,o.content.includes("M8.3")||o.content.includes("vue2")?r="M8.3":(o.content.includes("M8.4")||o.content.includes("vue3"))&&(r="M8.4")),o.type==="code"&&o.language&&["html","vue","js","javascript","typescript"].includes(o.language.toLowerCase())&&e.push({title:s,code:o.content,language:o.language,frameworkVersion:r});return e}function ze(t){try{let e=M(t),s=A.basename(t),{name:r,displayName:o}=_e(s),n=Re(t),a="";for(let f of e.nodes)if(f.type==="paragraph"){a=f.content.split(`
|
|
8
|
+
`)[0];break}let l=[],i=P(e.nodes,"props");for(let f of i)if(f.type==="table"&&f.rows){l=J(f.rows);break}if(l.length===0){let f=P(e.nodes,"api");for(let m of f)if(m.type==="table"&&m.rows){l=J(m.rows);break}}let c=[],p=P(e.nodes,"events");for(let f of p)if(f.type==="table"&&f.rows){c=Fe(f.rows);break}let u=B();for(let f of e.nodes)if(f.type==="table"&&f.rows&&f.rows.length>=2){let m=f.rows[0].join(" ").toLowerCase();if(m.includes("\u5E73\u53F0")||m.includes("ejs")||m.includes("\u5FAE\u4FE1")){u=He(f.rows);break}}let d=We(e.nodes);return{name:r,displayName:o||e.title||r,description:a||e.title,category:n,props:l,events:c,examples:d,platformSupport:u,filePath:t}}catch(e){return console.error(`[ComponentParser] \u89E3\u6790\u7EC4\u4EF6\u6587\u6863\u5931\u8D25: ${t}`,e),null}}function K(t){let e=[],s=v(t);for(let r of s)if(r.includes("UI\u7EC4\u4EF6")||r.includes("009-")){let o=ze(r);o&&e.push(o)}return e}import*as S from"path";function Y(){return{ejsH5:!1,ejsMiniProgram:!1,h5:!1,dingtalk:!1,wechat:!1,alipay:!1}}function Je(t){let s=S.basename(t,".md").match(/api_(\w+)/);if(s)return s[1];let o=S.basename(S.dirname(t)).match(/api_(\w+)/);return o?o[1]:"unknown"}function Q(t){let e=[];if(t.length<2)return e;let s=t[0].map(l=>l.toLowerCase()),r=s.findIndex(l=>l.includes("\u53C2\u6570")||l.includes("name")),o=s.findIndex(l=>l.includes("\u7C7B\u578B")||l.includes("type")),n=s.findIndex(l=>l.includes("\u8BF4\u660E")||l.includes("\u63CF\u8FF0")),a=s.findIndex(l=>l.includes("\u5E73\u53F0")||l.includes("\u5DEE\u5F02"));for(let l=1;l<t.length;l++){let i=t[l],c={name:r>=0&&i[r]?i[r].trim():"",type:o>=0&&i[o]?i[o].trim():"any",description:n>=0&&i[n]?i[n].trim():""};a>=0&&i[a]&&(c.platformNote=i[a].trim()),(c.description.includes("\u5FC5\u586B")||c.description.includes("required"))&&(c.required=!0),c.name&&e.push(c)}return e}function Be(t){if(t.length<2)return;let e=Q(t);if(e.length!==0)return{type:"object",description:"\u8FD4\u56DE\u503C\u5BF9\u8C61",fields:e}}function Ke(t){let e=Y();if(t.length<2)return e;let s=t[0].map(n=>n.toLowerCase()),r=t[1],o=[{keywords:["ejs\uFF08h5 \u5E94\u7528","ejs\uFF08h5\u5E94\u7528","ejs(h5"],key:"ejsH5"},{keywords:["\u65B0\u70B9\u5C0F\u7A0B\u5E8F","ejs\uFF08\u65B0\u70B9"],key:"ejsMiniProgram"},{keywords:["h5"],key:"h5"},{keywords:["\u9489\u9489"],key:"dingtalk"},{keywords:["\u5FAE\u4FE1"],key:"wechat"},{keywords:["\u652F\u4ED8\u5B9D"],key:"alipay"},{keywords:["weex"],key:"weex"}];for(let n=0;n<s.length&&n<r.length;n++){let a=s[n],l=r[n].trim().toLowerCase();for(let{keywords:i,key:c}of o)if(i.some(p=>a.includes(p))){l==="\u652F\u6301"||l.includes("\u652F\u6301")?e[c]=!0:l==="\u4E0D\u652F\u6301"||l.includes("\u4E0D\u652F\u6301")?e[c]=!1:l&&(e[c]=r[n].trim());break}}return e}function Ge(t){let e=[/支持版本[::]\s*[`><=]*\s*([\d.]+)/,/版本\s*[`><=]*\s*([\d.]+)\s*开始支持/,/ejs\s*[><=]+\s*([\d.]+[a-z]*)/i,/v([\d.]+)\s*版本/];for(let s of e){let r=t.match(s);if(r)return r[1]}}function Ye(t){let e=[];try{let s=M(t),r=Je(t),o=null,n="",a=[];for(let l of s.nodes)l.type==="heading"&&l.level===2?(o&&o.name&&(G(o,a),e.push(o)),o={module:r,name:l.content.replace(/[`*]/g,"").trim(),description:"",params:[],examples:[],platformSupport:Y(),filePath:t},a=[],n=""):l.type==="heading"&&l.level===3&&o?n=l.content.toLowerCase():o&&(a.push({...l,_section:n}),l.type==="paragraph"&&!o.description&&(o.description=l.content.split(`
|
|
9
|
+
`)[0]));o&&o.name&&(G(o,a),e.push(o))}catch(s){console.error(`[EjsApiParser] \u89E3\u6790 API \u6587\u6863\u5931\u8D25: ${t}`,s)}return e}function G(t,e){for(let s of e){let r=s._section||"";if(s.type==="table"&&s.rows){let o=s.rows[0]?.join(" ").toLowerCase()||"";o.includes("\u5E73\u53F0")||o.includes("ejs")||o.includes("\u5FAE\u4FE1")?t.platformSupport=Ke(s.rows):r.includes("\u53C2\u6570")||o.includes("\u53C2\u6570")||o.includes("\u7C7B\u578B")?t.params=Q(s.rows):(r.includes("\u8FD4\u56DE")||o.includes("\u8FD4\u56DE"))&&(t.returns=Be(s.rows))}if(s.type==="code"&&s.language&&["js","javascript"].includes(s.language.toLowerCase())&&t.examples.push({title:r||"\u4F7F\u7528\u793A\u4F8B",code:s.content,language:s.language}),s.type==="paragraph"){let o=Ge(s.content);o&&!t.minVersion&&(t.minVersion=o)}}}function X(t){let e=[],s=v(t);for(let r of s){let o=S.basename(r);if(o.startsWith("api_")&&o.endsWith(".md")){let n=Ye(r);e.push(...n)}}return e}function q(){return{ejsH5:!1,ejsMiniProgram:!1,h5:!1,dingtalk:!1,wechat:!1,alipay:!1}}function Qe(t){let e=t.replace(/\\/g,"/");return e.includes("005-\u6838\u5FC3\u901A\u7528Util")?"\u6838\u5FC3\u901A\u7528Util":e.includes("006-Util\u5DE5\u5177\u96C6")?"Util\u5DE5\u5177\u96C6":e.includes("009-UI\u7EC4\u4EF6")?"UI\u7EC4\u4EF6":e.includes("003-\u5178\u578B\u6848\u4F8B")?"\u5178\u578B\u6848\u4F8B":e.includes("002-\u89C4\u8303\u4E0E\u6A21\u5F0F")?"\u89C4\u8303\u4E0E\u6A21\u5F0F":e.includes("017-\u5185\u7F6E\u7EC4\u4EF6")?"\u5185\u7F6E\u7EC4\u4EF6":e.includes("018-EPUI\u7EC4\u4EF6")?"EPUI\u7EC4\u4EF6":"\u5176\u4ED6"}function L(t){let e=[];if(t.length<2)return e;let s=t[0].map(i=>i.toLowerCase()),r=s.findIndex(i=>i.includes("\u53C2\u6570")||i.includes("name")),o=s.findIndex(i=>i.includes("\u7C7B\u578B")||i.includes("type")),n=s.findIndex(i=>i.includes("\u8BF4\u660E")||i.includes("\u63CF\u8FF0")),a=s.findIndex(i=>i.includes("\u5E73\u53F0")||i.includes("\u5DEE\u5F02")),l=s.findIndex(i=>i.includes("\u9ED8\u8BA4"));for(let i=1;i<t.length;i++){let c=t[i],p={name:r>=0&&c[r]?c[r].trim().replace(/`/g,""):"",type:o>=0&&c[o]?c[o].trim():"any",description:n>=0&&c[n]?c[n].trim():""};a>=0&&c[a]&&(p.platformNote=c[a].trim()),l>=0&&c[l]&&(p.default=c[l].trim()),(p.description.includes("\u5FC5\u586B")||p.description.includes("required"))&&(p.required=!0),p.name&&e.push(p)}return e}function Xe(t){if(t.length<2)return;let e=L(t);if(e.length!==0)return{type:"object",description:"\u8FD4\u56DE\u503C\u5BF9\u8C61",fields:e}}function Ze(t){let e=q();if(t.length<2)return e;let s=t[0].map(n=>n.toLowerCase()),r=t[1],o=[{keywords:["h5","ejs h5","ejs\uFF08h5"],key:"h5"},{keywords:["\u65B0\u70B9\u5C0F\u7A0B\u5E8F","ejs\u5C0F\u7A0B\u5E8F"],key:"ejsMiniProgram"},{keywords:["\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F","\u5FAE\u4FE1"],key:"wechat"},{keywords:["\u652F\u4ED8\u5B9D\u5C0F\u7A0B\u5E8F","\u652F\u4ED8\u5B9D"],key:"alipay"},{keywords:["\u9489\u9489"],key:"dingtalk"},{keywords:["weex"],key:"weex"}];for(let n=0;n<s.length&&n<r.length;n++){let a=s[n],l=r[n].trim();for(let{keywords:i,key:c}of o)if(i.some(p=>a.includes(p))){l==="\u221A"||l==="\u2713"||l.includes("\u652F\u6301")?e[c]=!0:l==="x"||l==="\xD7"||l.includes("\u4E0D\u652F\u6301")?e[c]=!1:l&&(e[c]=l);break}}return e}function qe(t){let e=[/`?v?([\d.]+)`?\s*版本/,/版本\s*`?v?([\d.]+)`?/,/`v([\d.]+[a-z\-\.]*)`/i];for(let s of e){let r=t.match(s);if(r)return r[1]}}function et(t){return{isM84:t.includes("::: ifdef M84")||t.includes("ifdef M84"),isM83:t.includes("::: ifdef M83")||t.includes("ifdef M83")}}function tt(t){let e=[];try{let s=M(t),r=Qe(t),o=null,n="",a=[],l="";for(let i of s.nodes){if(i.type==="heading"&&i.level===1){l=i.content;continue}if(i.type==="heading"&&(i.level===2||i.level===3)){let c=i.content.replace(/[`*()]/g,"").trim();if((i.content.includes("(")||/^[a-z]/.test(c)||c.includes("Util."))&&i.level<=3){o&&o.name&&(Z(o,a),e.push(o));let u=c;u.includes("(")&&(u=u.split("(")[0].trim()),u.includes("Util.")&&(u=u.replace("Util.","")),o={name:u,fullName:`Util.${u}`,category:r,description:"",params:[],examples:[],platformSupport:q(),filePath:t,usageScenario:l},a=[],n=""}else n=c.toLowerCase()}else o&&(a.push({...i,_section:n}),i.type==="paragraph"&&!o.description&&(o.description=i.content.split(`
|
|
10
|
+
`)[0]))}o&&o.name&&(Z(o,a),e.push(o))}catch(s){console.error(`[UtilParser] \u89E3\u6790 Util \u6587\u6863\u5931\u8D25: ${t}`,s)}return e}function Z(t,e){for(let s of e){let r=s._section||"";if(s.type==="table"&&s.rows){let o=s.rows[0]?.join(" ").toLowerCase()||"";o.includes("h5")||o.includes("\u5C0F\u7A0B\u5E8F")||o.includes("\u5FAE\u4FE1")?s.rows.length===2?t.platformSupport=Ze(s.rows):(r.includes("\u53C2\u6570")||o.includes("\u53C2\u6570")||o.includes("\u7C7B\u578B"))&&(t.params=L(s.rows)):r.includes("\u53C2\u6570")||o.includes("\u53C2\u6570")||o.includes("\u7C7B\u578B")?t.params=L(s.rows):(r.includes("\u8FD4\u56DE")||o.includes("\u8FD4\u56DE"))&&(t.returns=Xe(s.rows))}if(s.type==="code"&&s.language&&["js","javascript","ts","typescript","html","vue"].includes(s.language.toLowerCase())){let o={title:r||"\u4F7F\u7528\u793A\u4F8B",code:s.content,language:s.language},n=et(s.content);n.isM84?o.frameworkVersion="M8.4":n.isM83&&(o.frameworkVersion="M8.3"),t.examples.push(o)}if(s.type==="paragraph"){let o=qe(s.content);o&&!t.version&&(t.version=o)}}}function ee(t){let e=[],s=v(t),r=["005-\u6838\u5FC3\u901A\u7528Util","006-Util\u5DE5\u5177\u96C6"];for(let o of s){let n=o.replace(/\\/g,"/");if(r.some(a=>n.includes(a))){let a=tt(o);e.push(...a)}}return e}function te(t){let e=[t.name.toLowerCase(),t.fullName.toLowerCase()],s={ajax:["\u8BF7\u6C42","\u63A5\u53E3","http","request","fetch","post","get","\u8C03\u7528\u63A5\u53E3"],upload:["\u4E0A\u4F20","\u6587\u4EF6\u4E0A\u4F20","\u56FE\u7247\u4E0A\u4F20","file"],ajaxAll:["\u5E76\u53D1\u8BF7\u6C42","\u591A\u4E2A\u8BF7\u6C42","promise.all"],date:["\u65E5\u671F","\u65F6\u95F4","time","format"],string:["\u5B57\u7B26\u4E32","str","text"],storage:["\u5B58\u50A8","\u7F13\u5B58","cache","localstorage"],base64:["\u7F16\u7801","\u89E3\u7801","encode","decode"],sha1:["\u52A0\u5BC6","hash","\u7B7E\u540D"],sha256:["\u52A0\u5BC6","hash","\u7B7E\u540D"],cookie:["cookie","\u4F1A\u8BDD"]};if(s[t.name.toLowerCase()]&&e.push(...s[t.name.toLowerCase()]),t.description){let r=t.description.replace(/[,。、;:""''()【】]/g," ").split(/\s+/).filter(o=>o.length>=2);e.push(...r.slice(0,5))}return[...new Set(e)]}var D={\u6309\u94AE:["button","\u70B9\u51FB","\u63D0\u4EA4","\u786E\u8BA4"],\u70B9\u51FB:["button","\u6309\u94AE","click"],\u8F93\u5165\u6846:["input","field","\u6587\u672C\u6846","\u8F93\u5165","textarea"],\u8F93\u5165:["input","field","\u8F93\u5165\u6846"],\u6587\u672C\u6846:["input","field","\u8F93\u5165\u6846","textarea"],\u9009\u62E9\u5668:["picker","select","\u4E0B\u62C9","\u9009\u62E9"],\u9009\u62E9:["picker","select","\u9009\u62E9\u5668","radio","checkbox"],\u4E0B\u62C9:["picker","select","\u9009\u62E9\u5668","dropdown"],\u5355\u9009:["radio","\u5355\u9009\u6846"],\u591A\u9009:["checkbox","\u590D\u9009\u6846","\u591A\u9009\u6846"],\u5F39\u7A97:["dialog","popup","modal","\u5BF9\u8BDD\u6846","\u5F39\u51FA\u5C42"],\u5BF9\u8BDD\u6846:["dialog","\u5F39\u7A97","modal"],\u5F39\u51FA\u5C42:["popup","\u5F39\u7A97","dialog"],\u5217\u8868:["list","cell","\u8868\u683C","table"],\u8868\u683C:["table","list","\u5217\u8868"],\u5355\u5143\u683C:["cell","\u5217\u8868\u9879"],\u8868\u5355:["form","\u63D0\u4EA4","\u8F93\u5165"],\u63D0\u4EA4:["submit","form","\u8868\u5355"],\u65E5\u671F:["date","calendar","\u65F6\u95F4","\u65E5\u5386","datepicker"],\u65F6\u95F4:["time","date","\u65E5\u671F","timepicker"],\u65E5\u5386:["calendar","date","\u65E5\u671F"],\u4E0A\u4F20:["upload","uploader","\u6587\u4EF6"],\u6587\u4EF6:["file","upload","\u4E0A\u4F20"],\u56FE\u7247:["image","img","\u56FE\u50CF","\u7167\u7247","picture"],\u52A0\u8F7D:["loading","spinner","\u7B49\u5F85"],\u7B49\u5F85:["loading","waiting","\u52A0\u8F7D"],\u63D0\u793A:["toast","notify","message","\u6D88\u606F","alert"],\u6D88\u606F:["message","notify","\u63D0\u793A","toast"],\u901A\u77E5:["notify","notification","\u6D88\u606F"],\u5BFC\u822A:["nav","header","tabbar","\u6807\u7B7E\u680F","navigation"],\u6807\u7B7E\u680F:["tabbar","tab","\u5BFC\u822A"],\u6807\u7B7E\u9875:["tab","tabs","\u6807\u7B7E"],\u5237\u65B0:["refresh","minirefresh","\u4E0B\u62C9\u5237\u65B0"],\u4E0B\u62C9\u5237\u65B0:["minirefresh","refresh","\u5237\u65B0"],\u8BF7\u6C42:["ajax","http","fetch","\u63A5\u53E3","request"],\u63A5\u53E3:["api","ajax","\u8BF7\u6C42","http"],\u641C\u7D22:["search","\u67E5\u627E","\u67E5\u8BE2"],\u5F00\u5173:["switch","\u5207\u6362"],\u6ED1\u5757:["slider","\u6ED1\u52A8"],\u8FDB\u5EA6:["progress","\u8FDB\u5EA6\u6761"],\u8BC4\u5206:["rate","\u661F\u7EA7","\u8BC4\u4EF7"],\u6B65\u9AA4:["steps","\u6B65\u9AA4\u6761"],\u6298\u53E0:["collapse","\u5C55\u5F00"],\u6807\u7B7E:["tag","\u6807\u8BB0"],\u5FBD\u6807:["badge","\u89D2\u6807"],\u7A7A\u72B6\u6001:["empty","\u65E0\u6570\u636E"],\u9AA8\u67B6\u5C4F:["skeleton","\u52A0\u8F7D\u5360\u4F4D"]};function U(t){let e=t.toLowerCase(),s=new Set([e]);if(D[t])for(let r of D[t])s.add(r.toLowerCase());for(let[r,o]of Object.entries(D))if(o.some(n=>n.toLowerCase()===e)){s.add(r.toLowerCase());for(let n of o)s.add(n.toLowerCase())}return Array.from(s)}function st(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ot(t,e,s){let r=t.toLowerCase(),o=e.toLowerCase(),n=s?.toLowerCase()||"";if(o===r||n===r)return 100;try{let i=new RegExp(`\\b${st(r)}\\b`,"i");if(i.test(o)||i.test(n))return 95}catch{}if(o.startsWith(r)||n.startsWith(r))return 85;if(o.includes(r)||n.includes(r))return 75;let a=U(t);for(let i of a)if(i!==r){if(o===i||n===i)return 65;if(o.includes(i)||n.includes(i))return 60}let l=0;for(let i of r)(o.includes(i)||n.includes(i))&&l++;return Math.min(55,Math.floor(l/r.length*55))}async function oe(t,e){console.error("[Index] \u5F00\u59CB\u6784\u5EFA\u7D22\u5F15..."),console.error(`[Index] EJS \u6587\u6863\u8DEF\u5F84: ${t}`),console.error(`[Index] M8 \u6587\u6863\u8DEF\u5F84: ${e}`);let s=K(e);console.error(`[Index] \u89E3\u6790\u5230 ${s.length} \u4E2A\u7EC4\u4EF6`);let r=X(t);console.error(`[Index] \u89E3\u6790\u5230 ${r.length} \u4E2A API`);let o=ee(e);console.error(`[Index] \u89E3\u6790\u5230 ${o.length} \u4E2A Util \u65B9\u6CD5`);let n={components:new Map,ejsApis:new Map,utilMethods:new Map,standards:new Map,keywords:new Map,categories:new Map,buildTime:new Date};for(let a of s){let l=`component:${a.name}`;n.components.set(a.name,a);let i=se(a.name,a.displayName,a.description);for(let p of i){let u=n.keywords.get(p)||[];u.push(l),n.keywords.set(p,u)}let c=n.categories.get(a.category)||[];c.push(l),n.categories.set(a.category,c)}for(let a of r){let l=`api:${a.module}.${a.name}`;n.ejsApis.set(`${a.module}.${a.name}`,a);let i=se(a.name,a.module,a.description);for(let p of i){let u=n.keywords.get(p)||[];u.push(l),n.keywords.set(p,u)}let c=n.categories.get(`module:${a.module}`)||[];c.push(l),n.categories.set(`module:${a.module}`,c)}for(let a of o){let l=`util:${a.name}`;n.utilMethods.set(a.name.toLowerCase(),a);let i=te(a);for(let p of i){let u=n.keywords.get(p)||[];u.push(l),n.keywords.set(p,u)}let c=n.categories.get(`util:${a.category}`)||[];c.push(l),n.categories.set(`util:${a.category}`,c)}return console.error(`[Index] \u7D22\u5F15\u6784\u5EFA\u5B8C\u6210\uFF0C\u5173\u952E\u8BCD\u6570: ${n.keywords.size}`),n}function se(...t){let e=new Set;for(let s of t){if(!s)continue;let r=s.toLowerCase();e.add(r);let o=r.split(/[\s\-_,.,。、;:""''()【】]+/);for(let a of o)a.length>=2&&e.add(a);let n=s.match(/[\u4e00-\u9fa5]+/g);if(n)for(let a of n){e.add(a);for(let l of a)e.add(l)}}return Array.from(e)}function $(t,e,s,r){return ot(t,e,r)}function T(t,e){let r={ejsh5:"ejsH5",ejs:"ejsH5",ejsminiprogram:"ejsMiniProgram",h5:"h5",dingtalk:"dingtalk",wechat:"wechat",alipay:"alipay",weex:"weex"}[e.toLowerCase()];if(!r)return!0;let o=t[r];return o===!0||typeof o=="string"&&o.length>0}function O(t,e,s={}){let r=[],o=e.toLowerCase(),a=s.enableSynonyms!==!1?U(e):[o];for(let[l,i]of t.components){if(s.category&&i.category!==s.category||s.platform&&!T(i.platformSupport,s.platform))continue;let c=0;c=Math.max(c,$(e,l,!0,i.displayName));for(let p of a)if(p!==o){let u=$(p,l,!0,i.displayName);c=Math.max(c,Math.min(u,65))}for(let p of a)if(i.description.toLowerCase().includes(p)){c=Math.max(c,50);break}for(let p of a)if(t.keywords.get(p)?.includes(`component:${l}`)){c=Math.max(c,55);break}c>0&&r.push({type:"component",id:`component:${l}`,name:l,displayName:i.displayName,description:i.description,score:c,platformSupport:i.platformSupport,category:i.category})}return r.sort((l,i)=>i.score-l.score),s.limit?r.slice(0,s.limit):r}function V(t,e,s={}){let r=[],o=e.toLowerCase(),a=s.enableSynonyms!==!1?U(e):[o];for(let[l,i]of t.ejsApis){if(s.module&&i.module!==s.module||s.platform&&!T(i.platformSupport,s.platform))continue;let c=0,p=`ejs.${i.module}.${i.name}`;c=Math.max(c,$(e,i.name,!0,p)),c=Math.max(c,$(e,`${i.module}.${i.name}`,!0)),i.module.toLowerCase()===o&&(c=Math.max(c,80));for(let u of a)if(u!==o){let d=$(u,i.name,!0,p);c=Math.max(c,Math.min(d,65))}for(let u of a)if(i.description.toLowerCase().includes(u)){c=Math.max(c,50);break}for(let u of a)if(t.keywords.get(u)?.includes(`api:${l}`)){c=Math.max(c,55);break}c>0&&r.push({type:"ejsApi",id:`api:${l}`,name:i.name,displayName:p,description:i.description,score:c,platformSupport:i.platformSupport,category:i.module})}return r.sort((l,i)=>i.score-l.score),s.limit?r.slice(0,s.limit):r}function E(t,e,s={}){let r=[],o=e.toLowerCase(),n=["ajax","\u8BF7\u6C42","http","request","fetch","post","get","\u63A5\u53E3","\u8C03\u7528\u63A5\u53E3"],a=["\u4E0A\u4F20","upload","\u6587\u4EF6\u4E0A\u4F20","\u56FE\u7247\u4E0A\u4F20"],l=n.some(c=>o.includes(c)),i=a.some(c=>o.includes(c));for(let[c,p]of t.utilMethods){if(s.category&&p.category!==s.category||s.platform&&!T(p.platformSupport,s.platform))continue;let u=0;u=Math.max(u,$(e,c,!0)),u=Math.max(u,$(e,p.fullName,!0)),p.description.toLowerCase().includes(o)&&(u=Math.max(u,50)),t.keywords.get(o)?.includes(`util:${c}`)&&(u=Math.max(u,60)),l&&c==="ajax"&&(u=Math.max(u,95)),i&&c==="upload"&&(u=Math.max(u,95)),u>0&&r.push({type:"util",id:`util:${c}`,name:p.name,displayName:p.fullName,description:p.description,score:u,platformSupport:p.platformSupport,category:p.category})}return r.sort((c,p)=>p.score-c.score),s.limit?r.slice(0,s.limit):r}function re(t,e,s={}){let r=O(t,e,s),o=V(t,e,s),a=[...E(t,e,s),...r,...o];return a.sort((l,i)=>i.score-l.score),s.limit?a.slice(0,s.limit):a}function ne(t,e,s={}){return!e||e.trim().length===0?[]:O(t,e.trim(),{...s,limit:s.limit||20})}function ae(t,e,s={}){return!e||e.trim().length===0?[]:V(t,e.trim(),{...s,limit:s.limit||20})}function ie(t,e){if(!e||e.trim().length===0)return{found:!1,error:"\u8BF7\u63D0\u4F9B\u7EC4\u4EF6\u540D\u79F0"};let s=e.toLowerCase().trim(),r=t.components.get(s);if(r)return{found:!0,component:r};let o=[];for(let[n,a]of t.components)(n.includes(s)||s.includes(n)||a.displayName.toLowerCase().includes(s))&&o.push(n);return{found:!1,error:`\u672A\u627E\u5230\u7EC4\u4EF6: ${e}`,suggestions:o.slice(0,5)}}function le(t,e,s){if(!e||!s)return{found:!1,error:"\u8BF7\u63D0\u4F9B\u6A21\u5757\u540D\u548C API \u540D\u79F0"};let r=`${e.toLowerCase()}.${s.toLowerCase()}`,o=t.ejsApis.get(r);if(o){let a=[];for(let[l,i]of t.ejsApis)i.module===o.module&&l!==r&&a.push(i.name);return{found:!0,api:o,relatedApis:a.slice(0,5)}}let n=[];for(let[a,l]of t.ejsApis)(a.includes(s.toLowerCase())||l.name.toLowerCase().includes(s.toLowerCase()))&&n.push(`${l.module}.${l.name}`);return{found:!1,error:`\u672A\u627E\u5230 API: ejs.${e}.${s}`,suggestions:n.slice(0,5)}}var ce={ajax:{components:[],apis:[],utils:["ajax"]},\u8BF7\u6C42:{components:[],apis:[],utils:["ajax"]},http:{components:[],apis:[],utils:["ajax"]},\u63A5\u53E3:{components:[],apis:[],utils:["ajax"]},\u8C03\u7528\u63A5\u53E3:{components:[],apis:[],utils:["ajax"]},fetch:{components:[],apis:[],utils:["ajax"]},post:{components:[],apis:[],utils:["ajax"]},get\u8BF7\u6C42:{components:[],apis:[],utils:["ajax"]},\u8868\u5355:{components:["form","field","input"],apis:[],utils:[]},\u8F93\u5165:{components:["field","input","textarea"],apis:[],utils:[]},\u9009\u62E9:{components:["picker","select","radio","checkbox"],apis:["ui.select"],utils:[]},\u65E5\u671F:{components:["datepicker","calendar"],apis:["ui.pickDate","ui.pickDateTime"],utils:["date"]},\u65F6\u95F4:{components:["datepicker"],apis:["ui.pickTime","ui.pickDateTime"],utils:["date"]},\u4E0A\u4F20:{components:["uploader"],apis:[],utils:["upload"]},\u6587\u4EF6:{components:["uploader"],apis:["io.chooseFile","io.downloadFile"],utils:["upload"]},\u6587\u4EF6\u4E0A\u4F20:{components:["uploader"],apis:[],utils:["upload"]},\u56FE\u7247\u4E0A\u4F20:{components:["uploader"],apis:["io.chooseImage"],utils:["upload"]},\u5217\u8868:{components:["cell","minirefresh"],apis:[],utils:[]},\u4E0B\u62C9\u5237\u65B0:{components:["minirefresh"],apis:[],utils:[]},\u52A0\u8F7D\u66F4\u591A:{components:["minirefresh"],apis:[],utils:[]},\u5F39\u7A97:{components:["dialog","popup"],apis:["ui.alert","ui.confirm"],utils:[]},\u63D0\u793A:{components:["toast","notify"],apis:["ui.toast","ui.alert"],utils:[]},\u786E\u8BA4:{components:["dialog"],apis:["ui.confirm"],utils:[]},\u52A0\u8F7D:{components:["loading"],apis:["ui.showWaiting","ui.closeWaiting"],utils:[]},\u5BFC\u822A:{components:["header","tabbar","tab"],apis:["navigator.push","navigator.pop"],utils:[]},\u6807\u7B7E\u9875:{components:["tab"],apis:[],utils:[]},\u5E95\u90E8\u680F:{components:["tabbar"],apis:[],utils:[]},\u62CD\u7167:{components:[],apis:["device.camera","io.chooseImage"],utils:[]},\u626B\u7801:{components:[],apis:["device.scan"],utils:[]},\u5B9A\u4F4D:{components:["amap"],apis:["device.getLocation"],utils:[]},\u5730\u56FE:{components:["amap"],apis:["device.getLocation"],utils:[]},\u7535\u8BDD:{components:[],apis:["device.callPhone"],utils:[]},\u5206\u4EAB:{components:[],apis:["device.sendTo"],utils:[]},\u5B58\u50A8:{components:[],apis:["storage.setItem","storage.getItem"],utils:["storage"]},\u7F13\u5B58:{components:[],apis:["storage.setItem","storage.getItem","storage.clear"],utils:["storage"]},\u65E5\u671F\u683C\u5F0F:{components:[],apis:[],utils:["date"]},\u5B57\u7B26\u4E32:{components:[],apis:[],utils:["string"]},\u52A0\u5BC6:{components:[],apis:[],utils:["sha1","sha256","base64"]},\u7F16\u7801:{components:[],apis:[],utils:["base64","charset"]},\u56FE\u7247:{components:["image","imagepreview"],apis:["io.chooseImage"],utils:[]},\u8F6E\u64AD:{components:["swipe"],apis:[],utils:[]},\u6B65\u9AA4:{components:["steps"],apis:[],utils:[]},\u8FDB\u5EA6:{components:["progress","circle"],apis:[],utils:[]},\u8BC4\u5206:{components:["rate"],apis:[],utils:[]},\u641C\u7D22:{components:["search"],apis:[],utils:[]},\u5F00\u5173:{components:["switch"],apis:[],utils:[]},\u6ED1\u5757:{components:["slider"],apis:[],utils:[]},\u6298\u53E0:{components:["collapse"],apis:[],utils:[]},\u6807\u7B7E:{components:["tag"],apis:[],utils:[]},\u5FBD\u6807:{components:["badge"],apis:[],utils:[]},\u7A7A\u72B6\u6001:{components:["empty"],apis:[],utils:[]},\u9AA8\u67B6\u5C4F:{components:["skeleton"],apis:[],utils:[]}},rt={ajax:"\u63A8\u8350\u4F7F\u7528 Util.ajax \u8FDB\u884C HTTP \u8BF7\u6C42\uFF0C\u5B83\u662F M8 \u6846\u67B6\u5BF9 axios \u7684\u5C01\u88C5\uFF0C\u652F\u6301\u81EA\u52A8\u4EE3\u7406\u3001token \u5904\u7406\u3001\u8BF7\u6C42\u53D6\u6D88\u7B49\u529F\u80FD\u3002",upload:"\u63A8\u8350\u4F7F\u7528 Util.upload \u8FDB\u884C\u6587\u4EF6\u4E0A\u4F20\uFF0C\u652F\u6301\u8DE8\u7AEF\uFF08H5\u3001\u5FAE\u4FE1\u3001\u652F\u4ED8\u5B9D\u5C0F\u7A0B\u5E8F\uFF09\uFF0C\u4F7F\u7528 filePath \u65B9\u5F0F\u53EF\u5B9E\u73B0\u6700\u4F73\u517C\u5BB9\u6027\u3002",date:"Util.date \u63D0\u4F9B\u65E5\u671F\u683C\u5F0F\u5316\u548C\u5904\u7406\u529F\u80FD\uFF0C\u652F\u6301\u591A\u79CD\u683C\u5F0F\u8F6C\u6362\u3002",storage:"Util.storage \u63D0\u4F9B\u672C\u5730\u5B58\u50A8\u529F\u80FD\uFF0C\u662F\u5BF9 localStorage \u7684\u5C01\u88C5\uFF0C\u652F\u6301\u8DE8\u7AEF\u4F7F\u7528\u3002",string:"Util.string \u63D0\u4F9B\u5B57\u7B26\u4E32\u5904\u7406\u5DE5\u5177\u65B9\u6CD5\u3002",base64:"Util.base64 \u63D0\u4F9B Base64 \u7F16\u7801\u89E3\u7801\u529F\u80FD\u3002",sha1:"Util.sha1 \u63D0\u4F9B SHA1 \u52A0\u5BC6\u529F\u80FD\u3002",sha256:"Util.sha256 \u63D0\u4F9B SHA256 \u52A0\u5BC6\u529F\u80FD\u3002"};function nt(t){let e=[],s=t.toLowerCase();for(let r of Object.keys(ce))s.includes(r)&&e.push(r);return e}function _(t,e){if(!e)return!0;let r={ejsh5:"ejsH5",ejs:"ejsH5",h5:"h5",wechat:"wechat",alipay:"alipay",dingtalk:"dingtalk"}[e.toLowerCase()];if(!r)return!0;let o=t[r];return o===!0||typeof o=="string"&&o.length>0}function pe(t,e,s){let r=[],o=[],n=[],a=new Set,l=new Set,i=new Set,c=nt(e);for(let u of c){let d=ce[u];if(d){for(let f of d.utils||[]){if(i.has(f))continue;let m=t.utilMethods?.get(f.toLowerCase());m&&_(m.platformSupport,s)&&(i.add(f),n.push({type:"util",name:m.name,displayName:m.fullName,description:m.description,reason:`\u5339\u914D\u9700\u6C42\u5173\u952E\u8BCD: ${u}`,score:95,platformSupport:m.platformSupport,usageTip:rt[f.toLowerCase()]}))}for(let f of d.components){if(a.has(f))continue;let m=t.components.get(f);m&&_(m.platformSupport,s)&&(a.add(f),r.push({type:"component",name:f,displayName:m.displayName,description:m.description,reason:`\u5339\u914D\u9700\u6C42\u5173\u952E\u8BCD: ${u}`,score:80,platformSupport:m.platformSupport}))}for(let f of d.apis){if(l.has(f))continue;let[m,I]=f.split("."),g=t.ejsApis.get(`${m}.${I}`);g&&_(g.platformSupport,s)&&(l.add(f),o.push({type:"ejsApi",name:g.name,displayName:`ejs.${g.module}.${g.name}`,description:g.description,reason:`\u5339\u914D\u9700\u6C42\u5173\u952E\u8BCD: ${u}`,score:70,platformSupport:g.platformSupport}))}}}if(r.length<3||o.length<2){let u=re(t,e,{limit:10,platform:s});for(let d of u)if(d.type==="component"&&!a.has(d.name)){if(r.length<5){a.add(d.name);let f=t.components.get(d.name);f&&r.push({type:"component",name:d.name,displayName:f.displayName,description:f.description,reason:"\u6839\u636E\u9700\u6C42\u63CF\u8FF0\u641C\u7D22\u5339\u914D",score:d.score,platformSupport:f.platformSupport})}}else if(d.type==="ejsApi"&&!l.has(d.name)&&o.length<5){let f=d.id.replace("api:","");l.add(d.name);let m=t.ejsApis.get(f);m&&o.push({type:"ejsApi",name:m.name,displayName:`ejs.${m.module}.${m.name}`,description:m.description,reason:"\u6839\u636E\u9700\u6C42\u63CF\u8FF0\u641C\u7D22\u5339\u914D",score:d.score,platformSupport:m.platformSupport})}}n.sort((u,d)=>d.score-u.score),r.sort((u,d)=>d.score-u.score),o.sort((u,d)=>d.score-u.score);let p="";if(n.length>0||r.length>0||o.length>0){if(p=`\u6839\u636E\u60A8\u7684\u9700\u6C42"${e}"\uFF0C\u63A8\u8350\u4EE5\u4E0B\u65B9\u6848\uFF1A
|
|
11
|
+
|
|
12
|
+
`,n.length>0){p+=`**\u63A8\u8350\u5DE5\u5177\u65B9\u6CD5\uFF1A** ${n.map(d=>d.displayName).join("\u3001")}
|
|
13
|
+
`;let u=n.filter(d=>d.usageTip).map(d=>`- ${d.usageTip}`);u.length>0&&(p+=`
|
|
14
|
+
${u.join(`
|
|
15
|
+
`)}
|
|
16
|
+
`)}r.length>0&&(p+=`
|
|
17
|
+
**UI \u7EC4\u4EF6\uFF1A** ${r.map(u=>u.displayName||u.name).join("\u3001")}
|
|
18
|
+
`),o.length>0&&(p+=`
|
|
19
|
+
**EJS API\uFF1A** ${o.map(u=>u.displayName).join("\u3001")}
|
|
20
|
+
`,n.length>0&&(p+=`
|
|
21
|
+
> \u6CE8\u610F\uFF1A\u5EFA\u8BAE\u4F18\u5148\u4F7F\u7528 Util \u5DE5\u5177\u65B9\u6CD5\uFF0C\u5B83\u4EEC\u662F\u6846\u67B6\u5C01\u88C5\u7684\u9AD8\u7EA7 API\uFF0C\u63D0\u4F9B\u66F4\u597D\u7684\u8DE8\u7AEF\u517C\u5BB9\u6027\u548C\u9519\u8BEF\u5904\u7406\u3002EJS API \u9002\u7528\u4E8E\u9700\u8981\u76F4\u63A5\u8C03\u7528\u539F\u751F\u80FD\u529B\u7684\u573A\u666F\u3002
|
|
22
|
+
`)),s&&(p+=`
|
|
23
|
+
\u4EE5\u4E0A\u63A8\u8350\u5747\u652F\u6301 ${s} \u5E73\u53F0\u3002`)}else p=`\u672A\u627E\u5230\u4E0E"${e}"\u76F4\u63A5\u76F8\u5173\u7684\u7EC4\u4EF6\u6216 API\uFF0C\u5EFA\u8BAE\u5C1D\u8BD5\u66F4\u5177\u4F53\u7684\u63CF\u8FF0\u6216\u4F7F\u7528\u641C\u7D22\u529F\u80FD\u3002`;return{components:r,apis:o,utils:n,summary:p}}var at="@anthropic/em-ui";function R(t){return`em-${t}`}function ue(t){return`import Em${t.split("-").map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join("")} from '${at}/lib/${t}';`}function it(t){let e=t.getFullYear(),s=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0"),o=String(t.getHours()).padStart(2,"0"),n=String(t.getMinutes()).padStart(2,"0"),a=String(t.getSeconds()).padStart(2,"0");return`${e}-${s}-${r} ${o}:${n}:${a}`}function fe(t){let s=it(new Date);return`<!--
|
|
24
|
+
* @\u4F5C\u8005: ${t.author||"\u5F00\u53D1\u8005"}
|
|
25
|
+
* @\u521B\u5EFA\u65F6\u95F4: ${s}
|
|
26
|
+
* @\u4FEE\u6539\u65F6\u95F4: ${s}
|
|
27
|
+
* @\u7248\u672C: [${t.version||"1.0"}]
|
|
28
|
+
* @\u7248\u6743: ${t.copyright||"\u56FD\u6CF0\u65B0\u70B9\u8F6F\u4EF6\u80A1\u4EFD\u6709\u9650\u516C\u53F8"}
|
|
29
|
+
* @\u63CF\u8FF0: ${t.description}
|
|
30
|
+
-->`}function de(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}function lt(t){let e=de(t);return`/**
|
|
31
|
+
* ${t} \u7EC4\u4EF6\u6837\u5F0F
|
|
32
|
+
* \u9075\u5FAA M8 \u6846\u67B6\u6837\u5F0F\u89C4\u8303
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
.${e}-container {
|
|
36
|
+
// \u5BB9\u5668\u57FA\u7840\u6837\u5F0F
|
|
37
|
+
padding: 16px;
|
|
38
|
+
|
|
39
|
+
// \u5185\u5BB9\u533A\u57DF\u6837\u5F0F
|
|
40
|
+
.${e}-content {
|
|
41
|
+
// TODO: \u6DFB\u52A0\u5185\u5BB9\u6837\u5F0F
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// \u64CD\u4F5C\u533A\u57DF\u6837\u5F0F
|
|
45
|
+
.${e}-actions {
|
|
46
|
+
margin-top: 16px;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
`}function me(t){let e=de(t.componentName),s=t.styleLineCount||0;return t.useExternalFile||s>20?{styleTag:`<style lang="scss" scoped>
|
|
50
|
+
@import './css/${e}.scss';
|
|
51
|
+
</style>`,externalFile:{path:`./css/${e}.scss`,content:lt(t.componentName)}}:{styleTag:`<style lang="scss" scoped>
|
|
52
|
+
.${e}-container {
|
|
53
|
+
padding: 16px;
|
|
54
|
+
}
|
|
55
|
+
</style>`}}function ct(t,e,s){return e==="M8.4"?ut(t,s):pt(t,s)}function pt(t,e){let s=R(t.name),o=`${fe({description:`${t.displayName}\u7EC4\u4EF6\u793A\u4F8B`})}
|
|
56
|
+
<template>
|
|
57
|
+
<div class="${t.name}-container">
|
|
58
|
+
<!-- ${t.displayName}\u7EC4\u4EF6 -->
|
|
59
|
+
<${s}`,n=t.props.slice(0,3);for(let i of n)i.name==="value"||i.name==="v-model"?o+=`
|
|
60
|
+
v-model="${t.name}Value"`:i.type==="boolean"?o+=`
|
|
61
|
+
:${i.name}="${i.default||"false"}"`:i.type==="string"&&(o+=`
|
|
62
|
+
${i.name}="${i.default||""}"`);if(t.events.length>0){let i=t.events[0];o+=`
|
|
63
|
+
@${i.name}="on${w(i.name)}"`}o+=`
|
|
22
64
|
/>
|
|
23
65
|
</div>
|
|
24
|
-
</template>`,
|
|
66
|
+
</template>`,e&&(o=he(o,e));let a=`<script>
|
|
25
67
|
/**
|
|
26
|
-
* ${
|
|
68
|
+
* ${t.displayName}\u7EC4\u4EF6\u793A\u4F8B
|
|
27
69
|
* \u6846\u67B6\u7248\u672C: M8.3 (Vue2)
|
|
70
|
+
*
|
|
71
|
+
* \u4F7F\u7528\u8BF4\u660E\uFF1A
|
|
72
|
+
* - \u8BE5\u7EC4\u4EF6\u5C55\u793A\u4E86 ${t.displayName} \u7684\u57FA\u672C\u7528\u6CD5
|
|
73
|
+
* - \u53EF\u6839\u636E\u5B9E\u9645\u9700\u6C42\u4FEE\u6539\u5C5E\u6027\u548C\u4E8B\u4EF6\u5904\u7406
|
|
28
74
|
*/
|
|
29
75
|
export default {
|
|
30
|
-
name: '${
|
|
76
|
+
name: '${w(t.name)}Demo',
|
|
31
77
|
|
|
32
78
|
data() {
|
|
33
79
|
return {
|
|
34
|
-
// ${
|
|
35
|
-
${
|
|
80
|
+
// ${t.displayName}\u7684\u7ED1\u5B9A\u503C
|
|
81
|
+
${t.name}Value: ${ge(t.props[0])}
|
|
36
82
|
};
|
|
37
83
|
},
|
|
38
84
|
|
|
39
85
|
methods: {
|
|
40
86
|
/**
|
|
41
|
-
* ${
|
|
87
|
+
* \u5904\u7406${t.displayName}\u4E8B\u4EF6
|
|
88
|
+
* ${t.events[0]?.description||"\u5F53\u7EC4\u4EF6\u503C\u53D8\u5316\u65F6\u89E6\u53D1"}
|
|
89
|
+
* @param {any} value - \u53D8\u5316\u540E\u7684\u503C
|
|
42
90
|
*/
|
|
43
|
-
on${
|
|
44
|
-
console.log('${
|
|
45
|
-
// TODO: \u5904\u7406${
|
|
91
|
+
on${w(t.events[0]?.name||"Change")}(value) {
|
|
92
|
+
console.log('${t.displayName}\u503C\u53D8\u5316:', value);
|
|
93
|
+
// TODO: \u5728\u6B64\u5904\u7406${t.displayName}\u4E8B\u4EF6\u903B\u8F91
|
|
46
94
|
}
|
|
47
95
|
}
|
|
48
96
|
};
|
|
49
|
-
</script>`,a
|
|
50
|
-
.${e.name}-container {
|
|
51
|
-
padding: 16px;
|
|
52
|
-
}
|
|
53
|
-
</style>`;return{template:n,script:i,style:a,imports:[`import Ne${g(e.name)} from '@anthropic/ne-ui/lib/${e.name}';`],explanation:`\u8FD9\u662F ${e.displayName} \u7EC4\u4EF6\u7684 M8.3 (Vue2) \u793A\u4F8B\u4EE3\u7801\u3002
|
|
97
|
+
</script>`,l=me({componentName:t.name,useExternalFile:!1});return{template:o,script:a,style:l.styleTag,imports:[ue(t.name)],explanation:`\u8FD9\u662F ${t.displayName} \u7EC4\u4EF6\u7684 M8.3 (Vue2) \u793A\u4F8B\u4EE3\u7801\u3002
|
|
54
98
|
- \u4F7F\u7528 Options API \u98CE\u683C
|
|
55
|
-
- \u5305\u542B\
|
|
56
|
-
- \
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
${
|
|
63
|
-
|
|
99
|
+
- \u5305\u542B\u6807\u51C6\u6587\u4EF6\u5934\u6CE8\u91CA\uFF08\u4F5C\u8005\u3001\u65F6\u95F4\u3001\u7248\u672C\u3001\u7248\u6743\u3001\u63CF\u8FF0\uFF09
|
|
100
|
+
- \u5305\u542B\u4E2D\u6587\u6CE8\u91CA\u8BF4\u660E\u4EE3\u7801\u903B\u8F91
|
|
101
|
+
- \u53EF\u6839\u636E\u5B9E\u9645\u9700\u6C42\u4FEE\u6539\u5C5E\u6027\u548C\u4E8B\u4EF6`,frameworkVersion:"M8.3"}}function ut(t,e){let s=R(t.name),o=`${fe({description:`${t.displayName}\u7EC4\u4EF6\u793A\u4F8B`})}
|
|
102
|
+
<template>
|
|
103
|
+
<div class="${t.name}-container">
|
|
104
|
+
<!-- ${t.displayName}\u7EC4\u4EF6 -->
|
|
105
|
+
<${s}`,n=t.props.slice(0,3);for(let i of n)i.name==="value"||i.name==="v-model"?o+=`
|
|
106
|
+
v-model="${t.name}Value"`:i.type==="boolean"?o+=`
|
|
107
|
+
:${i.name}="${i.default||"false"}"`:i.type==="string"&&(o+=`
|
|
108
|
+
${i.name}="${i.default||""}"`);if(t.events.length>0){let i=t.events[0];o+=`
|
|
109
|
+
@${i.name}="on${w(i.name)}"`}o+=`
|
|
64
110
|
/>
|
|
65
111
|
</div>
|
|
66
|
-
</template>`,
|
|
112
|
+
</template>`,e&&(o=he(o,e));let a=`<script setup>
|
|
67
113
|
/**
|
|
68
|
-
* ${
|
|
114
|
+
* ${t.displayName}\u7EC4\u4EF6\u793A\u4F8B
|
|
69
115
|
* \u6846\u67B6\u7248\u672C: M8.4 (Vue3 Composition API)
|
|
116
|
+
*
|
|
117
|
+
* \u4F7F\u7528\u8BF4\u660E\uFF1A
|
|
118
|
+
* - \u8BE5\u7EC4\u4EF6\u5C55\u793A\u4E86 ${t.displayName} \u7684\u57FA\u672C\u7528\u6CD5
|
|
119
|
+
* - \u4F7F\u7528 Composition API \u548C <script setup> \u8BED\u6CD5
|
|
120
|
+
* - \u53EF\u6839\u636E\u5B9E\u9645\u9700\u6C42\u4FEE\u6539\u5C5E\u6027\u548C\u4E8B\u4EF6\u5904\u7406
|
|
70
121
|
*/
|
|
71
122
|
import { ref } from 'vue';
|
|
72
123
|
|
|
73
|
-
//
|
|
74
|
-
|
|
124
|
+
// ============================================
|
|
125
|
+
// \u54CD\u5E94\u5F0F\u6570\u636E\u5B9A\u4E49
|
|
126
|
+
// ============================================
|
|
127
|
+
|
|
128
|
+
/** ${t.displayName}\u7684\u7ED1\u5B9A\u503C */
|
|
129
|
+
const ${t.name}Value = ref(${ge(t.props[0])});
|
|
130
|
+
|
|
131
|
+
// ============================================
|
|
132
|
+
// \u4E8B\u4EF6\u5904\u7406\u65B9\u6CD5
|
|
133
|
+
// ============================================
|
|
75
134
|
|
|
76
135
|
/**
|
|
77
|
-
* ${
|
|
136
|
+
* \u5904\u7406${t.displayName}\u4E8B\u4EF6
|
|
137
|
+
* ${t.events[0]?.description||"\u5F53\u7EC4\u4EF6\u503C\u53D8\u5316\u65F6\u89E6\u53D1"}
|
|
138
|
+
* @param value - \u53D8\u5316\u540E\u7684\u503C
|
|
78
139
|
*/
|
|
79
|
-
function on${
|
|
80
|
-
console.log('${
|
|
81
|
-
// TODO: \u5904\u7406${
|
|
82
|
-
}
|
|
83
|
-
</script>`,a=`<style scoped>
|
|
84
|
-
.${e.name}-container {
|
|
85
|
-
padding: 16px;
|
|
140
|
+
function on${w(t.events[0]?.name||"Change")}(value) {
|
|
141
|
+
console.log('${t.displayName}\u503C\u53D8\u5316:', value);
|
|
142
|
+
// TODO: \u5728\u6B64\u5904\u7406${t.displayName}\u4E8B\u4EF6\u903B\u8F91
|
|
86
143
|
}
|
|
87
|
-
</
|
|
144
|
+
</script>`,l=me({componentName:t.name,useExternalFile:!1});return{template:o,script:a,style:l.styleTag,imports:[],explanation:`\u8FD9\u662F ${t.displayName} \u7EC4\u4EF6\u7684 M8.4 (Vue3) \u793A\u4F8B\u4EE3\u7801\u3002
|
|
88
145
|
- \u4F7F\u7528 Composition API \u548C <script setup> \u8BED\u6CD5
|
|
89
|
-
- \u5305\u542B\
|
|
90
|
-
- \
|
|
91
|
-
|
|
92
|
-
* ${
|
|
146
|
+
- \u5305\u542B\u6807\u51C6\u6587\u4EF6\u5934\u6CE8\u91CA\uFF08\u4F5C\u8005\u3001\u65F6\u95F4\u3001\u7248\u672C\u3001\u7248\u6743\u3001\u63CF\u8FF0\uFF09
|
|
147
|
+
- \u5305\u542B\u4E2D\u6587\u6CE8\u91CA\u8BF4\u660E\u4EE3\u7801\u903B\u8F91
|
|
148
|
+
- \u53EF\u6839\u636E\u5B9E\u9645\u9700\u6C42\u4FEE\u6539\u5C5E\u6027\u548C\u4E8B\u4EF6`,frameworkVersion:"M8.4"}}function ft(t,e){let s=`ejs.${t.module}.${t.name}`,r=[];for(let a of t.params)a.required&&r.push(` ${a.name}: ${ye(a.type)} // ${a.description}`);let o=`/**
|
|
149
|
+
* \u8C03\u7528 ${s}
|
|
150
|
+
* ${t.description}
|
|
93
151
|
*/
|
|
94
|
-
${
|
|
95
|
-
${
|
|
152
|
+
${s}({
|
|
153
|
+
${r.join(`,
|
|
96
154
|
`)},
|
|
97
155
|
success: function(result) {
|
|
98
156
|
// \u6210\u529F\u56DE\u8C03
|
|
99
|
-
console.log('${
|
|
157
|
+
console.log('${t.name} \u6210\u529F:', result);
|
|
100
158
|
// TODO: \u5904\u7406\u6210\u529F\u7ED3\u679C
|
|
101
159
|
},
|
|
102
160
|
error: function(err) {
|
|
103
161
|
// \u9519\u8BEF\u56DE\u8C03
|
|
104
|
-
console.error('${
|
|
162
|
+
console.error('${t.name} \u5931\u8D25:', err);
|
|
105
163
|
// TODO: \u5904\u7406\u9519\u8BEF
|
|
106
164
|
}
|
|
107
|
-
});`,
|
|
108
|
-
* \u8C03\u7528 ${
|
|
109
|
-
* ${
|
|
165
|
+
});`,n=`/**
|
|
166
|
+
* \u8C03\u7528 ${s} (Promise \u98CE\u683C)
|
|
167
|
+
* ${t.description}
|
|
110
168
|
*/
|
|
111
|
-
async function call${
|
|
169
|
+
async function call${w(t.name)}() {
|
|
112
170
|
try {
|
|
113
|
-
const result = await ${
|
|
114
|
-
${
|
|
171
|
+
const result = await ${s}({
|
|
172
|
+
${r.join(`,
|
|
115
173
|
`)}
|
|
116
174
|
});
|
|
117
175
|
// \u6210\u529F\u5904\u7406
|
|
118
|
-
console.log('${
|
|
176
|
+
console.log('${t.name} \u6210\u529F:', result);
|
|
119
177
|
return result;
|
|
120
178
|
} catch (err) {
|
|
121
179
|
// \u9519\u8BEF\u5904\u7406
|
|
122
|
-
console.error('${
|
|
180
|
+
console.error('${t.name} \u5931\u8D25:', err);
|
|
123
181
|
throw err;
|
|
124
182
|
}
|
|
125
|
-
}`;return
|
|
183
|
+
}`;return e==="M8.4"?{script:`<script setup>
|
|
126
184
|
/**
|
|
127
|
-
* EJS API \u8C03\u7528\u793A\u4F8B: ${
|
|
185
|
+
* EJS API \u8C03\u7528\u793A\u4F8B: ${s}
|
|
128
186
|
* \u6846\u67B6\u7248\u672C: M8.4 (Vue3)
|
|
129
187
|
*/
|
|
130
188
|
import { ref } from 'vue';
|
|
@@ -134,26 +192,26 @@ const result = ref(null);
|
|
|
134
192
|
const loading = ref(false);
|
|
135
193
|
const error = ref(null);
|
|
136
194
|
|
|
137
|
-
${
|
|
195
|
+
${n}
|
|
138
196
|
|
|
139
197
|
// \u5728\u7EC4\u4EF6\u4E2D\u8C03\u7528
|
|
140
198
|
async function handleAction() {
|
|
141
199
|
loading.value = true;
|
|
142
200
|
error.value = null;
|
|
143
201
|
try {
|
|
144
|
-
result.value = await call${
|
|
202
|
+
result.value = await call${w(t.name)}();
|
|
145
203
|
} catch (e) {
|
|
146
204
|
error.value = e;
|
|
147
205
|
} finally {
|
|
148
206
|
loading.value = false;
|
|
149
207
|
}
|
|
150
208
|
}
|
|
151
|
-
</script>`,explanation:`\u8FD9\u662F ${
|
|
209
|
+
</script>`,explanation:`\u8FD9\u662F ${s} \u7684 M8.4 (Vue3) \u8C03\u7528\u793A\u4F8B\u3002
|
|
152
210
|
- \u4F7F\u7528 async/await \u548C Promise \u98CE\u683C
|
|
153
211
|
- \u5305\u542B\u5B8C\u6574\u7684\u9519\u8BEF\u5904\u7406
|
|
154
212
|
- \u4F7F\u7528\u54CD\u5E94\u5F0F\u72B6\u6001\u7BA1\u7406\u52A0\u8F7D\u548C\u9519\u8BEF\u72B6\u6001`,frameworkVersion:"M8.4"}:{script:`<script>
|
|
155
213
|
/**
|
|
156
|
-
* EJS API \u8C03\u7528\u793A\u4F8B: ${
|
|
214
|
+
* EJS API \u8C03\u7528\u793A\u4F8B: ${s}
|
|
157
215
|
* \u6846\u67B6\u7248\u672C: M8.3 (Vue2)
|
|
158
216
|
*/
|
|
159
217
|
export default {
|
|
@@ -167,9 +225,9 @@ export default {
|
|
|
167
225
|
|
|
168
226
|
methods: {
|
|
169
227
|
/**
|
|
170
|
-
* \u8C03\u7528 ${
|
|
228
|
+
* \u8C03\u7528 ${t.name} API
|
|
171
229
|
*/
|
|
172
|
-
call${
|
|
230
|
+
call${w(t.name)}() {
|
|
173
231
|
this.loading = true;
|
|
174
232
|
this.error = null;
|
|
175
233
|
|
|
@@ -179,22 +237,331 @@ export default {
|
|
|
179
237
|
}
|
|
180
238
|
}
|
|
181
239
|
};
|
|
182
|
-
</script>`,explanation:`\u8FD9\u662F ${
|
|
240
|
+
</script>`,explanation:`\u8FD9\u662F ${s} \u7684 M8.3 (Vue2) \u8C03\u7528\u793A\u4F8B\u3002
|
|
183
241
|
- \u4F7F\u7528\u56DE\u8C03\u51FD\u6570\u98CE\u683C
|
|
184
242
|
- \u5305\u542B success \u548C error \u56DE\u8C03\u5904\u7406
|
|
185
|
-
- \u53EF\u6839\u636E\u9700\u8981\u6539\u4E3A Promise \u98CE\u683C`,frameworkVersion:"M8.3"}}function
|
|
186
|
-
${
|
|
187
|
-
<!-- #endif -->`}function
|
|
243
|
+
- \u53EF\u6839\u636E\u9700\u8981\u6539\u4E3A Promise \u98CE\u683C`,frameworkVersion:"M8.3"}}function he(t,e){return`<!-- #ifdef ${{wechat:"MP-WEIXIN",alipay:"MP-ALIPAY",h5:"H5",ejs:"APP-PLUS",dingtalk:"MP-DINGTALK"}[e.toLowerCase()]||e.toUpperCase()} -->
|
|
244
|
+
${t}
|
|
245
|
+
<!-- #endif -->`}function w(t){return t?t.charAt(0).toUpperCase()+t.slice(1):""}function ge(t){if(!t)return"''";if(t.default)return t.default;switch(t.type.toLowerCase()){case"string":return"''";case"number":return"0";case"boolean":return"false";case"array":return"[]";case"object":return"{}";default:return"null"}}function ye(t){switch(t.toLowerCase()){case"string":return"'\u8BF7\u586B\u5199'";case"number":return"0";case"boolean":return"true";case"array":return"[]";case"object":return"{}";case"function":return"() => {}";default:return"null"}}function we(t){return t==="M8.4"?{script:`<script setup>
|
|
246
|
+
/**
|
|
247
|
+
* Util.ajax \u4F7F\u7528\u793A\u4F8B
|
|
248
|
+
* \u6846\u67B6\u7248\u672C: M8.4 (Vue3 Composition API)
|
|
249
|
+
*
|
|
250
|
+
* Util.ajax \u662F M8 \u6846\u67B6\u5BF9 axios \u7684\u5C01\u88C5\uFF0C\u63A8\u8350\u7528\u4E8E\u6240\u6709 HTTP \u8BF7\u6C42
|
|
251
|
+
*/
|
|
252
|
+
import { ref } from 'vue';
|
|
253
|
+
|
|
254
|
+
// \u54CD\u5E94\u5F0F\u6570\u636E
|
|
255
|
+
const data = ref(null);
|
|
256
|
+
const loading = ref(false);
|
|
257
|
+
const error = ref(null);
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* \u53D1\u9001 GET \u8BF7\u6C42
|
|
261
|
+
*/
|
|
262
|
+
async function fetchData() {
|
|
263
|
+
loading.value = true;
|
|
264
|
+
error.value = null;
|
|
265
|
+
|
|
266
|
+
try {
|
|
267
|
+
const result = await Util.ajax({
|
|
268
|
+
url: Config.serverUrl + '/api/data',
|
|
269
|
+
type: 'GET',
|
|
270
|
+
data: {
|
|
271
|
+
// \u8BF7\u6C42\u53C2\u6570
|
|
272
|
+
id: '12345'
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
data.value = result;
|
|
277
|
+
console.log('\u8BF7\u6C42\u6210\u529F:', result);
|
|
278
|
+
} catch (err) {
|
|
279
|
+
error.value = err;
|
|
280
|
+
console.error('\u8BF7\u6C42\u5931\u8D25:', err);
|
|
281
|
+
} finally {
|
|
282
|
+
loading.value = false;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* \u53D1\u9001 POST \u8BF7\u6C42
|
|
288
|
+
*/
|
|
289
|
+
async function submitData(formData) {
|
|
290
|
+
loading.value = true;
|
|
291
|
+
|
|
292
|
+
try {
|
|
293
|
+
const result = await Util.ajax({
|
|
294
|
+
url: Config.serverUrl + '/api/submit',
|
|
295
|
+
type: 'POST',
|
|
296
|
+
data: {
|
|
297
|
+
params: JSON.stringify(formData)
|
|
298
|
+
},
|
|
299
|
+
// \u4F7F\u7528 dataPath \u81EA\u52A8\u63D0\u53D6\u6570\u636E
|
|
300
|
+
dataPath: 'data'
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
if (result.code === 1) {
|
|
304
|
+
console.log('\u63D0\u4EA4\u6210\u529F:', result.data);
|
|
305
|
+
return result.data;
|
|
306
|
+
} else {
|
|
307
|
+
throw new Error(result.message);
|
|
308
|
+
}
|
|
309
|
+
} catch (err) {
|
|
310
|
+
error.value = err;
|
|
311
|
+
throw err;
|
|
312
|
+
} finally {
|
|
313
|
+
loading.value = false;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
</script>`,explanation:`\u8FD9\u662F Util.ajax \u7684 M8.4 (Vue3) \u4F7F\u7528\u793A\u4F8B\u3002
|
|
317
|
+
|
|
318
|
+
**\u63A8\u8350\u4F7F\u7528 Util.ajax \u800C\u4E0D\u662F ejs.http \u6216\u539F\u751F fetch\uFF1A**
|
|
319
|
+
- Util.ajax \u662F\u6846\u67B6\u5BF9 axios \u7684\u5C01\u88C5\uFF0C\u63D0\u4F9B\u7EDF\u4E00\u7684\u8BF7\u6C42\u5904\u7406
|
|
320
|
+
- \u81EA\u52A8\u5904\u7406 token \u548C\u4EE3\u7406\uFF08isAutoProxy \u9ED8\u8BA4\u4E3A true\uFF09
|
|
321
|
+
- \u652F\u6301 dataPath \u81EA\u52A8\u63D0\u53D6\u54CD\u5E94\u6570\u636E
|
|
322
|
+
- \u652F\u6301\u8BF7\u6C42\u53D6\u6D88\uFF08cancelKey\uFF09
|
|
323
|
+
- \u652F\u6301\u5E76\u53D1\u8BF7\u6C42\uFF08Util.ajaxAll\uFF09
|
|
324
|
+
|
|
325
|
+
**\u5E38\u7528\u53C2\u6570\uFF1A**
|
|
326
|
+
- url: \u8BF7\u6C42\u5730\u5740
|
|
327
|
+
- type: \u8BF7\u6C42\u65B9\u6CD5\uFF0CGET \u6216 POST
|
|
328
|
+
- data: \u8BF7\u6C42\u6570\u636E
|
|
329
|
+
- dataPath: \u54CD\u5E94\u6570\u636E\u8DEF\u5F84
|
|
330
|
+
- success/error: \u56DE\u8C03\u51FD\u6570\uFF08\u4E5F\u652F\u6301 Promise\uFF09`,frameworkVersion:"M8.4"}:{script:`<script>
|
|
331
|
+
/**
|
|
332
|
+
* Util.ajax \u4F7F\u7528\u793A\u4F8B
|
|
333
|
+
* \u6846\u67B6\u7248\u672C: M8.3 (Vue2 Options API)
|
|
334
|
+
*
|
|
335
|
+
* Util.ajax \u662F M8 \u6846\u67B6\u5BF9 axios \u7684\u5C01\u88C5\uFF0C\u63A8\u8350\u7528\u4E8E\u6240\u6709 HTTP \u8BF7\u6C42
|
|
336
|
+
*/
|
|
337
|
+
export default {
|
|
338
|
+
data() {
|
|
339
|
+
return {
|
|
340
|
+
data: null,
|
|
341
|
+
loading: false,
|
|
342
|
+
error: null
|
|
343
|
+
};
|
|
344
|
+
},
|
|
345
|
+
|
|
346
|
+
methods: {
|
|
347
|
+
/**
|
|
348
|
+
* \u53D1\u9001\u8BF7\u6C42 - \u56DE\u8C03\u98CE\u683C
|
|
349
|
+
*/
|
|
350
|
+
fetchDataCallback() {
|
|
351
|
+
this.loading = true;
|
|
352
|
+
|
|
353
|
+
Util.ajax({
|
|
354
|
+
url: Config.serverUrl + '/api/data',
|
|
355
|
+
type: 'GET',
|
|
356
|
+
data: {
|
|
357
|
+
id: '12345'
|
|
358
|
+
},
|
|
359
|
+
// \u4F7F\u7528 dataPath \u81EA\u52A8\u63D0\u53D6\u6570\u636E
|
|
360
|
+
dataPath: 'data',
|
|
361
|
+
success: (result) => {
|
|
362
|
+
this.loading = false;
|
|
363
|
+
if (result.code === 1) {
|
|
364
|
+
this.data = result.data;
|
|
365
|
+
console.log('\u8BF7\u6C42\u6210\u529F:', result.data);
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
error: (err) => {
|
|
369
|
+
this.loading = false;
|
|
370
|
+
this.error = err;
|
|
371
|
+
console.error('\u8BF7\u6C42\u5931\u8D25:', err);
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
},
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* \u53D1\u9001\u8BF7\u6C42 - Promise \u98CE\u683C
|
|
378
|
+
*/
|
|
379
|
+
async fetchDataPromise() {
|
|
380
|
+
this.loading = true;
|
|
381
|
+
|
|
382
|
+
try {
|
|
383
|
+
const result = await Util.ajax({
|
|
384
|
+
url: Config.serverUrl + '/api/data',
|
|
385
|
+
type: 'POST',
|
|
386
|
+
data: {
|
|
387
|
+
params: JSON.stringify({ id: '12345' })
|
|
388
|
+
},
|
|
389
|
+
dataPath: 'data'
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
if (result.code === 1) {
|
|
393
|
+
this.data = result.data;
|
|
394
|
+
}
|
|
395
|
+
} catch (err) {
|
|
396
|
+
this.error = err;
|
|
397
|
+
} finally {
|
|
398
|
+
this.loading = false;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
</script>`,explanation:`\u8FD9\u662F Util.ajax \u7684 M8.3 (Vue2) \u4F7F\u7528\u793A\u4F8B\u3002
|
|
404
|
+
|
|
405
|
+
**\u63A8\u8350\u4F7F\u7528 Util.ajax \u800C\u4E0D\u662F ejs.http \u6216\u539F\u751F fetch\uFF1A**
|
|
406
|
+
- Util.ajax \u662F\u6846\u67B6\u5BF9 axios \u7684\u5C01\u88C5\uFF0C\u63D0\u4F9B\u7EDF\u4E00\u7684\u8BF7\u6C42\u5904\u7406
|
|
407
|
+
- \u81EA\u52A8\u5904\u7406 token \u548C\u4EE3\u7406
|
|
408
|
+
- \u652F\u6301\u56DE\u8C03\u548C Promise \u4E24\u79CD\u98CE\u683C
|
|
409
|
+
- \u652F\u6301 dataPath \u81EA\u52A8\u63D0\u53D6\u54CD\u5E94\u6570\u636E
|
|
410
|
+
|
|
411
|
+
**\u5E38\u7528\u53C2\u6570\uFF1A**
|
|
412
|
+
- url: \u8BF7\u6C42\u5730\u5740
|
|
413
|
+
- type: \u8BF7\u6C42\u65B9\u6CD5\uFF0CGET \u6216 POST
|
|
414
|
+
- data: \u8BF7\u6C42\u6570\u636E
|
|
415
|
+
- dataPath: \u54CD\u5E94\u6570\u636E\u8DEF\u5F84
|
|
416
|
+
- success/error: \u56DE\u8C03\u51FD\u6570`,frameworkVersion:"M8.3"}}function xe(t){return t==="M8.4"?{script:`<script setup>
|
|
417
|
+
/**
|
|
418
|
+
* Util.upload \u6587\u4EF6\u4E0A\u4F20\u793A\u4F8B
|
|
419
|
+
* \u6846\u67B6\u7248\u672C: M8.4 (Vue3 Composition API)
|
|
420
|
+
*/
|
|
421
|
+
import { ref } from 'vue';
|
|
422
|
+
|
|
423
|
+
const uploading = ref(false);
|
|
424
|
+
const progress = ref(0);
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* \u4E0A\u4F20\u6587\u4EF6 - filePath \u65B9\u5F0F\uFF08\u63A8\u8350\uFF0C\u652F\u6301\u8DE8\u7AEF\uFF09
|
|
428
|
+
*/
|
|
429
|
+
async function uploadFile(file) {
|
|
430
|
+
uploading.value = true;
|
|
431
|
+
progress.value = 0;
|
|
432
|
+
|
|
433
|
+
try {
|
|
434
|
+
const result = await new Promise((resolve, reject) => {
|
|
435
|
+
Util.upload({
|
|
436
|
+
url: Config.serverUrl + '/api/upload',
|
|
437
|
+
filePath: file.path, // \u6587\u4EF6\u8DEF\u5F84
|
|
438
|
+
name: file.name, // \u6587\u4EF6\u540D
|
|
439
|
+
formData: {
|
|
440
|
+
// \u989D\u5916\u7684\u8868\u5355\u6570\u636E
|
|
441
|
+
type: 'image'
|
|
442
|
+
},
|
|
443
|
+
success: (res) => {
|
|
444
|
+
resolve(JSON.parse(res.data));
|
|
445
|
+
},
|
|
446
|
+
error: (err) => {
|
|
447
|
+
reject(err);
|
|
448
|
+
},
|
|
449
|
+
uploading: (p) => {
|
|
450
|
+
// \u4E0A\u4F20\u8FDB\u5EA6\u56DE\u8C03
|
|
451
|
+
progress.value = p;
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
console.log('\u4E0A\u4F20\u6210\u529F:', result);
|
|
457
|
+
return result;
|
|
458
|
+
} catch (err) {
|
|
459
|
+
console.error('\u4E0A\u4F20\u5931\u8D25:', err);
|
|
460
|
+
throw err;
|
|
461
|
+
} finally {
|
|
462
|
+
uploading.value = false;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
</script>`,explanation:`\u8FD9\u662F Util.upload \u7684 M8.4 (Vue3) \u4F7F\u7528\u793A\u4F8B\u3002
|
|
466
|
+
|
|
467
|
+
**\u63A8\u8350\u4F7F\u7528 filePath \u65B9\u5F0F\u4E0A\u4F20\uFF1A**
|
|
468
|
+
- \u652F\u6301\u8DE8\u7AEF\uFF08H5\u3001\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F\u3001\u652F\u4ED8\u5B9D\u5C0F\u7A0B\u5E8F\uFF09
|
|
469
|
+
- filePath \u9700\u8981\u4E0E name \u914D\u5957\u4F7F\u7528
|
|
470
|
+
|
|
471
|
+
**files \u65B9\u5F0F\u4EC5\u652F\u6301 H5\uFF1A**
|
|
472
|
+
- \u9002\u7528\u4E8E\u7EAF H5 \u9879\u76EE
|
|
473
|
+
- \u652F\u6301\u591A\u6587\u4EF6\u4E0A\u4F20`,frameworkVersion:"M8.4"}:{script:`<script>
|
|
474
|
+
/**
|
|
475
|
+
* Util.upload \u6587\u4EF6\u4E0A\u4F20\u793A\u4F8B
|
|
476
|
+
* \u6846\u67B6\u7248\u672C: M8.3 (Vue2 Options API)
|
|
477
|
+
*/
|
|
478
|
+
export default {
|
|
479
|
+
data() {
|
|
480
|
+
return {
|
|
481
|
+
uploading: false,
|
|
482
|
+
progress: 0
|
|
483
|
+
};
|
|
484
|
+
},
|
|
485
|
+
|
|
486
|
+
methods: {
|
|
487
|
+
/**
|
|
488
|
+
* \u4E0A\u4F20\u6587\u4EF6 - filePath \u65B9\u5F0F\uFF08\u63A8\u8350\uFF0C\u652F\u6301\u8DE8\u7AEF\uFF09
|
|
489
|
+
*/
|
|
490
|
+
uploadFile(file) {
|
|
491
|
+
this.uploading = true;
|
|
492
|
+
this.progress = 0;
|
|
493
|
+
|
|
494
|
+
Util.upload({
|
|
495
|
+
url: Config.serverUrl + '/api/upload',
|
|
496
|
+
filePath: file.path,
|
|
497
|
+
name: file.name,
|
|
498
|
+
formData: {
|
|
499
|
+
type: 'image'
|
|
500
|
+
},
|
|
501
|
+
success: (res) => {
|
|
502
|
+
this.uploading = false;
|
|
503
|
+
const result = JSON.parse(res.data);
|
|
504
|
+
console.log('\u4E0A\u4F20\u6210\u529F:', result);
|
|
505
|
+
},
|
|
506
|
+
error: (err) => {
|
|
507
|
+
this.uploading = false;
|
|
508
|
+
console.error('\u4E0A\u4F20\u5931\u8D25:', err);
|
|
509
|
+
},
|
|
510
|
+
uploading: (p) => {
|
|
511
|
+
this.progress = p;
|
|
512
|
+
}
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
</script>`,explanation:`\u8FD9\u662F Util.upload \u7684 M8.3 (Vue2) \u4F7F\u7528\u793A\u4F8B\u3002
|
|
518
|
+
|
|
519
|
+
**\u63A8\u8350\u4F7F\u7528 filePath \u65B9\u5F0F\u4E0A\u4F20\uFF1A**
|
|
520
|
+
- \u652F\u6301\u8DE8\u7AEF\uFF08H5\u3001\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F\u3001\u652F\u4ED8\u5B9D\u5C0F\u7A0B\u5E8F\uFF09
|
|
521
|
+
- filePath \u9700\u8981\u4E0E name \u914D\u5957\u4F7F\u7528`,frameworkVersion:"M8.3"}}function dt(t,e){if(t.name.toLowerCase()==="ajax")return we(e);if(t.name.toLowerCase()==="upload")return xe(e);let s=t.fullName,r=t.params.filter(o=>o.required).map(o=>`${o.name}: ${ye(o.type)} // ${o.description}`).join(`,
|
|
522
|
+
`);return e==="M8.4"?{script:`<script setup>
|
|
523
|
+
/**
|
|
524
|
+
* ${t.fullName} \u4F7F\u7528\u793A\u4F8B
|
|
525
|
+
* ${t.description}
|
|
526
|
+
* \u6846\u67B6\u7248\u672C: M8.4 (Vue3)
|
|
527
|
+
*/
|
|
528
|
+
|
|
529
|
+
// \u8C03\u7528 ${s}
|
|
530
|
+
const result = ${s}(${r?`{
|
|
531
|
+
${r}
|
|
532
|
+
}`:""});
|
|
533
|
+
console.log('\u7ED3\u679C:', result);
|
|
534
|
+
</script>`,explanation:`\u8FD9\u662F ${t.fullName} \u7684\u4F7F\u7528\u793A\u4F8B\u3002
|
|
535
|
+
${t.description}`,frameworkVersion:"M8.4"}:{script:`<script>
|
|
536
|
+
/**
|
|
537
|
+
* ${t.fullName} \u4F7F\u7528\u793A\u4F8B
|
|
538
|
+
* ${t.description}
|
|
539
|
+
* \u6846\u67B6\u7248\u672C: M8.3 (Vue2)
|
|
540
|
+
*/
|
|
541
|
+
export default {
|
|
542
|
+
methods: {
|
|
543
|
+
useUtil() {
|
|
544
|
+
const result = ${s}(${r?`{
|
|
545
|
+
${r}
|
|
546
|
+
}`:""});
|
|
547
|
+
console.log('\u7ED3\u679C:', result);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
</script>`,explanation:`\u8FD9\u662F ${t.fullName} \u7684\u4F7F\u7528\u793A\u4F8B\u3002
|
|
552
|
+
${t.description}`,frameworkVersion:"M8.3"}}var mt={form:[{related:["field","button","picker","datepicker"],reason:"\u8868\u5355\u5E38\u7528\u7EC4\u4EF6"},{related:["toast","dialog"],reason:"\u8868\u5355\u63D0\u4EA4\u53CD\u9988"}],field:[{related:["form","button"],reason:"\u8F93\u5165\u6846\u5E38\u4E0E\u8868\u5355\u914D\u5408\u4F7F\u7528"},{related:["picker","datepicker"],reason:"\u9009\u62E9\u7C7B\u8F93\u5165"}],button:[{related:["form","dialog"],reason:"\u6309\u94AE\u5E38\u7528\u573A\u666F"},{related:["loading"],reason:"\u6309\u94AE\u52A0\u8F7D\u72B6\u6001"}],cell:[{related:["minirefresh","empty"],reason:"\u5217\u8868\u5E38\u7528\u7EC4\u4EF6"},{related:["swipecell"],reason:"\u6ED1\u52A8\u64CD\u4F5C"}],minirefresh:[{related:["cell","empty","loading"],reason:"\u4E0B\u62C9\u5237\u65B0\u5217\u8868\u7EC4\u4EF6"}],picker:[{related:["field","form"],reason:"\u9009\u62E9\u5668\u5E38\u4E0E\u8868\u5355\u914D\u5408"},{related:["datepicker","area"],reason:"\u5176\u4ED6\u9009\u62E9\u5668"}],datepicker:[{related:["field","form"],reason:"\u65E5\u671F\u9009\u62E9\u5E38\u4E0E\u8868\u5355\u914D\u5408"},{related:["picker","calendar"],reason:"\u5176\u4ED6\u65E5\u671F\u7EC4\u4EF6"}],uploader:[{related:["imagepreview","toast"],reason:"\u4E0A\u4F20\u76F8\u5173\u7EC4\u4EF6"},{related:["form","button"],reason:"\u8868\u5355\u4E0A\u4F20\u573A\u666F"}],dialog:[{related:["button","form"],reason:"\u5F39\u7A97\u5185\u5BB9\u7EC4\u4EF6"},{related:["toast","overlay"],reason:"\u5176\u4ED6\u53CD\u9988\u7EC4\u4EF6"}],toast:[{related:["dialog","notify"],reason:"\u5176\u4ED6\u63D0\u793A\u7EC4\u4EF6"},{related:["loading"],reason:"\u52A0\u8F7D\u63D0\u793A"}]};function ht(t,e){let s=[],r=e.toLowerCase(),o=mt[r];if(o)for(let n of o)for(let a of n.related){let l=t.components.get(a);l&&!s.some(i=>i.name===a)&&s.push({name:a,displayName:l.displayName,reason:n.reason,docPath:l.filePath})}return s.slice(0,5)}function gt(t){if(t.length===0)return"";let e=["","","**\u76F8\u5173\u7EC4\u4EF6\u63A8\u8350\uFF1A**"];for(let s of t)e.push(`- ${s.displayName} (${s.name}): ${s.reason}`);return e.join(`
|
|
553
|
+
`)}function ve(t,e){let s=e.options?.frameworkVersion||"M8.4",r=e.options?.platform;if(e.type==="component"){let o=t.components.get(e.name.toLowerCase());if(!o)return{explanation:`\u672A\u627E\u5230\u7EC4\u4EF6: ${e.name}`,frameworkVersion:s};let n=ct(o,s,r),a=ht(t,e.name);return a.length>0&&(n.explanation+=gt(a)),n}if(e.type==="ejsApi"){let o="",n=e.name;e.name.includes(".")&&([o,n]=e.name.split("."));let a;if(o)a=t.ejsApis.get(`${o}.${n}`);else for(let[,l]of t.ejsApis)if(l.name===n){a=l;break}return a?ft(a,s):{explanation:`\u672A\u627E\u5230 API: ${e.name}`,frameworkVersion:s}}if(e.type==="util"){let o=e.name.toLowerCase();o.startsWith("util.")&&(o=o.replace("util.",""));let n=t.utilMethods?.get(o);return n?dt(n,s):o==="ajax"?we(s):o==="upload"?xe(s):{explanation:`\u672A\u627E\u5230 Util \u65B9\u6CD5: ${e.name}`,frameworkVersion:s}}return{explanation:`\u4E0D\u652F\u6301\u7684\u751F\u6210\u7C7B\u578B: ${e.type}`,frameworkVersion:s}}var F={ejsH5:"EJS H5 \u5E94\u7528",ejsMiniProgram:"EJS \u65B0\u70B9\u5C0F\u7A0B\u5E8F",h5:"H5",dingtalk:"\u9489\u9489",wechat:"\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F",alipay:"\u652F\u4ED8\u5B9D\u5C0F\u7A0B\u5E8F",weex:"Weex"},yt={ejsh5:"ejsH5",ejs:"ejsH5",ejsminiprogram:"ejsMiniProgram",h5:"h5",dingtalk:"dingtalk",wechat:"wechat",alipay:"alipay",weex:"weex"};function wt(t,e){let s=[],r=[];for(let o of e){let n=yt[o.toLowerCase()];if(!n)continue;let a=t[n],l=F[n]||o;a===!1?s.push(l):typeof a=="string"&&r.push(`${l}: ${a}`)}return{unsupported:s,limitations:r}}function xt(t,e,s,r){let o=[];if(s==="component"){let n=t.components.get(e.toLowerCase());if(n)for(let[a,l]of t.components){if(a===e.toLowerCase()||l.category!==n.category)continue;let i=!0;for(let c of r){let p=Object.entries(F).find(([u,d])=>d===c)?.[0];if(p&&l.platformSupport[p]===!1){i=!1;break}}i&&o.push(`${l.displayName} (${a})`)}}else{let n=e.split("."),a=n.length>1?n[0]:"";for(let[l,i]of t.ejsApis){if(l===e||i.module!==a)continue;let c=!0;for(let p of r){let u=Object.entries(F).find(([d,f])=>f===p)?.[0];if(u&&i.platformSupport[u]===!1){c=!1;break}}c&&o.push(`ejs.${i.module}.${i.name}`)}}return o.slice(0,3)}function $e(t,e,s){let r={items:[],allCompatible:!0,issues:[],suggestions:[]};for(let o of e){let n=o.toLowerCase(),a=!1,l="component",i,c=o,p=t.components.get(n);if(p&&(a=!0,l="component",i=p.platformSupport,c=p.displayName),!a){let m=t.ejsApis.get(n);if(m)a=!0,l="ejsApi",i=m.platformSupport,c=`ejs.${m.module}.${m.name}`;else for(let[I,g]of t.ejsApis)if(g.name.toLowerCase()===n||I===n){a=!0,l="ejsApi",i=g.platformSupport,c=`ejs.${g.module}.${g.name}`;break}}if(!a||!i){r.items.push({name:o,type:"component",platformSupport:vt(),unsupportedPlatforms:[],limitations:[`\u672A\u627E\u5230: ${o}`]}),r.issues.push(`\u672A\u627E\u5230\u7EC4\u4EF6\u6216 API: ${o}`);continue}let{unsupported:u,limitations:d}=wt(i,s),f={name:c,type:l,platformSupport:i,unsupportedPlatforms:u,limitations:d};if(u.length>0){r.allCompatible=!1,r.issues.push(`${c} \u4E0D\u652F\u6301: ${u.join(", ")}`);let m=xt(t,o,l,u);m.length>0&&(f.alternatives=m,r.suggestions.push(`${c} \u7684\u66FF\u4EE3\u65B9\u6848: ${m.join(", ")}`))}d.length>0&&r.issues.push(...d.map(m=>`${c} - ${m}`)),r.items.push(f)}return r.allCompatible?r.suggestions.push("\u6240\u6709\u7EC4\u4EF6\u548C API \u5728\u76EE\u6807\u5E73\u53F0\u4E0A\u5747\u5B8C\u5168\u652F\u6301\u3002"):r.suggestions.push("\u5EFA\u8BAE\u5728\u5F00\u53D1\u65F6\u4F7F\u7528\u6761\u4EF6\u7F16\u8BD1 (#ifdef) \u5904\u7406\u5E73\u53F0\u5DEE\u5F02\u3002"),r}function vt(){return{ejsH5:!1,ejsMiniProgram:!1,h5:!1,dingtalk:!1,wechat:!1,alipay:!1}}var $t={cell:{name:"cell",displayName:"\u5355\u5143\u683C",description:"\u7528\u4E8E\u5C55\u793A\u5217\u8868\u9879\uFF0C\u652F\u6301\u6807\u9898\u3001\u63CF\u8FF0\u3001\u56FE\u6807\u7B49",docPath:"009-UI\u7EC4\u4EF6/008-cell\u5355\u5143\u683C.md"},minirefresh:{name:"minirefresh",displayName:"\u4E0B\u62C9\u5237\u65B0",description:"\u5B9E\u73B0\u4E0B\u62C9\u5237\u65B0\u548C\u4E0A\u62C9\u52A0\u8F7D\u66F4\u591A\u529F\u80FD",docPath:"009-UI\u7EC4\u4EF6/042-minirefresh\u4E0B\u62C9\u5237\u65B0.md"},loading:{name:"loading",displayName:"\u52A0\u8F7D",description:"\u663E\u793A\u52A0\u8F7D\u72B6\u6001",docPath:"009-UI\u7EC4\u4EF6/020-loading\u52A0\u8F7D.md"},form:{name:"form",displayName:"\u8868\u5355",description:"\u8868\u5355\u5BB9\u5668\uFF0C\u63D0\u4F9B\u8868\u5355\u9A8C\u8BC1\u529F\u80FD",docPath:"009-UI\u7EC4\u4EF6/015-form\u8868\u5355.md"},field:{name:"field",displayName:"\u8F93\u5165\u6846",description:"\u8868\u5355\u8F93\u5165\u6846\u7EC4\u4EF6",docPath:"009-UI\u7EC4\u4EF6/013-field\u8F93\u5165\u6846.md"},button:{name:"button",displayName:"\u6309\u94AE",description:"\u6309\u94AE\u7EC4\u4EF6\uFF0C\u652F\u6301\u591A\u79CD\u7C7B\u578B\u548C\u72B6\u6001",docPath:"009-UI\u7EC4\u4EF6/005-button\u6309\u94AE.md"},picker:{name:"picker",displayName:"\u9009\u62E9\u5668",description:"\u901A\u7528\u9009\u62E9\u5668\u7EC4\u4EF6",docPath:"009-UI\u7EC4\u4EF6/026-picker\u9009\u62E9\u5668.md"},datepicker:{name:"datepicker",displayName:"\u65E5\u671F\u9009\u62E9",description:"\u65E5\u671F\u9009\u62E9\u5668\u7EC4\u4EF6",docPath:"009-UI\u7EC4\u4EF6/011-datepicker\u65E5\u671F\u9009\u62E9.md"},uploader:{name:"uploader",displayName:"\u6587\u4EF6\u4E0A\u4F20",description:"\u6587\u4EF6\u4E0A\u4F20\u7EC4\u4EF6\uFF0C\u652F\u6301\u56FE\u7247\u9884\u89C8",docPath:"009-UI\u7EC4\u4EF6/040-uploader\u6587\u4EF6\u4E0A\u4F20.md"},imagepreview:{name:"imagepreview",displayName:"\u56FE\u7247\u9884\u89C8",description:"\u56FE\u7247\u9884\u89C8\u7EC4\u4EF6",docPath:"009-UI\u7EC4\u4EF6/058-imagepreview\u56FE\u7247\u9884\u89C8.md"},empty:{name:"empty",displayName:"\u7A7A\u72B6\u6001",description:"\u7A7A\u72B6\u6001\u5360\u4F4D\u7EC4\u4EF6",docPath:"009-UI\u7EC4\u4EF6/057-empty\u7A7A\u72B6\u6001.md"},toast:{name:"toast",displayName:"\u8F7B\u63D0\u793A",description:"\u8F7B\u91CF\u7EA7\u63D0\u793A\u7EC4\u4EF6",docPath:"009-UI\u7EC4\u4EF6/045-toast\u8F7B\u63D0\u793A.md"},dialog:{name:"dialog",displayName:"\u5F39\u51FA\u6846",description:"\u5F39\u51FA\u6846\u7EC4\u4EF6",docPath:"009-UI\u7EC4\u4EF6/049-dialog\u5F39\u51FA\u6846.md"}};function ke(t){return t.map(e=>$t[e.toLowerCase()]).filter(e=>e!==void 0)}function je(t){if(t.length===0)return"";let e=["","**\u76F8\u5173\u7EC4\u4EF6\u6587\u6863\uFF1A**",""];for(let s of t)e.push(`- **${s.displayName}** (${s.name}): ${s.description}`),e.push(` - \u6587\u6863\u8DEF\u5F84: \`${s.docPath}\``);return e.join(`
|
|
554
|
+
`)}var H={\u5217\u8868\u8BE6\u60C5:{name:"\u5217\u8868\u8BE6\u60C5",description:"\u5217\u8868\u9875\u9762\u70B9\u51FB\u8FDB\u5165\u8BE6\u60C5\u9875\u7684\u5178\u578B\u6A21\u5F0F\uFF0C\u5305\u542B\u4E0B\u62C9\u5237\u65B0\u3001\u52A0\u8F7D\u66F4\u591A\u3001\u9875\u9762\u8DF3\u8F6C\u7B49\u529F\u80FD",components:["cell","minirefresh","loading"],apis:["navigator.push","navigator.pop"],vue2Code:kt(),vue3Code:jt(),keyPoints:["\u4F7F\u7528 minirefresh \u7EC4\u4EF6\u5B9E\u73B0\u4E0B\u62C9\u5237\u65B0\u548C\u52A0\u8F7D\u66F4\u591A","\u4F7F\u7528 cell \u7EC4\u4EF6\u5C55\u793A\u5217\u8868\u9879","\u4F7F\u7528 navigator.push \u8DF3\u8F6C\u5230\u8BE6\u60C5\u9875","\u8BE6\u60C5\u9875\u4F7F\u7528 navigator.pop \u8FD4\u56DE\u5217\u8868\u9875"]},\u8868\u5355\u63D0\u4EA4:{name:"\u8868\u5355\u63D0\u4EA4",description:"\u8868\u5355\u586B\u5199\u548C\u63D0\u4EA4\u7684\u5178\u578B\u6A21\u5F0F\uFF0C\u5305\u542B\u8868\u5355\u9A8C\u8BC1\u3001\u6570\u636E\u63D0\u4EA4\u3001\u7ED3\u679C\u53CD\u9988\u7B49\u529F\u80FD",components:["form","field","button","picker","datepicker"],apis:["ui.toast","ui.showWaiting","ui.closeWaiting"],vue2Code:Mt(),vue3Code:St(),keyPoints:["\u4F7F\u7528 form \u7EC4\u4EF6\u5305\u88F9\u8868\u5355\u5143\u7D20","\u4F7F\u7528 field \u7EC4\u4EF6\u5B9E\u73B0\u8F93\u5165\u6846","\u4F7F\u7528 picker/datepicker \u5B9E\u73B0\u9009\u62E9\u5668","\u63D0\u4EA4\u524D\u8FDB\u884C\u8868\u5355\u9A8C\u8BC1","\u4F7F\u7528 loading \u63D0\u793A\u7528\u6237\u7B49\u5F85","\u4F7F\u7528 toast \u53CD\u9988\u63D0\u4EA4\u7ED3\u679C"]},\u56FE\u7247\u4E0A\u4F20:{name:"\u56FE\u7247\u4E0A\u4F20",description:"\u56FE\u7247\u9009\u62E9\u548C\u4E0A\u4F20\u7684\u5178\u578B\u6A21\u5F0F\uFF0C\u5305\u542B\u56FE\u7247\u9009\u62E9\u3001\u9884\u89C8\u3001\u538B\u7F29\u3001\u4E0A\u4F20\u7B49\u529F\u80FD",components:["uploader","imagepreview"],apis:["io.chooseImage","io.uploadFile"],vue2Code:Ct(),vue3Code:bt(),keyPoints:["\u4F7F\u7528 uploader \u7EC4\u4EF6\u6216 io.chooseImage \u9009\u62E9\u56FE\u7247","\u652F\u6301\u56FE\u7247\u9884\u89C8\u529F\u80FD","\u4E0A\u4F20\u524D\u53EF\u8FDB\u884C\u56FE\u7247\u538B\u7F29","\u663E\u793A\u4E0A\u4F20\u8FDB\u5EA6"]}};function kt(){return{template:`<template>
|
|
188
555
|
<div class="list-page">
|
|
189
556
|
<!-- \u4E0B\u62C9\u5237\u65B0\u5217\u8868 -->
|
|
190
|
-
<
|
|
557
|
+
<em-minirefresh
|
|
191
558
|
ref="minirefresh"
|
|
192
559
|
:use-body-scroll="true"
|
|
193
560
|
@pulldown="onRefresh"
|
|
194
561
|
@pullup="onLoadMore"
|
|
195
562
|
>
|
|
196
563
|
<!-- \u5217\u8868\u5185\u5BB9 -->
|
|
197
|
-
<
|
|
564
|
+
<em-cell
|
|
198
565
|
v-for="item in list"
|
|
199
566
|
:key="item.id"
|
|
200
567
|
:title="item.title"
|
|
@@ -204,8 +571,8 @@ ${e}
|
|
|
204
571
|
/>
|
|
205
572
|
|
|
206
573
|
<!-- \u7A7A\u72B6\u6001 -->
|
|
207
|
-
<
|
|
208
|
-
</
|
|
574
|
+
<em-empty v-if="list.length === 0 && !loading" description="\u6682\u65E0\u6570\u636E" />
|
|
575
|
+
</em-minirefresh>
|
|
209
576
|
</div>
|
|
210
577
|
</template>`,script:`<script>
|
|
211
578
|
/**
|
|
@@ -300,17 +667,17 @@ export default {
|
|
|
300
667
|
min-height: 100vh;
|
|
301
668
|
background: #f5f5f5;
|
|
302
669
|
}
|
|
303
|
-
</style>`,explanation:"\u5217\u8868\u8BE6\u60C5\u6A21\u5F0F\u7684 Vue2 \u5B9E\u73B0\uFF0C\u5305\u542B\u4E0B\u62C9\u5237\u65B0\u3001\u52A0\u8F7D\u66F4\u591A\u3001\u8DF3\u8F6C\u8BE6\u60C5\u7B49\u529F\u80FD",frameworkVersion:"M8.3"}}function
|
|
670
|
+
</style>`,explanation:"\u5217\u8868\u8BE6\u60C5\u6A21\u5F0F\u7684 Vue2 \u5B9E\u73B0\uFF0C\u5305\u542B\u4E0B\u62C9\u5237\u65B0\u3001\u52A0\u8F7D\u66F4\u591A\u3001\u8DF3\u8F6C\u8BE6\u60C5\u7B49\u529F\u80FD",frameworkVersion:"M8.3"}}function jt(){return{template:`<template>
|
|
304
671
|
<div class="list-page">
|
|
305
672
|
<!-- \u4E0B\u62C9\u5237\u65B0\u5217\u8868 -->
|
|
306
|
-
<
|
|
673
|
+
<em-minirefresh
|
|
307
674
|
ref="minirefreshRef"
|
|
308
675
|
:use-body-scroll="true"
|
|
309
676
|
@pulldown="onRefresh"
|
|
310
677
|
@pullup="onLoadMore"
|
|
311
678
|
>
|
|
312
679
|
<!-- \u5217\u8868\u5185\u5BB9 -->
|
|
313
|
-
<
|
|
680
|
+
<em-cell
|
|
314
681
|
v-for="item in list"
|
|
315
682
|
:key="item.id"
|
|
316
683
|
:title="item.title"
|
|
@@ -320,8 +687,8 @@ export default {
|
|
|
320
687
|
/>
|
|
321
688
|
|
|
322
689
|
<!-- \u7A7A\u72B6\u6001 -->
|
|
323
|
-
<
|
|
324
|
-
</
|
|
690
|
+
<em-empty v-if="list.length === 0 && !loading" description="\u6682\u65E0\u6570\u636E" />
|
|
691
|
+
</em-minirefresh>
|
|
325
692
|
</div>
|
|
326
693
|
</template>`,script:`<script setup>
|
|
327
694
|
/**
|
|
@@ -409,11 +776,11 @@ onMounted(() => {
|
|
|
409
776
|
min-height: 100vh;
|
|
410
777
|
background: #f5f5f5;
|
|
411
778
|
}
|
|
412
|
-
</style>`,explanation:"\u5217\u8868\u8BE6\u60C5\u6A21\u5F0F\u7684 Vue3 \u5B9E\u73B0\uFF0C\u4F7F\u7528 Composition API \u548C <script setup> \u8BED\u6CD5",frameworkVersion:"M8.4"}}function
|
|
779
|
+
</style>`,explanation:"\u5217\u8868\u8BE6\u60C5\u6A21\u5F0F\u7684 Vue3 \u5B9E\u73B0\uFF0C\u4F7F\u7528 Composition API \u548C <script setup> \u8BED\u6CD5",frameworkVersion:"M8.4"}}function Mt(){return{template:`<template>
|
|
413
780
|
<div class="form-page">
|
|
414
|
-
<
|
|
781
|
+
<em-form ref="form" :model="formData" :rules="rules">
|
|
415
782
|
<!-- \u6587\u672C\u8F93\u5165 -->
|
|
416
|
-
<
|
|
783
|
+
<em-field
|
|
417
784
|
v-model="formData.name"
|
|
418
785
|
label="\u59D3\u540D"
|
|
419
786
|
placeholder="\u8BF7\u8F93\u5165\u59D3\u540D"
|
|
@@ -422,7 +789,7 @@ onMounted(() => {
|
|
|
422
789
|
/>
|
|
423
790
|
|
|
424
791
|
<!-- \u624B\u673A\u53F7 -->
|
|
425
|
-
<
|
|
792
|
+
<em-field
|
|
426
793
|
v-model="formData.phone"
|
|
427
794
|
label="\u624B\u673A\u53F7"
|
|
428
795
|
type="tel"
|
|
@@ -434,7 +801,7 @@ onMounted(() => {
|
|
|
434
801
|
/>
|
|
435
802
|
|
|
436
803
|
<!-- \u65E5\u671F\u9009\u62E9 -->
|
|
437
|
-
<
|
|
804
|
+
<em-field
|
|
438
805
|
v-model="formData.date"
|
|
439
806
|
label="\u65E5\u671F"
|
|
440
807
|
placeholder="\u8BF7\u9009\u62E9\u65E5\u671F"
|
|
@@ -444,7 +811,7 @@ onMounted(() => {
|
|
|
444
811
|
/>
|
|
445
812
|
|
|
446
813
|
<!-- \u9009\u62E9\u5668 -->
|
|
447
|
-
<
|
|
814
|
+
<em-field
|
|
448
815
|
v-model="formData.typeName"
|
|
449
816
|
label="\u7C7B\u578B"
|
|
450
817
|
placeholder="\u8BF7\u9009\u62E9\u7C7B\u578B"
|
|
@@ -455,19 +822,19 @@ onMounted(() => {
|
|
|
455
822
|
|
|
456
823
|
<!-- \u63D0\u4EA4\u6309\u94AE -->
|
|
457
824
|
<div class="form-actions">
|
|
458
|
-
<
|
|
825
|
+
<em-button type="primary" block @click="onSubmit">\u63D0\u4EA4</em-button>
|
|
459
826
|
</div>
|
|
460
|
-
</
|
|
827
|
+
</em-form>
|
|
461
828
|
|
|
462
829
|
<!-- \u65E5\u671F\u9009\u62E9\u5668\u5F39\u7A97 -->
|
|
463
|
-
<
|
|
830
|
+
<em-datepicker
|
|
464
831
|
v-model="showDatePicker"
|
|
465
832
|
:value="formData.date"
|
|
466
833
|
@confirm="onDateConfirm"
|
|
467
834
|
/>
|
|
468
835
|
|
|
469
836
|
<!-- \u9009\u62E9\u5668\u5F39\u7A97 -->
|
|
470
|
-
<
|
|
837
|
+
<em-picker
|
|
471
838
|
v-model="showPicker"
|
|
472
839
|
:columns="typeOptions"
|
|
473
840
|
@confirm="onTypeConfirm"
|
|
@@ -573,11 +940,11 @@ export default {
|
|
|
573
940
|
margin-top: 24px;
|
|
574
941
|
padding: 0 16px;
|
|
575
942
|
}
|
|
576
|
-
</style>`,explanation:"\u8868\u5355\u63D0\u4EA4\u6A21\u5F0F\u7684 Vue2 \u5B9E\u73B0\uFF0C\u5305\u542B\u8868\u5355\u9A8C\u8BC1\u3001\u9009\u62E9\u5668\u3001\u63D0\u4EA4\u53CD\u9988\u7B49\u529F\u80FD",frameworkVersion:"M8.3"}}function
|
|
943
|
+
</style>`,explanation:"\u8868\u5355\u63D0\u4EA4\u6A21\u5F0F\u7684 Vue2 \u5B9E\u73B0\uFF0C\u5305\u542B\u8868\u5355\u9A8C\u8BC1\u3001\u9009\u62E9\u5668\u3001\u63D0\u4EA4\u53CD\u9988\u7B49\u529F\u80FD",frameworkVersion:"M8.3"}}function St(){return{template:`<template>
|
|
577
944
|
<div class="form-page">
|
|
578
|
-
<
|
|
945
|
+
<em-form ref="formRef" :model="formData" :rules="rules">
|
|
579
946
|
<!-- \u6587\u672C\u8F93\u5165 -->
|
|
580
|
-
<
|
|
947
|
+
<em-field
|
|
581
948
|
v-model="formData.name"
|
|
582
949
|
label="\u59D3\u540D"
|
|
583
950
|
placeholder="\u8BF7\u8F93\u5165\u59D3\u540D"
|
|
@@ -585,7 +952,7 @@ export default {
|
|
|
585
952
|
/>
|
|
586
953
|
|
|
587
954
|
<!-- \u624B\u673A\u53F7 -->
|
|
588
|
-
<
|
|
955
|
+
<em-field
|
|
589
956
|
v-model="formData.phone"
|
|
590
957
|
label="\u624B\u673A\u53F7"
|
|
591
958
|
type="tel"
|
|
@@ -593,7 +960,7 @@ export default {
|
|
|
593
960
|
/>
|
|
594
961
|
|
|
595
962
|
<!-- \u65E5\u671F\u9009\u62E9 -->
|
|
596
|
-
<
|
|
963
|
+
<em-field
|
|
597
964
|
v-model="formData.date"
|
|
598
965
|
label="\u65E5\u671F"
|
|
599
966
|
placeholder="\u8BF7\u9009\u62E9\u65E5\u671F"
|
|
@@ -603,7 +970,7 @@ export default {
|
|
|
603
970
|
/>
|
|
604
971
|
|
|
605
972
|
<!-- \u9009\u62E9\u5668 -->
|
|
606
|
-
<
|
|
973
|
+
<em-field
|
|
607
974
|
v-model="formData.typeName"
|
|
608
975
|
label="\u7C7B\u578B"
|
|
609
976
|
placeholder="\u8BF7\u9009\u62E9\u7C7B\u578B"
|
|
@@ -614,19 +981,19 @@ export default {
|
|
|
614
981
|
|
|
615
982
|
<!-- \u63D0\u4EA4\u6309\u94AE -->
|
|
616
983
|
<div class="form-actions">
|
|
617
|
-
<
|
|
984
|
+
<em-button type="primary" block @click="onSubmit">\u63D0\u4EA4</em-button>
|
|
618
985
|
</div>
|
|
619
|
-
</
|
|
986
|
+
</em-form>
|
|
620
987
|
|
|
621
988
|
<!-- \u65E5\u671F\u9009\u62E9\u5668\u5F39\u7A97 -->
|
|
622
|
-
<
|
|
989
|
+
<em-datepicker
|
|
623
990
|
v-model="showDatePicker"
|
|
624
991
|
:value="formData.date"
|
|
625
992
|
@confirm="onDateConfirm"
|
|
626
993
|
/>
|
|
627
994
|
|
|
628
995
|
<!-- \u9009\u62E9\u5668\u5F39\u7A97 -->
|
|
629
|
-
<
|
|
996
|
+
<em-picker
|
|
630
997
|
v-model="showPicker"
|
|
631
998
|
:columns="typeOptions"
|
|
632
999
|
@confirm="onTypeConfirm"
|
|
@@ -731,9 +1098,9 @@ async function onSubmit() {
|
|
|
731
1098
|
margin-top: 24px;
|
|
732
1099
|
padding: 0 16px;
|
|
733
1100
|
}
|
|
734
|
-
</style>`,explanation:"\u8868\u5355\u63D0\u4EA4\u6A21\u5F0F\u7684 Vue3 \u5B9E\u73B0\uFF0C\u4F7F\u7528 Composition API \u548C reactive \u7BA1\u7406\u8868\u5355\u72B6\u6001",frameworkVersion:"M8.4"}}function
|
|
1101
|
+
</style>`,explanation:"\u8868\u5355\u63D0\u4EA4\u6A21\u5F0F\u7684 Vue3 \u5B9E\u73B0\uFF0C\u4F7F\u7528 Composition API \u548C reactive \u7BA1\u7406\u8868\u5355\u72B6\u6001",frameworkVersion:"M8.4"}}function Ct(){return{template:`<template>
|
|
735
1102
|
<div class="upload-page">
|
|
736
|
-
<
|
|
1103
|
+
<em-uploader
|
|
737
1104
|
v-model="fileList"
|
|
738
1105
|
:max-count="9"
|
|
739
1106
|
:max-size="5 * 1024 * 1024"
|
|
@@ -746,9 +1113,9 @@ async function onSubmit() {
|
|
|
746
1113
|
{{ file.progress }}%
|
|
747
1114
|
</div>
|
|
748
1115
|
</template>
|
|
749
|
-
</
|
|
1116
|
+
</em-uploader>
|
|
750
1117
|
|
|
751
|
-
<
|
|
1118
|
+
<em-button type="primary" block @click="uploadAll">\u4E0A\u4F20\u5168\u90E8</em-button>
|
|
752
1119
|
</div>
|
|
753
1120
|
</template>`,script:`<script>
|
|
754
1121
|
/**
|
|
@@ -849,9 +1216,9 @@ export default {
|
|
|
849
1216
|
font-size: 12px;
|
|
850
1217
|
padding: 2px 0;
|
|
851
1218
|
}
|
|
852
|
-
</style>`,explanation:"\u56FE\u7247\u4E0A\u4F20\u6A21\u5F0F\u7684 Vue2 \u5B9E\u73B0\uFF0C\u5305\u542B\u591A\u56FE\u4E0A\u4F20\u3001\u8FDB\u5EA6\u663E\u793A\u3001\u5927\u5C0F\u9650\u5236\u7B49\u529F\u80FD",frameworkVersion:"M8.3"}}function
|
|
1219
|
+
</style>`,explanation:"\u56FE\u7247\u4E0A\u4F20\u6A21\u5F0F\u7684 Vue2 \u5B9E\u73B0\uFF0C\u5305\u542B\u591A\u56FE\u4E0A\u4F20\u3001\u8FDB\u5EA6\u663E\u793A\u3001\u5927\u5C0F\u9650\u5236\u7B49\u529F\u80FD",frameworkVersion:"M8.3"}}function bt(){return{template:`<template>
|
|
853
1220
|
<div class="upload-page">
|
|
854
|
-
<
|
|
1221
|
+
<em-uploader
|
|
855
1222
|
v-model="fileList"
|
|
856
1223
|
:max-count="9"
|
|
857
1224
|
:max-size="5 * 1024 * 1024"
|
|
@@ -864,9 +1231,9 @@ export default {
|
|
|
864
1231
|
{{ file.progress }}%
|
|
865
1232
|
</div>
|
|
866
1233
|
</template>
|
|
867
|
-
</
|
|
1234
|
+
</em-uploader>
|
|
868
1235
|
|
|
869
|
-
<
|
|
1236
|
+
<em-button type="primary" block @click="uploadAll">\u4E0A\u4F20\u5168\u90E8</em-button>
|
|
870
1237
|
</div>
|
|
871
1238
|
</template>`,script:`<script setup>
|
|
872
1239
|
/**
|
|
@@ -960,4 +1327,22 @@ async function uploadAll() {
|
|
|
960
1327
|
font-size: 12px;
|
|
961
1328
|
padding: 2px 0;
|
|
962
1329
|
}
|
|
963
|
-
</style>`,explanation:"\u56FE\u7247\u4E0A\u4F20\u6A21\u5F0F\u7684 Vue3 \u5B9E\u73B0\uFF0C\u4F7F\u7528 Composition API \u7BA1\u7406\u6587\u4EF6\u5217\u8868\u548C\u4E0A\u4F20\u72B6\u6001",frameworkVersion:"M8.4"}}function
|
|
1330
|
+
</style>`,explanation:"\u56FE\u7247\u4E0A\u4F20\u6A21\u5F0F\u7684 Vue3 \u5B9E\u73B0\uFF0C\u4F7F\u7528 Composition API \u7BA1\u7406\u6587\u4EF6\u5217\u8868\u548C\u4E0A\u4F20\u72B6\u6001",frameworkVersion:"M8.4"}}function Me(t,e){let s=H[t];if(!s){let n=t.toLowerCase();for(let[a,l]of Object.entries(H))if(a.toLowerCase().includes(n)||n.includes(a.toLowerCase())){let i=ke(l.components),c=je(i);return{...l,componentDocReferences:i,vue2Code:{...l.vue2Code,explanation:l.vue2Code.explanation+c},vue3Code:{...l.vue3Code,explanation:l.vue3Code.explanation+c}}}return{error:`\u672A\u627E\u5230\u573A\u666F: ${t}`,availablePatterns:Object.keys(H)}}let r=ke(s.components),o=je(r);return e?{...s,componentDocReferences:r,vue2Code:e==="M8.3"?{...s.vue2Code,explanation:s.vue2Code.explanation+o}:{explanation:"\u8BF7\u4F7F\u7528 M8.3 \u7248\u672C\u67E5\u770B",frameworkVersion:"M8.3"},vue3Code:e==="M8.4"?{...s.vue3Code,explanation:s.vue3Code.explanation+o}:{explanation:"\u8BF7\u4F7F\u7528 M8.4 \u7248\u672C\u67E5\u770B",frameworkVersion:"M8.4"}}:{...s,componentDocReferences:r,vue2Code:{...s.vue2Code,explanation:s.vue2Code.explanation+o},vue3Code:{...s.vue3Code,explanation:s.vue3Code.explanation+o}}}function Se(t,e,s={}){return!e||e.trim().length===0?[]:E(t,e.trim(),{...s,limit:s.limit||20})}function Ce(t,e){if(!e)return{found:!1,error:"\u8BF7\u63D0\u4F9B\u65B9\u6CD5\u540D\u79F0"};let s=e.toLowerCase();s.startsWith("util.")&&(s=s.replace("util.",""));let r=t.utilMethods.get(s);if(r){let n=[];for(let[l,i]of t.utilMethods)i.category===r.category&&l!==s&&n.push(i.fullName);let a="";return s==="ajax"?a=`Util.ajax \u662F M8 \u6846\u67B6\u63A8\u8350\u7684 HTTP \u8BF7\u6C42\u65B9\u6CD5\uFF0C\u57FA\u4E8E axios \u5C01\u88C5\u3002
|
|
1331
|
+
- \u652F\u6301 Promise \u548C\u56DE\u8C03\u4E24\u79CD\u98CE\u683C
|
|
1332
|
+
- \u81EA\u52A8\u5904\u7406 token \u548C\u4EE3\u7406
|
|
1333
|
+
- \u652F\u6301\u8BF7\u6C42\u53D6\u6D88\u548C\u5E76\u53D1\u63A7\u5236
|
|
1334
|
+
- \u63A8\u8350\u4F7F\u7528 Promise \u98CE\u683C\u914D\u5408 async/await`:s==="upload"&&(a=`Util.upload \u662F M8 \u6846\u67B6\u63A8\u8350\u7684\u6587\u4EF6\u4E0A\u4F20\u65B9\u6CD5\u3002
|
|
1335
|
+
- \u652F\u6301 filePath \u548C files \u4E24\u79CD\u4E0A\u4F20\u65B9\u5F0F
|
|
1336
|
+
- filePath \u65B9\u5F0F\u652F\u6301\u8DE8\u7AEF\uFF08H5\u3001\u5FAE\u4FE1\u3001\u652F\u4ED8\u5B9D\u5C0F\u7A0B\u5E8F\uFF09
|
|
1337
|
+
- files \u65B9\u5F0F\u4EC5\u652F\u6301 H5
|
|
1338
|
+
- \u652F\u6301\u4E0A\u4F20\u8FDB\u5EA6\u56DE\u8C03`),{found:!0,method:r,relatedMethods:n.slice(0,5),usageTips:a}}let o=[];for(let[n,a]of t.utilMethods)(n.includes(s)||a.name.toLowerCase().includes(s))&&o.push(a.fullName);return{found:!1,error:`\u672A\u627E\u5230\u65B9\u6CD5: Util.${e}`,suggestions:o.slice(0,5)}}function be(t){let e=[];if(e.push(`# ${t.fullName}`),e.push(""),e.push(t.description),e.push(""),t.usageScenario&&(e.push("## \u4F7F\u7528\u573A\u666F"),e.push(""),e.push(t.usageScenario),e.push("")),t.version&&(e.push(`**\u7248\u672C\u8981\u6C42:** ${t.version}`),e.push("")),e.push("## \u5E73\u53F0\u652F\u6301"),e.push(""),e.push("| \u5E73\u53F0 | \u652F\u6301\u60C5\u51B5 |"),e.push("| --- | --- |"),e.push(`| H5 | ${N(t.platformSupport.h5)} |`),e.push(`| \u65B0\u70B9\u5C0F\u7A0B\u5E8F | ${N(t.platformSupport.ejsMiniProgram)} |`),e.push(`| \u5FAE\u4FE1\u5C0F\u7A0B\u5E8F | ${N(t.platformSupport.wechat)} |`),e.push(`| \u652F\u4ED8\u5B9D\u5C0F\u7A0B\u5E8F | ${N(t.platformSupport.alipay)} |`),e.push(""),t.params.length>0){e.push("## \u53C2\u6570"),e.push(""),e.push("| \u53C2\u6570 | \u7C7B\u578B | \u5FC5\u586B | \u8BF4\u660E |"),e.push("| --- | --- | --- | --- |");for(let s of t.params){let r=s.required?"\u662F":"\u5426",o=s.default?`${s.description}\uFF0C\u9ED8\u8BA4: ${s.default}`:s.description;e.push(`| ${s.name} | ${s.type} | ${r} | ${o} |`)}e.push("")}if(t.returns&&(e.push("## \u8FD4\u56DE\u503C"),e.push(""),e.push(`**\u7C7B\u578B:** ${t.returns.type}`),e.push(""),t.returns.fields&&t.returns.fields.length>0)){e.push("| \u5B57\u6BB5 | \u7C7B\u578B | \u8BF4\u660E |"),e.push("| --- | --- | --- |");for(let s of t.returns.fields)e.push(`| ${s.name} | ${s.type} | ${s.description} |`);e.push("")}if(t.examples.length>0){e.push("## \u4EE3\u7801\u793A\u4F8B"),e.push("");for(let s of t.examples)s.title&&(e.push(`### ${s.title}`),e.push("")),s.frameworkVersion&&(e.push(`> \u6846\u67B6\u7248\u672C: ${s.frameworkVersion}`),e.push("")),e.push(`\`\`\`${s.language}`),e.push(s.code),e.push("```"),e.push("")}return t.relatedMethods&&t.relatedMethods.length>0&&(e.push("## \u76F8\u5173\u65B9\u6CD5"),e.push(""),e.push(t.relatedMethods.map(s=>`- ${s}`).join(`
|
|
1339
|
+
`)),e.push("")),e.join(`
|
|
1340
|
+
`)}function N(t){return t===!0?"\u2705 \u652F\u6301":t===!1?"\u274C \u4E0D\u652F\u6301":`\u26A0\uFE0F ${t}`}import*as C from"fs";import*as k from"path";var Pt="docs/standards";function At(){let e=k.dirname(new URL(import.meta.url).pathname).replace(/^\/([A-Z]:)/,"$1");return k.join(e,"..","..",Pt)}function Nt(t){try{let s=C.readFileSync(t,"utf-8").split(`
|
|
1341
|
+
`),r={filePath:t,rules:[],examples:[],antiPatterns:[]},o="",n=null,a="",l=!1,i="";for(let p of s){if(p.startsWith("# ")){r.name=p.substring(2).trim();continue}if(p.startsWith("<!-- ")){let u=p.match(/<!--\s*(\w+):\s*(.+?)\s*-->/);if(u){let[,d,f]=u;d==="id"&&(r.id=f),d==="category"&&(r.category=f),d==="version"&&(r.version=f),d==="lastUpdated"&&(r.lastUpdated=f)}continue}if(p.startsWith("## ")){o=p.substring(3).trim().toLowerCase();continue}if(p.startsWith("### ")){n&&n.title&&r.rules.push(n),n={id:`rule-${r.rules.length+1}`,title:p.substring(4).trim(),description:"",severity:"warning"};continue}if(p.startsWith("```")){if(l){let u={code:a.trim(),language:i||"javascript"};o.includes("\u53CD\u6A21\u5F0F")||o.includes("anti")?r.antiPatterns.push(u):o.includes("\u793A\u4F8B")||o.includes("example")?r.examples.push(u):n&&(a.includes("// \u274C")||a.includes("// \u9519\u8BEF")?n.badExample=a.trim():n.goodExample=a.trim()),a="",l=!1}else l=!0,i=p.substring(3).trim();continue}if(l){a+=p+`
|
|
1342
|
+
`;continue}p.trim()&&!p.startsWith("-")&&!p.startsWith("|")&&(n&&!n.description?n.description=p.trim():!r.description&&o===""&&(r.description=p.trim()))}n&&n.title&&r.rules.push(n);let c=k.basename(t,".md");return r.id||(r.id=c),r.category||(c.includes("css")||c.includes("scss")?r.category="css":c.includes("vue")?r.category="vue":c.includes("js")||c.includes("javascript")?r.category="javascript":c.includes("ts")||c.includes("typescript")?r.category="typescript":c.includes("project")||c.includes("structure")?r.category="project":c.includes("git")?r.category="git":c.includes("naming")&&(r.category="naming")),r.version||(r.version="1.0.0"),r.lastUpdated||(r.lastUpdated=new Date().toISOString().split("T")[0]),r}catch(e){return console.error(`[StandardsManager] \u89E3\u6790\u89C4\u8303\u6587\u6863\u5931\u8D25: ${t}`,e),null}}function Pe(){let t=new Map,e=At();if(!C.existsSync(e))return console.error(`[StandardsManager] \u89C4\u8303\u76EE\u5F55\u4E0D\u5B58\u5728: ${e}`),t;let s=C.readdirSync(e);for(let r of s)if(r.endsWith(".md")){let o=k.join(e,r),n=Nt(o);n&&t.set(n.id,n)}return console.error(`[StandardsManager] \u52A0\u8F7D\u4E86 ${t.size} \u4E2A\u89C4\u8303\u6587\u6863`),t}function Ae(t,e){let s=[];for(let r of t.values())r.category===e&&s.push(r);return s}function Ne(t,e){return t.get(e)}function Ie(t,e){let s=[];for(let r of t.values())(!e||r.category===e)&&s.push({id:r.id,name:r.name,category:r.category,description:r.description});return s}function W(t){let e=[];if(e.push(`# ${t.name}`),e.push(""),e.push(`**\u5206\u7C7B:** ${t.category}`),e.push(`**\u7248\u672C:** ${t.version}`),e.push(`**\u66F4\u65B0\u65F6\u95F4:** ${t.lastUpdated}`),e.push(""),e.push(t.description),e.push(""),t.rules.length>0){e.push("## \u89C4\u5219"),e.push("");for(let s of t.rules)e.push(`### ${s.title}`),e.push(""),e.push(s.description),e.push(""),s.goodExample&&(e.push("**\u6B63\u786E\u793A\u4F8B:**"),e.push("```javascript"),e.push(s.goodExample),e.push("```"),e.push("")),s.badExample&&(e.push("**\u9519\u8BEF\u793A\u4F8B:**"),e.push("```javascript"),e.push(s.badExample),e.push("```"),e.push(""))}if(t.examples.length>0){e.push("## \u793A\u4F8B"),e.push("");for(let s of t.examples)s.title&&(e.push(`### ${s.title}`),e.push("")),e.push(`\`\`\`${s.language}`),e.push(s.code),e.push("```"),e.push("")}if(t.antiPatterns.length>0){e.push("## \u53CD\u6A21\u5F0F"),e.push("");for(let s of t.antiPatterns)s.title&&(e.push(`### ${s.title}`),e.push("")),e.push(`\`\`\`${s.language}`),e.push(s.code),e.push("```"),e.push("")}return e.join(`
|
|
1343
|
+
`)}function Le(t,e){let s=["css","vue","javascript","typescript","naming","project","git"];if(e.id){let r=Ne(t,e.id);return r?{found:!0,standard:r,markdown:W(r)}:{found:!1,error:`\u672A\u627E\u5230\u89C4\u8303: ${e.id}`,availableCategories:s}}if(e.category){let r=Ae(t,e.category);return r.length>0?r.length===1?{found:!0,standard:r[0],markdown:W(r[0])}:{found:!0,standards:r}:{found:!1,error:`\u672A\u627E\u5230\u5206\u7C7B "${e.category}" \u4E0B\u7684\u89C4\u8303`,availableCategories:s}}return{found:!1,error:"\u8BF7\u6307\u5B9A\u89C4\u8303 ID \u6216\u5206\u7C7B",availableCategories:s}}function De(t,e){let s=Ie(t,e),r=new Set;for(let o of t.values())r.add(o.category);return{standards:s,total:s.length,categories:Array.from(r).sort()}}function Ue(t){let e=[];e.push("# \u53EF\u7528\u7684\u7F16\u7801\u89C4\u8303"),e.push(""),e.push(`\u5171 ${t.total} \u4E2A\u89C4\u8303`),e.push("");let s=new Map;for(let o of t.standards){let n=s.get(o.category)||[];n.push(o),s.set(o.category,n)}let r={css:"CSS/SCSS \u89C4\u8303",vue:"Vue \u7EC4\u4EF6\u89C4\u8303",javascript:"JavaScript \u89C4\u8303",typescript:"TypeScript \u89C4\u8303",naming:"\u547D\u540D\u89C4\u8303",project:"\u9879\u76EE\u7ED3\u6784\u89C4\u8303",git:"Git \u89C4\u8303"};for(let[o,n]of s){e.push(`## ${r[o]||o}`),e.push("");for(let a of n)e.push(`- **${a.name}** (\`${a.id}\`)`),e.push(` ${a.description}`);e.push("")}return e.push("---"),e.push("\u4F7F\u7528 `get_standard` \u5DE5\u5177\u67E5\u770B\u89C4\u8303\u8BE6\u60C5\uFF0C\u4F8B\u5982\uFF1A"),e.push('- \u6309 ID \u67E5\u8BE2: `{ "id": "vue-style" }`'),e.push('- \u6309\u5206\u7C7B\u67E5\u8BE2: `{ "category": "css" }`'),e.join(`
|
|
1344
|
+
`)}var x=null,b=new Map,Ot=Dt(import.meta.url),Vt=Ut(Ot),Et=Te(Vt,"..");function Oe(t,e,s){if(process.env[t])return process.env[t];let r=Te(Et,"docs",e);return Tt(r)?r:s}var _t=Oe("EJS_DOC_PATH","ejs-doc","ejs-doc"),Rt=Oe("M8_DOC_PATH","m8mpdoc-develop","m8mpdoc-develop");async function Ft(){console.error("[M8 MCP] \u6B63\u5728\u521D\u59CB\u5316\u6587\u6863\u7D22\u5F15...");try{x=await oe(_t,Rt),console.error(`[M8 MCP] \u7D22\u5F15\u6784\u5EFA\u5B8C\u6210: ${x.components.size} \u4E2A\u7EC4\u4EF6, ${x.ejsApis.size} \u4E2A API, ${x.utilMethods.size} \u4E2A Util \u65B9\u6CD5`),b=Pe(),x.standards=b,console.error(`[M8 MCP] \u52A0\u8F7D\u4E86 ${b.size} \u4E2A\u7F16\u7801\u89C4\u8303`)}catch(t){console.error("[M8 MCP] \u7D22\u5F15\u6784\u5EFA\u5931\u8D25:",t),x={components:new Map,ejsApis:new Map,utilMethods:new Map,standards:new Map,keywords:new Map,categories:new Map,buildTime:new Date}}}function y(){if(!x)throw new Error("\u6587\u6863\u7D22\u5F15\u5C1A\u672A\u521D\u59CB\u5316");return x}function Ht(){let t=new It({name:"M8FrameworkMCP",version:"1.0.0"});return t.tool("search_component","\u641C\u7D22 M8 \u6846\u67B6 UI \u7EC4\u4EF6\uFF0C\u652F\u6301\u6309\u540D\u79F0\u6216\u529F\u80FD\u63CF\u8FF0\u641C\u7D22",{query:h.string().describe("\u641C\u7D22\u5173\u952E\u8BCD\uFF0C\u5982\u7EC4\u4EF6\u540D\u79F0\u6216\u529F\u80FD\u63CF\u8FF0"),category:h.string().optional().describe('\u53EF\u9009\u7684\u5206\u7C7B\u8FC7\u6EE4\uFF0C\u5982"\u8868\u5355\u7EC4\u4EF6"\u3001"\u53CD\u9988\u7EC4\u4EF6"'),platform:h.string().optional().describe('\u53EF\u9009\u7684\u5E73\u53F0\u8FC7\u6EE4\uFF0C\u5982"wechat"\u3001"alipay"')},async({query:e,category:s,platform:r})=>{let o=ne(y(),e,{category:s,platform:r});return{content:[{type:"text",text:JSON.stringify(o,null,2)}]}}),t.tool("search_ejs_api","\u641C\u7D22 EJS \u539F\u751F API\uFF0C\u652F\u6301\u6309\u6A21\u5757\u6216\u529F\u80FD\u63CF\u8FF0\u641C\u7D22",{query:h.string().describe("\u641C\u7D22\u5173\u952E\u8BCD\uFF0C\u5982 API \u540D\u79F0\u6216\u529F\u80FD\u63CF\u8FF0"),module:h.string().optional().describe('\u53EF\u9009\u7684\u6A21\u5757\u8FC7\u6EE4\uFF0C\u5982"ui"\u3001"device"\u3001"storage"')},async({query:e,module:s})=>{let r=ae(y(),e,{module:s});return{content:[{type:"text",text:JSON.stringify(r,null,2)}]}}),t.tool("get_component_detail","\u83B7\u53D6 M8 \u6846\u67B6 UI \u7EC4\u4EF6\u7684\u5B8C\u6574\u6587\u6863\uFF0C\u5305\u62EC Props\u3001Events\u3001\u793A\u4F8B\u4EE3\u7801",{name:h.string().describe('\u7EC4\u4EF6\u540D\u79F0\uFF0C\u5982"button"\u3001"form"\u3001"picker"')},async({name:e})=>{let s=ie(y(),e);return{content:[{type:"text",text:JSON.stringify(s,null,2)}]}}),t.tool("get_api_detail","\u83B7\u53D6 EJS API \u7684\u5B8C\u6574\u6587\u6863\uFF0C\u5305\u62EC\u53C2\u6570\u3001\u8FD4\u56DE\u503C\u3001\u5E73\u53F0\u5DEE\u5F02",{module:h.string().describe('\u6A21\u5757\u540D\uFF0C\u5982"ui"\u3001"device"'),name:h.string().describe('API \u540D\u79F0\uFF0C\u5982"toast"\u3001"alert"')},async({module:e,name:s})=>{let r=le(y(),e,s);return{content:[{type:"text",text:JSON.stringify(r,null,2)}]}}),t.tool("recommend","\u6839\u636E\u9700\u6C42\u63CF\u8FF0\u667A\u80FD\u63A8\u8350\u5408\u9002\u7684\u7EC4\u4EF6\u548C API",{requirement:h.string().describe('\u9700\u6C42\u63CF\u8FF0\uFF0C\u5982"\u5B9E\u73B0\u4E00\u4E2A\u5E26\u65E5\u671F\u9009\u62E9\u7684\u8868\u5355"'),platform:h.string().optional().describe('\u76EE\u6807\u5E73\u53F0\uFF0C\u5982"wechat"\u3001"h5"')},async({requirement:e,platform:s})=>{let r=pe(y(),e,s);return{content:[{type:"text",text:JSON.stringify(r,null,2)}]}}),t.tool("generate_code","\u751F\u6210\u7B26\u5408 M8 \u6846\u67B6\u89C4\u8303\u7684\u4EE3\u7801\uFF0C\u652F\u6301 M8.3(Vue2) \u548C M8.4(Vue3)",{type:h.enum(["component","ejsApi","pattern"]).describe("\u751F\u6210\u7C7B\u578B"),name:h.string().describe("\u7EC4\u4EF6/API/\u6A21\u5F0F\u540D\u79F0"),frameworkVersion:h.enum(["M8.3","M8.4"]).describe("\u6846\u67B6\u7248\u672C\uFF0CM8.3=Vue2, M8.4=Vue3"),platform:h.string().optional().describe("\u76EE\u6807\u5E73\u53F0\uFF0C\u7528\u4E8E\u751F\u6210\u6761\u4EF6\u7F16\u8BD1\u4EE3\u7801")},async({type:e,name:s,frameworkVersion:r,platform:o})=>{let n=ve(y(),{type:e,name:s,options:{frameworkVersion:r,platform:o}});return{content:[{type:"text",text:JSON.stringify(n,null,2)}]}}),t.tool("check_compatibility","\u68C0\u67E5\u7EC4\u4EF6\u6216 API \u5728\u76EE\u6807\u5E73\u53F0\u7684\u517C\u5BB9\u6027",{items:h.array(h.string()).describe("\u8981\u68C0\u67E5\u7684\u7EC4\u4EF6\u6216 API \u5217\u8868"),targetPlatforms:h.array(h.string()).describe('\u76EE\u6807\u5E73\u53F0\u5217\u8868\uFF0C\u5982["wechat", "alipay", "h5"]')},async({items:e,targetPlatforms:s})=>{let r=$e(y(),e,s);return{content:[{type:"text",text:JSON.stringify(r,null,2)}]}}),t.tool("get_pattern","\u83B7\u53D6\u5E38\u89C1\u573A\u666F\u7684\u5B9E\u73B0\u6A21\u5F0F\uFF0C\u5982\u5217\u8868\u8BE6\u60C5\u3001\u8868\u5355\u63D0\u4EA4",{scenario:h.string().describe('\u573A\u666F\u540D\u79F0\uFF0C\u5982"\u5217\u8868\u8BE6\u60C5"\u3001"\u8868\u5355\u63D0\u4EA4"'),frameworkVersion:h.enum(["M8.3","M8.4"]).optional().describe("\u6846\u67B6\u7248\u672C\uFF0C\u4E0D\u6307\u5B9A\u5219\u8FD4\u56DE\u4E24\u4E2A\u7248\u672C")},async({scenario:e,frameworkVersion:s})=>{let r=Me(e,s);return{content:[{type:"text",text:JSON.stringify(r,null,2)}]}}),t.tool("search_util","\u641C\u7D22 M8 \u6846\u67B6 Util \u5DE5\u5177\u65B9\u6CD5\uFF0C\u5982 Util.ajax\u3001Util.upload \u7B49",{query:h.string().describe('\u641C\u7D22\u5173\u952E\u8BCD\uFF0C\u5982"ajax"\u3001"\u8BF7\u6C42"\u3001"\u4E0A\u4F20"'),category:h.string().optional().describe('\u53EF\u9009\u7684\u5206\u7C7B\u8FC7\u6EE4\uFF0C\u5982"\u6838\u5FC3\u901A\u7528Util"\u3001"Util\u5DE5\u5177\u96C6"')},async({query:e,category:s})=>{let r=Se(y(),e,{category:s});return{content:[{type:"text",text:JSON.stringify(r,null,2)}]}}),t.tool("get_util_detail","\u83B7\u53D6 Util \u5DE5\u5177\u65B9\u6CD5\u7684\u5B8C\u6574\u6587\u6863\uFF0C\u5305\u62EC\u53C2\u6570\u3001\u8FD4\u56DE\u503C\u3001\u4EE3\u7801\u793A\u4F8B",{name:h.string().describe('\u65B9\u6CD5\u540D\uFF0C\u5982"ajax"\u6216"Util.ajax"')},async({name:e})=>{let s=Ce(y(),e),r=JSON.stringify(s,null,2);return s.found&&s.method&&(r+=`
|
|
1345
|
+
|
|
1346
|
+
---
|
|
1347
|
+
|
|
1348
|
+
`+be(s.method)),{content:[{type:"text",text:r}]}}),t.tool("get_standard","\u83B7\u53D6\u7F16\u7801\u89C4\u8303\u6587\u6863\uFF0C\u652F\u6301\u6309\u5206\u7C7B\u6216 ID \u67E5\u8BE2",{id:h.string().optional().describe('\u89C4\u8303 ID\uFF0C\u5982"vue-style"\u3001"css-style"'),category:h.enum(["css","vue","javascript","typescript","naming","project","git"]).optional().describe("\u89C4\u8303\u5206\u7C7B")},async({id:e,category:s})=>{let r=Le(b,{id:e,category:s}),o=JSON.stringify(r,null,2);return r.found&&r.markdown&&(o=r.markdown),{content:[{type:"text",text:o}]}}),t.tool("list_standards","\u5217\u51FA\u6240\u6709\u53EF\u7528\u7684\u7F16\u7801\u89C4\u8303",{category:h.enum(["css","vue","javascript","typescript","naming","project","git"]).optional().describe("\u53EF\u9009\u7684\u5206\u7C7B\u8FC7\u6EE4")},async({category:e})=>{let s=De(b,e);return{content:[{type:"text",text:Ue(s)}]}}),t}async function Wt(){await Ft();let t=Ht(),e=new Lt;console.error("[M8 MCP] \u670D\u52A1\u5668\u542F\u52A8\u4E2D..."),await t.connect(e),console.error("[M8 MCP] \u670D\u52A1\u5668\u5DF2\u542F\u52A8\uFF0C\u7B49\u5F85\u8FDE\u63A5...")}Wt().catch(t=>{console.error("[M8 MCP] \u670D\u52A1\u5668\u542F\u52A8\u5931\u8D25:",t),process.exit(1)});
|