diff --git a/README.md b/README.md index 8a89bc9..8fd1b6e 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@  - WinXray V4.1 增加CTRL+C/CTRL+V/CTRL+A/DELETE 快捷键操作!增加多选下批量复制及生成二维码!现在支持了文件解析节点(文件拖拽进入软件即可)! + WinXray V4.2 修复文件拖拽解析节点后空白的BUG! 导语: 请用官网地址下载:https://www.winxray.com - 另外推荐全协议机场:[速蛙云VPN](https://ads.iuvpn.com) + 推荐全协议机场[速蛙云VPN](https://ads.iuvpn.com) ![xray](./screenshots/Xray.png) diff --git a/default.aproj b/default.aproj index dd26c8b..1cc73f7 100644 --- a/default.aproj +++ b/default.aproj @@ -1,5 +1,5 @@  - + diff --git a/forms/main/xray.aardio b/forms/main/xray.aardio index 7122631..1fbdbc1 100644 --- a/forms/main/xray.aardio +++ b/forms/main/xray.aardio @@ -1040,15 +1040,14 @@ frmXray.onDropFiles = function(files){ if(str){ str = ..string.trim(str,'"\'\t\r\n '); - var impoutbounds = xray.outbounds.importFromString(str); - if(#impoutbounds){ - ..table.append(config.proxy.outbounds,impoutbounds); - publish("uiCommand.OutboundsChange","obadd",#impoutbounds); - publish("uiCommand.restartCore","change"); - publish("outbounds.updateConfigJson"); - frmXray.msgOk("已成功导入" + #impoutbounds + "个节点",1200); - return; - } + var outbounds = xray.outbounds.importFromString(str); + if(#outbounds){ + ..table.append(config.proxy.outbounds,outbounds); + publish("uiCommand.restartxrayCore"); + publish("outbounds.updateConfigJson"); + frmXray.msgOk("已成功导入" + #outbounds + "个服务器",1200); + return; + } } } frmXray.msgFrown('未能在文件中导入节点!'); diff --git a/lib/xray/outbounds.aardio b/lib/xray/outbounds.aardio index 649baf4..aeac2c0 100644 --- a/lib/xray/outbounds.aardio +++ b/lib/xray/outbounds.aardio @@ -203,7 +203,7 @@ var _subscriptionResponseCache = { importFromString = function(str,subscribeUrl){ if(!str){ return; } str = ..string.trim(str); - + var jsonData; if(..string.match(str,"%\[\]") || ( ..string.match(str,"%\{\}") && !..string.match(str,"%\{\}.+%\{\}") @@ -371,8 +371,8 @@ importFromString = function(str,subscribeUrl){ if(..string.match(str,"^\s*[\w=+/-_]+\s*$")){ str = ..crypt.decodeBin(str); if(!str) return; - } - + } + var outbounds = ..table.array(); for(line in ..string.lines(str) ){ if(#outbounds>=1500){ @@ -1200,10 +1200,117 @@ var currentActiveOutbound = ..globalActiveOutbound; ..publish("uiCommand.print","已自动刷新" + count + "个订阅服务器。") } ) +/*importFromClash = function(str,node){ + if(node){ + var start = false;var strTemp=""; + var levelTable = ..table.array();var levelATable = ..table.array(); + var levelLast = 0;var levelALast = 0; + for(line in ..string.lines(str) ){ + //删除注释字段和空白行 + line = ..string.splitEx(line,'\#')[1]; + if( line===null || ..string.match(line,"^\s*$") ){continue;} + //确定proxies范围 + if(..string.match(line,"^\a")){ + if(..string.startWith(line,"proxies")){start = true;continue;} + else {if(start){break;}continue;} + } + + if(start){ + if( ..string.match(line,"^\s*\-\s*%\{\}\s*$") ){strTemp += line+'\n';} + elseif( !..string.match(line,"^\s*\-\s*%\{\}\s*$") ){ + var numNow = #(..string.match(line,"^(\s*)\a"));//键缩进量 + var numANow = #(..string.match(line,"^(\s*)\-"));//数组缩进量 + //确定数组缩进等级 + var levelA; + for(index,num in levelATable){if(num = numANow){levelA=index;break;}} + if(!levelA && numANow){ + ..table.push(levelATable,numANow); + levelA=..table.count(levelATable); + } + elseif(!levelA && !numANow){levelA=0} + + if( levelA>1 ){ + line = ..string.replace(line,"^\s*(-)",''); + numNow = #(..string.match(line,"^(\s*)\a")); + } + elseif( levelA==1 ){ + var temp = '\n-{'; + if(levelLast){for(i=1;levelLast;1){temp = '}'+temp;}} + line = ..string.replace(line,"^\s*-\s*",temp); + } + + if( ..string.match(line,"^\}*\n\-\{\s*\a") ){strTemp += line+","}//-name:1 + elseif( ..string.match(line,"^\}\n\-\{\s*$") ){strTemp += line}//- + + levelALast = levelA; + //确定键缩进等级 + var level; + for(index,num in levelTable){if(num=numNow){level=index;break;}} + if(!level && numNow){..table.push(levelTable,numNow);level=..table.count(levelTable);} + elseif(!level && !numNow){level=0} + + if( ..string.match(line,"^\s*\a[^\s\:]*(\:)\s*$") ){//name: + line = ..string.trim(line); + if( levelLast>0 && level>levelLast ){strTemp += line+"{"} + elseif( level==levelLast ){strTemp += ","+line+"{"} + elseif( levellevelLast ){strTemp += line} + elseif( levelLast>0 && level