m8-framework-mcp 1.0.4 → 1.0.5
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/build/index.js +111 -92
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{McpServer as It}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as
|
|
2
|
+
import{McpServer as It}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as Ut}from"@modelcontextprotocol/sdk/server/stdio.js";import{z as h}from"zod";import{fileURLToPath as Dt}from"url";import{dirname as Lt,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(e){try{return j.readFileSync(e,"utf-8")}catch(t){return console.error(`[Parser] \u8BFB\u53D6\u6587\u4EF6\u5931\u8D25: ${e}`,t),""}}function v(e){let t=[];try{if(!j.existsSync(e))return console.error(`[Parser] \u76EE\u5F55\u4E0D\u5B58\u5728: ${e}`),t;let s=j.readdirSync(e,{withFileTypes:!0});for(let r of s){let o=z.join(e,r.name);r.isDirectory()?t.push(...v(o)):r.isFile()&&r.name.endsWith(".md")&&t.push(o)}}catch(s){console.error(`[Parser] \u626B\u63CF\u76EE\u5F55\u5931\u8D25: ${e}`,s)}return t}function Ee(e){let t=[];for(let s of e){if(/^\|[\s\-:]+\|$/.test(s.trim()))continue;let r=s.split("|").map(o=>o.trim()).filter(o=>o!=="");r.length>0&&t.push(r)}return t}function M(e){let t=Ve(e),s=[],r="",o=t.split(`
|
|
3
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
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
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
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:
|
|
8
|
-
`)[0];break}let l=[],i=P(
|
|
9
|
-
`)[0]));o&&o.name&&(G(o,a),
|
|
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
|
|
7
|
+
`)});continue}n++}return{filePath:e,title:r,nodes:s,rawContent:t}}function P(e,t,s){let r=[],o=!1,n=0;for(let a of e){if(a.type==="heading"){if(a.content.toLowerCase().includes(t.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(e){let t=e.replace(".md","").replace(/^\d+-/,""),s=t.match(/^([a-zA-Z\-]+)(.*)$/);return s?{name:s[1].toLowerCase(),displayName:s[2]||s[1]}:{name:t.toLowerCase(),displayName:t}}function Fe(e){let t=e.split(A.sep);for(let s of t)if(s.includes("\u7EC4\u4EF6")||s.includes("UI"))return s.replace(/^\d+-/,"");return"\u5176\u4ED6"}function J(e){let t=[];if(e.length<2)return t;let s=e[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<e.length;l++){let i=e[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&&t.push(c)}return t}function Re(e){let t=[];if(e.length<2)return t;let s=e[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<e.length;a++){let l=e[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&&t.push(i)}return t}function He(e){let t=B();if(e.length<2)return t;let s=e[0].map(n=>n.toLowerCase()),r=e[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"?t[c]=!0:l==="\u4E0D\u652F\u6301"||l==="\u5426"||l==="false"||l==="no"?t[c]=!1:l&&(t[c]=r[n].trim());break}}return t}function We(e){let t=[],s="",r;for(let o of e)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())&&t.push({title:s,code:o.content,language:o.language,frameworkVersion:r});return t}function ze(e){try{let t=M(e),s=A.basename(e),{name:r,displayName:o}=_e(s),n=Fe(e),a="";for(let f of t.nodes)if(f.type==="paragraph"){a=f.content.split(`
|
|
8
|
+
`)[0];break}let l=[],i=P(t.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(t.nodes,"api");for(let m of f)if(m.type==="table"&&m.rows){l=J(m.rows);break}}let c=[],p=P(t.nodes,"events");for(let f of p)if(f.type==="table"&&f.rows){c=Re(f.rows);break}let u=B();for(let f of t.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(t.nodes);return{name:r,displayName:o||t.title||r,description:a||t.title,category:n,props:l,events:c,examples:d,platformSupport:u,filePath:e}}catch(t){return console.error(`[ComponentParser] \u89E3\u6790\u7EC4\u4EF6\u6587\u6863\u5931\u8D25: ${e}`,t),null}}function K(e){let t=[],s=v(e);for(let r of s)if(r.includes("UI\u7EC4\u4EF6")||r.includes("009-")){let o=ze(r);o&&t.push(o)}return t}import*as S from"path";function Y(){return{ejsH5:!1,ejsMiniProgram:!1,h5:!1,dingtalk:!1,wechat:!1,alipay:!1}}function Je(e){let s=S.basename(e,".md").match(/api_(\w+)/);if(s)return s[1];let o=S.basename(S.dirname(e)).match(/api_(\w+)/);return o?o[1]:"unknown"}function X(e){let t=[];if(e.length<2)return t;let s=e[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<e.length;l++){let i=e[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&&t.push(c)}return t}function Be(e){if(e.length<2)return;let t=X(e);if(t.length!==0)return{type:"object",description:"\u8FD4\u56DE\u503C\u5BF9\u8C61",fields:t}}function Ke(e){let t=Y();if(e.length<2)return t;let s=e[0].map(n=>n.toLowerCase()),r=e[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")?t[c]=!0:l==="\u4E0D\u652F\u6301"||l.includes("\u4E0D\u652F\u6301")?t[c]=!1:l&&(t[c]=r[n].trim());break}}return t}function Ge(e){let t=[/支持版本[::]\s*[`><=]*\s*([\d.]+)/,/版本\s*[`><=]*\s*([\d.]+)\s*开始支持/,/ejs\s*[><=]+\s*([\d.]+[a-z]*)/i,/v([\d.]+)\s*版本/];for(let s of t){let r=e.match(s);if(r)return r[1]}}function Ye(e){let t=[];try{let s=M(e),r=Je(e),o=null,n="",a=[];for(let l of s.nodes)l.type==="heading"&&l.level===2?(o&&o.name&&(G(o,a),t.push(o)),o={module:r,name:l.content.replace(/[`*]/g,"").trim(),description:"",params:[],examples:[],platformSupport:Y(),filePath:e},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),t.push(o))}catch(s){console.error(`[EjsApiParser] \u89E3\u6790 API \u6587\u6863\u5931\u8D25: ${e}`,s)}return t}function G(e,t){for(let s of t){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")?e.platformSupport=Ke(s.rows):r.includes("\u53C2\u6570")||o.includes("\u53C2\u6570")||o.includes("\u7C7B\u578B")?e.params=X(s.rows):(r.includes("\u8FD4\u56DE")||o.includes("\u8FD4\u56DE"))&&(e.returns=Be(s.rows))}if(s.type==="code"&&s.language&&["js","javascript"].includes(s.language.toLowerCase())&&e.examples.push({title:r||"\u4F7F\u7528\u793A\u4F8B",code:s.content,language:s.language}),s.type==="paragraph"){let o=Ge(s.content);o&&!e.minVersion&&(e.minVersion=o)}}}function Q(e){let t=[],s=v(e);for(let r of s){let o=S.basename(r);if(o.startsWith("api_")&&o.endsWith(".md")){let n=Ye(r);t.push(...n)}}return t}function q(){return{ejsH5:!1,ejsMiniProgram:!1,h5:!1,dingtalk:!1,wechat:!1,alipay:!1}}function Xe(e){let s=e.replace(/\\/g,"/").match(/\/(\d{3})-(.+?)[\/]/);if(s&&s[2]){let r=s[2],o={\u6838\u5FC3\u901A\u7528Util:"\u6838\u5FC3\u901A\u7528Util",Util\u5DE5\u5177\u96C6:"Util\u5DE5\u5177\u96C6",UI\u7EC4\u4EF6:"UI\u7EC4\u4EF6",\u5178\u578B\u6848\u4F8B:"\u5178\u578B\u6848\u4F8B",\u89C4\u8303\u4E0E\u6A21\u5F0F:"\u89C4\u8303\u4E0E\u6A21\u5F0F",\u5185\u7F6E\u7EC4\u4EF6:"\u5185\u7F6E\u7EC4\u4EF6",EPUI\u7EC4\u4EF6:"EPUI\u7EC4\u4EF6",\u5DE5\u7A0B\u5316:"\u5DE5\u7A0B\u5316",Mock\u7684\u4F7F\u7528:"Mock\u7684\u4F7F\u7528",\u5E38\u89C1\u95EE\u9898:"\u5E38\u89C1\u95EE\u9898",\u9875\u9762\u5F00\u53D1:"\u9875\u9762\u5F00\u53D1"};if(r in o)return o[r]}return"\u5176\u4ED6"}function U(e){let t=[];if(e.length<2)return t;let s=e[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<e.length;i++){let c=e[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&&t.push(p)}return t}function Qe(e){if(e.length<2)return;let t=U(e);if(t.length!==0)return{type:"object",description:"\u8FD4\u56DE\u503C\u5BF9\u8C61",fields:t}}function Ze(e){let t=q();if(e.length<2)return t;let s=e[0].map(n=>n.toLowerCase()),r=e[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")?t[c]=!0:l==="x"||l==="\xD7"||l.includes("\u4E0D\u652F\u6301")?t[c]=!1:l&&(t[c]=l);break}}return t}function qe(e){let t=[/`?v?([\d.]+)`?\s*版本/,/版本\s*`?v?([\d.]+)`?/,/`v([\d.]+[a-z\-\.]*)`/i];for(let s of t){let r=e.match(s);if(r)return r[1]}}function et(e){return{isM84:e.includes("::: ifdef M84")||e.includes("ifdef M84"),isM83:e.includes("::: ifdef M83")||e.includes("ifdef M83")}}function tt(e){let t=[];try{let s=M(e),r=Xe(e),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),t.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:e,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),t.push(o))}catch(s){console.error(`[UtilParser] \u89E3\u6790 Util \u6587\u6863\u5931\u8D25: ${e}`,s)}return t}function Z(e,t){for(let s of t){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?e.platformSupport=Ze(s.rows):(r.includes("\u53C2\u6570")||o.includes("\u53C2\u6570")||o.includes("\u7C7B\u578B"))&&(e.params=U(s.rows)):r.includes("\u53C2\u6570")||o.includes("\u53C2\u6570")||o.includes("\u7C7B\u578B")?e.params=U(s.rows):(r.includes("\u8FD4\u56DE")||o.includes("\u8FD4\u56DE"))&&(e.returns=Qe(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"),e.examples.push(o)}if(s.type==="paragraph"){let o=qe(s.content);o&&!e.version&&(e.version=o)}}}function ee(e){let t=[],s=v(e),r=["005-\u6838\u5FC3\u901A\u7528Util","006-Util\u5DE5\u5177\u96C6","015-\u5DE5\u7A0B\u5316","012-Mock\u7684\u4F7F\u7528","014-\u5E38\u89C1\u95EE\u9898","001-\u9875\u9762\u5F00\u53D1","003-\u5178\u578B\u6848\u4F8B","002-\u89C4\u8303\u4E0E\u6A21\u5F0F","017-\u5185\u7F6E\u7EC4\u4EF6","011-vuex\u4E0Erouter\u7684\u4F7F\u7528"];for(let o of s){let n=o.replace(/\\/g,"/");if(r.some(a=>n.includes(a))){let a=tt(o);t.push(...a)}}return t}function te(e){let t=[e.name.toLowerCase(),e.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[e.name.toLowerCase()]&&t.push(...s[e.name.toLowerCase()]),e.filePath&&(e.filePath.includes("string.md")||e.filePath.includes("Util.string"))&&t.push("validation","\u6821\u9A8C","\u6B63\u5219","regular","check","validate"),e.description){let r=e.description.replace(/[,。、;:""''()【】]/g," ").split(/\s+/).filter(o=>o.length>=2);t.push(...r.slice(0,5))}return[...new Set(t)]}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 L(e){let t=e.toLowerCase(),s=new Set([t]);if(D[e])for(let r of D[e])s.add(r.toLowerCase());for(let[r,o]of Object.entries(D))if(o.some(n=>n.toLowerCase()===t)){s.add(r.toLowerCase());for(let n of o)s.add(n.toLowerCase())}return Array.from(s)}function st(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ot(e,t,s){let r=e.toLowerCase(),o=t.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=L(e);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(e,t){console.error("[Index] \u5F00\u59CB\u6784\u5EFA\u7D22\u5F15..."),console.error(`[Index] EJS \u6587\u6863\u8DEF\u5F84: ${e}`),console.error(`[Index] M8 \u6587\u6863\u8DEF\u5F84: ${t}`);let s=K(t);console.error(`[Index] \u89E3\u6790\u5230 ${s.length} \u4E2A\u7EC4\u4EF6`);let r=Q(e);console.error(`[Index] \u89E3\u6790\u5230 ${r.length} \u4E2A API`);let o=ee(t);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(...e){let t=new Set;for(let s of e){if(!s)continue;let r=s.toLowerCase();t.add(r);let o=r.split(/[\s\-_,.,。、;:""''()【】]+/);for(let a of o)a.length>=2&&t.add(a);let n=s.match(/[\u4e00-\u9fa5]+/g);if(n)for(let a of n){t.add(a);for(let l of a)t.add(l)}}return Array.from(t)}function $(e,t,s,r){return ot(e,t,r)}function T(e,t){let r={ejsh5:"ejsH5",ejs:"ejsH5",ejsminiprogram:"ejsMiniProgram",h5:"h5",dingtalk:"dingtalk",wechat:"wechat",alipay:"alipay",weex:"weex"}[t.toLowerCase()];if(!r)return!0;let o=e[r];return o===!0||typeof o=="string"&&o.length>0}function O(e,t,s={}){let r=[],o=t.toLowerCase(),a=s.enableSynonyms!==!1?L(t):[o];for(let[l,i]of e.components){if(s.category&&i.category!==s.category||s.platform&&!T(i.platformSupport,s.platform))continue;let c=0;c=Math.max(c,$(t,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(e.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(e,t,s={}){let r=[],o=t.toLowerCase(),a=s.enableSynonyms!==!1?L(t):[o];for(let[l,i]of e.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,$(t,i.name,!0,p)),c=Math.max(c,$(t,`${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(e.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(e,t,s={}){let r=[],o=t.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 e.utilMethods){if(s.category&&p.category!==s.category||s.platform&&!T(p.platformSupport,s.platform))continue;let u=0;u=Math.max(u,$(t,c,!0)),u=Math.max(u,$(t,p.fullName,!0)),p.description.toLowerCase().includes(o)&&(u=Math.max(u,50)),e.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(e,t,s={}){let r=O(e,t,s),o=V(e,t,s),a=[...E(e,t,s),...r,...o];return a.sort((l,i)=>i.score-l.score),s.limit?a.slice(0,s.limit):a}function ne(e,t,s={}){return!t||t.trim().length===0?[]:O(e,t.trim(),{...s,limit:s.limit||20})}function ae(e,t,s={}){return!t||t.trim().length===0?[]:V(e,t.trim(),{...s,limit:s.limit||20})}function ie(e,t){if(!t||t.trim().length===0)return{found:!1,error:"\u8BF7\u63D0\u4F9B\u7EC4\u4EF6\u540D\u79F0"};let s=t.toLowerCase().trim(),r=e.components.get(s);if(r)return{found:!0,component:r};let o=[];for(let[n,a]of e.components)(n.includes(s)||s.includes(n)||a.displayName.toLowerCase().includes(s))&&o.push(n);return{found:!1,error:`\u672A\u627E\u5230\u7EC4\u4EF6: ${t}`,suggestions:o.slice(0,5)}}function le(e,t,s){if(!t||!s)return{found:!1,error:"\u8BF7\u63D0\u4F9B\u6A21\u5757\u540D\u548C API \u540D\u79F0"};let r=`${t.toLowerCase()}.${s.toLowerCase()}`,o=e.ejsApis.get(r);if(o){let a=[];for(let[l,i]of e.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 e.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.${t}.${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(e){let t=[],s=e.toLowerCase();for(let r of Object.keys(ce))s.includes(r)&&t.push(r);return t}function _(e,t){if(!t)return!0;let r={ejsh5:"ejsH5",ejs:"ejsH5",h5:"h5",wechat:"wechat",alipay:"alipay",dingtalk:"dingtalk"}[t.toLowerCase()];if(!r)return!0;let o=e[r];return o===!0||typeof o=="string"&&o.length>0}function pe(e,t,s){let r=[],o=[],n=[],a=new Set,l=new Set,i=new Set,c=nt(t);for(let u of c){let d=ce[u];if(d){for(let f of d.utils||[]){if(i.has(f))continue;let m=e.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=e.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=e.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(e,t,{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=e.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=e.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"${t}"\uFF0C\u63A8\u8350\u4EE5\u4E0B\u65B9\u6848\uFF1A
|
|
11
11
|
|
|
12
12
|
`,n.length>0){p+=`**\u63A8\u8350\u5DE5\u5177\u65B9\u6CD5\uFF1A** ${n.map(d=>d.displayName).join("\u3001")}
|
|
13
13
|
`;let u=n.filter(d=>d.usageTip).map(d=>`- ${d.usageTip}`);u.length>0&&(p+=`
|
|
@@ -20,102 +20,98 @@ ${u.join(`
|
|
|
20
20
|
`,n.length>0&&(p+=`
|
|
21
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
22
|
`)),s&&(p+=`
|
|
23
|
-
\u4EE5\u4E0A\u63A8\u8350\u5747\u652F\u6301 ${s} \u5E73\u53F0\u3002`)}else p=`\u672A\u627E\u5230\u4E0E"${
|
|
24
|
-
* @\u4F5C\u8005: ${
|
|
23
|
+
\u4EE5\u4E0A\u63A8\u8350\u5747\u652F\u6301 ${s} \u5E73\u53F0\u3002`)}else p=`\u672A\u627E\u5230\u4E0E"${t}"\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 F(e){return`em-${e}`}function ue(e){return`import Em${e.split("-").map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join("")} from '${at}/lib/${e}';`}function it(e){let t=e.getFullYear(),s=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0"),o=String(e.getHours()).padStart(2,"0"),n=String(e.getMinutes()).padStart(2,"0"),a=String(e.getSeconds()).padStart(2,"0");return`${t}-${s}-${r} ${o}:${n}:${a}`}function fe(e){let s=it(new Date);return`<!--
|
|
24
|
+
* @\u4F5C\u8005: ${e.author||"M8 Assistant"}
|
|
25
25
|
* @\u521B\u5EFA\u65F6\u95F4: ${s}
|
|
26
26
|
* @\u4FEE\u6539\u65F6\u95F4: ${s}
|
|
27
|
-
* @\u7248\u672C: [${
|
|
28
|
-
* @\u7248\u6743: ${
|
|
29
|
-
* @\u63CF\u8FF0: ${
|
|
30
|
-
-->`}function de(
|
|
31
|
-
* ${
|
|
27
|
+
* @\u7248\u672C: [${e.version||"1.0"}]
|
|
28
|
+
* @\u7248\u6743: ${e.copyright||"\u56FD\u6CF0\u65B0\u70B9\u8F6F\u4EF6\u80A1\u4EFD\u6709\u9650\u516C\u53F8"}
|
|
29
|
+
* @\u63CF\u8FF0: ${e.description}
|
|
30
|
+
-->`}function de(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}function lt(e){let t=de(e);return`/**
|
|
31
|
+
* ${e} \u7EC4\u4EF6\u6837\u5F0F
|
|
32
32
|
* \u9075\u5FAA M8 \u6846\u67B6\u6837\u5F0F\u89C4\u8303
|
|
33
33
|
*/
|
|
34
34
|
|
|
35
|
-
.${
|
|
35
|
+
.${t}-container {
|
|
36
36
|
// \u5BB9\u5668\u57FA\u7840\u6837\u5F0F
|
|
37
37
|
padding: 16px;
|
|
38
38
|
|
|
39
39
|
// \u5185\u5BB9\u533A\u57DF\u6837\u5F0F
|
|
40
|
-
.${
|
|
40
|
+
.${t}-content {
|
|
41
41
|
// TODO: \u6DFB\u52A0\u5185\u5BB9\u6837\u5F0F
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
// \u64CD\u4F5C\u533A\u57DF\u6837\u5F0F
|
|
45
|
-
.${
|
|
45
|
+
.${t}-actions {
|
|
46
46
|
margin-top: 16px;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
`}function me(
|
|
50
|
-
@import './css/${
|
|
51
|
-
</style>`,externalFile:{path:`./css/${
|
|
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`})}
|
|
49
|
+
`}function me(e){let t=de(e.componentName);return{styleTag:`<style lang="scss" scoped>
|
|
50
|
+
@import './css/${t}.scss';
|
|
51
|
+
</style>`,externalFile:{path:`./css/${t}.scss`,content:lt(e.componentName)}}}function ct(e,t,s){return t==="M8.4"?ut(e,s):pt(e,s)}function pt(e,t){let s=F(e.name),o=`${fe({description:`${e.displayName}\u7EC4\u4EF6\u793A\u4F8B`})}
|
|
56
52
|
<template>
|
|
57
|
-
<div class="${
|
|
58
|
-
<!-- ${
|
|
59
|
-
<${s}`,n=
|
|
60
|
-
v-model="${
|
|
53
|
+
<div class="${e.name}-container">
|
|
54
|
+
<!-- ${e.displayName}\u7EC4\u4EF6 -->
|
|
55
|
+
<${s}`,n=e.props.slice(0,3);for(let i of n)i.name==="value"||i.name==="v-model"?o+=`
|
|
56
|
+
v-model="${e.name}Value"`:i.type==="boolean"?o+=`
|
|
61
57
|
:${i.name}="${i.default||"false"}"`:i.type==="string"&&(o+=`
|
|
62
|
-
${i.name}="${i.default||""}"`);if(
|
|
58
|
+
${i.name}="${i.default||""}"`);if(e.events.length>0){let i=e.events[0];o+=`
|
|
63
59
|
@${i.name}="on${w(i.name)}"`}o+=`
|
|
64
60
|
/>
|
|
65
61
|
</div>
|
|
66
|
-
</template>`,
|
|
62
|
+
</template>`,t&&(o=he(o,t));let a=`<script>
|
|
67
63
|
/**
|
|
68
|
-
* ${
|
|
64
|
+
* ${e.displayName}\u7EC4\u4EF6\u793A\u4F8B
|
|
69
65
|
* \u6846\u67B6\u7248\u672C: M8.3 (Vue2)
|
|
70
66
|
*
|
|
71
67
|
* \u4F7F\u7528\u8BF4\u660E\uFF1A
|
|
72
|
-
* - \u8BE5\u7EC4\u4EF6\u5C55\u793A\u4E86 ${
|
|
68
|
+
* - \u8BE5\u7EC4\u4EF6\u5C55\u793A\u4E86 ${e.displayName} \u7684\u57FA\u672C\u7528\u6CD5
|
|
73
69
|
* - \u53EF\u6839\u636E\u5B9E\u9645\u9700\u6C42\u4FEE\u6539\u5C5E\u6027\u548C\u4E8B\u4EF6\u5904\u7406
|
|
74
70
|
*/
|
|
75
71
|
export default {
|
|
76
|
-
name: '${w(
|
|
72
|
+
name: '${w(e.name)}Demo',
|
|
77
73
|
|
|
78
74
|
data() {
|
|
79
75
|
return {
|
|
80
|
-
// ${
|
|
81
|
-
${
|
|
76
|
+
// ${e.displayName}\u7684\u7ED1\u5B9A\u503C
|
|
77
|
+
${e.name}Value: ${ge(e.props[0])}
|
|
82
78
|
};
|
|
83
79
|
},
|
|
84
80
|
|
|
85
81
|
methods: {
|
|
86
82
|
/**
|
|
87
|
-
* \u5904\u7406${
|
|
88
|
-
* ${
|
|
83
|
+
* \u5904\u7406${e.displayName}\u4E8B\u4EF6
|
|
84
|
+
* ${e.events[0]?.description||"\u5F53\u7EC4\u4EF6\u503C\u53D8\u5316\u65F6\u89E6\u53D1"}
|
|
89
85
|
* @param {any} value - \u53D8\u5316\u540E\u7684\u503C
|
|
90
86
|
*/
|
|
91
|
-
on${w(
|
|
92
|
-
console.log('${
|
|
93
|
-
// TODO: \u5728\u6B64\u5904\u7406${
|
|
87
|
+
on${w(e.events[0]?.name||"Change")}(value) {
|
|
88
|
+
console.log('${e.displayName}\u503C\u53D8\u5316:', value);
|
|
89
|
+
// TODO: \u5728\u6B64\u5904\u7406${e.displayName}\u4E8B\u4EF6\u903B\u8F91
|
|
94
90
|
}
|
|
95
91
|
}
|
|
96
92
|
};
|
|
97
|
-
</script>`,l=me({componentName:
|
|
93
|
+
</script>`,l=me({componentName:e.name,useExternalFile:!0});return{template:o,script:a,style:l.styleTag,imports:[ue(e.name)],explanation:`\u8FD9\u662F ${e.displayName} \u7EC4\u4EF6\u7684 M8.3 (Vue2) \u793A\u4F8B\u4EE3\u7801\u3002
|
|
98
94
|
- \u4F7F\u7528 Options API \u98CE\u683C
|
|
99
95
|
- \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
96
|
- \u5305\u542B\u4E2D\u6587\u6CE8\u91CA\u8BF4\u660E\u4EE3\u7801\u903B\u8F91
|
|
101
|
-
- \
|
|
97
|
+
- \u6837\u5F0F\u5DF2\u6309\u89C4\u8303\u5206\u79BB\u5230\u5916\u90E8 SCSS \u6587\u4EF6`,frameworkVersion:"M8.3",externalFiles:l.externalFile?[l.externalFile]:[]}}function ut(e,t){let s=F(e.name),o=`${fe({description:`${e.displayName}\u7EC4\u4EF6\u793A\u4F8B`})}
|
|
102
98
|
<template>
|
|
103
|
-
<div class="${
|
|
104
|
-
<!-- ${
|
|
105
|
-
<${s}`,n=
|
|
106
|
-
v-model="${
|
|
99
|
+
<div class="${e.name}-container">
|
|
100
|
+
<!-- ${e.displayName}\u7EC4\u4EF6 -->
|
|
101
|
+
<${s}`,n=e.props.slice(0,3);for(let i of n)i.name==="value"||i.name==="v-model"?o+=`
|
|
102
|
+
v-model="${e.name}Value"`:i.type==="boolean"?o+=`
|
|
107
103
|
:${i.name}="${i.default||"false"}"`:i.type==="string"&&(o+=`
|
|
108
|
-
${i.name}="${i.default||""}"`);if(
|
|
104
|
+
${i.name}="${i.default||""}"`);if(e.events.length>0){let i=e.events[0];o+=`
|
|
109
105
|
@${i.name}="on${w(i.name)}"`}o+=`
|
|
110
106
|
/>
|
|
111
107
|
</div>
|
|
112
|
-
</template>`,
|
|
108
|
+
</template>`,t&&(o=he(o,t));let a=`<script setup>
|
|
113
109
|
/**
|
|
114
|
-
* ${
|
|
110
|
+
* ${e.displayName}\u7EC4\u4EF6\u793A\u4F8B
|
|
115
111
|
* \u6846\u67B6\u7248\u672C: M8.4 (Vue3 Composition API)
|
|
116
112
|
*
|
|
117
113
|
* \u4F7F\u7528\u8BF4\u660E\uFF1A
|
|
118
|
-
* - \u8BE5\u7EC4\u4EF6\u5C55\u793A\u4E86 ${
|
|
114
|
+
* - \u8BE5\u7EC4\u4EF6\u5C55\u793A\u4E86 ${e.displayName} \u7684\u57FA\u672C\u7528\u6CD5
|
|
119
115
|
* - \u4F7F\u7528 Composition API \u548C <script setup> \u8BED\u6CD5
|
|
120
116
|
* - \u53EF\u6839\u636E\u5B9E\u9645\u9700\u6C42\u4FEE\u6539\u5C5E\u6027\u548C\u4E8B\u4EF6\u5904\u7406
|
|
121
117
|
*/
|
|
@@ -125,62 +121,62 @@ import { ref } from 'vue';
|
|
|
125
121
|
// \u54CD\u5E94\u5F0F\u6570\u636E\u5B9A\u4E49
|
|
126
122
|
// ============================================
|
|
127
123
|
|
|
128
|
-
/** ${
|
|
129
|
-
const ${
|
|
124
|
+
/** ${e.displayName}\u7684\u7ED1\u5B9A\u503C */
|
|
125
|
+
const ${e.name}Value = ref(${ge(e.props[0])});
|
|
130
126
|
|
|
131
127
|
// ============================================
|
|
132
128
|
// \u4E8B\u4EF6\u5904\u7406\u65B9\u6CD5
|
|
133
129
|
// ============================================
|
|
134
130
|
|
|
135
131
|
/**
|
|
136
|
-
* \u5904\u7406${
|
|
137
|
-
* ${
|
|
132
|
+
* \u5904\u7406${e.displayName}\u4E8B\u4EF6
|
|
133
|
+
* ${e.events[0]?.description||"\u5F53\u7EC4\u4EF6\u503C\u53D8\u5316\u65F6\u89E6\u53D1"}
|
|
138
134
|
* @param value - \u53D8\u5316\u540E\u7684\u503C
|
|
139
135
|
*/
|
|
140
|
-
function on${w(
|
|
141
|
-
console.log('${
|
|
142
|
-
// TODO: \u5728\u6B64\u5904\u7406${
|
|
136
|
+
function on${w(e.events[0]?.name||"Change")}(value) {
|
|
137
|
+
console.log('${e.displayName}\u503C\u53D8\u5316:', value);
|
|
138
|
+
// TODO: \u5728\u6B64\u5904\u7406${e.displayName}\u4E8B\u4EF6\u903B\u8F91
|
|
143
139
|
}
|
|
144
|
-
</script>`,l=me({componentName:
|
|
140
|
+
</script>`,l=me({componentName:e.name,useExternalFile:!0});return{template:o,script:a,style:l.styleTag,imports:[],explanation:`\u8FD9\u662F ${e.displayName} \u7EC4\u4EF6\u7684 M8.4 (Vue3) \u793A\u4F8B\u4EE3\u7801\u3002
|
|
145
141
|
- \u4F7F\u7528 Composition API \u548C <script setup> \u8BED\u6CD5
|
|
146
142
|
- \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
143
|
- \u5305\u542B\u4E2D\u6587\u6CE8\u91CA\u8BF4\u660E\u4EE3\u7801\u903B\u8F91
|
|
148
|
-
- \
|
|
144
|
+
- \u6837\u5F0F\u5DF2\u6309\u89C4\u8303\u5206\u79BB\u5230\u5916\u90E8 SCSS \u6587\u4EF6`,frameworkVersion:"M8.4",externalFiles:l.externalFile?[l.externalFile]:[]}}function ft(e,t){let s=`ejs.${e.module}.${e.name}`,r=[];for(let a of e.params)a.required&&r.push(` ${a.name}: ${ye(a.type)} // ${a.description}`);let o=`/**
|
|
149
145
|
* \u8C03\u7528 ${s}
|
|
150
|
-
* ${
|
|
146
|
+
* ${e.description}
|
|
151
147
|
*/
|
|
152
148
|
${s}({
|
|
153
149
|
${r.join(`,
|
|
154
150
|
`)},
|
|
155
151
|
success: function(result) {
|
|
156
152
|
// \u6210\u529F\u56DE\u8C03
|
|
157
|
-
console.log('${
|
|
153
|
+
console.log('${e.name} \u6210\u529F:', result);
|
|
158
154
|
// TODO: \u5904\u7406\u6210\u529F\u7ED3\u679C
|
|
159
155
|
},
|
|
160
156
|
error: function(err) {
|
|
161
157
|
// \u9519\u8BEF\u56DE\u8C03
|
|
162
|
-
console.error('${
|
|
158
|
+
console.error('${e.name} \u5931\u8D25:', err);
|
|
163
159
|
// TODO: \u5904\u7406\u9519\u8BEF
|
|
164
160
|
}
|
|
165
161
|
});`,n=`/**
|
|
166
162
|
* \u8C03\u7528 ${s} (Promise \u98CE\u683C)
|
|
167
|
-
* ${
|
|
163
|
+
* ${e.description}
|
|
168
164
|
*/
|
|
169
|
-
async function call${w(
|
|
165
|
+
async function call${w(e.name)}() {
|
|
170
166
|
try {
|
|
171
167
|
const result = await ${s}({
|
|
172
168
|
${r.join(`,
|
|
173
169
|
`)}
|
|
174
170
|
});
|
|
175
171
|
// \u6210\u529F\u5904\u7406
|
|
176
|
-
console.log('${
|
|
172
|
+
console.log('${e.name} \u6210\u529F:', result);
|
|
177
173
|
return result;
|
|
178
174
|
} catch (err) {
|
|
179
175
|
// \u9519\u8BEF\u5904\u7406
|
|
180
|
-
console.error('${
|
|
176
|
+
console.error('${e.name} \u5931\u8D25:', err);
|
|
181
177
|
throw err;
|
|
182
178
|
}
|
|
183
|
-
}`;return
|
|
179
|
+
}`;return t==="M8.4"?{script:`<script setup>
|
|
184
180
|
/**
|
|
185
181
|
* EJS API \u8C03\u7528\u793A\u4F8B: ${s}
|
|
186
182
|
* \u6846\u67B6\u7248\u672C: M8.4 (Vue3)
|
|
@@ -199,7 +195,7 @@ async function handleAction() {
|
|
|
199
195
|
loading.value = true;
|
|
200
196
|
error.value = null;
|
|
201
197
|
try {
|
|
202
|
-
result.value = await call${w(
|
|
198
|
+
result.value = await call${w(e.name)}();
|
|
203
199
|
} catch (e) {
|
|
204
200
|
error.value = e;
|
|
205
201
|
} finally {
|
|
@@ -225,9 +221,9 @@ export default {
|
|
|
225
221
|
|
|
226
222
|
methods: {
|
|
227
223
|
/**
|
|
228
|
-
* \u8C03\u7528 ${
|
|
224
|
+
* \u8C03\u7528 ${e.name} API
|
|
229
225
|
*/
|
|
230
|
-
call${w(
|
|
226
|
+
call${w(e.name)}() {
|
|
231
227
|
this.loading = true;
|
|
232
228
|
this.error = null;
|
|
233
229
|
|
|
@@ -240,9 +236,9 @@ export default {
|
|
|
240
236
|
</script>`,explanation:`\u8FD9\u662F ${s} \u7684 M8.3 (Vue2) \u8C03\u7528\u793A\u4F8B\u3002
|
|
241
237
|
- \u4F7F\u7528\u56DE\u8C03\u51FD\u6570\u98CE\u683C
|
|
242
238
|
- \u5305\u542B success \u548C error \u56DE\u8C03\u5904\u7406
|
|
243
|
-
- \u53EF\u6839\u636E\u9700\u8981\u6539\u4E3A Promise \u98CE\u683C`,frameworkVersion:"M8.3"}}function he(t
|
|
244
|
-
${
|
|
245
|
-
<!-- #endif -->`}function w(
|
|
239
|
+
- \u53EF\u6839\u636E\u9700\u8981\u6539\u4E3A Promise \u98CE\u683C`,frameworkVersion:"M8.3"}}function he(e,t){return`<!-- #ifdef ${{wechat:"MP-WEIXIN",alipay:"MP-ALIPAY",h5:"H5",ejs:"APP-PLUS",dingtalk:"MP-DINGTALK"}[t.toLowerCase()]||t.toUpperCase()} -->
|
|
240
|
+
${e}
|
|
241
|
+
<!-- #endif -->`}function w(e){return e?e.charAt(0).toUpperCase()+e.slice(1):""}function ge(e){if(!e)return"''";if(e.default)return e.default;switch(e.type.toLowerCase()){case"string":return"''";case"number":return"0";case"boolean":return"false";case"array":return"[]";case"object":return"{}";default:return"null"}}function ye(e){switch(e.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(e){return e==="M8.4"?{script:`<script setup>
|
|
246
242
|
/**
|
|
247
243
|
* Util.ajax \u4F7F\u7528\u793A\u4F8B
|
|
248
244
|
* \u6846\u67B6\u7248\u672C: M8.4 (Vue3 Composition API)
|
|
@@ -402,6 +398,29 @@ export default {
|
|
|
402
398
|
};
|
|
403
399
|
</script>`,explanation:`\u8FD9\u662F Util.ajax \u7684 M8.3 (Vue2) \u4F7F\u7528\u793A\u4F8B\u3002
|
|
404
400
|
|
|
401
|
+
### Mock \u6A21\u62DF\u6570\u636E\u96C6\u6210
|
|
402
|
+
|
|
403
|
+
\u5982\u679C\u9700\u8981\u4F7F\u7528 Mock.js \u6A21\u62DF\u6570\u636E\uFF0C\u53EF\u4EE5\u5728 main.js \u6216\u5355\u72EC\u7684 mock.js \u6587\u4EF6\u4E2D\u914D\u7F6E\uFF1A
|
|
404
|
+
|
|
405
|
+
\`\`\`javascript
|
|
406
|
+
import Mock from 'mockjs';
|
|
407
|
+
|
|
408
|
+
// \u62E6\u622A Ajax \u8BF7\u6C42
|
|
409
|
+
Mock.mock(new RegExp('/api/data'), 'post', {
|
|
410
|
+
code: 1,
|
|
411
|
+
message: 'success',
|
|
412
|
+
data: {
|
|
413
|
+
'list|10': [{
|
|
414
|
+
'id|+1': 1,
|
|
415
|
+
'title': '@ctitle(5, 10)',
|
|
416
|
+
'date': '@date("yyyy-MM-dd")'
|
|
417
|
+
}]
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
// \u6CE8\u610F\uFF1AMock.js \u4F1A\u62E6\u622A XMLHttpRequest\uFF0CUtil.ajax \u57FA\u4E8E axios\uFF0C\u5B8C\u5168\u517C\u5BB9\u3002
|
|
422
|
+
\`\`\`
|
|
423
|
+
|
|
405
424
|
**\u63A8\u8350\u4F7F\u7528 Util.ajax \u800C\u4E0D\u662F ejs.http \u6216\u539F\u751F fetch\uFF1A**
|
|
406
425
|
- Util.ajax \u662F\u6846\u67B6\u5BF9 axios \u7684\u5C01\u88C5\uFF0C\u63D0\u4F9B\u7EDF\u4E00\u7684\u8BF7\u6C42\u5904\u7406
|
|
407
426
|
- \u81EA\u52A8\u5904\u7406 token \u548C\u4EE3\u7406
|
|
@@ -413,7 +432,7 @@ export default {
|
|
|
413
432
|
- type: \u8BF7\u6C42\u65B9\u6CD5\uFF0CGET \u6216 POST
|
|
414
433
|
- data: \u8BF7\u6C42\u6570\u636E
|
|
415
434
|
- dataPath: \u54CD\u5E94\u6570\u636E\u8DEF\u5F84
|
|
416
|
-
- success/error: \u56DE\u8C03\u51FD\u6570`,frameworkVersion:"M8.3"}}function xe(
|
|
435
|
+
- success/error: \u56DE\u8C03\u51FD\u6570`,frameworkVersion:"M8.3"}}function xe(e){return e==="M8.4"?{script:`<script setup>
|
|
417
436
|
/**
|
|
418
437
|
* Util.upload \u6587\u4EF6\u4E0A\u4F20\u793A\u4F8B
|
|
419
438
|
* \u6846\u67B6\u7248\u672C: M8.4 (Vue3 Composition API)
|
|
@@ -518,11 +537,11 @@ export default {
|
|
|
518
537
|
|
|
519
538
|
**\u63A8\u8350\u4F7F\u7528 filePath \u65B9\u5F0F\u4E0A\u4F20\uFF1A**
|
|
520
539
|
- \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
|
|
522
|
-
`);return
|
|
540
|
+
- filePath \u9700\u8981\u4E0E name \u914D\u5957\u4F7F\u7528`,frameworkVersion:"M8.3"}}function dt(e,t){if(e.name.toLowerCase()==="ajax")return we(t);if(e.name.toLowerCase()==="upload")return xe(t);let s=e.fullName,r=e.params.filter(o=>o.required).map(o=>`${o.name}: ${ye(o.type)} // ${o.description}`).join(`,
|
|
541
|
+
`);return t==="M8.4"?{script:`<script setup>
|
|
523
542
|
/**
|
|
524
|
-
* ${
|
|
525
|
-
* ${
|
|
543
|
+
* ${e.fullName} \u4F7F\u7528\u793A\u4F8B
|
|
544
|
+
* ${e.description}
|
|
526
545
|
* \u6846\u67B6\u7248\u672C: M8.4 (Vue3)
|
|
527
546
|
*/
|
|
528
547
|
|
|
@@ -531,11 +550,11 @@ const result = ${s}(${r?`{
|
|
|
531
550
|
${r}
|
|
532
551
|
}`:""});
|
|
533
552
|
console.log('\u7ED3\u679C:', result);
|
|
534
|
-
</script>`,explanation:`\u8FD9\u662F ${
|
|
535
|
-
${
|
|
553
|
+
</script>`,explanation:`\u8FD9\u662F ${e.fullName} \u7684\u4F7F\u7528\u793A\u4F8B\u3002
|
|
554
|
+
${e.description}`,frameworkVersion:"M8.4"}:{script:`<script>
|
|
536
555
|
/**
|
|
537
|
-
* ${
|
|
538
|
-
* ${
|
|
556
|
+
* ${e.fullName} \u4F7F\u7528\u793A\u4F8B
|
|
557
|
+
* ${e.description}
|
|
539
558
|
* \u6846\u67B6\u7248\u672C: M8.3 (Vue2)
|
|
540
559
|
*/
|
|
541
560
|
export default {
|
|
@@ -548,9 +567,9 @@ export default {
|
|
|
548
567
|
}
|
|
549
568
|
}
|
|
550
569
|
};
|
|
551
|
-
</script>`,explanation:`\u8FD9\u662F ${
|
|
552
|
-
${
|
|
553
|
-
`)}function ve(t
|
|
570
|
+
</script>`,explanation:`\u8FD9\u662F ${e.fullName} \u7684\u4F7F\u7528\u793A\u4F8B\u3002
|
|
571
|
+
${e.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(e,t){let s=[],r=t.toLowerCase(),o=mt[r];if(o)for(let n of o)for(let a of n.related){let l=e.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(e){if(e.length===0)return"";let t=["","","**\u76F8\u5173\u7EC4\u4EF6\u63A8\u8350\uFF1A**"];for(let s of e)t.push(`- ${s.displayName} (${s.name}): ${s.reason}`);return t.join(`
|
|
572
|
+
`)}function ve(e,t){let s=t.options?.frameworkVersion||"M8.4",r=t.options?.platform;if(t.type==="component"){let o=e.components.get(t.name.toLowerCase());if(!o)return{explanation:`\u672A\u627E\u5230\u7EC4\u4EF6: ${t.name}`,frameworkVersion:s};let n=ct(o,s,r),a=ht(e,t.name);return a.length>0&&(n.explanation+=gt(a)),n}if(t.type==="ejsApi"){let o="",n=t.name;t.name.includes(".")&&([o,n]=t.name.split("."));let a;if(o)a=e.ejsApis.get(`${o}.${n}`);else for(let[,l]of e.ejsApis)if(l.name===n){a=l;break}return a?ft(a,s):{explanation:`\u672A\u627E\u5230 API: ${t.name}`,frameworkVersion:s}}if(t.type==="util"){let o=t.name.toLowerCase();o.startsWith("util.")&&(o=o.replace("util.",""));let n=e.utilMethods?.get(o);return n?dt(n,s):o==="ajax"?we(s):o==="upload"?xe(s):{explanation:`\u672A\u627E\u5230 Util \u65B9\u6CD5: ${t.name}`,frameworkVersion:s}}return{explanation:`\u4E0D\u652F\u6301\u7684\u751F\u6210\u7C7B\u578B: ${t.type}`,frameworkVersion:s}}var R={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(e,t){let s=[],r=[];for(let o of t){let n=yt[o.toLowerCase()];if(!n)continue;let a=e[n],l=R[n]||o;a===!1?s.push(l):typeof a=="string"&&r.push(`${l}: ${a}`)}return{unsupported:s,limitations:r}}function xt(e,t,s,r){let o=[];if(s==="component"){let n=e.components.get(t.toLowerCase());if(n)for(let[a,l]of e.components){if(a===t.toLowerCase()||l.category!==n.category)continue;let i=!0;for(let c of r){let p=Object.entries(R).find(([u,d])=>d===c)?.[0];if(p&&l.platformSupport[p]===!1){i=!1;break}}i&&o.push(`${l.displayName} (${a})`)}}else{let n=t.split("."),a=n.length>1?n[0]:"";for(let[l,i]of e.ejsApis){if(l===t||i.module!==a)continue;let c=!0;for(let p of r){let u=Object.entries(R).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(e,t,s){let r={items:[],allCompatible:!0,issues:[],suggestions:[]};for(let o of t){let n=o.toLowerCase(),a=!1,l="component",i,c=o,p=e.components.get(n);if(p&&(a=!0,l="component",i=p.platformSupport,c=p.displayName),!a){let m=e.ejsApis.get(n);if(m)a=!0,l="ejsApi",i=m.platformSupport,c=`ejs.${m.module}.${m.name}`;else for(let[I,g]of e.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(e,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(e){return e.map(t=>$t[t.toLowerCase()]).filter(t=>t!==void 0)}function je(e){if(e.length===0)return"";let t=["","**\u76F8\u5173\u7EC4\u4EF6\u6587\u6863\uFF1A**",""];for(let s of e)t.push(`- **${s.displayName}** (${s.name}): ${s.description}`),t.push(` - \u6587\u6863\u8DEF\u5F84: \`${s.docPath}\``);return t.join(`
|
|
554
573
|
`)}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>
|
|
555
574
|
<div class="list-page">
|
|
556
575
|
<!-- \u4E0B\u62C9\u5237\u65B0\u5217\u8868 -->
|
|
@@ -1327,7 +1346,7 @@ async function uploadAll() {
|
|
|
1327
1346
|
font-size: 12px;
|
|
1328
1347
|
padding: 2px 0;
|
|
1329
1348
|
}
|
|
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
|
|
1349
|
+
</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(e,t){let s=H[e];if(!s){let n=e.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: ${e}`,availablePatterns:Object.keys(H)}}let r=ke(s.components),o=je(r);return t?{...s,componentDocReferences:r,vue2Code:t==="M8.3"?{...s.vue2Code,explanation:s.vue2Code.explanation+o}:{explanation:"\u8BF7\u4F7F\u7528 M8.3 \u7248\u672C\u67E5\u770B",frameworkVersion:"M8.3"},vue3Code:t==="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(e,t,s={}){return!t||t.trim().length===0?[]:E(e,t.trim(),{...s,limit:s.limit||20})}function Ce(e,t){if(!t)return{found:!1,error:"\u8BF7\u63D0\u4F9B\u65B9\u6CD5\u540D\u79F0"};let s=t.toLowerCase();s.startsWith("util.")&&(s=s.replace("util.",""));let r=e.utilMethods.get(s);if(r){let n=[];for(let[l,i]of e.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
1350
|
- \u652F\u6301 Promise \u548C\u56DE\u8C03\u4E24\u79CD\u98CE\u683C
|
|
1332
1351
|
- \u81EA\u52A8\u5904\u7406 token \u548C\u4EE3\u7406
|
|
1333
1352
|
- \u652F\u6301\u8BF7\u6C42\u53D6\u6D88\u548C\u5E76\u53D1\u63A7\u5236
|
|
@@ -1335,14 +1354,14 @@ async function uploadAll() {
|
|
|
1335
1354
|
- \u652F\u6301 filePath \u548C files \u4E24\u79CD\u4E0A\u4F20\u65B9\u5F0F
|
|
1336
1355
|
- filePath \u65B9\u5F0F\u652F\u6301\u8DE8\u7AEF\uFF08H5\u3001\u5FAE\u4FE1\u3001\u652F\u4ED8\u5B9D\u5C0F\u7A0B\u5E8F\uFF09
|
|
1337
1356
|
- 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
|
|
1339
|
-
`)),
|
|
1340
|
-
`)}function N(
|
|
1341
|
-
`),r={filePath:
|
|
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(
|
|
1343
|
-
`)}function
|
|
1344
|
-
`)}var x=null,b=new Map,Ot=Dt(import.meta.url),Vt=
|
|
1357
|
+
- \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 e.utilMethods)(n.includes(s)||a.name.toLowerCase().includes(s))&&o.push(a.fullName);return{found:!1,error:`\u672A\u627E\u5230\u65B9\u6CD5: Util.${t}`,suggestions:o.slice(0,5)}}function be(e){let t=[];if(t.push(`# ${e.fullName}`),t.push(""),t.push(e.description),t.push(""),e.usageScenario&&(t.push("## \u4F7F\u7528\u573A\u666F"),t.push(""),t.push(e.usageScenario),t.push("")),e.version&&(t.push(`**\u7248\u672C\u8981\u6C42:** ${e.version}`),t.push("")),t.push("## \u5E73\u53F0\u652F\u6301"),t.push(""),t.push("| \u5E73\u53F0 | \u652F\u6301\u60C5\u51B5 |"),t.push("| --- | --- |"),t.push(`| H5 | ${N(e.platformSupport.h5)} |`),t.push(`| \u65B0\u70B9\u5C0F\u7A0B\u5E8F | ${N(e.platformSupport.ejsMiniProgram)} |`),t.push(`| \u5FAE\u4FE1\u5C0F\u7A0B\u5E8F | ${N(e.platformSupport.wechat)} |`),t.push(`| \u652F\u4ED8\u5B9D\u5C0F\u7A0B\u5E8F | ${N(e.platformSupport.alipay)} |`),t.push(""),e.params.length>0){t.push("## \u53C2\u6570"),t.push(""),t.push("| \u53C2\u6570 | \u7C7B\u578B | \u5FC5\u586B | \u8BF4\u660E |"),t.push("| --- | --- | --- | --- |");for(let s of e.params){let r=s.required?"\u662F":"\u5426",o=s.default?`${s.description}\uFF0C\u9ED8\u8BA4: ${s.default}`:s.description;t.push(`| ${s.name} | ${s.type} | ${r} | ${o} |`)}t.push("")}if(e.returns&&(t.push("## \u8FD4\u56DE\u503C"),t.push(""),t.push(`**\u7C7B\u578B:** ${e.returns.type}`),t.push(""),e.returns.fields&&e.returns.fields.length>0)){t.push("| \u5B57\u6BB5 | \u7C7B\u578B | \u8BF4\u660E |"),t.push("| --- | --- | --- |");for(let s of e.returns.fields)t.push(`| ${s.name} | ${s.type} | ${s.description} |`);t.push("")}if(e.examples.length>0){t.push("## \u4EE3\u7801\u793A\u4F8B"),t.push("");for(let s of e.examples)s.title&&(t.push(`### ${s.title}`),t.push("")),s.frameworkVersion&&(t.push(`> \u6846\u67B6\u7248\u672C: ${s.frameworkVersion}`),t.push("")),t.push(`\`\`\`${s.language}`),t.push(s.code),t.push("```"),t.push("")}return e.relatedMethods&&e.relatedMethods.length>0&&(t.push("## \u76F8\u5173\u65B9\u6CD5"),t.push(""),t.push(e.relatedMethods.map(s=>`- ${s}`).join(`
|
|
1358
|
+
`)),t.push("")),t.join(`
|
|
1359
|
+
`)}function N(e){return e===!0?"\u2705 \u652F\u6301":e===!1?"\u274C \u4E0D\u652F\u6301":`\u26A0\uFE0F ${e}`}import*as C from"fs";import*as k from"path";var Pt="docs/standards";function At(){let t=k.dirname(new URL(import.meta.url).pathname).replace(/^\/([A-Z]:)/,"$1");return k.join(t,"..","..",Pt)}function Nt(e){try{let s=C.readFileSync(e,"utf-8").split(`
|
|
1360
|
+
`),r={filePath:e,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+`
|
|
1361
|
+
`;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(e,".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(t){return console.error(`[StandardsManager] \u89E3\u6790\u89C4\u8303\u6587\u6863\u5931\u8D25: ${e}`,t),null}}function Pe(){let e=new Map,t=At();if(!C.existsSync(t))return console.error(`[StandardsManager] \u89C4\u8303\u76EE\u5F55\u4E0D\u5B58\u5728: ${t}`),e;let s=C.readdirSync(t);for(let r of s)if(r.endsWith(".md")){let o=k.join(t,r),n=Nt(o);n&&e.set(n.id,n)}return console.error(`[StandardsManager] \u52A0\u8F7D\u4E86 ${e.size} \u4E2A\u89C4\u8303\u6587\u6863`),e}function Ae(e,t){let s=[];for(let r of e.values())r.category===t&&s.push(r);return s}function Ne(e,t){return e.get(t)}function Ie(e,t){let s=[];for(let r of e.values())(!t||r.category===t)&&s.push({id:r.id,name:r.name,category:r.category,description:r.description});return s}function W(e){let t=[];if(t.push(`# ${e.name}`),t.push(""),t.push(`**\u5206\u7C7B:** ${e.category}`),t.push(`**\u7248\u672C:** ${e.version}`),t.push(`**\u66F4\u65B0\u65F6\u95F4:** ${e.lastUpdated}`),t.push(""),t.push(e.description),t.push(""),e.rules.length>0){t.push("## \u89C4\u5219"),t.push("");for(let s of e.rules)t.push(`### ${s.title}`),t.push(""),t.push(s.description),t.push(""),s.goodExample&&(t.push("**\u6B63\u786E\u793A\u4F8B:**"),t.push("```javascript"),t.push(s.goodExample),t.push("```"),t.push("")),s.badExample&&(t.push("**\u9519\u8BEF\u793A\u4F8B:**"),t.push("```javascript"),t.push(s.badExample),t.push("```"),t.push(""))}if(e.examples.length>0){t.push("## \u793A\u4F8B"),t.push("");for(let s of e.examples)s.title&&(t.push(`### ${s.title}`),t.push("")),t.push(`\`\`\`${s.language}`),t.push(s.code),t.push("```"),t.push("")}if(e.antiPatterns.length>0){t.push("## \u53CD\u6A21\u5F0F"),t.push("");for(let s of e.antiPatterns)s.title&&(t.push(`### ${s.title}`),t.push("")),t.push(`\`\`\`${s.language}`),t.push(s.code),t.push("```"),t.push("")}return t.join(`
|
|
1362
|
+
`)}function Ue(e,t){let s=["css","vue","javascript","typescript","naming","project","git"];if(t.id){let r=Ne(e,t.id);return r?{found:!0,standard:r,markdown:W(r)}:{found:!1,error:`\u672A\u627E\u5230\u89C4\u8303: ${t.id}`,availableCategories:s}}if(t.category){let r=Ae(e,t.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 "${t.category}" \u4E0B\u7684\u89C4\u8303`,availableCategories:s}}return{found:!1,error:"\u8BF7\u6307\u5B9A\u89C4\u8303 ID \u6216\u5206\u7C7B",availableCategories:s}}function De(e,t){let s=Ie(e,t),r=new Set;for(let o of e.values())r.add(o.category);return{standards:s,total:s.length,categories:Array.from(r).sort()}}function Le(e){let t=[];t.push("# \u53EF\u7528\u7684\u7F16\u7801\u89C4\u8303"),t.push(""),t.push(`\u5171 ${e.total} \u4E2A\u89C4\u8303`),t.push("");let s=new Map;for(let o of e.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){t.push(`## ${r[o]||o}`),t.push("");for(let a of n)t.push(`- **${a.name}** (\`${a.id}\`)`),t.push(` ${a.description}`);t.push("")}return t.push("---"),t.push("\u4F7F\u7528 `get_standard` \u5DE5\u5177\u67E5\u770B\u89C4\u8303\u8BE6\u60C5\uFF0C\u4F8B\u5982\uFF1A"),t.push('- \u6309 ID \u67E5\u8BE2: `{ "id": "vue-style" }`'),t.push('- \u6309\u5206\u7C7B\u67E5\u8BE2: `{ "category": "css" }`'),t.join(`
|
|
1363
|
+
`)}var x=null,b=new Map,Ot=Dt(import.meta.url),Vt=Lt(Ot),Et=Te(Vt,"..");function Oe(e,t,s){if(process.env[e])return process.env[e];let r=Te(Et,"docs",t);return Tt(r)?r:s}var _t=Oe("EJS_DOC_PATH","ejs-doc","ejs-doc"),Ft=Oe("M8_DOC_PATH","m8mpdoc-develop","m8mpdoc-develop");async function Rt(){console.error("[M8 MCP] \u6B63\u5728\u521D\u59CB\u5316\u6587\u6863\u7D22\u5F15...");try{x=await oe(_t,Ft),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(e){console.error("[M8 MCP] \u7D22\u5F15\u6784\u5EFA\u5931\u8D25:",e),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 e=new It({name:"M8FrameworkMCP",version:"1.0.0"});return e.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:t,category:s,platform:r})=>{let o=ne(y(),t,{category:s,platform:r});return{content:[{type:"text",text:JSON.stringify(o,null,2)}]}}),e.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:t,module:s})=>{let r=ae(y(),t,{module:s});return{content:[{type:"text",text:JSON.stringify(r,null,2)}]}}),e.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:t})=>{let s=ie(y(),t);return{content:[{type:"text",text:JSON.stringify(s,null,2)}]}}),e.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:t,name:s})=>{let r=le(y(),t,s);return{content:[{type:"text",text:JSON.stringify(r,null,2)}]}}),e.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:t,platform:s})=>{let r=pe(y(),t,s);return{content:[{type:"text",text:JSON.stringify(r,null,2)}]}}),e.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:t,name:s,frameworkVersion:r,platform:o})=>{let n=ve(y(),{type:t,name:s,options:{frameworkVersion:r,platform:o}});return{content:[{type:"text",text:JSON.stringify(n,null,2)}]}}),e.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:t,targetPlatforms:s})=>{let r=$e(y(),t,s);return{content:[{type:"text",text:JSON.stringify(r,null,2)}]}}),e.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:t,frameworkVersion:s})=>{let r=Me(t,s);return{content:[{type:"text",text:JSON.stringify(r,null,2)}]}}),e.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:t,category:s})=>{let r=Se(y(),t,{category:s});return{content:[{type:"text",text:JSON.stringify(r,null,2)}]}}),e.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:t})=>{let s=Ce(y(),t),r=JSON.stringify(s,null,2);return s.found&&s.method&&(r+=`
|
|
1345
1364
|
|
|
1346
1365
|
---
|
|
1347
1366
|
|
|
1348
|
-
`+be(s.method)),{content:[{type:"text",text:r}]}}),
|
|
1367
|
+
`+be(s.method)),{content:[{type:"text",text:r}]}}),e.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:t,category:s})=>{let r=Ue(b,{id:t,category:s}),o=JSON.stringify(r,null,2);return r.found&&r.markdown&&(o=r.markdown),{content:[{type:"text",text:o}]}}),e.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:t})=>{let s=De(b,t);return{content:[{type:"text",text:Le(s)}]}}),e}async function Wt(){await Rt();let e=Ht(),t=new Ut;console.error("[M8 MCP] \u670D\u52A1\u5668\u542F\u52A8\u4E2D..."),await e.connect(t),console.error("[M8 MCP] \u670D\u52A1\u5668\u5DF2\u542F\u52A8\uFF0C\u7B49\u5F85\u8FDE\u63A5...")}Wt().catch(e=>{console.error("[M8 MCP] \u670D\u52A1\u5668\u542F\u52A8\u5931\u8D25:",e),process.exit(1)});
|