UNPKG

mixone

Version:

MixOne is a Node scaffolding tool implemented based on Vite, used for compiling HTML5, JavasCript, Vue, React and other codes. It supports packaging Web applications with multiple HTML entry points (BS architecture) and desktop installation packages (CS a

1 lines 22.1 kB
const W=d;(function(e,f){const O=d,g=e();while(!![]){try{const h=parseInt(O(0xf0))/0x1+-parseInt(O(0xf6))/0x2+parseInt(O(0x14d))/0x3*(-parseInt(O(0x12c))/0x4)+-parseInt(O(0xef))/0x5+parseInt(O(0xf1))/0x6+parseInt(O(0x10b))/0x7*(parseInt(O(0xed))/0x8)+parseInt(O(0xfc))/0x9*(parseInt(O(0x12f))/0xa);if(h===f)break;else g['push'](g['shift']());}catch(i){g['push'](g['shift']());}}}(c,0xb8286));const b=(function(){const P=d,e={'NkYSC':function(g,h){return g===h;},'KBbiL':'MemberExpression','lQjuj':P(0x11c),'phcWD':'whenReady','qjaSr':'ArrowFunctionExpression','gGKiO':function(g,h){return g===h;},'bPzfp':'FunctionExpression','phYmN':function(g,h,i){return g(h,i);},'dAmVj':P(0x101),'myEeu':P(0x14e),'Orcql':function(g,h){return g!==h;},'oXRQL':'rABDN'};let f=!![];return function(g,h){const R=P,i={'EEyLw':function(k,l){const Q=d;return e[Q(0x126)](k,l);},'ZxDeR':e[R(0x13e)],'CwJtK':e['lQjuj'],'LVVDX':e[R(0xfe)],'lMSLj':e['qjaSr'],'MQFXi':function(k,l){return e['gGKiO'](k,l);},'NrSbP':e[R(0x104)],'mUqCP':function(k,l,m){const S=R;return e[S(0x142)](k,l,m);},'yZmbQ':e[R(0x139)],'jNyRt':e['myEeu'],'gQMJt':function(k,l){const T=R;return e[T(0x146)](k,l);},'DmSum':e['oXRQL']},j=f?function(){const U=R;if(h){if(i[U(0xf3)](i[U(0x145)],i[U(0x145)])){if(p['node'][U(0xec)]&&i['EEyLw'](q[U(0x10c)][U(0xec)][U(0x141)],i['ZxDeR'])&&r[U(0x10c)][U(0xec)][U(0x128)][U(0x115)]===i[U(0x149)]&&i[U(0x132)](s[U(0x10c)][U(0xec)][U(0x147)][U(0x141)],U(0xeb))&&u[U(0x10c)][U(0xec)][U(0x147)]['callee']['property'][U(0x115)]===i['LVVDX']){const l=B[U(0x10c)][U(0x116)][0x0];if(l[U(0x141)]===i['lMSLj']||i[U(0x135)](l[U(0x141)],i[U(0xfa)])){const m=i[U(0x11f)](H,l[U(0x144)],{'retainLines':!![],'compact':![],'quotes':i[U(0x143)]});I=m['code'],l[U(0x144)]=J['blockStatement']([K[U(0xf7)](L[U(0xee)](i['jNyRt']))]);}}}else{const l=h[U(0x122)](g,arguments);return h=null,l;}}}:function(){};return f=![],j;};}()),a=b(this,function(){const V=d,e={'ptEUJ':V(0x119)};return a['toString']()[V(0x117)](V(0x119))[V(0x11a)]()['constructor'](a)['search'](e[V(0x11b)]);});function d(a,b){const e=c();return d=function(f,g){f=f-0xeb;let h=e[f];return h;},d(a,b);}a();const parser=require('@babel/parser'),traverse=require(W(0xf5))[W(0x12a)],generate=require(W(0x137))['default'],t=require(W(0x13f));function processMainProcessFile(e,f){const X=W,g={'BLxta':function(r,s){return r!==s;},'Nwujv':X(0x13d),'hUyJv':function(r,s){return r===s;},'WxxKc':'whenReady','UMqsl':function(r,s){return r===s;},'TRpMi':function(r,s,u){return r(s,u);},'icIkx':X(0x101),'Bounl':function(r,s){return r>s;},'aHBCa':function(r,s){return r-s;},'NlJDr':function(r,s){return r+s;},'auPXb':X(0x133),'SSkKr':'module','UCZGU':'jsx','aprSA':function(r,s,u){return r(s,u);},'wZleB':function(r,s,u){return r(s,u);},'DUUVh':function(r){return r();},'JjAuB':function(r,s){return r(s);},'mGYRM':X(0x148),'RiXca':'const\x20{\x20setupConsoleRedirect\x20}\x20=\x20require(\x27./reset_console\x27);\x0a','xgccy':X(0xfd),'BQjEy':X(0x102),'MwTro':X(0x14c),'XYBYr':function(r,s){return r+s;},'MKgRR':'\x0aregisterMainFunctions();\x0a'},h=parser[X(0x11e)](e,{'sourceType':g['SSkKr'],'plugins':[g[X(0x125)],X(0x123)]});let i='';g['aprSA'](traverse,h,{'Program'(r){const a1=X,s={'zHgaC':function(v,w){const Y=d;return g[Y(0x110)](v,w);},'npGed':g['Nwujv'],'yTdkw':function(v,w){const Z=d;return g[Z(0x106)](v,w);},'tJIIL':g['WxxKc'],'LMqFP':function(v,w){return g['UMqsl'](v,w);},'xVUGC':function(v,w,x){const a0=d;return g[a0(0x113)](v,w,x);},'jchqT':g[a1(0x112)]},u=r[a1(0x10c)]['body'][a1(0x120)](v=>t[a1(0x108)](v)&&v[a1(0x109)]['some'](w=>t[a1(0x136)](w[a1(0x124)])&&t[a1(0x105)](w[a1(0x124)]['callee'])&&w['init']['callee'][a1(0x115)]===a1(0x10a)));r[a1(0x107)]({'CallExpression'(v){const a2=a1;if(s[a2(0x134)]('OPAcy',s[a2(0x10e)])){if(v['node'][a2(0xec)]&&v[a2(0x10c)]['callee'][a2(0x141)]===a2(0x13c)&&s['yTdkw'](v['node'][a2(0xec)][a2(0x128)][a2(0x115)],'then')&&s[a2(0x140)](v['node']['callee'][a2(0x147)][a2(0x141)],'CallExpression')&&s[a2(0x140)](v[a2(0x10c)][a2(0xec)][a2(0x147)][a2(0xec)][a2(0x128)][a2(0x115)],s[a2(0xfb)])){const w=v[a2(0x10c)]['arguments'][0x0];if(s[a2(0x140)](w['type'],a2(0x13a))||s['LMqFP'](w['type'],a2(0x127))){const x=s[a2(0x10f)](generate,w[a2(0x144)],{'retainLines':!![],'compact':![],'quotes':s['jchqT']});i=x[a2(0x121)],w['body']=t[a2(0x118)]([t[a2(0xf7)](t['stringLiteral'](a2(0x14e)))]);}}}else return'\x0aconst\x20rmSync\x20=\x20(targetPath,\x20options\x20=\x20{})\x20=>\x20{\x0a\x20\x20\x20\x20//\x20检查fs.rmSync是否存在(Node.js\x2014.14.0+)\x0a\x20\x20\x20\x20if\x20(typeof\x20fs.rmSync\x20===\x20\x27function\x27)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20fs.rmSync(targetPath,\x20options);\x0a\x20\x20\x20\x20\x20\x20\x20\x20return;\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20//\x20模拟实现fs.rmSync\x0a\x20\x20\x20\x20const\x20recursive\x20=\x20options.recursive\x20||\x20false;\x0a\x20\x20\x20\x20const\x20force\x20=\x20options.force\x20||\x20false;\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20try\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20const\x20stat\x20=\x20fs.statSync(targetPath);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20if\x20(stat.isDirectory())\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(recursive)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20递归删除目录内容\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20const\x20items\x20=\x20fs.readdirSync(targetPath);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20for\x20(const\x20item\x20of\x20items)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20const\x20itemPath\x20=\x20path.join(targetPath,\x20item);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20rmSync(itemPath,\x20options);\x20//\x20递归调用\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20删除空目录\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20fs.rmdirSync(targetPath);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x20else\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20非递归模式,只删除空目录\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20fs.rmdirSync(targetPath);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x20else\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20删除文件\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20fs.unlinkSync(targetPath);\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20}\x20catch\x20(error)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20if\x20(!force)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20throw\x20error;\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20//\x20force模式下忽略错误\x0a\x20\x20\x20\x20}\x0a}\x0a//\x20过滤特殊字符,只保留中文和普通字符\x0afunction\x20filterString(str)\x20{\x0a\x20\x20return\x20str.replace(/[\x5cuD800-\x5cuDBFF][\x5cuDC00-\x5cuDFFF]|[^\x5cx00-\x5cx7F\x5cu4E00-\x5cu9FFF]/g,\x20\x27\x27);\x0a}\x0a\x0a//\x20重写控制台输出方法\x0aconsole.log\x20=\x20(...args)\x20=>\x20{\x0a\x20\x20const\x20message\x20=\x20args.map(arg\x20=>\x20{\x0a\x20\x20\x20\x20if\x20(typeof\x20arg\x20===\x20\x27string\x27)\x20{\x0a\x20\x20\x20\x20\x20\x20return\x20filterString(arg);\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20return\x20arg;\x0a\x20\x20}).join(\x27\x20\x27);\x0a\x20\x20process.stdout.write(message);\x0a}\x0a\x0aconsole.error\x20=\x20(...args)\x20=>\x20{\x0a\x20\x20const\x20message\x20=\x20args.map(arg\x20=>\x20{\x0a\x20\x20\x20\x20if\x20(typeof\x20arg\x20===\x20\x27string\x27)\x20{\x0a\x20\x20\x20\x20\x20\x20return\x20filterString(arg);\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20return\x20arg;\x0a\x20\x20}).join(\x27\x20\x27);\x0a\x20\x20process.stderr.write(message);\x0a}\x0a//\x20定义一个日志文件路径,通常放在用户数据目录\x0aconst\x20logFilePath\x20=\x20path.join(app.getPath(\x27userData\x27),\x20\x27logs\x27,\x20\x27main_process.log\x27);\x0aif(fs.existsSync(path.dirname(logFilePath)))\x20{\x0a\x20\x20rmSync(logFilePath,\x20{\x20force:\x20true\x20});\x0a}\x0afs.mkdirSync(path.dirname(logFilePath),\x20{\x20recursive:\x20true\x20});\x0aapp.on(\x27uncaughtException\x27,\x20(error)\x20=>\x20{\x0a\x20\x20\x20\x20const\x20timestamp\x20=\x20new\x20Date().toISOString();\x0a\x20\x20\x20\x20const\x20errorMessage\x20=\x20\x22[\x22+timestamp+\x22]\x20Uncaught\x20Exception\x20in\x20Main\x20Process\x22;\x0a\x20\x20\x20\x20const\x20errorStack\x20=\x20error.stack\x20||\x20error.message;\x0a\x0a\x20\x20\x20\x20console.error(errorMessage,\x20errorStack);\x20//\x20打印到控制台\x20(如果通过终端启动)\x0a\x0a\x20\x20\x20\x20//\x20将错误信息写入日志文件\x0a\x20\x20\x20\x20fs.appendFileSync(logFilePath,\x20errorMessage\x20+\x20errorStack,\x20(err)\x20=>\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20if\x20(err)\x20console.error(\x27Failed\x20to\x20write\x20uncaughtException\x20to\x20log\x20file:\x27,\x20err);\x0a\x20\x20\x20\x20});\x0a\x20\x20\x20\x20//\x20可以在这里通知用户,或者上传错误报告\x0a\x20\x20\x20\x20//\x20app.quit();\x20//\x20根据需要决定是否退出应用\x0a});\x0a\x0aprocess.on(\x27unhandledRejection\x27,\x20(reason,\x20promise)\x20=>\x20{\x0a\x20\x20\x20\x20const\x20timestamp\x20=\x20new\x20Date().toISOString();\x0a\x20\x20\x20\x20const\x20errorMessage\x20=\x20\x22[\x22+timestamp+\x22]\x20Unhandled\x20Promise\x20Rejection\x20in\x20Main\x20Process\x22;\x0a\x20\x20\x20\x20const\x20errorStack\x20=\x20reason\x20instanceof\x20Error\x20?\x20reason.stack\x20:\x20String(reason);\x0a\x0a\x20\x20\x20\x20console.error(errorMessage,\x20errorStack);\x0a\x20\x20\x20\x20fs.appendFileSync(logFilePath,\x20errorMessage\x20+\x20errorStack,\x20(err)\x20=>\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20if\x20(err)\x20console.error(\x27Failed\x20to\x20write\x20unhandledRejection\x20to\x20log\x20file:\x27,\x20err);\x0a\x20\x20\x20\x20});\x0a\x20\x20\x20\x20//\x20通常建议在\x20unhandledRejection\x20发生后,进程会终止,\x0a\x20\x20\x20\x20//\x20但你可以选择是否立即退出应用,或进行其他恢复尝试。\x0a});\x0a';}});if(g[a1(0xf9)](u['length'],0x0)){const v=u[g[a1(0x10d)](u[a1(0x100)],0x1)],w=r[a1(0x10c)]['body'][a1(0x11d)](v);r['node']['body'][a1(0x129)](g[a1(0x130)](w,0x1),0x0,t['expressionStatement'](t['stringLiteral'](a1(0x14a))),t[a1(0xf7)](t[a1(0xee)](g['auPXb'])));}}});const j=g[X(0xff)](generate,h,{'retainLines':!![],'compact':![],'quotes':X(0x101),'concise':![],'jsescOption':{'quotes':g[X(0x112)]}}),k=j[X(0x121)]['replace'](X(0x14b),g[X(0x13b)](getIconvLiteCode))['replace'](X(0xf2),g[X(0x13b)](getHandleOpenWindowCode))[X(0x103)]('\x27____replace_app_ready_code____\x27',g['JjAuB'](getHotReloadHandleCode,i)),l=g[X(0x13b)](getHotReloadSetup),m=g[X(0x12d)],n=g['RiXca'],o=g[X(0xf8)],p=g[X(0x138)],q=g[X(0x131)];return g[X(0x130)](g['XYBYr'](g[X(0x12b)](m+p,q)+o,n)+k+g[X(0x111)],l);}function c(){const a5=['____replace_handle_open_window____','\x27____replace_iconv_lite____\x27','const\x20{\x20ipcMain\x20}\x20=\x20require(\x27electron\x27);\x0a\x20const\x20path\x20=\x20require(\x27path\x27);\x0a','87pslnwI','____replace_app_ready_code____','CallExpression','callee','11433168HVkytB','stringLiteral','4479825dtJhAY','1221086QwpmlX','2016480ZJANNw','\x27____replace_handle_open_window____\x27','gQMJt','\x0a\x20\x20setupConsoleRedirect(isDevelopmentMode());\x0a\x20\x20//\x20检查是否有窗口状态需要恢复\x0a\x20\x20const\x20statesArg\x20=\x20process.argv.find(arg\x20=>\x20arg.startsWith(\x27--window-states=\x27));\x0a\x20\x20if\x20(statesArg)\x20{\x0a\x20\x20\x20\x20try\x20{\x0a\x20\x20\x20\x20\x20\x20const\x20statesPath\x20=\x20statesArg.split(\x27=\x27)[1];\x0a\x20\x20\x20\x20\x20\x20let\x20content\x20=\x20fs.readFileSync(statesPath,\x20\x27utf-8\x27);\x0a\x20\x20\x20\x20\x20\x20console.log(\x27content:\x27,\x20content);\x0a\x20\x20\x20\x20\x20\x20const\x20states\x20=\x20content.split(\x22------\x22).map(item\x20=>\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20let\x20_item\x20=\x20item.trim();\x0a\x20\x20\x20\x20\x20\x20\x20\x20if(!_item){\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20return\x20{}\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20return\x20JSON.parse(_item)\x0a\x20\x20\x20\x20\x20\x20}).reverse();\x0a\x20\x20\x20\x20\x20\x20//\x20恢复所有窗口\x0a\x20\x20\x20\x20\x20\x20for\x20(const\x20state\x20of\x20states)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20let\x20windowPath\x20=\x20state.windowPath;\x0a\x20\x20\x20\x20\x20\x20\x20\x20await\x20windowManager.restoreWindow(windowPath,\x20state);\x0a\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20//\x20清理临时文件\x0a\x20\x20\x20\x20\x20\x20fs.unlinkSync(statesPath);\x0a\x20\x20\x20\x20}\x20catch\x20(error)\x20{\x0a\x20\x20\x20\x20\x20\x20console.error(\x27Failed\x20in\x20the\x20duplicate\x20window\x20state:\x27,\x20error);\x0a\x20\x20\x20\x20}\x0a\x20\x20}\x20else\x20\x0a\x20\x20\x20','@babel/traverse','2155622aksutz','expressionStatement','xgccy','Bounl','NrSbP','tJIIL','6687hmiHAh','const\x20windowManager\x20=\x20require(\x27./window-manager\x27);\x0a','phcWD','wZleB','length','single','const\x20fs\x20=\x20require(\x27fs\x27);\x0a','replace','bPzfp','isIdentifier','hUyJv','traverse','isVariableDeclaration','declarations','require','7SmXczO','node','aHBCa','npGed','xVUGC','BLxta','MKgRR','icIkx','TRpMi','\x0aconst\x20rmSync\x20=\x20(targetPath,\x20options\x20=\x20{})\x20=>\x20{\x0a\x20\x20\x20\x20//\x20检查fs.rmSync是否存在(Node.js\x2014.14.0+)\x0a\x20\x20\x20\x20if\x20(typeof\x20fs.rmSync\x20===\x20\x27function\x27)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20fs.rmSync(targetPath,\x20options);\x0a\x20\x20\x20\x20\x20\x20\x20\x20return;\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20//\x20模拟实现fs.rmSync\x0a\x20\x20\x20\x20const\x20recursive\x20=\x20options.recursive\x20||\x20false;\x0a\x20\x20\x20\x20const\x20force\x20=\x20options.force\x20||\x20false;\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20try\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20const\x20stat\x20=\x20fs.statSync(targetPath);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20if\x20(stat.isDirectory())\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(recursive)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20递归删除目录内容\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20const\x20items\x20=\x20fs.readdirSync(targetPath);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20for\x20(const\x20item\x20of\x20items)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20const\x20itemPath\x20=\x20path.join(targetPath,\x20item);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20rmSync(itemPath,\x20options);\x20//\x20递归调用\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20删除空目录\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20fs.rmdirSync(targetPath);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x20else\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20非递归模式,只删除空目录\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20fs.rmdirSync(targetPath);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x20else\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20删除文件\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20fs.unlinkSync(targetPath);\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20}\x20catch\x20(error)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20if\x20(!force)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20throw\x20error;\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20//\x20force模式下忽略错误\x0a\x20\x20\x20\x20}\x0a}\x0a//\x20过滤特殊字符,只保留中文和普通字符\x0afunction\x20filterString(str)\x20{\x0a\x20\x20return\x20str.replace(/[\x5cuD800-\x5cuDBFF][\x5cuDC00-\x5cuDFFF]|[^\x5cx00-\x5cx7F\x5cu4E00-\x5cu9FFF]/g,\x20\x27\x27);\x0a}\x0a\x0a//\x20重写控制台输出方法\x0aconsole.log\x20=\x20(...args)\x20=>\x20{\x0a\x20\x20const\x20message\x20=\x20args.map(arg\x20=>\x20{\x0a\x20\x20\x20\x20if\x20(typeof\x20arg\x20===\x20\x27string\x27)\x20{\x0a\x20\x20\x20\x20\x20\x20return\x20filterString(arg);\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20return\x20arg;\x0a\x20\x20}).join(\x27\x20\x27);\x0a\x20\x20process.stdout.write(message);\x0a}\x0a\x0aconsole.error\x20=\x20(...args)\x20=>\x20{\x0a\x20\x20const\x20message\x20=\x20args.map(arg\x20=>\x20{\x0a\x20\x20\x20\x20if\x20(typeof\x20arg\x20===\x20\x27string\x27)\x20{\x0a\x20\x20\x20\x20\x20\x20return\x20filterString(arg);\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20return\x20arg;\x0a\x20\x20}).join(\x27\x20\x27);\x0a\x20\x20process.stderr.write(message);\x0a}\x0a//\x20定义一个日志文件路径,通常放在用户数据目录\x0aconst\x20logFilePath\x20=\x20path.join(app.getPath(\x27userData\x27),\x20\x27logs\x27,\x20\x27main_process.log\x27);\x0aif(fs.existsSync(path.dirname(logFilePath)))\x20{\x0a\x20\x20rmSync(logFilePath,\x20{\x20force:\x20true\x20});\x0a}\x0afs.mkdirSync(path.dirname(logFilePath),\x20{\x20recursive:\x20true\x20});\x0aapp.on(\x27uncaughtException\x27,\x20(error)\x20=>\x20{\x0a\x20\x20\x20\x20const\x20timestamp\x20=\x20new\x20Date().toISOString();\x0a\x20\x20\x20\x20const\x20errorMessage\x20=\x20\x22[\x22+timestamp+\x22]\x20Uncaught\x20Exception\x20in\x20Main\x20Process\x22;\x0a\x20\x20\x20\x20const\x20errorStack\x20=\x20error.stack\x20||\x20error.message;\x0a\x0a\x20\x20\x20\x20console.error(errorMessage,\x20errorStack);\x20//\x20打印到控制台\x20(如果通过终端启动)\x0a\x0a\x20\x20\x20\x20//\x20将错误信息写入日志文件\x0a\x20\x20\x20\x20fs.appendFileSync(logFilePath,\x20errorMessage\x20+\x20errorStack,\x20(err)\x20=>\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20if\x20(err)\x20console.error(\x27Failed\x20to\x20write\x20uncaughtException\x20to\x20log\x20file:\x27,\x20err);\x0a\x20\x20\x20\x20});\x0a\x20\x20\x20\x20//\x20可以在这里通知用户,或者上传错误报告\x0a\x20\x20\x20\x20//\x20app.quit();\x20//\x20根据需要决定是否退出应用\x0a});\x0a\x0aprocess.on(\x27unhandledRejection\x27,\x20(reason,\x20promise)\x20=>\x20{\x0a\x20\x20\x20\x20const\x20timestamp\x20=\x20new\x20Date().toISOString();\x0a\x20\x20\x20\x20const\x20errorMessage\x20=\x20\x22[\x22+timestamp+\x22]\x20Unhandled\x20Promise\x20Rejection\x20in\x20Main\x20Process\x22;\x0a\x20\x20\x20\x20const\x20errorStack\x20=\x20reason\x20instanceof\x20Error\x20?\x20reason.stack\x20:\x20String(reason);\x0a\x0a\x20\x20\x20\x20console.error(errorMessage,\x20errorStack);\x0a\x20\x20\x20\x20fs.appendFileSync(logFilePath,\x20errorMessage\x20+\x20errorStack,\x20(err)\x20=>\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20if\x20(err)\x20console.error(\x27Failed\x20to\x20write\x20unhandledRejection\x20to\x20log\x20file:\x27,\x20err);\x0a\x20\x20\x20\x20});\x0a\x20\x20\x20\x20//\x20通常建议在\x20unhandledRejection\x20发生后,进程会终止,\x0a\x20\x20\x20\x20//\x20但你可以选择是否立即退出应用,或进行其他恢复尝试。\x0a});\x0a','name','arguments','search','blockStatement','(((.+)+)+)+$','toString','ptEUJ','then','indexOf','parse','mUqCP','filter','code','apply','typescript','init','UCZGU','NkYSC','FunctionExpression','property','splice','default','XYBYr','124060wFOcBH','mGYRM','exports','8630cNYGlr','NlJDr','MwTro','EEyLw','____replace_iconv_lite____','zHgaC','MQFXi','isCallExpression','@babel/generator','BQjEy','dAmVj','ArrowFunctionExpression','DUUVh','MemberExpression','Vdslg','KBbiL','@babel/types','yTdkw','type','phYmN','yZmbQ','body','DmSum','Orcql','object','const\x20{\x20registerMainFunctions\x20}\x20=\x20require(\x27./fn\x27);\x0a','CwJtK'];c=function(){return a5;};return c();}function getHandleOpenWindowCode(){return'\x0a//\x20注册\x20WindowManager\x20方法调用的\x20IPC\x20处理器\x0aipcMain.handle(\x27window-manager-action\x27,\x20async\x20(event,\x20{\x20method,\x20args\x20})\x20=>\x20{\x0a\x20\x20try\x20{\x0a\x20\x20\x20\x20if\x20(typeof\x20windowManager[method]\x20===\x20\x27function\x27)\x20{\x0a\x20\x20\x20\x20\x20\x20const\x20result\x20=\x20await\x20windowManager[method].apply(windowManager,\x20args);\x0a\x20\x20\x20\x20\x20\x20return\x20{\x20success:\x20true,\x20result\x20};\x0a\x20\x20\x20\x20}\x20else\x20{\x0a\x20\x20\x20\x20\x20\x20throw\x20new\x20Error(\x22方法\x20\x22+method+\x22\x20不存在\x22);\x0a\x20\x20\x20\x20}\x0a\x20\x20}\x20catch\x20(error)\x20{\x0a\x20\x20\x20\x20return\x20{\x20success:\x20false,\x20error:\x20error.message\x20};\x0a\x20\x20}\x0a})\x0a';}function getIconvLiteCode(){const a3=W;return a3(0x114);}function getHotReloadHandleCode(e){const a4=W;return a4(0xf4)+e+'\x0a';}function getHotReloadSetup(){return'\x0a//\x20判断是否为开发模式\x0afunction\x20isDevelopmentMode()\x20{\x0a\x20\x20//\x20检查命令行参数是否有\x20--dev\x20标志\x0a\x20\x20const\x20isDev\x20=\x20process.argv.includes(\x27--dev\x27);\x0a\x20\x20\x0a\x20\x20//\x20检查环境变量\x0a\x20\x20const\x20nodeEnv\x20=\x20process.env.NODE_ENV;\x0a\x20\x20const\x20isDevEnv\x20=\x20nodeEnv\x20===\x20\x27development\x27\x20||\x20nodeEnv\x20===\x20\x27dev\x27;\x0a\x20\x20\x0a\x20\x20return\x20isDev\x20||\x20isDevEnv;\x0a}\x0a//\x20设置主进程热重载\x0aif\x20(isDevelopmentMode())\x20{\x0a\x20\x20const\x20{\x20setupMainProcessHotReload\x20}\x20=\x20require(\x27./hot-reload\x27);\x0a\x20\x20//\x20console.log(\x27setupMainProcessHotReload\x27,__dirname);\x0a\x20\x20setupMainProcessHotReload(__dirname);\x0a}';}module[W(0x12e)]={'processMainProcessFile':processMainProcessFile};