1class DiskMirror{constructor(url){this.diskMirrorUrl=url;this.setSk();this.setController('/FsCrud')}xorEncrypt(value){let encrypted=value;const sk_str=this.sk.toString();for(let i=0;i<sk_str.length;i++){encrypted-=sk_str.charCodeAt(i)<<1}return encrypted}setController(controllerName){this.controller=controllerName}getController(){return this.controller}setSk(key=0,domain=undefined){this.sk=key;if(key!==0){this.setDiskMirrorXorSecureKey(domain)}}getSk(){return this.sk}upload(params,file,okFun=undefined,errorFun=(e)=>'res'in e?alert(e['res']):alert(e),checkFun=undefined){if(checkFun!==undefined&&!checkFun(params,file)){return}const formData=new FormData();params["secure.key"]=this.getSk();const blob=new Blob([JSON.stringify(params)],{type:'application/json'});formData.append('params',blob,"params");formData.append('file',file,"file");axios.defaults.withCredentials=true;axios({method:'post',url:this.diskMirrorUrl+this.getController()+'/add',data:formData,headers:{'Content-Type':'multipart/form-data'}}).then(function(res){if(res.data['res']!=='ok!!!!'){if(errorFun!==undefined){errorFun(res.data)}return}if(okFun!==undefined){okFun(res.data)}else{console.info(res.data)}}).catch(function(err){if(errorFun!==undefined){errorFun(err)}else{console.error(err)}})}getUrls(userId,type,okFun=undefined,errorFun=(e)=>'res'in e?alert(e['res']):alert(e),checkFun=undefined,){if(userId===undefined||type===undefined||type===''){const err="æ¨å¿
é¡»è¦è¾å
¥ userId 以å type åæ°æå¯ä»¥è¿è¡ url çè·å";if(errorFun!==undefined){errorFun(err)}else{console.error(err)}return}const formData=new FormData();const params={userId:userId,type:type,"secure.key":this.getSk()};if(checkFun!==undefined&&!checkFun(params)){return}const blob=new Blob([JSON.stringify(params)],{type:'application/json'});formData.append('params',blob,"params");axios.defaults.withCredentials=true;axios({method:'post',url:this.diskMirrorUrl+this.getController()+'/getUrls',data:formData,headers:{'Content-Type':'multipart/form-data'}}).then(function(res){if(res.data['res']!=='ok!!!!'){if(errorFun!==undefined){errorFun(res.data)}return}if(okFun!==undefined){okFun(res.data)}else{console.info(res.data)}}).catch(function(err){if(errorFun!==undefined){errorFun(err)}else{console.error(err)}})}remove(userId,type,fileName,okFun=undefined,errorFun=(e)=>'res'in e?alert(e['res']):alert(e),checkFun=undefined,){if(userId===undefined||type==null||type===''||fileName===undefined||fileName===''){const err="æ¨å¿
é¡»è¦è¾å
¥ userId 以å type å fileName åæ°æå¯ä»¥è¿è¡å é¤";if(errorFun!==undefined){errorFun(err)}else{console.error(err)}return}const formData=new FormData();const params={fileName:fileName,userId:userId,type:type,"secure.key":this.getSk()};if(checkFun!==undefined&&!checkFun(params)){return}const blob=new Blob([JSON.stringify(params)],{type:'application/json'});formData.append('params',blob,"params");axios.defaults.withCredentials=true;axios({method:'post',url:this.diskMirrorUrl+this.getController()+'/remove',data:formData,headers:{'Content-Type':'multipart/form-data'}}).then(function(res){if(res.data['res']!=='ok!!!!'){if(errorFun!==undefined){errorFun(res.data)}return}if(okFun!==undefined){okFun(res.data)}else{console.info(res.data)}}).catch(function(err){if(errorFun!==undefined){errorFun(err)}else{console.error(err)}})}reName(userId,type,fileName,newName,okFun=undefined,errorFun=(e)=>'res'in e?alert(e['res']):alert(e),checkFun=undefined){if(userId===undefined||type==null||type===''||fileName===undefined||fileName===''||newName===undefined||newName===''){const err="æ¨å¿
é¡»è¦è¾å
¥ userId å type 以å fileName å newName åæ°æå¯ä»¥è¿è¡éå½å";if(errorFun!==undefined){errorFun(err)}else{console.error(err)}return}const formData=new FormData();const params={fileName:fileName,newName:newName,userId:userId,type:type,"secure.key":this.getSk()};if(checkFun!==undefined&&!checkFun(params)){return}const blob=new Blob([JSON.stringify(params)],{type:'application/json'});formData.append('params',blob,"params");axios.defaults.withCredentials=true;axios({method:'post',url:this.diskMirrorUrl+this.getController()+'/reName',data:formData,headers:{'Content-Type':'multipart/form-data'}}).then(function(res){if(res.data['res']!=='ok!!!!'){if(errorFun!==undefined){errorFun(res.data)}return}if(okFun!==undefined){okFun(res.data)}else{console.info(res.data)}}).catch(function(err){if(errorFun!==undefined){errorFun(err)}else{console.error(err)}})}mkdirs(userId,type,fileName,okFun=undefined,errorFun=(e)=>'res'in e?alert(e['res']):alert(e),checkFun=undefined){if(userId===undefined||t
1ype==null||type===''||fileName===undefined||fileName===''){const err="æ¨å¿ é¡»è¦è¾å ¥ userId å type 以å fileName åæ°æå¯ä»¥è¿è¡æä»¶ç®å½çå建";if(errorFun!==undefined){errorFun(err)}else{console.error(err)}return}const formData=new FormData();const params={fileName:fileName,userId:userId,type:type,"secure.key":this.getSk()};if(checkFun!==undefined&&!checkFun(params)){return}const blob=new Blob([JSON.stringify(params)],{type:'application/json'});formData.append('params',blob,"params");axios.defaults.withCredentials=true;axios({method:'post',url:this.diskMirrorUrl+this.getController()+'/mkdirs',data:formData,headers:{'Content-Type':'multipart/form-data'}}).then(function(res){if(res.data['res']!=='ok!!!!'){if(errorFun!==undefined){errorFun(res.data)}return}if(okFun!==undefined){okFun(res.data)}else{console.info(res.data)}}).catch(function(err){if(errorFun!==undefined){errorFun(err)}else{console.error(err)}})}downLoad(userId,type,fileName,okFun=undefined,errorFun=(e)=>'res'in e?alert(e['res']):alert(e),checkFun=undefined,version=1){if(userId===undefined||type==null||type===''||fileName===undefined||fileName===''||okFun===undefined){const err="æ¨å¿ é¡»è¦è¾å ¥ userId å type 以å fileName å okFun åæ°æå¯ä»¥è¿è¡æä»¶å¯¹è±¡çè·åï¼";if(errorFun!==undefined){errorFun(err)}else{console.error(err)}return}if(checkFun!==undefined&&!checkFun({userId:userId,type:type,fileName:fileName})){return}okFun(version<2?this.diskMirrorUrl+this.getController()+`/downLoad/${userId}/${type}?fileName=${fileName}` : this.diskMirrorUrl + this.getController() + `/downLoad2/${userId}/${type}/${this.getSk()}/${fileName.startsWith('/') ? fileName.substring(1) : fileName}`); 2} 3 4 /** 5 * åå端ä¸è½¬åä¸ä¸ªæä»¶ 6 * @param params {{ 7 * fileName: string, 8 * userId: int, 9 * type: 'Binary'|'TEXT', 10 * url: string 11 * }} è¿éæ¯è¯·æ±åæ°å¯¹è±¡ å ¶ä¸çæä»¶åå代表ä¸ä¼ å°å端ä¹åçæä»¶ååï¼userId 代表çå°±æ¯æä»¶è¦ä¸ä¼ å°çæå®ç©ºé´çidï¼typeå°±æ¯ä»£è¡¨çæä»¶çç±»å æ¯æäºè¿å¶åææ¬ä¸¤ç§æ ¼å¼ 12 * @param okFun {function} æä½æåä¹åçåè°å½æ° è¾å ¥æ¯è¢«ä¸ä¼ æä»¶çjson对象 13 * @param errorFun {function} æä½å¤±è´¥ä¹åçåè°å½æ° è¾å ¥æ¯éè¯¯ä¿¡æ¯ 14 * @param checkFun {function} ä¸ä¼ åçæ£æ¥å½æ° è¾å ¥æ¯ä¸ä¼ çæä»¶å¯¹è±¡ç json æ°æ® ï¼å¦æè¿åçæ¯ä¸ä¸ªfalse å代表ä¸è¿è¡ä¸ä¼ æä½ 15 */ 16 transferDeposit(params, okFun = undefined, errorFun = (e) => 'res' in e ? alert(e['res']) : alert(e), checkFun = undefined) { 17 if (checkFun !== undefined && !checkFun(params)) { 18 return; 19 } 20 const formData = new FormData(); 21 // 设置请æ±åæ°æ°æ®å 22 params["secure.key"] = this.getSk(); 23 const blob = new Blob([JSON.stringify(params)], { 24 type: 'application/json' 25 }); 26 formData.append('params', blob, "params"); 27 // å¼å§è¿è¡è¯·æ±åé 28 axios.defaults.withCredentials = true; 29 axios( 30 { 31 method: 'post', 32 url: this.diskMirrorUrl + this.getController() + '/transferDeposit', 33 data: formData, 34 headers: { 35 'Content-Type': 'multipart/form-data' 36 } 37 } 38 ).then(function (res) { 39 if (res.data['res'] !== 'ok!!!!') { 40 if (errorFun !== undefined) { 41 errorFun(res.data); 42 } 43 return; 44 } 45 // å¤çæå 46 if (okFun !== undefined) { 47 okFun(res.data); 48 } else { 49 console.info(res.data); 50 } 51 }).catch(function (err) { 52 // å¤çé误 53 if (errorFun !== undefined) { 54 errorFun(err); 55 } else { 56 console.error(err); 57 } 58 }); 59 } 60 61 /** 62 * ååç«¯ä¸æ¥è¯¢æä»¶è½¬åæ åµ 63 * @param params {{ 64 * userId: int, 65 * type: 'Binary'|'TEXT', 66 * }} è¿éæ¯è¯·æ±åæ°å¯¹è±¡ å ¶ä¸çæä»¶åå代表ä¸ä¼ å°å端ä¹åçæä»¶ååï¼userId 代表çå°±æ¯æä»¶è¦ä¸ä¼ å°çæå®ç©ºé´çidï¼typeå°±æ¯ä»£è¡¨çæä»¶çç±»å æ¯æäºè¿å¶åææ¬ä¸¤ç§æ ¼å¼ 67 * @param okFun {function} æä½æåä¹åçåè°å½æ° è¾å ¥æ¯è¢«ä¸ä¼ æä»¶çjson对象 68 * @param errorFun {function} æä½å¤±è´¥ä¹åçåè°å½æ° è¾å ¥æ¯éè¯¯ä¿¡æ¯ 69 * @param checkFun {function} ä¸ä¼ åçæ£æ¥å½æ° è¾å ¥æ¯ä¸ä¼ çæä»¶å¯¹è±¡ç json æ°æ® ä»¥å æä»¶å¯¹è±¡æ¬èº«ï¼å¦æè¿åçæ¯ä¸ä¸ªfalse å代表ä¸è¿è¡ä¸ä¼ æä½ 70 */ 71 transferDepositStatus(params, okFun = undefined, errorFun = (e) => 'res' in e ? alert(e['res']) : alert(e), checkFun = undefined) {
72 if (checkFun !== undefined && !checkFun(params)) { 73 return; 74 } 75 const formData = new FormData(); 76 // 设置请æ±åæ°æ°æ®å 77 params["secure.key"] = this.getSk(); 78 const blob = new Blob([JSON.stringify(params)], { 79 type: 'application/json' 80 }); 81 formData.append('params', blob, "params"); // å¼å§è¿è¡è¯·æ±åé 82 axios.defaults.withCredentials = true; 83 axios( 84 { 85 method: 'post', 86 url: this.diskMirrorUrl + this.getController() + '/transferDepositStatus', 87 data: formData, 88 headers: { 89 'Content-Type': 'multipart/form-data' 90 } 91 } 92 ).then(function (res) { 93 // å¤çæå 94 if (okFun !== undefined) { 95 okFun(res.data); 96 } else { 97 console.info(res.data); 98 } 99 }).catch(function (err) { 100 // å¤çé误 101 if (errorFun !== undefined) { 102 errorFun(err); 103 } else { 104 console.error(err); 105 } 106 }); 107 } 108 109 /** 110 * è·åæå®ç©ºé´çæå¤§å®¹é å使¯ åè 111 * 112 * éè¦ç¡®ä¿è¿ç¨ç diskMirror æå¡å¨æ¯å¨ 2024å¹´ 2 æ 17 æ¥ ä»¥åä¹ååå¸çï¼ï¼ 113 * 114 * @param userId {int} éè¦è¢«æ£ç´¢ç空é´id 115 * @param okFun {function} æä½æåä¹åçåè°å½æ° è¾å ¥æ¯è¢«å建çæä»¶ç®å½çjson对象 116 * @param errorFun {function} æä½å¤±è´¥ä¹åçåè°å½æ° è¾å ¥æ¯éè¯¯ä¿¡æ¯ 117 */ 118 getSpaceMaxSize(userId, okFun = undefined, errorFun = (e) => 'res' in e ? alert(e['res']) : alert(e)) { 119 // å¼å§è¿è¡è¯·æ±åé 120 axios.defaults.withCredentials = true; 121 axios( 122 { 123 method: 'post', 124 url: this.diskMirrorUrl + this.getController() + '/getSpaceSize', 125 params: { 126 spaceId: userId.toString() 127 } 128 } 129 ).then(function (res) { 130 const data = res.data; 131 if (isNaN(data['res'])) { 132 if (errorFun !== undefined) { 133 errorFun(data['res'] + " is NAN!!!"); 134 } 135 return; 136 } 137 if (okFun !== undefined) { 138 okFun(data['res']); 139 } else { 140 console.info(data['res']); 141 } 142 }).catch(function (err) { 143 if (errorFun !== undefined) { 144 errorFun(err); 145 } else { 146 console.error(err); 147 } 148 }); 149 } 150 151 /** 152 * è·åå端ä¸ççéå æ ¸ççæ¬ 153 * 154 * éè¦ç¡®ä¿è¿ç¨ç diskMirror æå¡å¨æ¯å¨ 2024å¹´ 2 æ 17 æ¥ ä»¥åä¹ååå¸çï¼ï¼ 155 * 156 * @param okFun {function} æä½æåä¹åçåè°å½æ° è¾å ¥æ¯è¢«å建çæä»¶ç®å½çjson对象 157 * @param errorFun {function} æä½å¤±è´¥ä¹åçåè°å½æ° è¾å ¥æ¯éè¯¯ä¿¡æ¯ 158 */ 159 getVersion(okFun = undefined, errorFun = (e) => 'res' in e ? alert(e['res']) : alert(e)) { 160 // å¼å§è¿è¡è¯·æ±åé 161 axios.defaults.withCredentials = true; 162 axios( 163 { 164 method: 'post', 165 url: this.diskMirrorUrl + this.getController() + '/getVersion', 166 } 167 ).then(function (res) { 168 if (okFun !== undefined) { 169 okFun(res.data); 170 } else { 171 console.info(res.data); 172 } 173 }).catch(function (err) { 174 if (errorFun !== undefined) { 175 errorFun(err); 176 } else { 177 console.error(err); 178 } 179 }); 180 } 181 182 /** 183 * è·åæå®ç©ºé´ç已使ç¨å®¹é å使¯ åè 184 * @param userId {int} éè¦è¢«æ£ç´¢ç空é´id 185 * @param type {'Binary'|'TEXT'} éè¦è¢«æ£ç´¢çæä»¶ç±»å 186 * @param okFun {function} æä½æåä¹åçåè°å½æ° è¾å ¥æ¯è®¡ç®åºæ¥ç已使ç¨å®¹é 187 * @param errorFun {function} æä½å¤±è´¥ä¹åçåè°å½æ° è¾å ¥æ¯éè¯¯ä¿¡æ¯ 188 */ 189 getUseSize(userId, type, okFun = undefined, errorFun = (e) => 'res' in e ? alert(e['res']) : alert(e)) { 190 if (userId === undefined || type == null || type === '') { 191 const err = "æ¨å¿ é¡»è¦è¾å ¥ userId å type åæ°æå¯ä»¥è¿è¡ä½¿ç¨æ°éçè·å"; 192 if (errorFun !== undefined) { 193 errorFun(err); 194 } else { 195 console.error(err); 196 } 197 return; 198 } 199 const formData = new FormData(); 200 // 设置请æ±åæ° 201 const params = { 202 userId: userId, 203 type: type,
204 "secure.key": this.getSk() 205 }; 206 const blob = new Blob([JSON.stringify(params)], { 207 type: 'application/json' 208 }); 209 formData.append('params', blob, "params"); 210 211 // å¼å§è¿è¡è¯·æ±åé 212 axios.defaults.withCredentials = true; 213 axios( 214 { 215 method: 'post', 216 url: this.diskMirrorUrl + this.getController() + '/getUseSize', 217 data: formData, 218 headers: { 219 'Content-Type': 'multipart/form-data' 220 } 221 } 222 ).then(function (res) { 223 if (okFun !== undefined) { 224 okFun(res.data); 225 } else { 226 console.info(res.data); 227 } 228 }).catch(function (err) { 229 if (errorFun !== undefined) { 230 errorFun(err); 231 } else { 232 console.error(err); 233 } 234 }); 235 } 236 237 /** 238 * å¨ä¸äºæä½ä¸ï¼æä»¬å¯è½éè¦å° sk å å«å¨ cookie ä¸ï¼å æ¤å¯è½ä¼éè¦ä½¿ç¨è¿ä¸ªå½æ°ï¼è¿ä¸ªå½æ°ä¸è¬æ¥è¯´ä¸éè¦ç¨æ·æå¨è°ç¨ï¼ 239 * 240 * å 为å¨è®¾ç½®å¥½ sk çæ¶åï¼å®ä¼èªå¨è¢«è°ç¨ï¼è¯·å¿éæä¿®æ¹æ¤å½æ°å¸¦æ¥çcookieï¼æäºå端æå¡ä¼ä½¿ç¨å°ï¼ 241 * 242 * @param domain {string} éè¦è¢«è®¾ç½®çcookieçåå é»è®¤æ¯å½åå 243 */ 244 setDiskMirrorXorSecureKey(domain) { 245 // æ£æ¥å为 diskMirror_xor_secure_key ç cookie æ¯å¦åå¨ 246 const cookieName = 'diskMirror_xor_secure_key'; 247 // 妿åå¨å°±æ´æ° cookie çå¼ 248 const encryptedValue = this.xorEncrypt(this.getSk()); 249 if (this.isSetCookie && this.cookieValue === encryptedValue && this.cookieDoMain === domain) { 250 // å¦æè®¾ç½®è¿ cookie ä¸ å¼ å å ç¸å åè¿éå°±ä¸ç»§ç»æ´æ° cookie äº 251 return; 252 } 253 if (domain) { 254 document.cookie = `${cookieName}=${encryptedValue};path=/;domain=${domain}`; 255 return; 256 } 257 document.cookie = `${cookieName}=${encryptedValue};path=/`; 258 // æ è®° cookie ä¿¡æ¯ 259 this.isSetCookie = true; 260 this.cookieValue = encryptedValue; 261 this.cookieDoMain = domain; 262 } 263 264 /** 265 * è·åæå®ç©ºé´çææçè¿åº¦æ¡ 266 * @param userId {int|string} æå®è¦è·åå°çæä»¶è¿åº¦æ°æ®å¯¹åºç空é´id 267 * @param okFun {function} æä½æåä¹åçåè°å½æ° è¾å ¥æ¯è¢«æä»¶è¿åº¦çjson对象 268 * @param errorFun {function} æä½å¤±è´¥ä¹åçåè°å½æ° è¾å ¥æ¯éè¯¯ä¿¡æ¯ 269 * @param checkFun {function} æä½åçæ£æ¥å½æ° è¾å ¥æ¯è¯·æ±åæ°å¯¹è±¡ï¼å¦æè¿åçæ¯ä¸ä¸ªfalse åä»£è¡¨æ£æ¥å¤±è´¥ä¸ç»§ç»æä½ 270 */ 271 getAllProgressBar(userId, okFun = undefined, errorFun = (e) => 'res' in e ? alert(e['res']) : alert(e), checkFun = undefined) { 272 if (userId === undefined || okFun === undefined) { 273 const err = "æ¨å¿ é¡»è¦è¾å ¥ userId å okFun åæ°æå¯ä»¥è¿è¡æä»¶å¯¹è±¡çè·åï¼"; 274 if (errorFun !== undefined) { 275 errorFun(err); 276 } else { 277 console.error(err); 278 } 279 return; 280 } 281 if (checkFun !== undefined && !checkFun(userId)) { 282 return; 283 } 284 axios.defaults.withCredentials = true; 285 // å¼å§è·å 286 axios( 287 { 288 method: 'post', 289 url: this.diskMirrorUrl + this.getController() + '/getAllProgressBar', 290 params: { 291 id: userId 292 } 293 } 294 ).then(function (res) { 295 // å¤çæå 296 if (okFun !== undefined) { 297 okFun(res.data); 298 } else { 299 console.info(res.data); 300 } 301 }).catch(function (err) { 302 // å¤çé误 303 if (errorFun !== undefined) { 304 errorFun(err); 305 } else { 306 console.error(err); 307 } 308 }); 309 } 310 311 /** 312 * å°å½å客æ·ç«¯è¿æ¥çæå¡å¨å ³æºï¼å¦ææå¡å¨ç«¯åæ¯æçè¯ï¼åä¼è¿åå ³æºæææä¿¡æ¯ï¼ 313 * 314 * @param password {string} å ³æºæä½çæ ¡éªç ï¼å¦ææ ¡éªç 䏿£ç¡®ï¼åæ æ³å¤çå ³æºè¯·æ± 315 * @param okFun {function} æä½æåä¹åçåè°å½æ° è¾å ¥æ¯è¢«æä»¶è¿åº¦çjson对象 316 * @param errorFun {function} æä½å¤±è´¥ä¹åçåè°å½æ° è¾å ¥æ¯éè¯¯ä¿¡æ¯ 317 */ 318 shutdown(password, okFun = undefined, errorFun = (e) => 'res' in e ? alert(e['res']) : alert(e)) { 319 axios.defaults.withCredentials = true; 320 // å¼å§è·å 321 axios( 322 { 323 method: 'post', 324 url: this.diskMirrorUrl + this.getController() + '/shutdown',params:{password:password}}).then(function(res){if(okFun!==undefined){okFun(res.data)}else{console.info(res.data)}}).catch(function(err){if(errorFun!==undefined){errorFun(err)}else{console.error(err)}})}}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.