neo-cmp-cli 1.10.6 → 1.10.8
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/dist/config/default.config.js +1 -1
- package/dist/main2.js +1 -1
- package/dist/neo/neoRequire.js +1 -1
- package/dist/neo/neoService.js +1 -1
- package/dist/neo/pushCmp.js +1 -1
- package/dist/package.json.js +1 -1
- package/dist/plugins/babel-plugin-add-data-scope.js +1 -0
- package/package.json +1 -1
- package/template/antd-custom-cmp-template/package.json +1 -1
- package/template/antd-custom-cmp-template/src/components/dataDashboard__c/index.tsx +1 -1
- package/template/antd-custom-cmp-template/src/components/dataDashboard__c/style.scss +5 -5
- package/template/antd-custom-cmp-template/src/components/infoCard__c/index.tsx +1 -1
- package/template/antd-custom-cmp-template/src/components/infoCard__c/style.scss +1 -1
- package/template/antd-custom-cmp-template/tsconfig.json +1 -1
- package/template/echarts-custom-cmp-template/package.json +1 -1
- package/template/echarts-custom-cmp-template/src/components/chartWidget__c/index.tsx +1 -1
- package/template/echarts-custom-cmp-template/src/components/chartWidget__c/style.scss +3 -3
- package/template/echarts-custom-cmp-template/src/components/mapWidget__c/index.tsx +1 -1
- package/template/echarts-custom-cmp-template/src/components/mapWidget__c/style.scss +2 -2
- package/template/echarts-custom-cmp-template/tsconfig.json +1 -1
- package/template/empty-custom-cmp-template/tsconfig.json +9 -1
- package/template/neo-custom-cmp-template/package.json +1 -1
- package/template/neo-custom-cmp-template/src/components/entityCardList__c/index.tsx +1 -1
- package/template/neo-custom-cmp-template/src/components/entityCardList__c/style.scss +1 -1
- package/template/neo-custom-cmp-template/src/components/entityDetail__c/README.md +1 -1
- package/template/neo-custom-cmp-template/src/components/entityDetail__c/index.tsx +1 -1
- package/template/neo-custom-cmp-template/src/components/entityDetail__c/style.scss +2 -2
- package/template/neo-custom-cmp-template/src/components/entityForm__c/index.tsx +1 -1
- package/template/neo-custom-cmp-template/src/components/entityForm__c/model.ts +4 -0
- package/template/neo-custom-cmp-template/src/components/entityForm__c/style.scss +1 -1
- package/template/neo-custom-cmp-template/src/components/entityTable__c/index.tsx +1 -1
- package/template/neo-custom-cmp-template/src/components/entityTable__c/style.scss +1 -1
- package/template/neo-custom-cmp-template/src/components/simpleCmp__c/index.tsx +1 -1
- package/template/neo-custom-cmp-template/src/components/simpleCmp__c/style.scss +1 -1
- package/template/neo-custom-cmp-template/tsconfig.json +1 -1
- package/template/react-custom-cmp-template/package.json +1 -1
- package/template/react-custom-cmp-template/src/components/infoCard__c/index.jsx +1 -1
- package/template/react-custom-cmp-template/src/components/infoCard__c/style.scss +1 -1
- package/template/react-ts-custom-cmp-template/package.json +1 -1
- package/template/react-ts-custom-cmp-template/src/components/listWidget__c/index.tsx +1 -1
- package/template/react-ts-custom-cmp-template/src/components/listWidget__c/style.scss +3 -3
- package/template/react-ts-custom-cmp-template/tsconfig.json +2 -1
- package/template/vue2-custom-cmp-template/package.json +1 -1
- package/template/vue2-custom-cmp-template/src/components/vueInfoCard__c/index.vue +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("akfun"),s=require("node:path");var
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("akfun"),s=require("node:path"),t=require("../plugins/babel-plugin-add-data-scope.js");var o,a;exports.__require=function(){if(a)return o;a=1;const{resolve:r}=e,i=s,n=t.__require(),l=c("../loaders/component-scope-style-loader.js");function c(e){return i.resolve(__dirname,e)}const u={settings:{enableESLint:!1,enableESLintFix:!1,enableStyleLint:!1,enableStyleLintFix:!1},webpack:{resolve:{extensions:[".js",".jsx",".ts",".tsx",".vue",".min.js",".json"],alias:{"@":r("src")}},createDeclaration:!1,ignoreNodeModules:!1,allowList:[],externals:{},projectDir:["src"],template:c("../../template/initData/defaultTemplate.html"),sassResources:[],babelPlugins:[["import",{libraryName:"antd",style:"css"}],[n,{scopeKey:"data-scope"}]],moduleRules:[{enforce:"pre",test:/(index|style)\.(scss|less)$/i,use:[{loader:l,options:{scopeKey:"data-scope"}}]}]},envParams:{common:{"#version#":"20221229.1"},local:{"#dataApiBase#":"http://localhost:1024","#assetsPublicPath#":"http://localhost:1024","#routeBasePath#":"/"},online:{"#dataApiBase#":"/","#assetsPublicPath#":"","#routeBasePath#":"/"}},dev:{NODE_ENV:"development",port:80,autoOpenBrowser:!0,assetsPublicPath:"/",assetsSubDirectory:"",hostname:"localhost",proxyTable:{},cssSourceMap:!0},build:{NODE_ENV:"production",assetsRoot:r("dist"),assetsPublicPath:"/",assetsSubDirectory:"",productionSourceMap:!1,productionGzip:!1,productionGzipExtensions:["js","css","json"],bundleAnalyzerReport:!1},build2lib:{NODE_ENV:"production",libraryName:"",assetsRoot:r("dist"),assetsPublicPath:"/",assetsSubDirectory:"",productionSourceMap:!1,productionGzip:!1,productionGzipExtensions:["js","css","json"],bundleAnalyzerReport:!1},linkDebug:{NODE_ENV:"development",closeHtmlWebpackPlugin:!0,autoOpenBrowser:!1,cssExtract:!1,consoleInfo:"当前自定义组件可用外链地址"},publish2oss:{output:{filename:"[name].js",library:{type:"var",export:"default"},globalObject:"this"},cssExtract:!1,ossType:"ali",ossConfig:{endpoint:"https://oss-cn-beijing.aliyuncs.com",AccessKeyId:"xx",AccessKeySecret:"xx",bucket:"neo-widgets"},assetsRoot:r("dist")},pushCmp:{output:{filename:"[name].js",library:{type:"var",export:"default"},globalObject:"this"},cssExtract:!1,assetsRoot:r("dist")}};return o=u};
|
package/dist/main2.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("akfun");require("lodash");const r=require("./module/neoInit.js"),i=require("./module/neoInitByCopy.js"),s=require("./module/inspect.js"),t=require("./utils/neoConfigInit.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("akfun");require("lodash");const r=require("./module/neoInit.js"),i=require("./module/neoInitByCopy.js"),s=require("./module/inspect.js"),t=require("./utils/neoConfigInit.js"),u=require("./utils/neoParams.js"),o=require("./config/index.js"),l=require("./oss/publish2oss.js"),p=require("./neo/pushCmp.js"),n=require("./neo/pullCmp.js"),c=require("./neo/deleteCmp.js"),d=require("./utils/cmpUtils/previewCmp.js"),b=require("./utils/generateEntries.js"),a=require("./utils/cmpUtils/createCmpByTemplate.js"),m=require("./utils/projectUtils/createCmpProjectByTemplate.js"),q=require("./utils/projectUtils/openProject.js"),_=require("./utils/configureNeoBuild.js"),y=require("./utils/common.js"),g=require("./utils/projectNameValidator.js"),j=require("./utils/cmpUtils/getCmpTypeByDir.js"),v=require("./neo/neoService.js"),T=require("./neo/neoLogin.js"),f=require("./utils/projectUtils/hasNeoProject.js"),C=require("./plugins/babel-plugin-add-data-scope.js");var x,h;exports.__require=function(){if(h)return x;h=1;const E=e,N=r.__require(),w=i.__require(),B=s.__require(),D=t.__require(),{consoleTag:P}=u.__require(),k=o.__require(),I=l.__require(),L=p.__require(),M=n.__require(),S=c.__require(),U=d.__require(),O=b.__require(),A=a.__require(),R=m.__require(),V=q.__require(),{configureNeoBuild:z}=_.__require(),{errorLog:F,successLog:G}=y.__require(),{validateProjectName:H}=g.__require(),J=j.__require(),K=v.__require(),Q=T.__require(),W=f.__require(),X=C.__require();function Y(e,r){const{entryType:i,cmpType:s}=r;let t=[],u={};try{const{entries:r,cmpTypes:o,defaultExports:l}=O({configEntry:e.entry,disableAutoRegister:e.disableAutoRegister,componentsDir:k.componentsDir,entryType:i,cmpType:s});r&&Object.keys(r).length>0&&(e.entry=r,t=o,console.info("已自动生成 entry 入口配置:",r)),u=l}catch(e){F(e.message||e.msg),process.exit(1)}return{cmpTypes:t,defaultExports:u}}function Z(e){return Object.assign(k.build2lib,e)}return x={babelPluginAddDataScope:X,neoInit:N,neoInitByCopy:w,inspect:B,neoConfigInit:D,projectConfig:k,consoleTag:P,errorLog:F,successLog:G,validateProjectName:H,getCmpTypeByDir:J,NeoService:K,NeoLoginService:Q,hasNeoProject:W,createCmpProjectByTemplate:R,createCmpByTemplate:A,dev:()=>{k.dev||(F("未找到 dev 相关配置。"),process.exit(1)),E.dev(k,P)},previewCmp:e=>{e||(F("请输入要预览的组件名称。"),process.exit(1)),k.preview||(F("未找到 preview 相关配置。"),process.exit(1)),k.dev=Object.assign(k.dev,k.preview),delete k.preview,U(k,e)},linkDebug:()=>{k.linkDebug||(F("未找到 debug 相关配置。"),process.exit(1)),k.dev=Object.assign(k.dev,k.linkDebug),delete k.linkDebug,delete k.dev.ignoreNodeModules,k.webpack.ignoreNodeModules=!1;const{cmpTypes:e,defaultExports:r}=Y(k.dev,{entryType:"linkDebug"});z(k.dev,{cmpTypes:e,defaultExports:r,verbose:!0,excludeModel:!1}),E.dev(k,P)},build:()=>E.build("build",k,P),build2lib:()=>{Y(k.build2lib,{entryType:"widget"}),E.build("lib",k,P)},publish2oss:e=>{const r=k.publish2oss;k.build2lib=Z(r);const{cmpTypes:i,defaultExports:s}=Y(k.build2lib,{entryType:"widget",cmpType:e});z(k.build2lib,{cmpTypes:i,defaultExports:s,verbose:!0,excludeModel:!0}),E.build("lib",k,P,()=>{I(r.ossType,r.ossConfig,r.assetsRoot)})},pushCmp:e=>{const{pushCmp:r}=k;k.build2lib=Z(r);const{cmpTypes:i,defaultExports:s}=Y(k.build2lib,{entryType:"widget",cmpType:e});z(k.build2lib,{cmpTypes:i,defaultExports:s,verbose:!1,excludeModel:!0}),E.build("lib",k,P,()=>{L(r,e)})},pullCmp:(e,r)=>{M(e,r)},deleteCmp:(e,r)=>{S(e,r)},build2esm:()=>E.build2esm(k,P),openEditor:V},x};
|
package/dist/neo/neoRequire.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("lodash");var e,n;exports.__require=function(){if(n)return e;n=1;const s=o,d={react:"^16.13.1","react-dom":"^16.13.1",mobx:"^6.3.0","mobx-react":"^7.0.0","mobx-state-tree":"^5.4.0",echarts:"5.4.2",antd:"4.9.4","antd-mobile":"2.3.4","@ant-design/icons":"^4.8.0","video-react":"0.14.1",axios:"^0.27.2",classnames:"^2.3.2",qs:"^6.11.0",lodash:"^4.17.21","neo-ui-component-web":"^1.0.0","neo-ui-common":"^1.0.0","neo-open-api":"^1.1.9",amis:"^1.1.5"};return e={initNeoRequire:()=>{window.neoRequire||(window.neoRequire=o=>window.__NeoCommonModules[o]||window[o])},addNeoCommonModules:o=>{if(window.__NeoCommonModules||(window.__NeoCommonModules={}),isPlainObject(o)){Object.keys(o).forEach(e=>{const n=o[e],s=window.__NeoCommonModules[e];if(!Object.isFrozen(s)&&s&&Object.keys(s).length<3)try{window.__NeoCommonModules[e]=Object.assign(s,n),void 0!==n.__esModule&&(window.__NeoCommonModules[e].__esModule=n.__esModule),void 0!==n.default&&(window.__NeoCommonModules[e].default=n.default)}catch(o){console.warn(`window.__NeoCommonModules[${e}] Object.assign error:`,o),window.__NeoCommonModules[e]=n}else window.__NeoCommonModules[e]=n})}},addNeoRemoteDeps:o=>{window.__NeoCommonModules||(window.__NeoCommonModules={}),window.__NeoCommonModules.__neoRemoteDeps||(window.__NeoCommonModules.__neoRemoteDeps={}),s.isPlainObject(o)&&(window.__NeoCommonModules.__neoRemoteDeps=Object.assign(window.__NeoCommonModules.__neoRemoteDeps,o))},getExternalsByNeoCommonModules:o=>{const e={};return Object.keys(d).forEach(o=>{e[o]=`commonjs ${o}`}),o&&o.length>0&&o.forEach(o=>{e[o]=`commonjs ${o}`}),e}}};
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("lodash");var e,n;exports.__require=function(){if(n)return e;n=1;const s=o,d={react:"^16.13.1","react-dom":"^16.13.1",mobx:"^6.3.0","mobx-react":"^7.0.0","mobx-state-tree":"^5.4.0",echarts:"5.4.2",antd:"4.9.4","antd-mobile":"2.3.4","@ant-design/icons":"^4.8.0","video-react":"0.14.1",axios:"^0.27.2",classnames:"^2.3.2",qs:"^6.11.0",lodash:"^4.17.21","neo-ui-component-web":"^1.0.0","neo-ui-component-h5":"^1.0.0","neo-ui-common":"^1.0.0","neo-open-api":"^1.1.9",amis:"^1.1.5"};return e={initNeoRequire:()=>{window.neoRequire||(window.neoRequire=o=>window.__NeoCommonModules[o]||window[o])},addNeoCommonModules:o=>{if(window.__NeoCommonModules||(window.__NeoCommonModules={}),isPlainObject(o)){Object.keys(o).forEach(e=>{const n=o[e],s=window.__NeoCommonModules[e];if(!Object.isFrozen(s)&&s&&Object.keys(s).length<3)try{window.__NeoCommonModules[e]=Object.assign(s,n),void 0!==n.__esModule&&(window.__NeoCommonModules[e].__esModule=n.__esModule),void 0!==n.default&&(window.__NeoCommonModules[e].default=n.default)}catch(o){console.warn(`window.__NeoCommonModules[${e}] Object.assign error:`,o),window.__NeoCommonModules[e]=n}else window.__NeoCommonModules[e]=n})}},addNeoRemoteDeps:o=>{window.__NeoCommonModules||(window.__NeoCommonModules={}),window.__NeoCommonModules.__neoRemoteDeps||(window.__NeoCommonModules.__neoRemoteDeps={}),s.isPlainObject(o)&&(window.__NeoCommonModules.__neoRemoteDeps=Object.assign(window.__NeoCommonModules.__neoRemoteDeps,o))},getExternalsByNeoCommonModules:o=>{const e={};return Object.keys(d).forEach(o=>{e[o]=`commonjs ${o}`}),o&&o.length>0&&o.forEach(o=>{e[o]=`commonjs ${o}`}),e}}};
|
package/dist/neo/neoService.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("axios"),t=require("form-data"),s=require("node:fs"),o=require("node:path"),i=require("ora"),r=require("lodash"),n=require("akfun"),a=require("./neoLogin.js"),c=require("../utils/projectUtils/updatePublishLog.js"),l=require("../utils/common.js"),h=require("./neoEnvManager.js"),u=require("../utils/tableLog.js");var d,p;exports.__require=function(){if(p)return d;p=1;const m=e,f=t,y=s,g=o,w=i,k=r,{resolve:A}=n,C=a.__require(),$=c.__require(),{getFramework:x,errorLog:T,successLog:F}=l.__require(),L=h.__require(),{tableLog:P}=u.__require(),b=["cmpType","label","componentCategory","description","framework","icon","iconUrl","orderNo","version","propsSchema","defaultProps","previewProps","events","functions","asset","modelAsset","cssAsset","codeLib"];return d=class{constructor(){const e=L.getEnvConfig(),{assetsRoot:t,auth:s,authType:o}=e||{};this.authType=o||"oauth2",this.NeoCrmAPI=e,"password"!==this.authType||s||(T("密码授权模式时,neo.config.js / neoConfig / auth 配置不能为空"),process.exit(1)),"password"===this.authType?s.client_id&&s.client_secret&&s.username&&s.password||(T("neo.config.js / neoConfig / auth 配置不完整(password 模式),需要包含 client_id、client_secret、username、password"),process.exit(1)):"oauth2"!=this.authType&&(T(`不支持的授权类型: ${this.authType},可选值:oauth2、password`),process.exit(1)),this.assetsRoot=t||A("dist"),this.auth=s,this.cmpList=[],this.cmpInfoMap={},this.tokenCache={token:null,expiresAt:null}}buildFullUrl(e){return e.startsWith("http://")||e.startsWith("https://")?e:`${this.NeoCrmAPI.neoBaseURL}${e}`}uploadAPI(){return this.buildFullUrl(this.NeoCrmAPI.uploadAPI)}saveAPI(){return this.buildFullUrl(this.NeoCrmAPI.saveAPI)}isTokenExpired(){return!this.tokenCache.token||!this.tokenCache.expiresAt||Date.now()>=this.tokenCache.expiresAt}async getToken(){return this.isTokenExpired()?"oauth2"===this.authType?await this.getTokenByOAuth2():await this.getTokenByPassword():this.tokenCache.token}async getTokenByPassword(){const e=w("获取 token(密码模式)...").start();if(!this.isTokenExpired())return F("使用缓存的 token。",e),this.tokenCache.token;const t=new URLSearchParams;t.append("grant_type","password"),t.append("client_id",this.auth.client_id),t.append("client_secret",this.auth.client_secret),t.append("username",this.auth.username),t.append("password",this.auth.password);const s=this.buildFullUrl(this.NeoCrmAPI.tokenURL);try{const o=await m.post(s,t.toString(),{headers:{"Content-Type":"application/x-www-form-urlencoded"}}),i=o.data||{},{access_token:r,expires_in:n}=i;r||(T("获取 token 失败(授权配置错误):响应中未包含 access_token,"+JSON.stringify(o.data),e),process.exit(1));const a=parseInt(n)||3600;return this.tokenCache={...i,token:r,expiresAt:Date.now()+1e3*(a-60)},e.clear(),e.stop(),r}catch(o){T("获取 token 失败",e),T(`\n获取 token 失败: ${o.message||o.msg}`),T(`\ntoken 授权地址: ${s}`),T(`\ntoken 请求参数: ${t}`),o.response&&T(`响应数据: ${JSON.stringify(o.response.data)}`),process.exit(1)}}async getTokenByOAuth2(){const e=w("获取 token(OAuth2 模式)...").start();try{const t={neoBaseURL:this.NeoCrmAPI.neoBaseURL,loginURL:this.NeoCrmAPI.loginURL,tokenURL:this.NeoCrmAPI.tokenURL},s=new C(t),o=await s.getAccessToken(),i=o.access_token;return this.tokenCache={...o,token:i,expiresAt:Date.now()+72e5},e.clear(),e.stop(),i}catch(t){T("获取 token 失败(OAuth2 模式)",e),T(`\n获取 token 失败: ${t.message||t.msg}`),t.response&&T(`响应数据: ${JSON.stringify(t.response.data)}`),process.exit(1)}}async refreshToken(){return this.tokenCache={token:null,expiresAt:null},await this.getToken()}async ensureValidToken(){if(!this.tokenCache.token)return await this.getToken();if(this.isTokenExpired()){const e=w("token 已过期,正在刷新...").start();try{const t=await this.refreshToken();return F("token 刷新成功。",e),t}catch(t){throw T("token 刷新失败。",e),t}}return this.tokenCache.token}async uploadFile(e,t={}){const s=await this.ensureValidToken();if(!e||"string"!=typeof e)throw new Error(`文件路径无效: ${e}`);if(!y.existsSync(e))throw new Error(`文件不存在: ${e}`);const o=y.statSync(e);if(!o.isFile())throw new Error(`路径不是文件: ${e}`);const i=t.maxSize||5242880;if(o.size>i){const e=(o.size/1024/1024).toFixed(2),t=(i/1024/1024).toFixed(2);throw new Error(`文件大小超过限制: ${e}MB > ${t}MB`)}if(0===o.size)throw new Error(`文件为空: ${e}`);const r=g.basename(e),n=(o.size/1024).toFixed(2),a=w(`正在上传文件: ${r} (${n}KB)...`).start();try{const o=new f,i=t.fieldName||"customComponentCode",n=y.createReadStream(e);o.append(i,n,r);const c=this.uploadAPI(),l=t.timeout||6e4,h={headers:{Authorization:`Bearer ${s}`,"xsy-inner-source":"bff",...o.getHeaders()},timeout:l,maxContentLength:1/0,maxBodyLength:1/0},u=await m.post(c,o,h);let d;const p=u.data;if(200!==u.status&&201!==u.status)throw new Error(`上传失败: HTTP ${u.status}`);if("string"==typeof p)d=p.trim();else{if(!p||"object"!=typeof p)throw new Error("响应数据格式不正确: "+typeof p);if(void 0!==p.code&&200!==p.code&&0!==p.code){const e=p.message||p.msg||"未知错误";throw new Error(`上传失败: ${e} (code: ${p.code})`)}d=void 0!==p.data?p.data:void 0!==p.url?p.url:void 0!==p.fileUrl?p.fileUrl:p}if(!d)throw new Error("返回的文件地址为空");let g;return"string"==typeof d?g=d:d&&"object"==typeof d&&d.url&&(g=d.url),F(`文件上传成功: ${r} -> ${g}`,a),g}catch(t){if(T(`上传文件失败: ${t.message||t.msg}, 文件路径: ${e}`,a),t.response){const e=t.response.status,s=t.response.statusText,o=t.response.data,i=t.config?.url||this.uploadAPI();if(T("\n========== 上传请求详情 =========="),T(`请求 URL: ${i}`),T(`HTTP 状态码: ${e} ${s}`),T(`响应数据: ${JSON.stringify(o)}`),T("==================================\n"),404===e)throw new Error(`上传 API 不存在 (404): ${i}\n请检查 neo.config.js 中的 neoBaseURL 配置是否正确,或者 API 路径是否存在。\n当前配置的 API 路径: ${this.NeoCrmAPI.uploadAPI}`)}else t.request&&T("请求已发送但未收到响应,请检查网络连接或代理配置。");throw t}}async publish2oss(e,t=[".js",".css",".zip"]){if(!e)return void T(`自定义组件名称不能为空: ${e}`);if(!y.existsSync(this.assetsRoot))return void T(`未找到自定义组件资源目录: ${this.assetsRoot}`);const s={cmpType:e},o=y.readdirSync(this.assetsRoot).map(async o=>{const i=g.join(this.assetsRoot,o),r=y.statSync(i),n=g.parse(i);if(r.isFile()&&t.includes(n.ext)){let t=k.camelCase(e);if(o.indexOf(t)<0)return;try{const e=await this.uploadFile(i);o.indexOf("Model")>-1?s.modelAsset=e:o.endsWith(".css")?s.cssAsset=e:o.endsWith(".zip")?s.codeLib=e:s.asset=e}catch(e){T(`文件上传失败(${o}):\n`),process.exit(1)}}});return await Promise.all(o),s&&s.cmpType&&(console.info("上传至 OSS 的文件信息:\n",s),$(s)),s}async getCmpAssets(e,t=[".js",".css",".zip"]){if(!e)return void T(`自定义组件名称不能为空: ${e}`);if(!y.existsSync(this.assetsRoot))return void T(`未找到自定义组件资源目录: ${this.assetsRoot}`);const s={cmpType:e};return y.readdirSync(this.assetsRoot).forEach(o=>{const i=g.join(this.assetsRoot,o),r=y.statSync(i),n=g.parse(i);if(r.isFile()&&t.includes(n.ext)){let t=k.camelCase(e);if(o.indexOf(t)<0)return;const n=5242880;if(r.size>n){const e=(r.size/1024/1024).toFixed(2),t=(n/1024/1024).toFixed(2);throw new Error(`${o} 文件大小超过限制: ${e}MB > ${t}MB`)}const a={fileContent:y.createReadStream(i),fileName:o,fileSize:r.size};o.indexOf("Model")>-1?s.modelAssetFile=a:o.endsWith(".css")?s.cssAssetFile=a:o.endsWith(".zip")?s.codeLibFile=a:s.assetFile=a}}),s}async updateCustomComponent(e){const t=await this.ensureValidToken();if(!e)throw new Error("componentData 不能为空");const s=w("正在保存自定义组件信息...").start();try{const o=this.saveAPI(),i=new f;e.assetFile&&i.append("assetFile",e.assetFile.fileContent,e.assetFile.fileName),e.modelAssetFile&&i.append("modelAssetFile",e.modelAssetFile.fileContent,e.modelAssetFile.fileName),e.cssAssetFile&&i.append("cssAssetFile",e.cssAssetFile.fileContent,e.cssAssetFile.fileName),e.codeLibFile&&i.append("codeLibFile",e.codeLibFile.fileContent,e.codeLibFile.fileName),i.append("component",JSON.stringify(k.omit(e,["assetFile","modelAssetFile","cssAssetFile","codeLibFile"])));const r=await m.post(o,i,{headers:{Authorization:`Bearer ${t}`,"xsy-inner-source":"bff",...i.getHeaders()},timeout:12e4,maxContentLength:1/0,maxBodyLength:1/0}),{code:n,message:a,msg:c}=r.data||{};n&&200!==n&&(T(`保存自定义组件信息失败: ${a||c||"未知错误"}`),process.exit(1)),s.clear(),s.stop()}catch(e){const t=e.message||e.msg;T(t?`保存自定义组件信息失败: ${t}`:`保存自定义组件信息失败: ${JSON.stringify(e)}`,s),process.exit(1)}}async getCustomCmpList(){const e=await this.ensureValidToken();try{let t=this.buildFullUrl(this.NeoCrmAPI.queryAll);t+=`&fields=${b.join(",")}`;const s=await m.get(t,{headers:{Authorization:`Bearer ${e}`,"xsy-inner-source":"bff","Content-Type":"application/json"}}),{code:o,message:i,msg:r}=s.data||{};o&&200!==o&&(T(`获取自定义组件列表失败: ${i||r||"未知错误"}`),process.exit(1)),this.updateCustomCmpList(s.data.data||[])}catch(e){const t=e.message||e.msg;T(t?`获取自定义组件列表失败: ${t}`:`响应数据: ${JSON.stringify(e)}`),process.exit(1)}return this.cmpList||[]}getCodeLibByCmpType(e){return e?this.buildFullUrl(this.NeoCrmAPI.getCodeLibAPI(e)):null}async deleteCmp(e){const t=await this.ensureValidToken();e||(T("自定义组件名称不能为空。"),process.exit(1));let s=this.buildFullUrl(this.NeoCrmAPI.delete);s+=`/${e}`;const o=await m.delete(s,{headers:{Authorization:`Bearer ${t}`,"xsy-inner-source":"bff","Content-Type":"application/json"}}),{code:i,message:r,msg:n,errorInfo:a}=o.data||{};return i&&200!==i&&(a&&a.length>0?P(a,{title:"删除自定义组件失败",columns:["reason","instance"],headers:{reason:"原因",instance:"实例"},align:{reason:"center",instance:"center"},padding:2,showBorder:!0}):T(`删除自定义组件失败: ${r||n||"未知错误"}`),process.exit(1)),o.data}getCmpListByFramework(e){if(!e)return this.cmpList;const t=x(e);return this.cmpList.filter(e=>e.framework===t)}getCmpInfoByCmpType(e){return e&&this.cmpInfoMap[e]||null}updateCustomCmpList(e){e&&Array.isArray(e)&&(this.cmpList=e,e.forEach(e=>{this.cmpInfoMap[e.cmpType]=e}))}async request(e,t,s={}){const o=await this.ensureValidToken(),{data:i,headers:r={},params:n}=s,a=this.buildFullUrl(t);try{const t=await m({method:e,url:a,data:i,params:n,headers:{Authorization:`Bearer ${o}`,"xsy-inner-source":"bff",...r}});if(t.data&&t.data.code&&200!==t.data.code)throw new Error(`请求失败: ${t.data.message||t.data.msg||"未知错误"}`);return t.data}catch(s){throw T(`请求失败 [${e} ${t}]: ${s.message||s.msg}`),s.response&&T(`响应数据: ${JSON.stringify(s.response.data)}`),s}}async get(e,t={}){return await this.request("GET",e,t)}async post(e,t={}){return await this.request("POST",e,t)}async put(e,t={}){return await this.request("PUT",e,t)}async delete(e,t={}){return await this.request("DELETE",e,t)}}};
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("axios"),t=require("form-data"),s=require("node:fs"),o=require("node:path"),i=require("node:crypto"),r=require("ora"),n=require("lodash"),a=require("akfun"),c=require("./neoLogin.js"),l=require("../utils/projectUtils/updatePublishLog.js"),h=require("../utils/common.js"),d=require("./neoEnvManager.js"),u=require("../utils/tableLog.js");var p,m;exports.__require=function(){if(m)return p;m=1;const f=e,y=t,g=s,w=o,k=i,A=r,$=n,{resolve:C}=a,x=c.__require(),T=l.__require(),{getFramework:F,errorLog:L,successLog:P}=h.__require(),b=d.__require(),{tableLog:I}=u.__require(),S=["cmpType","label","componentCategory","description","framework","icon","iconUrl","orderNo","version","propsSchema","defaultProps","previewProps","events","functions","asset","modelAsset","cssAsset","codeLib"];return p=class{constructor(){const e=b.getEnvConfig(),{assetsRoot:t,auth:s,authType:o}=e||{};this.authType=o||"oauth2",this.NeoCrmAPI=e,"password"!==this.authType||s||(L("密码授权模式时,neo.config.js / neoConfig / auth 配置不能为空"),process.exit(1)),"password"===this.authType?s.client_id&&s.client_secret&&s.username&&s.password||(L("neo.config.js / neoConfig / auth 配置不完整(password 模式),需要包含 client_id、client_secret、username、password"),process.exit(1)):"oauth2"!=this.authType&&(L(`不支持的授权类型: ${this.authType},可选值:oauth2、password`),process.exit(1)),this.assetsRoot=t||C("dist"),this.auth=s,this.cmpList=[],this.cmpInfoMap={},this.tokenCache={token:null,expiresAt:null}}buildFullUrl(e){return e.startsWith("http://")||e.startsWith("https://")?e:`${this.NeoCrmAPI.neoBaseURL}${e}`}uploadAPI(){return this.buildFullUrl(this.NeoCrmAPI.uploadAPI)}saveAPI(){return this.buildFullUrl(this.NeoCrmAPI.saveAPI)}isTokenExpired(){return!this.tokenCache.token||!this.tokenCache.expiresAt||Date.now()>=this.tokenCache.expiresAt}async getToken(){return this.isTokenExpired()?"oauth2"===this.authType?await this.getTokenByOAuth2():await this.getTokenByPassword():this.tokenCache.token}async getTokenByPassword(){const e=A("获取 token(密码模式)...").start();if(!this.isTokenExpired())return P("使用缓存的 token。",e),this.tokenCache.token;const t=new URLSearchParams;t.append("grant_type","password"),t.append("client_id",this.auth.client_id),t.append("client_secret",this.auth.client_secret),t.append("username",this.auth.username),t.append("password",this.auth.password);const s=this.buildFullUrl(this.NeoCrmAPI.tokenURL);try{const o=await f.post(s,t.toString(),{headers:{"Content-Type":"application/x-www-form-urlencoded"}}),i=o.data||{},{access_token:r,expires_in:n}=i;r||(L("获取 token 失败(授权配置错误):响应中未包含 access_token,"+JSON.stringify(o.data),e),process.exit(1));const a=parseInt(n)||3600;return this.tokenCache={...i,token:r,expiresAt:Date.now()+1e3*(a-60)},e.clear(),e.stop(),r}catch(o){L("获取 token 失败",e),L(`\n获取 token 失败: ${o.message||o.msg}`),L(`\ntoken 授权地址: ${s}`),L(`\ntoken 请求参数: ${t}`),o.response&&L(`响应数据: ${JSON.stringify(o.response.data)}`),process.exit(1)}}async getTokenByOAuth2(){const e=A("获取 token(OAuth2 模式)...").start();try{const t={neoBaseURL:this.NeoCrmAPI.neoBaseURL,loginURL:this.NeoCrmAPI.loginURL,tokenURL:this.NeoCrmAPI.tokenURL},s=new x(t),o=await s.getAccessToken(),i=o.access_token;return this.tokenCache={...o,token:i,expiresAt:Date.now()+72e5},e.clear(),e.stop(),i}catch(t){L("获取 token 失败(OAuth2 模式)",e),L(`\n获取 token 失败: ${t.message||t.msg}`),t.response&&L(`响应数据: ${JSON.stringify(t.response.data)}`),process.exit(1)}}async refreshToken(){return this.tokenCache={token:null,expiresAt:null},await this.getToken()}async ensureValidToken(){if(!this.tokenCache.token)return await this.getToken();if(this.isTokenExpired()){const e=A("token 已过期,正在刷新...").start();try{const t=await this.refreshToken();return P("token 刷新成功。",e),t}catch(t){throw L("token 刷新失败。",e),t}}return this.tokenCache.token}async uploadFile(e,t={}){const s=await this.ensureValidToken();if(!e||"string"!=typeof e)throw new Error(`文件路径无效: ${e}`);if(!g.existsSync(e))throw new Error(`文件不存在: ${e}`);const o=g.statSync(e);if(!o.isFile())throw new Error(`路径不是文件: ${e}`);const i=t.maxSize||5242880;if(o.size>i){const e=(o.size/1024/1024).toFixed(2),t=(i/1024/1024).toFixed(2);throw new Error(`文件大小超过限制: ${e}MB > ${t}MB`)}if(0===o.size)throw new Error(`文件为空: ${e}`);const r=w.basename(e),n=(o.size/1024).toFixed(2),a=A(`正在上传文件: ${r} (${n}KB)...`).start();try{const o=new y,i=t.fieldName||"customComponentCode",n=g.createReadStream(e);o.append(i,n,r);const c=this.uploadAPI(),l=t.timeout||6e4,h={headers:{Authorization:`Bearer ${s}`,"xsy-inner-source":"bff",...o.getHeaders()},timeout:l,maxContentLength:1/0,maxBodyLength:1/0},d=await f.post(c,o,h);let u;const p=d.data;if(200!==d.status&&201!==d.status)throw new Error(`上传失败: HTTP ${d.status}`);if("string"==typeof p)u=p.trim();else{if(!p||"object"!=typeof p)throw new Error("响应数据格式不正确: "+typeof p);if(void 0!==p.code&&200!==p.code&&0!==p.code){const e=p.message||p.msg||"未知错误";throw new Error(`上传失败: ${e} (code: ${p.code})`)}u=void 0!==p.data?p.data:void 0!==p.url?p.url:void 0!==p.fileUrl?p.fileUrl:p}if(!u)throw new Error("返回的文件地址为空");let m;return"string"==typeof u?m=u:u&&"object"==typeof u&&u.url&&(m=u.url),P(`文件上传成功: ${r} -> ${m}`,a),m}catch(t){if(L(`上传文件失败: ${t.message||t.msg}, 文件路径: ${e}`,a),t.response){const e=t.response.status,s=t.response.statusText,o=t.response.data,i=t.config?.url||this.uploadAPI();if(L("\n========== 上传请求详情 =========="),L(`请求 URL: ${i}`),L(`HTTP 状态码: ${e} ${s}`),L(`响应数据: ${JSON.stringify(o)}`),L("==================================\n"),404===e)throw new Error(`上传 API 不存在 (404): ${i}\n请检查 neo.config.js 中的 neoBaseURL 配置是否正确,或者 API 路径是否存在。\n当前配置的 API 路径: ${this.NeoCrmAPI.uploadAPI}`)}else t.request&&L("请求已发送但未收到响应,请检查网络连接或代理配置。");throw t}}async publish2oss(e,t=[".js",".css",".zip"]){if(!e)return void L(`自定义组件名称不能为空: ${e}`);if(!g.existsSync(this.assetsRoot))return void L(`未找到自定义组件资源目录: ${this.assetsRoot}`);const s={cmpType:e},o=g.readdirSync(this.assetsRoot).map(async o=>{const i=w.join(this.assetsRoot,o),r=g.statSync(i),n=w.parse(i);if(r.isFile()&&t.includes(n.ext)){let t=$.camelCase(e);if(o.indexOf(t)<0)return;try{const e=await this.uploadFile(i);o.indexOf("Model")>-1?s.modelAsset=e:o.endsWith(".css")?s.cssAsset=e:o.endsWith(".zip")?s.codeLib=e:s.asset=e}catch(e){L(`文件上传失败(${o}):\n`),process.exit(1)}}});return await Promise.all(o),s&&s.cmpType&&(console.info("上传至 OSS 的文件信息:\n",s),T(s)),s}async getCmpAssets(e,t=[".js",".css",".zip"]){if(!e)return void L(`自定义组件名称不能为空: ${e}`);if(!g.existsSync(this.assetsRoot))return void L(`未找到自定义组件资源目录: ${this.assetsRoot}`);const s={cmpType:e};return g.readdirSync(this.assetsRoot).forEach(o=>{const i=w.join(this.assetsRoot,o),r=g.statSync(i),n=w.parse(i);if(r.isFile()&&t.includes(n.ext)){let t=$.camelCase(e);if(o.indexOf(t)<0)return;const n=5242880;if(r.size>n){const e=(r.size/1024/1024).toFixed(2),t=(n/1024/1024).toFixed(2);throw new Error(`${o} 文件大小超过限制: ${e}MB > ${t}MB`)}const a=g.readFileSync(i),c=k.createHash("md5").update(a).digest("hex").substring(0,8),l={fileContent:g.createReadStream(i),fileName:`${c}-${o}`,fileSize:r.size};o.indexOf("Model")>-1?s.modelAssetFile=l:o.endsWith(".css")?s.cssAssetFile=l:o.endsWith(".zip")?s.codeLibFile=l:s.assetFile=l}}),s}async updateCustomComponent(e){const t=await this.ensureValidToken();if(!e)throw new Error("componentData 不能为空");const s=A("正在保存自定义组件信息...").start();try{const o=this.saveAPI(),i=new y;e.assetFile&&i.append("assetFile",e.assetFile.fileContent,e.assetFile.fileName),e.modelAssetFile&&i.append("modelAssetFile",e.modelAssetFile.fileContent,e.modelAssetFile.fileName),e.cssAssetFile&&i.append("cssAssetFile",e.cssAssetFile.fileContent,e.cssAssetFile.fileName),e.codeLibFile&&i.append("codeLibFile",e.codeLibFile.fileContent,e.codeLibFile.fileName),i.append("component",JSON.stringify($.omit(e,["assetFile","modelAssetFile","cssAssetFile","codeLibFile"])));const r=await f.post(o,i,{headers:{Authorization:`Bearer ${t}`,"xsy-inner-source":"bff",...i.getHeaders()},timeout:12e4,maxContentLength:1/0,maxBodyLength:1/0}),{code:n,message:a,msg:c}=r.data||{};n&&200!==n&&(L(`保存自定义组件信息失败: ${a||c||"未知错误"}`),process.exit(1)),s.clear(),s.stop()}catch(e){const t=e.message||e.msg;L(t?`保存自定义组件信息失败: ${t}`:`保存自定义组件信息失败: ${JSON.stringify(e)}`,s),process.exit(1)}}async getCustomCmpList(){const e=await this.ensureValidToken();try{let t=this.buildFullUrl(this.NeoCrmAPI.queryAll);t+=`&fields=${S.join(",")}`;const s=await f.get(t,{headers:{Authorization:`Bearer ${e}`,"xsy-inner-source":"bff","Content-Type":"application/json"}}),{code:o,message:i,msg:r}=s.data||{};o&&200!==o&&(L(`获取自定义组件列表失败: ${i||r||"未知错误"}`),process.exit(1)),this.updateCustomCmpList(s.data.data||[])}catch(e){const t=e.message||e.msg;L(t?`获取自定义组件列表失败: ${t}`:`响应数据: ${JSON.stringify(e)}`),process.exit(1)}return this.cmpList||[]}getCodeLibByCmpType(e){return e?this.buildFullUrl(this.NeoCrmAPI.getCodeLibAPI(e)):null}async deleteCmp(e){const t=await this.ensureValidToken();e||(L("自定义组件名称不能为空。"),process.exit(1));let s=this.buildFullUrl(this.NeoCrmAPI.delete);s+=`/${e}`;const o=await f.delete(s,{headers:{Authorization:`Bearer ${t}`,"xsy-inner-source":"bff","Content-Type":"application/json"}}),{code:i,message:r,msg:n,errorInfo:a}=o.data||{};return i&&200!==i&&(a&&a.length>0?I(a,{title:"删除自定义组件失败",columns:["reason","instance"],headers:{reason:"原因",instance:"实例"},align:{reason:"center",instance:"center"},padding:2,showBorder:!0}):L(`删除自定义组件失败: ${r||n||"未知错误"}`),process.exit(1)),o.data}getCmpListByFramework(e){if(!e)return this.cmpList;const t=F(e);return this.cmpList.filter(e=>e.framework===t)}getCmpInfoByCmpType(e){return e&&this.cmpInfoMap[e]||null}updateCustomCmpList(e){e&&Array.isArray(e)&&(this.cmpList=e,e.forEach(e=>{this.cmpInfoMap[e.cmpType]=e}))}async request(e,t,s={}){const o=await this.ensureValidToken(),{data:i,headers:r={},params:n}=s,a=this.buildFullUrl(t);try{const t=await f({method:e,url:a,data:i,params:n,headers:{Authorization:`Bearer ${o}`,"xsy-inner-source":"bff",...r}});if(t.data&&t.data.code&&200!==t.data.code)throw new Error(`请求失败: ${t.data.message||t.data.msg||"未知错误"}`);return t.data}catch(s){throw L(`请求失败 [${e} ${t}]: ${s.message||s.msg}`),s.response&&L(`响应数据: ${JSON.stringify(s.response.data)}`),s}}async get(e,t={}){return await this.request("GET",e,t)}async post(e,t={}){return await this.request("POST",e,t)}async put(e,t={}){return await this.request("PUT",e,t)}async delete(e,t={}){return await this.request("DELETE",e,t)}}};
|
package/dist/neo/pushCmp.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("node:fs"),t=require("node:path"),s=require("lodash"),r=require("akfun"),o=require("ora"),i=require("./neoService.js"),a=require("../utils/common.js"),n=require("../utils/pathUtils.js"),c=require("../utils/projectUtils/createCmpProjectZip.js"),l=require("../utils/projectUtils/updatePublishLog.js"),p=require("../utils/cmpTypeValidator.js");var u,g;exports.__require=function(){if(g)return u;g=1;const m=e,d=t,w=s,{getConfigObj:
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("node:fs"),t=require("node:path"),s=require("lodash"),r=require("akfun"),o=require("ora"),i=require("./neoService.js"),a=require("../utils/common.js"),n=require("../utils/pathUtils.js"),c=require("../utils/projectUtils/createCmpProjectZip.js"),l=require("../utils/projectUtils/updatePublishLog.js"),p=require("../utils/cmpTypeValidator.js");var u,g;exports.__require=function(){if(g)return u;g=1;const m=e,d=t,w=s,{getConfigObj:f}=r,y=o,h=i.__require(),{getFramework:b,errorLog:v,successLog:C}=a.__require(),{catchCurPackageJson:T}=n.__require(),q=c.__require(),j=l.__require(),{validateApiName:P}=p.__require(),$=f(T()),_=(e=[])=>e.map(e=>({label:e.label,description:e.description,propSchema:JSON.stringify(e)})),D=(e=[],t)=>e&&0!==e.length?e.map(e=>({...e,componentType:t,eventCategory:e.eventCategory||2,pageType:e.pageType||1,targetDevice:e.targetDevice||1,eventParams:e.eventParams||[]})):[],S=(e=[],t)=>e&&0!==e.length?e.map(e=>({...e,componentType:t,funcScope:e.funcScope||1,pageType:e.pageType||1,targetDevice:e.targetDevice||1,custom:!0,funcInParams:e.funcInParams||[],funcOutParams:e.funcOutParams||[]})):[];return u=async(e,t)=>{const s=y("正在发布组件...").start(),{isValid:r,errors:o}=P(t);r||(v(o.join("\n")),process.exit(1));try{let r,o=new h;await o.ensureValidToken(),s.start("[1/4] 打包源码文件(含单个自定义组件源码)...");try{r=q(t,process.cwd(),e.assetsRoot),r?C(`[1/4] 源码文件打包完成: ${d.basename(r)}。`,s):v("[1/4] 源码文件打包失败,未返回 zip 文件路径。",s)}catch(e){v("[1/4] 源码文件打包失败。",s)}s.start("[2/4] 获取自定义组件构建产物...");const i=await o.getCmpAssets(t);let a;s.start("[3/4] 构建组件数据...");try{a=await(async(e,t)=>{if(!t||!t.cmpType)return v("自定义组件信息或组件名称不能为空"),null;const{cmpType:s}=t;if(!e||!m.existsSync(e))return v(`未找到自定义组件目录: ${e}`),null;const r=w.camelCase(s),o=d.join(e,`${r}Model.js`),i=globalThis.window;globalThis.window||(globalThis.window={console:console,neoRequire:()=>{},postMessage:()=>{}});try{m.existsSync(o)?require(o):(v(`未找到自定义组件模型文件,请检查以下路径是否存在:${o}`),process.exit(1)),globalThis.window&&globalThis.window.NEOEditorCustomModels||(v(`模型文件未导出有效模型方法(CatchCustomCmpModelClass),模型文件地址: ${o} `),process.exit(1));const e=globalThis.window.NEOEditorCustomModels[s];e||(v(`未找到自定义组件模型类(${s}),模型文件地址: ${o} `),process.exit(1));const r=new e;return r||(v(`未找到自定义组件模型信息(${s}),模型文件地址: ${o} `),process.exit(1)),{...t,version:$.version||"1.0.0",framework:$.framework?b($.framework):0,label:r.label||s,description:r.description||"",componentCategory:(r.tags||["自定义组件"]).join(","),targetPage:r.targetPage||["all"],targetObject:r.targetObject||["all"],targetApplication:r.targetApplication||["all"],targetDevice:r.targetDevice||"web",iconUrl:r.iconUrl||r.iconUrl,defaultProps:JSON.stringify(r.defaultComProps||{}),previewProps:JSON.stringify(r.previewComProps||{}),props:_(r.propsSchema||[]),events:D(r.events||[],s),functions:S(r.functions||r.actions||[],s),exposedToDesigner:void 0===r.exposedToDesigner||r.exposedToDesigner,namespace:r.namespace||"neo-cmp-cli",enableDuplicate:void 0===r.enableDuplicate||r.enableDuplicate}}catch(e){return v(`自定义组件模型文件解析失败 (${o||"未知路径"}): ${e.message||e.msg}`),v(e.stack),null}finally{void 0===i?delete globalThis.window:globalThis.window=i}})(e.assetsRoot,i),a?C("[3/4] 组件数据构建完成。",s):v(`[3/4] 未获取到自定义组件模型信息(${t})。`,s)}catch(e){v(`[3/4] 组件数据构建失败: ${e.message||e.msg}`,s)}s.start("[4/4] 保存组件信息到 NeoCRM 平台...");const n=["assetFile","modelAssetFile","cssAssetFile","codeLibFile"],c={...a};n.forEach(e=>{c[e]&&c[e].fileContent&&(c[e]=w.omit(c[e],["fileContent"]))}),j(c);try{await o.updateCustomComponent(a),C("[4/4] 组件信息保存成功",s)}catch(e){v("[4/4] 组件信息保存失败",s)}const{tenant_id:l,instance_uri:p}=o.tokenCache||{};console.log(`\n✅ 自定义组件发布成功!\n(当前租户 ID: ${l||"未返回"},所在租户的 API 域名: ${p||"未返回"}。)`)}catch(e){try{s&&s.isSpinning&&v(`❌ 自定义组件发布失败: ${e.message||e.msg}`,s)}catch{v(`\n❌ 自定义组件发布失败: ${e.message||e.msg}`)}throw e}},u};
|
package/dist/package.json.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e="1.10.
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e="1.10.8";const o={version:e};exports.default=o,exports.version=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("node:path");var t,n;exports.__require=function(){if(n)return t;n=1;const r=e;return t=function(e,t){const{types:n}=e,i=(t||{}).scopeKey||"data-scope";function s(e){if(!e)return"";try{const t=r.dirname(e);return r.basename(t)||""}catch(e){return""}}const o=new Set(["jsx","jsxs","jsxDEV","_jsx","_jsxs","_jsxDEV"]);function a(e){if(!e||!e.isCallExpression())return!1;const t=e.get("callee");return function(e){return!!e&&(!!(e.isMemberExpression()&&n.isIdentifier(e.get("object").node,{name:"React"})&&n.isIdentifier(e.get("property").node,{name:"createElement"}))||e.isIdentifier({name:"createElement"}))}(t)||function(e){return e&&e.isIdentifier()&&o.has(e.node.name)}(t)}function c(e){const t=n.isValidIdentifier(i)?n.identifier(i):n.stringLiteral(i);return n.objectProperty(t,n.stringLiteral(e))}function u(e,t){if(e)if(e.isNullLiteral()||e.isIdentifier({name:"undefined"}))e.replaceWith(n.objectExpression([c(t)]));else if(e.isObjectExpression()){if(e.node.properties.some(e=>!(!n.isObjectProperty(e)||e.computed)&&(!(!n.isIdentifier(e.key)||e.key.name!==i)||n.isStringLiteral(e.key)&&e.key.value===i)))return;e.node.properties.unshift(c(t))}else{e.replaceWith(n.callExpression(n.memberExpression(n.identifier("Object"),n.identifier("assign")),[n.objectExpression([c(t)]),e.node]))}}function f(e,t){if(!a(e))return!1;const r=e.get("arguments"),i=function(e){return!!(e&&e.node&&(n.isIdentifier(e.node,{name:"Fragment"})||n.isMemberExpression(e.node)&&n.isIdentifier(e.node.object,{name:"React"})&&n.isIdentifier(e.node.property,{name:"Fragment"})))}(r[0]);if(i){const r=function(e,t){const r=e.get("arguments"),i=r[1];if(i&&i.isObjectExpression()){const e=i.get("properties");for(const r of e)if(r.isObjectProperty()&&!r.node.computed&&(n.isIdentifier(r.node.key)&&"children"===r.node.key.name||n.isStringLiteral(r.node.key)&&"children"===r.node.key.value)){const e=r.get("value");if(Array.isArray(e))continue;if(m(e,t))return!0}}for(let e=2;e<r.length;e++)if(m(r[e],t))return!0;return!1}(e,t);if(r)return!0}r[1]||(e.node.arguments[1]=n.objectExpression([]));return u(e.get("arguments")[1],t),!0}function d(e){return!(!e||!e.node)&&(!(!e.isJSXElement()&&!e.isJSXFragment())||(e.isArrayExpression()?e.get("elements").some(e=>d(e)):e.isConditionalExpression()?d(e.get("consequent"))||d(e.get("alternate")):e.isLogicalExpression()?d(e.get("left"))||d(e.get("right")):!!e.isCallExpression()&&(!!a(e)||e.get("arguments").some(e=>d(e)))))}function m(e,t){if(!e||!e.node)return!1;if(e.isJSXElement())return function(e,t=""){const r=e.openingElement.attributes;if(!r.some(e=>n.isJSXAttribute(e)&&e.name.name===i)){const e=n.jsxAttribute(n.jsxIdentifier(i),n.stringLiteral(t));r.unshift(e)}}(e.node,t),!0;if(e.isJSXFragment()){const n=e.get("children");for(const e of n)if(m(e,t))return!0;return!1}if(e.isArrayExpression()){const n=e.get("elements");for(const e of n)if(m(e,t))return!0;return!1}if(e.isConditionalExpression()){const n=m(e.get("consequent"),t),r=m(e.get("alternate"),t);return n||r}if(e.isLogicalExpression()){const n=m(e.get("left"),t),r=m(e.get("right"),t);return n||r}return!!e.isCallExpression()&&f(e,t)}function l(e,t){const n=e.get("argument");n.node&&m(n,t)}return{visitor:{Function(e){if(!function(e){const t=e.get("body");if(t.isBlockStatement()){let e=!1;return t.traverse({ReturnStatement(t){const n=t.get("argument");n.node&&d(n)&&(e=!0,t.stop())}}),e}return!!d(t)}(e))return;const t=s(e.hub?.file?.opts?.filename||""),n=e.get("body");n.isBlockStatement()?n.traverse({ReturnStatement(e){l(e,t)}}):m(n,t)},Class(e){const t=e.node.superClass;if(!t)return;if(!(n.isIdentifier(t)&&("Component"===t.name||"PureComponent"===t.name||"BaseCmp"===t.name)||n.isMemberExpression(t)&&n.isIdentifier(t.object)&&"React"===t.object.name))return;const r=s(e.hub?.file?.opts?.filename||"");e.traverse({ClassMethod(e){const t=e.node.key;if("method"===e.node.kind&&n.isIdentifier(t)&&"render"===t.name){const t=e.get("body");t.isBlockStatement()&&t.traverse({ReturnStatement(e){l(e,r)}})}}})},ClassMethod(e){const t=e.node.key;if("method"===e.node.kind&&n.isIdentifier(t)&&"render"===t.name){const t=s(e.hub?.file?.opts?.filename||""),n=e.get("body");n.isBlockStatement()&&n.traverse({ReturnStatement(e){l(e,t)}})}}}}}};
|
package/package.json
CHANGED
|
@@ -183,7 +183,7 @@ export default class DataDashboard extends React.PureComponent<DataDashboardProp
|
|
|
183
183
|
|
|
184
184
|
return (
|
|
185
185
|
<div
|
|
186
|
-
className={`
|
|
186
|
+
className={`dataDashboard__c ${theme} ${
|
|
187
187
|
isAnimating ? 'animating' : ''
|
|
188
188
|
}`}
|
|
189
189
|
>
|
|
@@ -214,7 +214,7 @@
|
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
// 主容器 - 现代化设计
|
|
217
|
-
.
|
|
217
|
+
.dataDashboard__c {
|
|
218
218
|
position: relative;
|
|
219
219
|
min-height: 100vh;
|
|
220
220
|
padding: var(--space-lg);
|
|
@@ -1307,7 +1307,7 @@
|
|
|
1307
1307
|
|
|
1308
1308
|
// 响应式设计 - 现代化移动端适配
|
|
1309
1309
|
@media (max-width: 1200px) {
|
|
1310
|
-
.
|
|
1310
|
+
.dataDashboard__c {
|
|
1311
1311
|
padding: var(--space-md);
|
|
1312
1312
|
}
|
|
1313
1313
|
|
|
@@ -1330,7 +1330,7 @@
|
|
|
1330
1330
|
}
|
|
1331
1331
|
|
|
1332
1332
|
@media (max-width: 768px) {
|
|
1333
|
-
.
|
|
1333
|
+
.dataDashboard__c {
|
|
1334
1334
|
padding: var(--space-sm);
|
|
1335
1335
|
}
|
|
1336
1336
|
|
|
@@ -1409,7 +1409,7 @@
|
|
|
1409
1409
|
}
|
|
1410
1410
|
|
|
1411
1411
|
@media (max-width: 480px) {
|
|
1412
|
-
.
|
|
1412
|
+
.dataDashboard__c {
|
|
1413
1413
|
padding: var(--space-xs);
|
|
1414
1414
|
}
|
|
1415
1415
|
|
|
@@ -1501,7 +1501,7 @@
|
|
|
1501
1501
|
}
|
|
1502
1502
|
|
|
1503
1503
|
// 额外的交互元素和微动画
|
|
1504
|
-
.
|
|
1504
|
+
.dataDashboard__c {
|
|
1505
1505
|
// 添加全局悬停效果
|
|
1506
1506
|
.metric-card,
|
|
1507
1507
|
.products-card,
|
|
@@ -40,7 +40,7 @@ export default class InfoCard extends React.PureComponent<InfoCardProps> {
|
|
|
40
40
|
const curBackgroundImage =
|
|
41
41
|
backgroundImage || 'https://neo-widgets.bj.bcebos.com/NeoCRM.jpg';
|
|
42
42
|
return (
|
|
43
|
-
<div className={`
|
|
43
|
+
<div className={`infoCard__c ${className}`}>
|
|
44
44
|
<div className="news-title">
|
|
45
45
|
{title ||
|
|
46
46
|
'营销服全场景智能CRM,帮助企业搭建数字化客户经营平台,实现业绩高质量增长。'}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// "lib": [], /* Specify library files to be included in the compilation. */
|
|
9
9
|
"allowJs": false /* 指定是否允许编译JS文件,默认false,即不编译JS文件. */,
|
|
10
10
|
// "checkJs": true, /* 指定是否检查和报告JS文件中的错误,默认false */
|
|
11
|
-
"jsx": "
|
|
11
|
+
"jsx": "preserve" /* 保留 JSX 交由 Babel(含 data-scope 插件)处理,确保作用域属性可注入 */,
|
|
12
12
|
"declaration": false /* 指定是否在编译的时候生成相的d.ts声明文件 */,
|
|
13
13
|
// "declarationMap": true, /* 指定编译时是否生成.map文件 */
|
|
14
14
|
// "sourceMap": true, /* 指定编译时是否生成.map文件 */
|
|
@@ -699,7 +699,7 @@ export default class ChartWidget extends React.PureComponent<ChartWidgetProps> {
|
|
|
699
699
|
const systemInfo = curAmisData.__NeoSystemInfo || {};
|
|
700
700
|
|
|
701
701
|
return (
|
|
702
|
-
<div className="
|
|
702
|
+
<div className="chartWidget__c">
|
|
703
703
|
{/* 显示当前用户信息 */}
|
|
704
704
|
{userInfo && userInfo.name && (
|
|
705
705
|
<div className="user-info">
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.
|
|
1
|
+
.chartWidget__c {
|
|
2
2
|
position: relative;
|
|
3
3
|
width: 100%;
|
|
4
4
|
height: 100%;
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
// 图表类型特定样式
|
|
133
|
-
.
|
|
133
|
+
.chartWidget__c {
|
|
134
134
|
&.line-chart {
|
|
135
135
|
.chart-container {
|
|
136
136
|
background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
|
|
@@ -181,7 +181,7 @@
|
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
// 全局图表样式覆盖
|
|
184
|
-
.
|
|
184
|
+
.chartWidget__c {
|
|
185
185
|
.chart-container {
|
|
186
186
|
// 确保 ECharts 图表在容器内正确显示
|
|
187
187
|
canvas {
|
|
@@ -350,7 +350,7 @@ export default class MapWidget extends React.PureComponent<
|
|
|
350
350
|
console.log('this.props:', this.props);
|
|
351
351
|
|
|
352
352
|
return (
|
|
353
|
-
<div className={`
|
|
353
|
+
<div className={`mapWidget__c ${className}`}>
|
|
354
354
|
{/*
|
|
355
355
|
// 地图头部: 显示地图标题和当前位置地址
|
|
356
356
|
<div className="map-widget-header">
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// 地图组件样式文件
|
|
2
|
-
.
|
|
2
|
+
.mapWidget__c {
|
|
3
3
|
width: 100%;
|
|
4
4
|
background: #fff;
|
|
5
5
|
border-radius: 8px;
|
|
@@ -153,7 +153,7 @@
|
|
|
153
153
|
|
|
154
154
|
// 响应式适配
|
|
155
155
|
@media (max-width: 768px) {
|
|
156
|
-
.
|
|
156
|
+
.mapWidget__c {
|
|
157
157
|
.map-widget-header {
|
|
158
158
|
padding: 12px 16px;
|
|
159
159
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// "lib": [], /* Specify library files to be included in the compilation. */
|
|
9
9
|
"allowJs": false /* 指定是否允许编译JS文件,默认false,即不编译JS文件. */,
|
|
10
10
|
// "checkJs": true, /* 指定是否检查和报告JS文件中的错误,默认false */
|
|
11
|
-
"jsx": "
|
|
11
|
+
"jsx": "preserve" /* 保留 JSX 交由 Babel(含 data-scope 插件)处理,确保作用域属性可注入 */,
|
|
12
12
|
"declaration": false /* 指定是否在编译的时候生成相的d.ts声明文件 */,
|
|
13
13
|
// "declarationMap": true, /* 指定编译时是否生成.map文件 */
|
|
14
14
|
// "sourceMap": true, /* 指定编译时是否生成.map文件 */
|
|
@@ -8,7 +8,15 @@
|
|
|
8
8
|
// "lib": [], /* Specify library files to be included in the compilation. */
|
|
9
9
|
"allowJs": false /* 指定是否允许编译JS文件,默认false,即不编译JS文件. */,
|
|
10
10
|
// "checkJs": true, /* 指定是否检查和报告JS文件中的错误,默认false */
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* jsx 常见取值与含义:
|
|
13
|
+
* preserve:保留 JSX,不转成 JS 调用,交给后续工具(如 Babel、SWC)处理;输出仍含 JSX。
|
|
14
|
+
* react:老版转换,编译为 React.createElement,并插入 __source/__self 等帮助信息(仅在开发模式)。
|
|
15
|
+
* react-jsx:React 17+ 新转换(自动引入 jsx/jsxs from react/jsx-runtime),无需显式 import React from 'react';用于生产构建。
|
|
16
|
+
* react-jsxdev:同上,但带额外调试信息(开发模式)。
|
|
17
|
+
* react-native:保留 JSX 但针对 React Native 打包器的特殊行为(不加 React.createElement),通常配合 React Native 工具链。
|
|
18
|
+
*/
|
|
19
|
+
"jsx": "preserve" /* 保留 JSX,不转成 JS 调用,交给后续工具(如 Babel、SWC)处理;输出仍含 JSX。 */,
|
|
12
20
|
"declaration": false /* 指定是否在编译的时候生成相的d.ts声明文件 */,
|
|
13
21
|
// "declarationMap": true, /* 指定编译时是否生成.map文件 */
|
|
14
22
|
// "sourceMap": true, /* 指定编译时是否生成.map文件 */
|
|
@@ -164,7 +164,7 @@ export default class EntityCardList extends BaseCmp<
|
|
|
164
164
|
console.log('this.props:', this.props);
|
|
165
165
|
|
|
166
166
|
return (
|
|
167
|
-
<div className={`
|
|
167
|
+
<div className={`entityCardList__c ${className}`}>
|
|
168
168
|
<div className="card-list-header">
|
|
169
169
|
<div className="header-content">
|
|
170
170
|
<h3 className="header-title">
|
|
@@ -278,7 +278,7 @@ export default class EntityDetail extends React.PureComponent<
|
|
|
278
278
|
console.log('this.props:', this.props);
|
|
279
279
|
|
|
280
280
|
return (
|
|
281
|
-
<div className={`
|
|
281
|
+
<div className={`entityDetail__c ${className}`}>
|
|
282
282
|
{showTitle && (
|
|
283
283
|
<div className="detail-header">
|
|
284
284
|
<div className="header-content">
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.
|
|
1
|
+
.entityDetail__c {
|
|
2
2
|
position: relative;
|
|
3
3
|
box-sizing: border-box;
|
|
4
4
|
height: 100%;
|
|
@@ -269,7 +269,7 @@
|
|
|
269
269
|
}
|
|
270
270
|
|
|
271
271
|
// 自定义滚动条样式
|
|
272
|
-
.
|
|
272
|
+
.entityDetail__c .detail-content {
|
|
273
273
|
&::-webkit-scrollbar {
|
|
274
274
|
width: 6px;
|
|
275
275
|
height: 6px;
|
|
@@ -574,7 +574,7 @@ export default class EntityForm extends React.PureComponent<
|
|
|
574
574
|
const displayTitle = formTitle || title || '新增数据';
|
|
575
575
|
|
|
576
576
|
return (
|
|
577
|
-
<div className="
|
|
577
|
+
<div className="entityForm__c">
|
|
578
578
|
<Card>
|
|
579
579
|
<div className="form-header">
|
|
580
580
|
<h3 className="form-title">
|
|
@@ -713,7 +713,7 @@ export default class EntityTable extends BaseCmp<
|
|
|
713
713
|
console.log('this.props:', this.props, columns, this);
|
|
714
714
|
|
|
715
715
|
return (
|
|
716
|
-
<div className={`
|
|
716
|
+
<div className={`entityTable__c ${className}`}>
|
|
717
717
|
<Card>
|
|
718
718
|
<div className="table-header">
|
|
719
719
|
<div className="header-content">
|
|
@@ -31,7 +31,7 @@ export default class CustomCmp extends BaseCmp<CustomCmpProps, CustomCmpStates>
|
|
|
31
31
|
console.log('当前自定义组件:', this.props);
|
|
32
32
|
|
|
33
33
|
return (
|
|
34
|
-
<div className={`
|
|
34
|
+
<div className={`simpleCmp__c ${className}`}>
|
|
35
35
|
<div className="news-title">
|
|
36
36
|
{languageCode === 'zh-CN' ? '你好,销售易!' : 'Hello NeoCRM!'}
|
|
37
37
|
</div>
|
|
@@ -19,7 +19,7 @@ export default class InfoCard extends React.PureComponent {
|
|
|
19
19
|
const curBackgroundImage =
|
|
20
20
|
backgroundImage || 'https://neo-widgets.bj.bcebos.com/NeoCRM.jpg';
|
|
21
21
|
return (
|
|
22
|
-
<div className={`
|
|
22
|
+
<div className={`infoCard__c ${className}`}>
|
|
23
23
|
<div className="news-title">
|
|
24
24
|
{title ||
|
|
25
25
|
'营销服全场景智能CRM,帮助企业搭建数字化客户经营平台,实现业绩高质量增长。'}
|
|
@@ -192,7 +192,7 @@ export default class ListWidget extends React.PureComponent<ListWidgetProps> {
|
|
|
192
192
|
const mockData = this.generateMockData(itemCount);
|
|
193
193
|
|
|
194
194
|
return (
|
|
195
|
-
<div className={`
|
|
195
|
+
<div className={`listWidget__c ${className}`}>
|
|
196
196
|
<div className="list-header">
|
|
197
197
|
<h2 className="list-title">
|
|
198
198
|
{title || '内容列表'}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
--list-hover-shadow: 0 4px 12px rgb(0 0 0 / 15%);
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
.
|
|
8
|
+
.listWidget__c {
|
|
9
9
|
position: relative;
|
|
10
10
|
box-sizing: border-box;
|
|
11
11
|
margin: 12px;
|
|
@@ -276,7 +276,7 @@
|
|
|
276
276
|
|
|
277
277
|
// 响应式设计
|
|
278
278
|
@media (max-width: 768px) {
|
|
279
|
-
.
|
|
279
|
+
.listWidget__c {
|
|
280
280
|
margin: 8px;
|
|
281
281
|
padding: 12px;
|
|
282
282
|
|
|
@@ -306,7 +306,7 @@
|
|
|
306
306
|
|
|
307
307
|
// 暗色主题支持
|
|
308
308
|
@media (prefers-color-scheme: dark) {
|
|
309
|
-
.
|
|
309
|
+
.listWidget__c {
|
|
310
310
|
background-color: #1f1f1f;
|
|
311
311
|
color: #fff;
|
|
312
312
|
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
// "lib": [], /* Specify library files to be included in the compilation. */
|
|
9
9
|
"allowJs": false /* 指定是否允许编译JS文件,默认false,即不编译JS文件. */,
|
|
10
10
|
// "checkJs": true, /* 指定是否检查和报告JS文件中的错误,默认false */
|
|
11
|
-
"jsx": "react" /* 指定jsx代码用于的开发环境:'preserve','react-native', or 'react'. */,
|
|
11
|
+
// "jsx": "react" /* 指定jsx代码用于的开发环境:'preserve','react-native', or 'react'. */,
|
|
12
|
+
"jsx": "preserve" /* 保留 JSX 交由 Babel(含 data-scope 插件)处理,确保作用域属性可注入 */,
|
|
12
13
|
"declaration": false /* 指定是否在编译的时候生成相的d.ts声明文件 */,
|
|
13
14
|
// "declarationMap": true, /* 指定编译时是否生成.map文件 */
|
|
14
15
|
// "sourceMap": true, /* 指定编译时是否生成.map文件 */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="
|
|
2
|
+
<div class="vueInfoCard__c">
|
|
3
3
|
<div class="news-title">
|
|
4
4
|
{{ title }}
|
|
5
5
|
</div>
|
|
@@ -60,8 +60,8 @@ export default {
|
|
|
60
60
|
},
|
|
61
61
|
};
|
|
62
62
|
</script>
|
|
63
|
-
<style lang="scss">
|
|
64
|
-
.
|
|
63
|
+
<style lang="scss" scoped>
|
|
64
|
+
.vueInfoCard__c {
|
|
65
65
|
position: relative;
|
|
66
66
|
box-sizing: border-box;
|
|
67
67
|
// border-bottom: 1px solid #ececec;
|