@lovrabet/cli 1.1.26 → 1.2.1-beta.3
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/lib/add-page/input-page-router.js +1 -1
- package/lib/add-page/main.js +1 -1
- package/lib/add-page/select-page-template.js +1 -1
- package/lib/api/api-doc-ui.js +1 -1
- package/lib/api/api-doc.js +1 -1
- package/lib/api/api-pull-ui.js +1 -1
- package/lib/api/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.js +1 -1
- package/lib/api/main.js +1 -1
- package/lib/api/pull-silent.js +1 -1
- package/lib/app-menu/app-menu-sync-ui.js +1 -1
- package/lib/app-menu/create-menu.js +1 -1
- package/lib/app-menu/get-local-pages.js +1 -1
- package/lib/app-menu/get-online-menu-list.js +1 -1
- package/lib/app-menu/use-get-online-menu-list.js +1 -1
- package/lib/app-menu/utils.js +1 -1
- package/lib/app-menu/valid-url.js +1 -1
- package/lib/app-menu-update-cdn/current-content.js +1 -1
- package/lib/app-menu-update-cdn/input-cdn-asset.js +1 -1
- package/lib/app-menu-update-cdn/main.js +1 -1
- package/lib/app-menu-update-cdn/update-menu-cdn-url.js +1 -0
- package/lib/auth/auth-server-ui.js +1 -1
- package/lib/auth/auth-server.js +1 -1
- package/lib/auth/constant.js +1 -1
- package/lib/auth/get-cookie.js +1 -1
- package/lib/auth/is-session-valid.js +1 -1
- package/lib/auth/logout.js +1 -1
- package/lib/cli.js +1 -1
- package/lib/cmd/build-watch.js +1 -1
- package/lib/cmd/build.js +1 -1
- package/lib/cmd/logs.js +1 -1
- package/lib/cmd/preview.js +1 -1
- package/lib/cmd/start.js +1 -1
- package/lib/config/config-help.js +1 -1
- package/lib/config/main.js +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/create-app/enhanced-guided-create.js +1 -1
- package/lib/create-app/format-elapsed.js +1 -1
- package/lib/create-app/main.js +1 -1
- package/lib/create-app/task-finished.js +1 -1
- package/lib/create-app/task-loading.js +1 -1
- package/lib/create-app/task-running.js +1 -1
- package/lib/create-app/task-time.js +1 -1
- package/lib/create-app/use-copy-project-template.js +1 -1
- package/lib/create-app/use-format-code.js +1 -1
- package/lib/create-app/use-install-dependencies.js +1 -1
- package/lib/help.js +1 -1
- package/lib/init/main.js +1 -1
- package/lib/mcp/cursor.js +1 -1
- package/lib/mcp/main.js +1 -1
- package/lib/types/index.js +1 -0
- package/lib/utils/check-sdk-version.js +1 -0
- package/lib/utils/config.js +1 -1
- package/lib/utils/copy-directory.js +1 -1
- package/lib/utils/http-client.js +1 -1
- package/lib/utils/logger.js +1 -1
- package/lib/utils/router-updater.js +1 -1
- package/lib/utils/sleep.js +1 -1
- package/lib/utils/template-replacer.js +1 -1
- package/package.json +3 -1
- package/templates/generate-api/api.ts.tpl +9 -4
- package/templates/rules/lovrabet_rules.mdc.tpl +90 -34
- package/lib/app-menu-cdn-version/app-menu-sync-cdn-version-ui.js +0 -1
- package/lib/app-menu-cdn-version/cdn-url-compare-table.js +0 -1
- package/lib/app-menu-cdn-version/update-menu-cdn-url.js +0 -1
- /package/lib/{app-menu-cdn-version → app-menu-update-cdn}/types.js +0 -0
package/lib/mcp/cursor.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function a51_0x58e7(){const _0x541b04=['请重启\x20Cursor\x20以加载新的\x20MCP\x20配置。','复制\x20Cursor\x20Rules\x20文件','lovrabet-dataset','\x0a✓\x20Cursor\x20MCP\x20配置成功!','online','配置\x20Cursor\x20MCP\x20成功','utf8','创建新的\x20mcp.json\x20配置','9909330VuuXPt','4332318wZeqxI','✓\x20创建\x20.cursor\x20目录:\x20','mcp-cursor','log','✓\x20创建\x20mcp.json\x20配置文件','\x20\x20-\x20环境:\x20','exit','Cursor\x20Rules\x20文件已存在,跳过','stringify','npx','error','1581905ZWNYut','错误:\x20解析现有\x20mcp.json\x20失败:\x20','5479280SFfXxu','配置\x20Cursor\x20MCP\x20失败','\x0a现在您可以在\x20Cursor\x20中使用\x20Lovrabet\x20数据集\x20MCP\x20工具了。','message','mcpServers','9356102DJOanI','创建\x20.cursor\x20目录','1lyKYWG','cwd','错误:\x20未找到\x20appcode\x20配置,请先运行\x20\x27lovrabet\x20init\x27\x20初始化项目配置','创建\x20.cursor/rules\x20目录','303274CgWFcd','\x20\x20-\x20AppCode:\x20','2731228Xiwzqt','✓\x20更新\x20mcp.json\x20配置','.cursor','复制\x20Cursor\x20Rules\x20文件失败','app','警告:\x20复制\x20Cursor\x20Rules\x20文件失败:\x20','info','!\x20Cursor\x20Rules\x20文件已存在,跳过创建,如需重新创建,请删除\x20.cursor/rules/lovrabet_rules.mdc\x20文件','lovrabet_rules.mdc','更新现有\x20mcp.json\x20配置','warn','\x0a配置信息:'];a51_0x58e7=function(){return _0x541b04;};return a51_0x58e7();}(function(_0x2a8886,_0x71719f){const _0x27da31=a51_0x5420,_0x36e2ab=_0x2a8886();while(!![]){try{const _0x41cb87=-parseInt(_0x27da31(0x173))/0x1*(-parseInt(_0x27da31(0x148))/0x2)+parseInt(_0x27da31(0x15f))/0x3+-parseInt(_0x27da31(0x14a))/0x4+parseInt(_0x27da31(0x16a))/0x5+parseInt(_0x27da31(0x15e))/0x6+-parseInt(_0x27da31(0x171))/0x7+-parseInt(_0x27da31(0x16c))/0x8;if(_0x41cb87===_0x71719f)break;else _0x36e2ab['push'](_0x36e2ab['shift']());}catch(_0x49437c){_0x36e2ab['push'](_0x36e2ab['shift']());}}}(a51_0x58e7,0xd1cf0));function a51_0x5420(_0x1a9cb1,_0x1ce972){_0x1a9cb1=_0x1a9cb1-0x147;const _0x58e737=a51_0x58e7();let _0x542099=_0x58e737[_0x1a9cb1];return _0x542099;}import{existsSync,mkdirSync,writeFileSync,readFileSync,copyFileSync}from'node:fs';import{resolve,dirname}from'node:path';import{fileURLToPath}from'node:url';import{readConfig}from'../utils/config.js';import{logger}from'../utils/logger.js';export async function configureCursorMcp(){const _0x255bd9=a51_0x5420;try{const _0x32cd8c=process[_0x255bd9(0x174)](),_0x1c1f91=resolve(_0x32cd8c,_0x255bd9(0x14c)),_0x31297a=resolve(_0x1c1f91,'mcp.json'),_0x16a4d0=readConfig(),_0x469726=_0x16a4d0['appcode']||_0x16a4d0[_0x255bd9(0x14e)],_0x148978=_0x16a4d0['env']||_0x255bd9(0x15a);!_0x469726&&(console[_0x255bd9(0x169)](_0x255bd9(0x175)),logger[_0x255bd9(0x169)]('mcp-cursor','未找到\x20appcode\x20配置'),process[_0x255bd9(0x165)](0x1));!existsSync(_0x1c1f91)&&(mkdirSync(_0x1c1f91,{'recursive':!![]}),logger[_0x255bd9(0x150)](_0x255bd9(0x161),_0x255bd9(0x172),{'path':_0x1c1f91}),console[_0x255bd9(0x162)](_0x255bd9(0x160)+_0x1c1f91));const _0x5be5e8={'command':_0x255bd9(0x168),'args':['-y','@lovrabet/dataset-mcp-server'],'env':{'LOVRABET_APP_CODE':String(_0x469726),'LOVRABET_ENV':String(_0x148978)}};let _0x248989;if(existsSync(_0x31297a))try{const _0x365bee=readFileSync(_0x31297a,'utf8');_0x248989=JSON['parse'](_0x365bee),!_0x248989['mcpServers']&&(_0x248989[_0x255bd9(0x170)]={}),_0x248989[_0x255bd9(0x170)][_0x255bd9(0x158)]=_0x5be5e8,logger[_0x255bd9(0x150)](_0x255bd9(0x161),_0x255bd9(0x153),{'path':_0x31297a,'appcode':_0x469726,'env':_0x148978}),console['log'](_0x255bd9(0x14b));}catch(_0x3619e7){logger[_0x255bd9(0x169)](_0x255bd9(0x161),'解析现有\x20mcp.json\x20失败',{'error':_0x3619e7 instanceof Error?_0x3619e7[_0x255bd9(0x16f)]:String(_0x3619e7)}),console[_0x255bd9(0x169)](_0x255bd9(0x16b)+(_0x3619e7 instanceof Error?_0x3619e7[_0x255bd9(0x16f)]:String(_0x3619e7))),process[_0x255bd9(0x165)](0x1);}else _0x248989={'mcpServers':{'lovrabet-dataset':_0x5be5e8}},logger[_0x255bd9(0x150)](_0x255bd9(0x161),_0x255bd9(0x15d),{'path':_0x31297a,'appcode':_0x469726,'env':_0x148978}),console['log'](_0x255bd9(0x163));writeFileSync(_0x31297a,JSON[_0x255bd9(0x167)](_0x248989,null,0x2),{'encoding':_0x255bd9(0x15c)});const _0x276d81=resolve(_0x1c1f91,'rules'),_0x2896ce=resolve(_0x276d81,_0x255bd9(0x152));if(!existsSync(_0x2896ce))try{!existsSync(_0x276d81)&&(mkdirSync(_0x276d81,{'recursive':!![]}),logger[_0x255bd9(0x150)](_0x255bd9(0x161),_0x255bd9(0x147),{'path':_0x276d81}));const _0x287955=fileURLToPath(import.meta.url),_0x5e5207=dirname(_0x287955),_0x16c6a2=resolve(_0x5e5207,'../../templates/rules/lovrabet_rules.mdc.tpl');existsSync(_0x16c6a2)?(copyFileSync(_0x16c6a2,_0x2896ce),logger[_0x255bd9(0x150)](_0x255bd9(0x161),_0x255bd9(0x157),{'from':_0x16c6a2,'to':_0x2896ce}),console[_0x255bd9(0x162)]('✓\x20创建\x20Cursor\x20Rules\x20文件:\x20.cursor/rules/lovrabet_rules.mdc')):logger[_0x255bd9(0x154)](_0x255bd9(0x161),'Cursor\x20Rules\x20模板文件不存在',{'templatePath':_0x16c6a2});}catch(_0xe0a568){logger['error'](_0x255bd9(0x161),_0x255bd9(0x14d),{'error':_0xe0a568 instanceof Error?_0xe0a568[_0x255bd9(0x16f)]:String(_0xe0a568)}),console[_0x255bd9(0x154)](_0x255bd9(0x14f)+(_0xe0a568 instanceof Error?_0xe0a568['message']:String(_0xe0a568)));}else console['log'](_0x255bd9(0x151)),logger['info'](_0x255bd9(0x161),_0x255bd9(0x166),{'path':_0x2896ce});console[_0x255bd9(0x162)](_0x255bd9(0x159)),console[_0x255bd9(0x162)](_0x255bd9(0x155)),console[_0x255bd9(0x162)](_0x255bd9(0x149)+_0x469726),console[_0x255bd9(0x162)](_0x255bd9(0x164)+_0x148978),console[_0x255bd9(0x162)]('\x20\x20-\x20配置文件:\x20'+_0x31297a),console['log'](_0x255bd9(0x16e)),console[_0x255bd9(0x162)](_0x255bd9(0x156)),logger[_0x255bd9(0x150)](_0x255bd9(0x161),_0x255bd9(0x15b),{'appcode':_0x469726,'env':_0x148978,'configPath':_0x31297a}),process['exit'](0x0);}catch(_0xd5c64f){logger[_0x255bd9(0x169)](_0x255bd9(0x161),_0x255bd9(0x16d),{'error':_0xd5c64f instanceof Error?_0xd5c64f[_0x255bd9(0x16f)]:String(_0xd5c64f)}),console[_0x255bd9(0x169)]('错误:\x20配置失败:\x20'+(_0xd5c64f instanceof Error?_0xd5c64f[_0x255bd9(0x16f)]:String(_0xd5c64f))),process[_0x255bd9(0x165)](0x1);}}
|
package/lib/mcp/main.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x5f0395,_0x2fb262){var _0x2173ee=a52_0x2a73,_0x202374=_0x5f0395();while(!![]){try{var _0x133ffc=-parseInt(_0x2173ee(0x6e))/0x1*(-parseInt(_0x2173ee(0x71))/0x2)+parseInt(_0x2173ee(0x7a))/0x3+parseInt(_0x2173ee(0x72))/0x4+-parseInt(_0x2173ee(0x78))/0x5*(-parseInt(_0x2173ee(0x6f))/0x6)+-parseInt(_0x2173ee(0x77))/0x7+-parseInt(_0x2173ee(0x81))/0x8*(-parseInt(_0x2173ee(0x70))/0x9)+parseInt(_0x2173ee(0x74))/0xa*(-parseInt(_0x2173ee(0x7e))/0xb);if(_0x133ffc===_0x2fb262)break;else _0x202374['push'](_0x202374['shift']());}catch(_0x353d13){_0x202374['push'](_0x202374['shift']());}}}(a52_0x2858,0xbfe6f));import{configureCursorMcp}from'./cursor.js';import{logger}from'../utils/logger.js';function a52_0x2a73(_0x4ce2ac,_0x37a174){_0x4ce2ac=_0x4ce2ac-0x6d;var _0x285806=a52_0x2858();var _0x2a73d3=_0x285806[_0x4ce2ac];return _0x2a73d3;}export async function mcpCommand(_0x418af2){var _0x2de01c=a52_0x2a73;logger['setLogPath'](process[_0x2de01c(0x7c)]());if(!_0x418af2){console[_0x2de01c(0x6d)]('错误:\x20请指定\x20IDE\x20类型'),console[_0x2de01c(0x7b)]('\x0a使用方法:'),console[_0x2de01c(0x7b)]('\x20\x20lovrabet\x20mcp\x20cursor\x20\x20\x20\x20配置\x20Cursor\x20的\x20MCP'),console[_0x2de01c(0x7b)](_0x2de01c(0x79)),console['log']('\x20\x20lovrabet\x20mcp\x20cursor'),logger[_0x2de01c(0x6d)](_0x2de01c(0x7f),_0x2de01c(0x82)),process['exit'](0x1);return;}switch(_0x418af2[_0x2de01c(0x83)]()){case _0x2de01c(0x75):logger[_0x2de01c(0x76)](_0x2de01c(0x7f),'执行配置\x20Cursor\x20MCP\x20命令'),await configureCursorMcp();break;default:console['error']('错误:\x20不支持的\x20IDE\x20类型:\x20'+_0x418af2),console[_0x2de01c(0x7b)](_0x2de01c(0x80)),console[_0x2de01c(0x7b)]('\x20\x20-\x20cursor'),logger[_0x2de01c(0x6d)](_0x2de01c(0x7f),_0x2de01c(0x7d)+_0x418af2),process[_0x2de01c(0x73)](0x1);break;}}function a52_0x2858(){var _0x5750a4=['2003uKKTiX','2239788wzfpCF','12113604xtJOhH','398dSRxil','4625984MmUbQl','exit','1560xfbGqJ','cursor','info','8120651rsyHhd','15LxAEdK','\x0a示例:','3693399NzojBI','log','cwd','不支持的\x20IDE\x20类型:\x20','233112wKjVaY','mcp','\x0a当前支持的\x20IDE:','8ilyMMp','未指定\x20IDE\x20类型','toLowerCase','error'];a52_0x2858=function(){return _0x5750a4;};return a52_0x2858();}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const a54_0x39d9e7=a54_0x7248;function a54_0x7248(_0x31c9ae,_0x4741c7){_0x31c9ae=_0x31c9ae-0x8c;const _0x22146b=a54_0x2214();let _0x7248df=_0x22146b[_0x31c9ae];return _0x7248df;}(function(_0x426a7a,_0x3498c3){const _0x5345c1=a54_0x7248,_0xfe4abf=_0x426a7a();while(!![]){try{const _0xb43e92=parseInt(_0x5345c1(0x9b))/0x1*(parseInt(_0x5345c1(0xa6))/0x2)+-parseInt(_0x5345c1(0xa5))/0x3*(parseInt(_0x5345c1(0x9e))/0x4)+-parseInt(_0x5345c1(0x93))/0x5*(-parseInt(_0x5345c1(0xa9))/0x6)+parseInt(_0x5345c1(0xa7))/0x7+parseInt(_0x5345c1(0x91))/0x8+-parseInt(_0x5345c1(0x8f))/0x9*(-parseInt(_0x5345c1(0x94))/0xa)+-parseInt(_0x5345c1(0x9d))/0xb;if(_0xb43e92===_0x3498c3)break;else _0xfe4abf['push'](_0xfe4abf['shift']());}catch(_0x414f98){_0xfe4abf['push'](_0xfe4abf['shift']());}}}(a54_0x2214,0xd83bf));import a54_0x1fe313 from'node:fs';import a54_0x182787 from'node:path';function a54_0x2214(){const _0x22da34=['2158452OOMQCz','coerce','6808896Zdvqbc','join','41555TkdjDN','10mAdNeg','@lovrabet/sdk','\x1b[1m','\x20\x20\x20当前\x20CLI\x20版本已升级模型注册协议,但检测到您的\x20@lovrabet/sdk\x20版本\x20','\x1b[33m','\x1b[0m','readFileSync','132287StYLui','\x20或更高版本:','12731686QJdNkI','30252OSMEMh','\x20不支持新协议。','parse','log','\x20\x20\x20npm\x20install\x20@lovrabet/sdk@latest','⚠️\x20\x20SDK\x20版本不兼容','utf8','207qUpsKt','2LPboeJ','6599691uTfdIm','minVersion','288yVpjpU','\x20\x20\x20查看最新版本:\x20https://www.npmjs.com/package/@lovrabet/sdk','1.2.0','package.json','version'];a54_0x2214=function(){return _0x22da34;};return a54_0x2214();}import a54_0x4932b4 from'semver';const MIN_SDK_VERSION=a54_0x39d9e7(0x8c);export function checkSdkVersion(_0x25f189){const _0x5194c4=a54_0x39d9e7,_0x290967=a54_0x182787[_0x5194c4(0x92)](_0x25f189,_0x5194c4(0x8d));if(!a54_0x1fe313['existsSync'](_0x290967))return{'installed':![],'version':null,'needsUpgrade':![],'minVersion':MIN_SDK_VERSION};try{const _0x3bc01c=JSON[_0x5194c4(0xa0)](a54_0x1fe313[_0x5194c4(0x9a)](_0x290967,_0x5194c4(0xa4))),_0x2aadaa=_0x3bc01c['dependencies']||{},_0x200849=_0x3bc01c['devDependencies']||{},_0x101532=_0x2aadaa['@lovrabet/sdk']||_0x200849[_0x5194c4(0x95)];if(!_0x101532)return{'installed':![],'version':null,'needsUpgrade':![],'minVersion':MIN_SDK_VERSION};const _0x3645ae=a54_0x4932b4[_0x5194c4(0x90)](_0x101532),_0x269ef1=_0x3645ae?a54_0x4932b4['lt'](_0x3645ae,MIN_SDK_VERSION):![];return{'installed':!![],'version':_0x101532,'needsUpgrade':_0x269ef1,'minVersion':MIN_SDK_VERSION};}catch{return{'installed':![],'version':null,'needsUpgrade':![],'minVersion':MIN_SDK_VERSION};}}export function printSdkUpgradeWarning(_0x1b3410){const _0x3d46e6=a54_0x39d9e7;if(!_0x1b3410['needsUpgrade'])return;const _0x44f064=_0x3d46e6(0x98),_0x180a28=_0x3d46e6(0x99),_0x109e09=_0x3d46e6(0x96);console[_0x3d46e6(0xa1)](),console[_0x3d46e6(0xa1)](''+_0x44f064+_0x109e09+_0x3d46e6(0xa3)+_0x180a28),console[_0x3d46e6(0xa1)](_0x44f064+_0x3d46e6(0x97)+_0x1b3410[_0x3d46e6(0x8e)]+_0x3d46e6(0x9f)+_0x180a28),console[_0x3d46e6(0xa1)](_0x44f064+'\x20\x20\x20请升级\x20SDK\x20至\x20'+_0x1b3410[_0x3d46e6(0xa8)]+_0x3d46e6(0x9c)+_0x180a28),console[_0x3d46e6(0xa1)](_0x44f064+_0x3d46e6(0xa2)+_0x180a28),console[_0x3d46e6(0xa1)](_0x44f064+_0x3d46e6(0xaa)+_0x180a28),console[_0x3d46e6(0xa1)]();}
|
package/lib/utils/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a55_0x2b3111=a55_0x68aa;(function(_0x3a1fc1,_0x365917){const _0x54f898=a55_0x68aa,_0x82369f=_0x3a1fc1();while(!![]){try{const _0x222136=parseInt(_0x54f898(0x18b))/0x1*(parseInt(_0x54f898(0x183))/0x2)+parseInt(_0x54f898(0x188))/0x3*(parseInt(_0x54f898(0x187))/0x4)+parseInt(_0x54f898(0x184))/0x5+-parseInt(_0x54f898(0x17f))/0x6*(-parseInt(_0x54f898(0x185))/0x7)+-parseInt(_0x54f898(0x181))/0x8+parseInt(_0x54f898(0x17e))/0x9*(parseInt(_0x54f898(0x17b))/0xa)+-parseInt(_0x54f898(0x180))/0xb;if(_0x222136===_0x365917)break;else _0x82369f['push'](_0x82369f['shift']());}catch(_0xfa3075){_0x82369f['push'](_0x82369f['shift']());}}}(a55_0x2bb6,0x648e5));import{existsSync,readFileSync}from'node:fs';function a55_0x68aa(_0x5efb66,_0x1de5d3){_0x5efb66=_0x5efb66-0x17b;const _0x2bb6f3=a55_0x2bb6();let _0x68aa0f=_0x2bb6f3[_0x5efb66];return _0x68aa0f;}import{resolve}from'node:path';import{homedir}from'node:os';export const projectConfigPath=resolve(process['cwd'](),a55_0x2b3111(0x182));export const globalConfigPath=resolve(homedir(),a55_0x2b3111(0x182));export function readConfig(){const _0x42cd20=a55_0x2b3111;let _0x95b6f5={};try{if(existsSync(globalConfigPath)){const _0x3238f0=readFileSync(globalConfigPath,{'encoding':_0x42cd20(0x18a)});_0x3238f0&&(_0x95b6f5=JSON[_0x42cd20(0x17d)](_0x3238f0));}}catch(_0x18c779){}try{if(existsSync(projectConfigPath)){const _0x1038d0=readFileSync(projectConfigPath,{'encoding':'utf8'});if(_0x1038d0){const _0x2ad0dd=JSON[_0x42cd20(0x17d)](_0x1038d0);_0x95b6f5={..._0x95b6f5,..._0x2ad0dd};}}}catch(_0x3ed847){}return _0x95b6f5;}export function getConfigAppCode(){const _0x3400bf=a55_0x2b3111;let _0x36e05d={},_0x3b1401={};try{if(existsSync(globalConfigPath)){const _0x32deb3=readFileSync(globalConfigPath,{'encoding':'utf8'});_0x32deb3&&(_0x3b1401=JSON[_0x3400bf(0x17d)](_0x32deb3));}}catch(_0x2c85c0){}try{if(existsSync(projectConfigPath)){const _0x4dffdb=readFileSync(projectConfigPath,{'encoding':_0x3400bf(0x18a)});_0x4dffdb&&(_0x36e05d=JSON[_0x3400bf(0x17d)](_0x4dffdb));}}catch(_0x5b39ca){}let _0x5090bf;if('appcode'in _0x36e05d)_0x5090bf=_0x36e05d[_0x3400bf(0x18c)];else{if(_0x3400bf(0x17c)in _0x36e05d)_0x5090bf=_0x36e05d['app'];else{if(_0x3400bf(0x18c)in _0x3b1401)_0x5090bf=_0x3b1401['appcode'];else'app'in _0x3b1401&&(_0x5090bf=_0x3b1401[_0x3400bf(0x17c)]);}}if(typeof _0x5090bf!==_0x3400bf(0x189)||_0x5090bf[_0x3400bf(0x186)]()==='')return undefined;return _0x5090bf;}export function isInProject(){return existsSync(projectConfigPath);}function a55_0x2bb6(){const _0x5e4370=['app','parse','1579077OFYxYj','17250hNXdST','18653426ZXCRzl','5303664erbOLL','.lovrabetrc','65700joEHJr','2455625UfiFWg','1358twxiVn','trim','3162892EvSNmp','3yJqgPR','string','utf8','23KfrQNQ','appcode','10hCjZZp'];a55_0x2bb6=function(){return _0x5e4370;};return a55_0x2bb6();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
function a56_0x36b9(){const _0x4b29a7=['365490TKVqWe','4735440OLEVTg','215931qfpveW','511280vVvzUR','23720upuPCo','40TqNJmO','join','copyFileSync','isDirectory','name','1122dETXPL','4852iwpmZn','readdirSync','error','4612338WoGbho','1183pLbIJA'];a56_0x36b9=function(){return _0x4b29a7;};return a56_0x36b9();}(function(_0x537358,_0x1b7110){const _0x4b4be1=a56_0x1f34,_0x16235f=_0x537358();while(!![]){try{const _0x16a8ca=parseInt(_0x4b4be1(0x84))/0x1+parseInt(_0x4b4be1(0x7d))/0x2*(parseInt(_0x4b4be1(0x7c))/0x3)+-parseInt(_0x4b4be1(0x87))/0x4*(parseInt(_0x4b4be1(0x85))/0x5)+parseInt(_0x4b4be1(0x82))/0x6+-parseInt(_0x4b4be1(0x81))/0x7*(-parseInt(_0x4b4be1(0x86))/0x8)+parseInt(_0x4b4be1(0x80))/0x9+-parseInt(_0x4b4be1(0x83))/0xa;if(_0x16a8ca===_0x1b7110)break;else _0x16235f['push'](_0x16235f['shift']());}catch(_0x5e6beb){_0x16235f['push'](_0x16235f['shift']());}}}(a56_0x36b9,0xab4c1));function a56_0x1f34(_0x35e738,_0x2a4e73){_0x35e738=_0x35e738-0x7c;const _0x36b9c8=a56_0x36b9();let _0x1f3450=_0x36b9c8[_0x35e738];return _0x1f3450;}import a56_0xcbb85a from'node:path';import a56_0x739597 from'node:fs';export async function copyDirectory(_0x503fbc,_0x22494c){const _0x4770d4=a56_0x1f34;try{const _0x45ce86=a56_0x739597[_0x4770d4(0x7e)](_0x503fbc,{'withFileTypes':!![]});a56_0x739597['mkdirSync'](_0x22494c,{'recursive':!![]});for(const _0x45187c of _0x45ce86){const _0x41d686=a56_0xcbb85a[_0x4770d4(0x88)](_0x503fbc,_0x45187c[_0x4770d4(0x8b)]),_0x2d8984=a56_0xcbb85a['join'](_0x22494c,_0x45187c[_0x4770d4(0x8b)]);_0x45187c[_0x4770d4(0x8a)]()?await copyDirectory(_0x41d686,_0x2d8984):a56_0x739597[_0x4770d4(0x89)](_0x41d686,_0x2d8984);}}catch(_0x17c2d7){console[_0x4770d4(0x7f)]('复制目录时出错:',_0x17c2d7);}}
|
package/lib/utils/http-client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0xb529ac,_0x7dbdd5){const _0x4ee4b2=a57_0x3e20,_0x28c3f4=_0xb529ac();while(!![]){try{const _0x42074b=parseInt(_0x4ee4b2(0xa6))/0x1+-parseInt(_0x4ee4b2(0xab))/0x2+parseInt(_0x4ee4b2(0xa0))/0x3*(parseInt(_0x4ee4b2(0x9c))/0x4)+parseInt(_0x4ee4b2(0x9a))/0x5+-parseInt(_0x4ee4b2(0x96))/0x6*(parseInt(_0x4ee4b2(0xa4))/0x7)+-parseInt(_0x4ee4b2(0xaa))/0x8+parseInt(_0x4ee4b2(0x9d))/0x9;if(_0x42074b===_0x7dbdd5)break;else _0x28c3f4['push'](_0x28c3f4['shift']());}catch(_0x23d5d9){_0x28c3f4['push'](_0x28c3f4['shift']());}}}(a57_0x13b3,0x50a15));export async function httpRequest(_0xb7bfc5,_0x244120={}){const _0x4246c4=a57_0x3e20,{timeout:timeout=0x7530,retries:retries=0x3,retryDelay:retryDelay=0x3e8,headers:headers={}}=_0x244120;let _0x5a31e4=null;for(let _0x26be9c=0x0;_0x26be9c<=retries;_0x26be9c++){try{const _0x2e8a86=new AbortController(),_0x59b7df=setTimeout(()=>_0x2e8a86[_0x4246c4(0xad)](),timeout),_0x4dad5b=await fetch(_0xb7bfc5,{'headers':headers,'signal':_0x2e8a86[_0x4246c4(0xa2)]});clearTimeout(_0x59b7df);let _0x5998f1;const _0x305a3d=_0x4dad5b[_0x4246c4(0xac)][_0x4246c4(0x98)]('content-type');return _0x305a3d?.[_0x4246c4(0xa9)](_0x4246c4(0x9b))?_0x5998f1=await _0x4dad5b[_0x4246c4(0xae)]():_0x5998f1=await _0x4dad5b[_0x4246c4(0x97)](),{'ok':_0x4dad5b['ok'],'status':_0x4dad5b[_0x4246c4(0x94)],'statusText':_0x4dad5b['statusText'],'data':_0x5998f1,'headers':_0x4dad5b['headers'],'url':_0x4dad5b['url'],'text':()=>_0x4dad5b[_0x4246c4(0x97)]()};}catch(_0x3a51a5){_0x5a31e4=_0x3a51a5 instanceof Error?_0x3a51a5:new Error(String(_0x3a51a5));if(_0x26be9c===retries)break;if(shouldRetry(_0x3a51a5)){console[_0x4246c4(0xa7)](_0x4246c4(0x9e)+retryDelay+_0x4246c4(0xa8)+(_0x26be9c+0x1)+_0x4246c4(0x9f)),await sleep(retryDelay);continue;}else break;}}throw _0x5a31e4||new Error('Request\x20failed');}function shouldRetry(_0x361c61){const _0x2f64bd=a57_0x3e20;if(_0x361c61 instanceof Error){if(_0x361c61[_0x2f64bd(0xa5)]==='AbortError')return![];if(_0x361c61[_0x2f64bd(0xa5)]===_0x2f64bd(0xa3)&&_0x361c61[_0x2f64bd(0x99)][_0x2f64bd(0xa9)](_0x2f64bd(0xa1)))return!![];if(_0x361c61[_0x2f64bd(0x99)][_0x2f64bd(0xa9)](_0x2f64bd(0x95)))return!![];if(_0x361c61[_0x2f64bd(0x99)][_0x2f64bd(0xa9)]('ENOTFOUND'))return![];}return![];}function a57_0x3e20(_0x48e6b2,_0xebb905){_0x48e6b2=_0x48e6b2-0x94;const _0x13b373=a57_0x13b3();let _0x3e2097=_0x13b373[_0x48e6b2];return _0x3e2097;}function sleep(_0x44a0f3){return new Promise(_0x2b6f09=>setTimeout(_0x2b6f09,_0x44a0f3));}export function validateUrl(_0x421110){try{return new URL(_0x421110),!![];}catch{return![];}}function a57_0x13b3(){const _0x5483a4=['status','ECONNRESET','1267902WQFCnK','text','get','message','393945eLjxUV','application/json','596MqXSmH','2529477hGtEJG','*\x20请求失败,','\x20次重试...','5697axKytu','fetch','signal','TypeError','21HhjhSr','name','529322WhJURF','log','ms\x20后进行第\x20','includes','581200dwaVTq','270506PxZmfk','headers','abort','json'];a57_0x13b3=function(){return _0x5483a4;};return a57_0x13b3();}
|
package/lib/utils/logger.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a58_0x3a32(){const _0x5cd369=['currentRawCommand','createLogger','split','now','rawCommand','filter','green','mkdirSync','.lovrabet.log','existsSync','details','error','winstonLogger','errors','7Nouczp','combine','level','red','2FtoRmU','539899kEidkk','6409341xPVWCQ','3000380CVfQTs','Failed\x20to\x20clear\x20logs:','parse','readLogs','2169670JrLfgc','blue','unknown','trim','logTask','14468700YFUhHa','timestamp','transports','readFileSync','utf8','2026230QJLxkR','logFilePath','printf','map','command','yellow','失败:\x20','success','toISOString','message','开始执行:\x20','warn','log','addColors','duration','6hafSmU','join','format','getWinstonInstance','initWinstonLogger','753952fJUszW','clear','info'];a58_0x3a32=function(){return _0x5cd369;};return a58_0x3a32();}const a58_0x5f3a53=a58_0x2699;(function(_0x1c27af,_0x1b84f0){const _0x32779c=a58_0x2699,_0x118e04=_0x1c27af();while(!![]){try{const _0x5a1ef8=-parseInt(_0x32779c(0x10c))/0x1*(-parseInt(_0x32779c(0x10b))/0x2)+-parseInt(_0x32779c(0x11c))/0x3+parseInt(_0x32779c(0x10e))/0x4+-parseInt(_0x32779c(0x112))/0x5*(-parseInt(_0x32779c(0x12b))/0x6)+-parseInt(_0x32779c(0x107))/0x7*(-parseInt(_0x32779c(0x130))/0x8)+parseInt(_0x32779c(0x10d))/0x9+-parseInt(_0x32779c(0x117))/0xa;if(_0x5a1ef8===_0x1b84f0)break;else _0x118e04['push'](_0x118e04['shift']());}catch(_0x124ee9){_0x118e04['push'](_0x118e04['shift']());}}}(a58_0x3a32,0x639e9));import a58_0x180002 from'winston';import a58_0x3ef3d1 from'node:fs';import a58_0x3a5c2d from'node:path';class Logger{[a58_0x5f3a53(0x105)];[a58_0x5f3a53(0x11d)];[a58_0x5f3a53(0x133)]='';constructor(){const _0x2ccb72=a58_0x5f3a53;this[_0x2ccb72(0x11d)]='';}['setRawCommand'](_0x1baa3a){this['currentRawCommand']=_0x1baa3a;}[a58_0x5f3a53(0x12f)](){const _0x1e8d3f=a58_0x5f3a53,_0x1a5a05=a58_0x3a5c2d['dirname'](this[_0x1e8d3f(0x11d)]);!a58_0x3ef3d1['existsSync'](_0x1a5a05)&&a58_0x3ef3d1[_0x1e8d3f(0x100)](_0x1a5a05,{'recursive':!![]});const _0x64f09f=a58_0x180002[_0x1e8d3f(0x12d)][_0x1e8d3f(0x108)](a58_0x180002[_0x1e8d3f(0x12d)][_0x1e8d3f(0x118)](),a58_0x180002['format'][_0x1e8d3f(0x106)]({'stack':!![]}),a58_0x180002['format'][_0x1e8d3f(0x11e)](_0x4080fa=>{const _0x3cc28e=_0x1e8d3f,_0x27dd66={'timestamp':_0x4080fa['timestamp']||new Date()[_0x3cc28e(0x124)](),'level':_0x4080fa[_0x3cc28e(0x109)]||'info','command':_0x4080fa[_0x3cc28e(0x120)]||_0x3cc28e(0x114),'rawCommand':_0x4080fa[_0x3cc28e(0xfd)]||this['currentRawCommand']||undefined,'message':_0x4080fa[_0x3cc28e(0x125)]||'','duration':_0x4080fa[_0x3cc28e(0x12a)]||undefined,'details':_0x4080fa[_0x3cc28e(0x103)]||undefined};return JSON['stringify'](_0x27dd66);}));this['winstonLogger']=a58_0x180002[_0x1e8d3f(0x134)]({'level':'info','format':_0x64f09f,'transports':[new a58_0x180002[(_0x1e8d3f(0x119))]['File']({'filename':this[_0x1e8d3f(0x11d)],'level':'info'})],'silent':![]}),a58_0x180002[_0x1e8d3f(0x129)]({'success':_0x1e8d3f(0xff),'error':_0x1e8d3f(0x10a),'warn':_0x1e8d3f(0x121),'info':_0x1e8d3f(0x113)});}['setLogPath'](_0x3f89b2){const _0x40e42e=a58_0x5f3a53;this[_0x40e42e(0x11d)]=a58_0x3a5c2d[_0x40e42e(0x12c)](_0x3f89b2,_0x40e42e(0x101)),this[_0x40e42e(0x105)]&&this[_0x40e42e(0x105)][_0x40e42e(0x131)](),this['initWinstonLogger']();}[a58_0x5f3a53(0x132)](_0x345d59,_0x6139b3,_0x50cb75){const _0x50b295=a58_0x5f3a53;if(!this[_0x50b295(0x11d)]||!this[_0x50b295(0x105)])return;this[_0x50b295(0x105)]['info'](_0x6139b3,{'command':_0x345d59,'details':_0x50cb75});}[a58_0x5f3a53(0x123)](_0x14e786,_0x3c063e,_0xd90664,_0x611fa0){const _0x595e68=a58_0x5f3a53;if(!this[_0x595e68(0x11d)]||!this[_0x595e68(0x105)])return;this[_0x595e68(0x105)][_0x595e68(0x128)](_0x595e68(0x132),_0x3c063e,{'level':_0x595e68(0x123),'command':_0x14e786,'duration':_0xd90664,'details':_0x611fa0});}['error'](_0x490530,_0x28858d,_0xb055){const _0x6a62cb=a58_0x5f3a53;if(!this[_0x6a62cb(0x11d)]||!this[_0x6a62cb(0x105)])return;this[_0x6a62cb(0x105)][_0x6a62cb(0x104)](_0x28858d,{'command':_0x490530,'details':_0xb055});}[a58_0x5f3a53(0x127)](_0x5b6459,_0x40b27f,_0x5df843){const _0x8e46cc=a58_0x5f3a53;if(!this[_0x8e46cc(0x11d)]||!this[_0x8e46cc(0x105)])return;this[_0x8e46cc(0x105)]['warn'](_0x40b27f,{'command':_0x5b6459,'details':_0x5df843});}async[a58_0x5f3a53(0x116)](_0x1176d9,_0x4aa8b0,_0x46dd50){const _0x4a59a3=a58_0x5f3a53,_0x1e13dd=Date[_0x4a59a3(0xfc)]();this[_0x4a59a3(0x132)](_0x1176d9,_0x4a59a3(0x126)+_0x4aa8b0);try{const _0x14e6e7=await _0x46dd50(),_0x34e1f8=Date['now']()-_0x1e13dd;return this[_0x4a59a3(0x123)](_0x1176d9,'完成:\x20'+_0x4aa8b0,_0x34e1f8),_0x14e6e7;}catch(_0x19aaf4){const _0x33be44=Date[_0x4a59a3(0xfc)]()-_0x1e13dd;this[_0x4a59a3(0x104)](_0x1176d9,_0x4a59a3(0x122)+_0x4aa8b0,{'error':_0x19aaf4 instanceof Error?_0x19aaf4[_0x4a59a3(0x125)]:String(_0x19aaf4),'duration':_0x33be44});throw _0x19aaf4;}}[a58_0x5f3a53(0x111)](){const _0x3946b3=a58_0x5f3a53;try{if(!a58_0x3ef3d1[_0x3946b3(0x102)](this[_0x3946b3(0x11d)]))return[];const _0x2ed9ae=a58_0x3ef3d1[_0x3946b3(0x11a)](this[_0x3946b3(0x11d)],_0x3946b3(0x11b));return _0x2ed9ae[_0x3946b3(0x135)]('\x0a')[_0x3946b3(0xfe)](_0x9f2df3=>_0x9f2df3[_0x3946b3(0x115)]())[_0x3946b3(0x11f)](_0x1369e6=>JSON[_0x3946b3(0x110)](_0x1369e6));}catch(_0x4fa0e5){return console['warn']('Failed\x20to\x20read\x20logs:',_0x4fa0e5),[];}}['clearLogs'](){const _0x15ce35=a58_0x5f3a53;try{a58_0x3ef3d1['existsSync'](this[_0x15ce35(0x11d)])&&a58_0x3ef3d1['writeFileSync'](this[_0x15ce35(0x11d)],'',_0x15ce35(0x11b));}catch(_0x47e3f6){console[_0x15ce35(0x127)](_0x15ce35(0x10f),_0x47e3f6);}}[a58_0x5f3a53(0x12e)](){const _0x14c53e=a58_0x5f3a53;return this[_0x14c53e(0x105)];}}function a58_0x2699(_0x4a0ec5,_0x113198){_0x4a0ec5=_0x4a0ec5-0xfc;const _0x3a32a6=a58_0x3a32();let _0x269914=_0x3a32a6[_0x4a0ec5];return _0x269914;}export const logger=new Logger();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function a59_0x1fc0(){const _0xfcc70a=['path:\x20\x22','187422bZfDEF','promises','utf8','includes','1972491qEzWzN','join','1488236gBBadh','开始更新路由配置','addImport','\x20\x20\x20\x20\x20\x20\x20\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20path:\x20\x22','message','src','router','未找到路由配置的\x20children\x20数组','20nidUxG','info','32704OqQTDI','9mqZMuc','addRoute','index','toComponentName','indexOf','\x20from\x20\x22../pages/','charAt','347287Omqklf','2WKlhnU','\x22,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20element:\x20<','4044210eoGGvN','735evJfMV','2897807qAddhL','routerFilePath','now','路由配置更新失败','success','lastIndexOf','import\x20','index.tsx','map','readFile','\x20/>,\x0a\x20\x20\x20\x20\x20\x20\x20\x20},','length','路由配置更新完成','previewChanges','match','路由文件不存在:\x20','addPageRoute','split','slice'];a59_0x1fc0=function(){return _0xfcc70a;};return a59_0x1fc0();}function a59_0x3caf(_0x1616ec,_0x1c692a){_0x1616ec=_0x1616ec-0xff;const _0x1fc0f1=a59_0x1fc0();let _0x3caf16=_0x1fc0f1[_0x1616ec];return _0x3caf16;}const a59_0x348a1c=a59_0x3caf;(function(_0x9412ea,_0x3d9739){const _0xab1243=a59_0x3caf,_0x30b763=_0x9412ea();while(!![]){try{const _0x1160f9=-parseInt(_0xab1243(0x110))/0x1+parseInt(_0xab1243(0x111))/0x2*(-parseInt(_0xab1243(0x12d))/0x3)+parseInt(_0xab1243(0x12f))/0x4+parseInt(_0xab1243(0x106))/0x5*(-parseInt(_0xab1243(0x129))/0x6)+-parseInt(_0xab1243(0x114))/0x7*(-parseInt(_0xab1243(0x108))/0x8)+parseInt(_0xab1243(0x109))/0x9*(parseInt(_0xab1243(0x113))/0xa)+parseInt(_0xab1243(0x115))/0xb;if(_0x1160f9===_0x3d9739)break;else _0x30b763['push'](_0x30b763['shift']());}catch(_0x54638c){_0x30b763['push'](_0x30b763['shift']());}}}(a59_0x1fc0,0x52de1));import a59_0x619160 from'node:fs';import a59_0x3cbd46 from'node:path';import{logger}from'./logger.js';export class RouterUpdater{[a59_0x348a1c(0x116)];constructor(_0x4ef82e){const _0x4f0881=a59_0x348a1c;this[_0x4f0881(0x116)]=a59_0x3cbd46[_0x4f0881(0x12e)](_0x4ef82e,_0x4f0881(0x103),'router',_0x4f0881(0x11c));}async[a59_0x348a1c(0x125)](_0x315f5f,_0x32c660){const _0x53a1b0=a59_0x348a1c;if(!a59_0x619160['existsSync'](this['routerFilePath']))throw new Error(_0x53a1b0(0x124)+this['routerFilePath']);const _0x5653b6=Date['now']();logger[_0x53a1b0(0x107)](_0x53a1b0(0x104),_0x53a1b0(0xff),{'pageName':_0x315f5f,'routePath':_0x32c660,'file':this[_0x53a1b0(0x116)]});try{const _0x35747f=await a59_0x619160[_0x53a1b0(0x12a)]['readFile'](this[_0x53a1b0(0x116)],_0x53a1b0(0x12b)),_0xae0449=this[_0x53a1b0(0x10c)](_0x315f5f),_0x1368cf=this['addImport'](_0x35747f,_0xae0449,_0x315f5f),_0x89dd5b=this[_0x53a1b0(0x10a)](_0x1368cf,_0x32c660,_0xae0449);await a59_0x619160['promises']['writeFile'](this[_0x53a1b0(0x116)],_0x89dd5b,_0x53a1b0(0x12b));const _0x422817=Date[_0x53a1b0(0x117)]()-_0x5653b6;logger[_0x53a1b0(0x119)](_0x53a1b0(0x104),_0x53a1b0(0x121),_0x422817,{'pageName':_0x315f5f,'routePath':_0x32c660,'componentName':_0xae0449});}catch(_0x4b22b5){const _0x39c682=Date['now']()-_0x5653b6;logger['error']('router',_0x53a1b0(0x118),{'pageName':_0x315f5f,'routePath':_0x32c660,'error':_0x4b22b5 instanceof Error?_0x4b22b5[_0x53a1b0(0x102)]:String(_0x4b22b5),'duration':_0x39c682});throw _0x4b22b5;}}[a59_0x348a1c(0x10c)](_0x3b3c8b){const _0x4a6483=a59_0x348a1c;return _0x3b3c8b[_0x4a6483(0x126)]('-')[_0x4a6483(0x11d)](_0x24c474=>_0x24c474[_0x4a6483(0x10f)](0x0)['toUpperCase']()+_0x24c474['slice'](0x1)['toLowerCase']())[_0x4a6483(0x12e)]('');}[a59_0x348a1c(0x100)](_0x191ad4,_0xbd8716,_0x43861b){const _0x418e5d=a59_0x348a1c,_0x3448e6=/import\s+\w+\s+from\s+["']\.\.\/pages\/\w+["'];?\n/g,_0x3af816=_0x191ad4[_0x418e5d(0x123)](_0x3448e6)||[],_0x730a93=_0x418e5d(0x11b)+_0xbd8716+_0x418e5d(0x10e)+_0x43861b+'\x22;';if(_0x191ad4[_0x418e5d(0x12c)](_0x730a93))return _0x191ad4;if(_0x3af816[_0x418e5d(0x120)]>0x0){const _0x5453bd=_0x3af816[_0x3af816[_0x418e5d(0x120)]-0x1];if(_0x5453bd){const _0x5c6b21=_0x191ad4[_0x418e5d(0x11a)](_0x5453bd),_0xf8004c=_0x5c6b21+_0x5453bd[_0x418e5d(0x120)];return _0x191ad4[_0x418e5d(0x127)](0x0,_0xf8004c)+_0x730a93+'\x0a'+_0x191ad4[_0x418e5d(0x127)](_0xf8004c);}}const _0x4c611c=_0x191ad4[_0x418e5d(0x123)](/import\s+\w+\s+from\s+["']\.\.\/layouts\/\w+["'];?\n/);if(_0x4c611c&&_0x4c611c['index']!==undefined){const _0x153ff5=_0x4c611c[_0x418e5d(0x10b)]+_0x4c611c[0x0][_0x418e5d(0x120)];return _0x191ad4[_0x418e5d(0x127)](0x0,_0x153ff5)+_0x730a93+'\x0a'+_0x191ad4[_0x418e5d(0x127)](_0x153ff5);}return _0x191ad4;}[a59_0x348a1c(0x10a)](_0x50ccb3,_0x2decde,_0x262e73){const _0x527039=a59_0x348a1c,_0xd3ff07=_0x527039(0x101)+_0x2decde+_0x527039(0x112)+_0x262e73+_0x527039(0x11f);if(_0x50ccb3['includes'](_0x527039(0x128)+_0x2decde+'\x22'))return _0x50ccb3;const _0x208db2=/children:\s*\[([\s\S]*?)\]/,_0x433406=_0x50ccb3[_0x527039(0x123)](_0x208db2);if(!_0x433406||_0x433406[_0x527039(0x10b)]===undefined)throw new Error(_0x527039(0x105));const _0x3ffb1f=_0x433406[0x1],_0x38ada4=_0x433406[_0x527039(0x10b)]+_0x433406[0x0][_0x527039(0x10d)]('[')+0x1,_0x7422fa=_0x3ffb1f?.[_0x527039(0x123)](/\{[\s\S]*?\},/g)||[];if(_0x7422fa[_0x527039(0x120)]>0x0){const _0x7397d7=_0x7422fa[_0x7422fa[_0x527039(0x120)]-0x1];if(_0x7397d7){const _0x35ea59=_0x50ccb3[_0x527039(0x11a)](_0x7397d7),_0x1172bc=_0x35ea59+_0x7397d7[_0x527039(0x120)];return _0x50ccb3[_0x527039(0x127)](0x0,_0x1172bc)+'\x0a'+_0xd3ff07+_0x50ccb3['slice'](_0x1172bc);}}return _0x50ccb3[_0x527039(0x127)](0x0,_0x38ada4)+'\x0a'+_0xd3ff07+_0x50ccb3[_0x527039(0x127)](_0x38ada4);}async[a59_0x348a1c(0x122)](_0x47afdd,_0x214b34){const _0x14fea7=a59_0x348a1c;if(!a59_0x619160['existsSync'](this[_0x14fea7(0x116)]))throw new Error('路由文件不存在:\x20'+this['routerFilePath']);const _0x25e22d=await a59_0x619160['promises'][_0x14fea7(0x11e)](this[_0x14fea7(0x116)],_0x14fea7(0x12b)),_0x55fb1d=this[_0x14fea7(0x10c)](_0x47afdd);let _0x3f908d=this[_0x14fea7(0x100)](_0x25e22d,_0x55fb1d,_0x47afdd);return _0x3f908d=this[_0x14fea7(0x10a)](_0x3f908d,_0x214b34,_0x55fb1d),_0x3f908d;}}
|
package/lib/utils/sleep.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export function sleep(
|
|
1
|
+
export function sleep(_0x58abdb){return new Promise(_0x2d5459=>setTimeout(_0x2d5459,_0x58abdb));}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a61_0x25e3a7=a61_0x3af9;function a61_0x3af9(_0x2775cf,_0x14c408){_0x2775cf=_0x2775cf-0x1a8;const _0x1fdb36=a61_0x1fdb();let _0x3af912=_0x1fdb36[_0x2775cf];return _0x3af912;}(function(_0x498f44,_0x2d17a8){const _0x54b128=a61_0x3af9,_0xd2e899=_0x498f44();while(!![]){try{const _0x95c4f5=-parseInt(_0x54b128(0x1e2))/0x1*(parseInt(_0x54b128(0x1b2))/0x2)+parseInt(_0x54b128(0x1b6))/0x3+parseInt(_0x54b128(0x1d9))/0x4*(parseInt(_0x54b128(0x1dc))/0x5)+parseInt(_0x54b128(0x1b7))/0x6+parseInt(_0x54b128(0x1ad))/0x7+parseInt(_0x54b128(0x1e3))/0x8+-parseInt(_0x54b128(0x1b4))/0x9*(parseInt(_0x54b128(0x1df))/0xa);if(_0x95c4f5===_0x2d17a8)break;else _0xd2e899['push'](_0xd2e899['shift']());}catch(_0x549726){_0xd2e899['push'](_0xd2e899['shift']());}}}(a61_0x1fdb,0x61fe1));import a61_0x2fee1a from'node:fs';function a61_0x1fdb(){const _0xde54da=['toLocaleDateString','2dPXVwo','4547848oYnSmb','writeFile','includes','toUpperCase','slice','numeric','alias','push','\x20},','.tpl','datasetCode:\x20\x22','error','message','1929746lLHeek','.tsx','name','.md','mkdir','38566FyusHZ','2-digit','1764ZWGpcm','toComponentName','2083932WoAxBA','484620atHqbg','replace','promises','alias:\x20\x22','YourModel','utf8','success','\x0a\x20\x20\x20\x20{\x20','name:\x20\x22','pop','.scss','tableName:\x20\x22','processTemplate','.json','replaceContent','charAt','map','模板内容替换完成','toDisplayTitle','now','开始处理模板内容替换','info','toISOString','processFile','toLowerCase','processDirectory','.ts','endsWith','.jsx','.css','readFile','.js','split','template','24cEtnlS','tableName','datasetCode','140055VDYZOx','toLocaleString','replaceApiContent','68760DvufRW','join'];a61_0x1fdb=function(){return _0xde54da;};return a61_0x1fdb();}import a61_0x24a344 from'node:path';import{logger}from'./logger.js';export class TemplateReplacer{static['toComponentName'](_0x1e14b3){const _0x2b9d32=a61_0x3af9,_0x3d4dcb=_0x1e14b3[_0x2b9d32(0x1d7)]('/')['pop']()||_0x1e14b3;return _0x3d4dcb[_0x2b9d32(0x1d7)]('-')[_0x2b9d32(0x1c7)](_0x20e8d5=>_0x20e8d5['charAt'](0x0)[_0x2b9d32(0x1e6)]()+_0x20e8d5[_0x2b9d32(0x1e7)](0x1)[_0x2b9d32(0x1cf)]())[_0x2b9d32(0x1e0)]('');}static[a61_0x25e3a7(0x1c9)](_0x2d4583){const _0x5a1b7c=a61_0x25e3a7,_0x3bfaa1=_0x2d4583[_0x5a1b7c(0x1d7)]('/')[_0x5a1b7c(0x1c0)]()||_0x2d4583;return _0x3bfaa1[_0x5a1b7c(0x1d7)]('-')['map'](_0x3ed427=>_0x3ed427[_0x5a1b7c(0x1c6)](0x0)[_0x5a1b7c(0x1e6)]()+_0x3ed427[_0x5a1b7c(0x1e7)](0x1)[_0x5a1b7c(0x1cf)]())[_0x5a1b7c(0x1e0)]('\x20');}static[a61_0x25e3a7(0x1c5)](_0x4bc5de,_0x1736e1,_0x232820){const _0x59207f=a61_0x25e3a7,_0x305f53=this[_0x59207f(0x1b5)](_0x1736e1),_0x494372=this[_0x59207f(0x1c9)](_0x1736e1),_0x119f2a=new Date(),_0x115dd2=_0x119f2a[_0x59207f(0x1dd)](undefined,{'year':_0x59207f(0x1e8),'month':'2-digit','day':_0x59207f(0x1b3),'hour':_0x59207f(0x1b3),'minute':_0x59207f(0x1b3),'second':'2-digit','hour12':![]})[_0x59207f(0x1b8)](/\//g,'-'),_0x206fa9=_0x119f2a[_0x59207f(0x1e1)](undefined,{'year':_0x59207f(0x1e8),'month':'2-digit','day':_0x59207f(0x1b3)})['replace'](/\//g,'-'),_0xe270b5=_0x119f2a['toLocaleTimeString'](undefined,{'hour12':![]});let _0x104761=_0x4bc5de[_0x59207f(0x1b8)](/\{ComponentName\}/g,_0x305f53)[_0x59207f(0x1b8)](/\{DisplayTitle\}/g,_0x494372)[_0x59207f(0x1b8)](/\{PageName\}/g,_0x1736e1)[_0x59207f(0x1b8)](/\{TemplateName\}/g,_0x232820)[_0x59207f(0x1b8)](/\{CreatedAt\}/g,_0x115dd2)[_0x59207f(0x1b8)](/\{CreatedDate\}/g,_0x206fa9)[_0x59207f(0x1b8)](/\{CreatedTime\}/g,_0xe270b5);return _0x104761;}static[a61_0x25e3a7(0x1de)](_0x5065bc,_0x5a113f,_0xafb80a,_0xa64009,_0x527c58,_0x245673,_0x28b0e2){const _0x23d98f=a61_0x25e3a7,_0x5c7416=new Date(),_0x44a28a=_0x5c7416[_0x23d98f(0x1cd)](),_0xde054d=_0xafb80a[_0x23d98f(0x1c7)](_0x3df37c=>{const _0x215c9f=_0x23d98f,_0x1c08ea=[_0x215c9f(0x1aa)+_0x3df37c[_0x215c9f(0x1db)]+'\x22',_0x215c9f(0x1c2)+_0x3df37c[_0x215c9f(0x1da)]+'\x22',_0x215c9f(0x1bf)+_0x3df37c[_0x215c9f(0x1af)]+'\x22'];return _0x3df37c['alias']&&_0x1c08ea[_0x215c9f(0x1ea)](_0x215c9f(0x1ba)+_0x3df37c[_0x215c9f(0x1e9)]+'\x22'),_0x215c9f(0x1be)+_0x1c08ea[_0x215c9f(0x1e0)](',\x20')+_0x215c9f(0x1a8);})[_0x23d98f(0x1e0)](''),_0x54d1d3=_0xa64009||_0xafb80a[0x0]?.[_0x23d98f(0x1e9)]||_0x23d98f(0x1bb);let _0x45fdbb=_0x5065bc[_0x23d98f(0x1b8)](/\{AppCode\}/g,_0x5a113f)[_0x23d98f(0x1b8)](/\{ModelConfigs\}/g,_0xde054d)[_0x23d98f(0x1b8)](/\{ExampleModelName\}/g,_0x54d1d3)['replace'](/\{ApiFileName\}/g,_0x527c58||'api')[_0x23d98f(0x1b8)](/\{ConfigName\}/g,_0x245673||'default')[_0x23d98f(0x1b8)](/\{ClientConfigParam\}/g,_0x28b0e2||'')[_0x23d98f(0x1b8)](/\{CreatedAt\}/g,_0x44a28a);return _0x45fdbb;}static async[a61_0x25e3a7(0x1c3)](_0xa43e3,_0x53743b,_0x3c4381,_0xf2042e,_0x5e7ed1=!![]){const _0xe2ff2d=a61_0x25e3a7,_0x2b603b=Date[_0xe2ff2d(0x1ca)]();try{_0x5e7ed1&&logger[_0xe2ff2d(0x1cc)](_0xe2ff2d(0x1d8),_0xe2ff2d(0x1cb),{'templatePath':_0xa43e3,'targetPath':_0x53743b,'pageName':_0x3c4381,'templateName':_0xf2042e});await a61_0x2fee1a[_0xe2ff2d(0x1b9)]['mkdir'](_0x53743b,{'recursive':!![]}),await this[_0xe2ff2d(0x1d0)](_0xa43e3,_0x53743b,_0x3c4381,_0xf2042e);if(_0x5e7ed1){const _0xede5a2=Date[_0xe2ff2d(0x1ca)]()-_0x2b603b;logger[_0xe2ff2d(0x1bd)](_0xe2ff2d(0x1d8),_0xe2ff2d(0x1c8),_0xede5a2,{'pageName':_0x3c4381,'templateName':_0xf2042e});}}catch(_0x451627){if(_0x5e7ed1){const _0x19c0cf=Date[_0xe2ff2d(0x1ca)]()-_0x2b603b;logger[_0xe2ff2d(0x1ab)](_0xe2ff2d(0x1d8),'模板内容替换失败',{'templatePath':_0xa43e3,'targetPath':_0x53743b,'pageName':_0x3c4381,'templateName':_0xf2042e,'error':_0x451627 instanceof Error?_0x451627[_0xe2ff2d(0x1ac)]:String(_0x451627),'duration':_0x19c0cf});}throw _0x451627;}}static async['processDirectory'](_0x1ae37b,_0x50649d,_0x35276b,_0x2e9b3f){const _0x3473c3=a61_0x25e3a7,_0x56c7c3=await a61_0x2fee1a['promises']['readdir'](_0x1ae37b,{'withFileTypes':!![]});for(const _0x1583af of _0x56c7c3){const _0x3a47cf=a61_0x24a344[_0x3473c3(0x1e0)](_0x1ae37b,_0x1583af['name']);let _0x525a8c=a61_0x24a344[_0x3473c3(0x1e0)](_0x50649d,_0x1583af[_0x3473c3(0x1af)]);_0x1583af[_0x3473c3(0x1af)][_0x3473c3(0x1d2)]('.tpl')&&(_0x525a8c=a61_0x24a344[_0x3473c3(0x1e0)](_0x50649d,_0x1583af[_0x3473c3(0x1af)][_0x3473c3(0x1b8)](/\.tpl$/,'')));if(_0x1583af['isDirectory']())await a61_0x2fee1a[_0x3473c3(0x1b9)][_0x3473c3(0x1b1)](_0x525a8c,{'recursive':!![]}),await this[_0x3473c3(0x1d0)](_0x3a47cf,_0x525a8c,_0x35276b,_0x2e9b3f);else _0x1583af['isFile']()&&await this[_0x3473c3(0x1ce)](_0x3a47cf,_0x525a8c,_0x35276b,_0x2e9b3f);}}static async['processFile'](_0x21efc3,_0x2cb40c,_0x5ac83d,_0x30b11f){const _0x2fc4=a61_0x25e3a7,_0x19fcde=a61_0x24a344['extname'](_0x21efc3)['toLowerCase']();_0x21efc3['endsWith']('.tpl')&&(_0x2cb40c=_0x2cb40c['replace'](/\.tpl$/,''));const _0x34807b=[_0x2fc4(0x1ae),_0x2fc4(0x1d1),_0x2fc4(0x1d3),_0x2fc4(0x1d6),_0x2fc4(0x1c4),_0x2fc4(0x1b0),_0x2fc4(0x1d4),_0x2fc4(0x1c1),_0x2fc4(0x1a9)];if(_0x34807b[_0x2fc4(0x1e5)](_0x19fcde)||_0x21efc3['endsWith']('.tpl')){const _0x4b82d0=await a61_0x2fee1a[_0x2fc4(0x1b9)][_0x2fc4(0x1d5)](_0x21efc3,_0x2fc4(0x1bc)),_0x2c41a6=this[_0x2fc4(0x1c5)](_0x4b82d0,_0x5ac83d,_0x30b11f);await a61_0x2fee1a[_0x2fc4(0x1b9)][_0x2fc4(0x1e4)](_0x2cb40c,_0x2c41a6,'utf8');}else await a61_0x2fee1a[_0x2fc4(0x1b9)]['copyFile'](_0x21efc3,_0x2cb40c);}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lovrabet/cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.2.1-beta.3",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"bin": {
|
|
6
6
|
"lovrabet": "lib/cli.js"
|
|
@@ -44,12 +44,14 @@
|
|
|
44
44
|
"meow": "^13.2.0",
|
|
45
45
|
"prettier": "^3.6.2",
|
|
46
46
|
"react": "^19.1.1",
|
|
47
|
+
"semver": "^7.7.3",
|
|
47
48
|
"winston": "^3.17.0"
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|
|
50
51
|
"@types/listr": "^0.14.9",
|
|
51
52
|
"@types/node": "^24.5.2",
|
|
52
53
|
"@types/react": "^19.1.12",
|
|
54
|
+
"@types/semver": "^7.7.1",
|
|
53
55
|
"@vitest/coverage-v8": "^3.2.4",
|
|
54
56
|
"@vitest/ui": "^3.2.4",
|
|
55
57
|
"c8": "^10.1.3",
|
|
@@ -12,11 +12,16 @@ export const LOVRABET_APP_CODE = "{AppCode}";
|
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* 项目的模型配置
|
|
15
|
-
*
|
|
15
|
+
* 使用数组格式,每个模型包含 datasetCode、tableName、name 和可选的 alias
|
|
16
|
+
*
|
|
17
|
+
* 访问方式:
|
|
18
|
+
* - 标准访问:client.models.dataset_[datasetCode]
|
|
19
|
+
* - 别名访问:client.models.[alias](如果配置了 alias)
|
|
16
20
|
*/
|
|
17
21
|
export const LOVRABET_MODELS_CONFIG: ModelsConfig = {
|
|
18
22
|
appCode: LOVRABET_APP_CODE,
|
|
19
|
-
models: {
|
|
23
|
+
models: [{ModelConfigs}
|
|
24
|
+
]
|
|
20
25
|
} as const;
|
|
21
26
|
|
|
22
27
|
/**
|
|
@@ -31,12 +36,12 @@ registerModels(LOVRABET_MODELS_CONFIG, {ConfigName});
|
|
|
31
36
|
* // 开发环境配置
|
|
32
37
|
* registerModels({
|
|
33
38
|
* appCode: 'app-dev-123',
|
|
34
|
-
* models:
|
|
39
|
+
* models: [...]
|
|
35
40
|
* }, 'dev');
|
|
36
41
|
*
|
|
37
42
|
* // 其他项目配置
|
|
38
43
|
* registerModels({
|
|
39
44
|
* appCode: 'other-project',
|
|
40
|
-
* models:
|
|
45
|
+
* models: [...]
|
|
41
46
|
* }, 'project-b');
|
|
42
47
|
*/
|
|
@@ -83,23 +83,90 @@ const response = await client.models.<modelName>.getOne(<id>);
|
|
|
83
83
|
if (response.success) { ... } // 错误!成功时只返回 data 内容
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
### 3.
|
|
86
|
+
### 3. SDK 调用注释规范(人类友好)
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
**重要**:每次调用 SDK 方法时,必须在代码前添加注释说明正在调用的数据集和数据表,便于代码阅读和维护。
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
```typescript
|
|
91
|
+
// 正确:添加数据集和数据表注释
|
|
92
|
+
// 数据集: 项目成员 | 数据表: project_members
|
|
93
|
+
const members = await client.models.projectMembers.filter({
|
|
94
|
+
where: { status: { $eq: 'active' } },
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// 数据集: 用户信息 | 数据表: users
|
|
98
|
+
const user = await client.models.users.getOne(userId);
|
|
99
|
+
|
|
100
|
+
// 错误:缺少注释,不清楚在操作什么数据
|
|
101
|
+
const members = await client.models.projectMembers.filter({ ... });
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**注释格式**:`// 数据集: <数据集名称> | 数据表: <表名>`
|
|
105
|
+
|
|
106
|
+
无论使用标准方式(`dataset_xxx`)还是别名方式(`projectMembers`),都应添加此注释。
|
|
107
|
+
|
|
108
|
+
### 3.1 模型访问方式与别名规范
|
|
109
|
+
|
|
110
|
+
**⚠️ SDK 版本要求**:
|
|
111
|
+
- `dataset_[code]` 标准模式和 alias 别名模式需要 `@lovrabet/sdk >= 1.2.0`
|
|
112
|
+
- 如果用户的 SDK 版本 < 1.2.0,只能使用 `createClient` 或 `registerModels` 中配置的 key
|
|
113
|
+
- **编写代码前,请先检查用户 `package.json` 中的 `@lovrabet/sdk` 版本**
|
|
114
|
+
|
|
115
|
+
SDK 支持两种模型访问方式(需 SDK >= 1.2.0):
|
|
116
|
+
|
|
117
|
+
**1. 标准方式(默认推荐)**:使用 `dataset_[完整datasetCode]` 格式,稳定可靠,无需额外配置。
|
|
118
|
+
|
|
119
|
+
**2. 别名方式**:使用用户在 `createClient` 或 `registerModels` 中配置的 alias。
|
|
120
|
+
|
|
121
|
+
**重要规则**:
|
|
122
|
+
- 如果用户代码中已配置自定义 alias,**必须使用用户定义的 alias**
|
|
123
|
+
- 不要假设 alias 是默认的 camelCase 表名,先检查用户的 SDK 初始化代码
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
// 方式1:在 createClient 时定义 alias
|
|
127
|
+
const client = createClient({
|
|
128
|
+
appCode: '<appcode>',
|
|
129
|
+
models: {
|
|
130
|
+
// 用户自定义 alias 为 'members',而非默认的 'projectMembers'
|
|
131
|
+
members: {
|
|
132
|
+
tableName: 'project_members',
|
|
133
|
+
datasetCode: '<dataset-code>',
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// 方式2:通过 registerModels 动态注册 alias
|
|
139
|
+
client.registerModels({
|
|
140
|
+
tasks: {
|
|
141
|
+
tableName: 'project_tasks',
|
|
142
|
+
datasetCode: '<dataset-code>',
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// 正确:使用用户定义的 alias
|
|
147
|
+
const result = await client.models.members.filter({...});
|
|
148
|
+
const tasks = await client.models.tasks.filter({...});
|
|
149
|
+
|
|
150
|
+
// 错误:使用默认 alias,但用户配置的是 'members'
|
|
151
|
+
const result = await client.models.projectMembers.filter({...});
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
**编写代码前,请先检查用户的 `createClient` 和 `registerModels` 代码,确认使用的是用户定义的 alias。**
|
|
155
|
+
|
|
156
|
+
### 4. 数据模型操作
|
|
157
|
+
|
|
158
|
+
#### 列表查询:使用 `filter()` 方法
|
|
159
|
+
|
|
160
|
+
`filter()` 方法支持 **OpenAPI 和 WebAPI 两种模式**:
|
|
161
|
+
- 强大的查询能力(支持复杂条件、范围查询、模糊匹配)
|
|
162
|
+
- 高性能(通过 `select` 参数只返回需要的字段)
|
|
163
|
+
- 简洁的返回结构(直接返回 `{ tableData, total }`)
|
|
94
164
|
- 支持 11 种条件操作符和 `$and`/`$or` 逻辑组合
|
|
95
165
|
- 支持的操作符(11 种):
|
|
96
166
|
- $eq, $ne, $gte ($gteq), $lte ($lteq), $in, $contain, $startWith, $endWith
|
|
97
167
|
- 逻辑操作符:$and, $or(支持嵌套)
|
|
98
168
|
|
|
99
|
-
#### 高级过滤查询(v1.1.22+,OpenAPI 和 WebAPI 都支持,强烈推荐!)
|
|
100
|
-
|
|
101
169
|
```typescript
|
|
102
|
-
// 强烈推荐:filter 功能强大,性能更好,两种模式都支持
|
|
103
170
|
const result = await client.models.<modelName>.filter({
|
|
104
171
|
where: {
|
|
105
172
|
$and: [
|
|
@@ -226,19 +293,16 @@ const options = await client.models.<modelName>.getSelectOptions({
|
|
|
226
293
|
});
|
|
227
294
|
```
|
|
228
295
|
|
|
229
|
-
###
|
|
296
|
+
### 5. 认证模式支持
|
|
230
297
|
|
|
231
298
|
**OpenAPI 模式(accessKey/token)**:
|
|
232
|
-
- 支持:
|
|
233
|
-
- 支持:**filter**(v1.1.22+ 新增)
|
|
299
|
+
- 支持:filter, getOne, create, update
|
|
234
300
|
- 支持:executeSql
|
|
235
|
-
- 不支持:user.getList
|
|
236
301
|
- 不支持:delete(暂不支持)
|
|
237
302
|
- 不支持:getSelectOptions(暂不支持)
|
|
238
303
|
|
|
239
304
|
**WebAPI 模式(Cookie)**:
|
|
240
|
-
- 支持:
|
|
241
|
-
- 支持:filter
|
|
305
|
+
- 支持:filter, getOne, create, update
|
|
242
306
|
- 支持:delete
|
|
243
307
|
- 支持:getSelectOptions
|
|
244
308
|
- 支持:executeSql
|
|
@@ -298,18 +362,12 @@ await client.models.<modelName>.create({
|
|
|
298
362
|
### 1. 减少 API 调用和数据传输
|
|
299
363
|
|
|
300
364
|
```typescript
|
|
301
|
-
//
|
|
365
|
+
// 使用 filter + select 只返回需要的字段
|
|
302
366
|
const result = await client.models.<modelName>.filter({
|
|
303
367
|
where: { <field>: <value> },
|
|
304
368
|
select: ['<field1>', '<field2>', '<field3>'], // 只返回3个字段,减少数据传输
|
|
305
369
|
});
|
|
306
370
|
|
|
307
|
-
// 不推荐:getList 返回所有字段,浪费带宽
|
|
308
|
-
const response = await client.models.<modelName>.getList({
|
|
309
|
-
<field>: <value>,
|
|
310
|
-
pageSize: 20,
|
|
311
|
-
}); // 返回所有字段,无法筛选
|
|
312
|
-
|
|
313
371
|
// 批量操作,避免循环
|
|
314
372
|
const items = await Promise.all(
|
|
315
373
|
ids.map(id => client.models.<modelName>.getOne(id))
|
|
@@ -377,8 +435,8 @@ const [loading, setLoading] = useState(false);
|
|
|
377
435
|
async function loadData() {
|
|
378
436
|
setLoading(true);
|
|
379
437
|
try {
|
|
380
|
-
const
|
|
381
|
-
setData(
|
|
438
|
+
const result = await client.models.<modelName>.filter({ pageSize: 20 });
|
|
439
|
+
setData(result.tableData);
|
|
382
440
|
} catch (error) {
|
|
383
441
|
alert('加载失败');
|
|
384
442
|
} finally {
|
|
@@ -401,9 +459,9 @@ interface DataType {
|
|
|
401
459
|
<field2>: number;
|
|
402
460
|
}
|
|
403
461
|
|
|
404
|
-
const
|
|
462
|
+
const result = await client.models.<modelName>.filter<DataType>({ pageSize: 20 });
|
|
405
463
|
|
|
406
|
-
|
|
464
|
+
result.tableData.forEach(item => {
|
|
407
465
|
console.log(item.<field1>); // 类型安全
|
|
408
466
|
console.log(item.unknownField); // 编译错误
|
|
409
467
|
});
|
|
@@ -420,9 +478,8 @@ response.tableData.forEach(item => {
|
|
|
420
478
|
5. **不要假设返回值结构** - 注意不同方法返回值的差异
|
|
421
479
|
6. **不要在循环中调用 API** - 使用 Promise.all 批量处理
|
|
422
480
|
7. **不要在每次渲染时调用 API** - 使用 useEffect 控制
|
|
423
|
-
8.
|
|
424
|
-
9.
|
|
425
|
-
10. **不要假设 executeSql 返回数组** - 返回的是 `{ execSuccess, execResult }` 对象
|
|
481
|
+
8. **不要忘记检查 execSuccess** - executeSql 返回的数据必须检查 `execSuccess` 状态
|
|
482
|
+
9. **不要假设 executeSql 返回数组** - 返回的是 `{ execSuccess, execResult }` 对象
|
|
426
483
|
|
|
427
484
|
|
|
428
485
|
|
|
@@ -432,14 +489,13 @@ response.tableData.forEach(item => {
|
|
|
432
489
|
|
|
433
490
|
| 方法 | 返回结构 | 认证限制 |
|
|
434
491
|
|------|----------|----------|
|
|
435
|
-
| `filter()`
|
|
436
|
-
| `getList()` | `{ paging, tableData, tableColumns }` | OpenAPI + WebAPI |
|
|
437
|
-
| `executeSql()` | `{ execSuccess, execResult }` | OpenAPI + WebAPI |
|
|
438
|
-
| `user.getList()` | `User[]` | OpenAPI + WebAPI |
|
|
492
|
+
| `filter()` | `{ tableData, total }` | OpenAPI + WebAPI |
|
|
439
493
|
| `getOne()` | 单个对象 | OpenAPI + WebAPI |
|
|
440
494
|
| `create/update()` | 操作结果对象 | OpenAPI + WebAPI |
|
|
441
495
|
| `delete()` | 删除结果 | 仅 WebAPI |
|
|
442
496
|
| `getSelectOptions()` | `[{ label, value }]` | 仅 WebAPI |
|
|
497
|
+
| `executeSql()` | `{ execSuccess, execResult }` | OpenAPI + WebAPI |
|
|
498
|
+
| `user.getList()` | `User[]` | 仅 WebAPI |
|
|
443
499
|
|
|
444
500
|
### 记住
|
|
445
501
|
|
|
@@ -448,7 +504,7 @@ response.tableData.forEach(item => {
|
|
|
448
504
|
- **所有调用**:必须用 `try-catch` 包裹
|
|
449
505
|
- **先获取元数据**:使用 MCP 确认字段存在
|
|
450
506
|
- **注意参数名**:`select`(不是 `fields`),`orderBy`(不是 `sortList`)
|
|
451
|
-
-
|
|
507
|
+
- **列表查询用 filter**:使用 `filter()` 方法进行列表查询
|
|
452
508
|
- **executeSql 检查状态**:应用层必须检查 `execSuccess` 状态
|
|
453
509
|
- **用户列表**:使用 `client.api.user.getList()` 获取平台用户
|
|
454
510
|
|