Skip to content

Commit 54871d3

Browse files
committed
bug fix
1 parent d5dc251 commit 54871d3

File tree

17 files changed

+127
-872
lines changed

17 files changed

+127
-872
lines changed

app/localWebServer.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ const Tool = require("./tools/initSystem");
2323
const Async = require("async");
2424
const Fs = require("fs");
2525
const Util = require("util");
26-
const freePort = require("portastic");
2726
const Uuid = require("node-uuid");
2827
const Imap = require("./tools/imap");
2928
const coNETConnect_1 = require("./tools/coNETConnect");
@@ -77,14 +76,6 @@ const imapErrorCallBack = (message) => {
7776
}
7877
return -1;
7978
};
80-
const findPort = (port, CallBack) => {
81-
return freePort.test(port).then(isOpen => {
82-
if (isOpen)
83-
return CallBack(null, port);
84-
++port;
85-
return findPort(port, CallBack);
86-
});
87-
};
8879
class localServer {
8980
constructor(cmdResponse, test) {
9081
this.cmdResponse = cmdResponse;

app/localWebServer.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import * as Tool from './tools/initSystem'
2222
import * as Async from 'async'
2323
import * as Fs from 'fs'
2424
import * as Util from 'util'
25-
import * as freePort from 'portastic'
2625
import * as Uuid from 'node-uuid'
2726
import * as Imap from './tools/imap'
2827
import CoNETConnectCalss from './tools/coNETConnect'
@@ -96,14 +95,6 @@ const imapErrorCallBack = ( message: string ) => {
9695

9796
}
9897

99-
const findPort = ( port: number, CallBack ) => {
100-
return freePort.test ( port ).then ( isOpen => {
101-
if ( isOpen )
102-
return CallBack ( null, port )
103-
++ port
104-
return findPort ( port, CallBack )
105-
})
106-
}
10798

10899
export default class localServer {
109100
private expressServer = Express()

app/package.json

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "conet",
3-
"version": "3.0.6",
3+
"version": "3.0.7",
44
"license": "MIT",
55
"description": "CoNET",
66
"repository": {
@@ -26,7 +26,6 @@
2626
"node-uuid": "^1.4.8",
2727
"nodemailer": "^6.3.1",
2828
"openpgp": "^4.6.2",
29-
"portastic": "^1.0.1",
3029
"pug": "^2.0.4",
3130
"socket.io": "^2.3.0",
3231
"socket.io-client": "^2.3.0"
@@ -35,20 +34,18 @@
3534
"start": "node main false true"
3635
},
3736
"devDependencies": {
38-
"@types/async": "^2.4.2",
39-
"@types/cleave.js": "^1.4.0",
40-
"@types/cookie-parser": "^1.4.1",
41-
"@types/express": "^4.17.0",
37+
"@types/async": "^3.0.3",
38+
"@types/cleave.js": "^1.4.1",
39+
"@types/cookie-parser": "^1.4.2",
40+
"@types/express": "^4.17.1",
4241
"@types/jcanvas": "^15.2.2",
43-
"@types/jquery": "^3.3.30",
42+
"@types/jquery": "^3.3.31",
4443
"@types/jquery.cookie": "^1.4.31",
4544
"@types/knockout": "^3.4.66",
46-
"@types/openpgp": "0.0.29",
45+
"@types/openpgp": "^4.4.7",
4746
"@types/semantic-ui": "^2.2.7",
48-
"@types/socket.io": "^1.4.40",
47+
"@types/socket.io": "^2.1.4",
4948
"@types/socket.io-client": "^1.4.32",
50-
"istanbul": "^0.4.5",
51-
"nyc": "^11.9.0",
52-
"source-map-support": "^0.5.12"
49+
"source-map-support": "^0.5.16"
5350
}
5451
}

app/public/scripts/appsManager.js

Lines changed: 34 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ const _mainMenuObj = {
2424
]
2525
}
2626
],
27+
appScript: [{
28+
startup: {},
29+
_appScriptGlobal: {}
30+
}]
2731
};
2832
const _appScriptGlobal = `
2933
@@ -325,7 +329,6 @@ const _appScript = {
325329
this.showErrorMessage = ko.observable(false);
326330
this.showHtmlCodePage = ko.observable(false);
327331
this.showImgPage = ko.observable(true);
328-
this.urlPool = [];
329332
this.png = ko.observable('');
330333
const self = this;
331334
_view.showIconBar(false);
@@ -342,18 +345,21 @@ const _appScript = {
342345
const regex = new RegExp(`${filename}`, 'g');
343346
const index = html.indexOf(`${filename}`);
344347
if (index > -1) {
345-
if (/\.js$/.test(filename)) {
348+
if (/js$/.test(filename)) {
346349
_data = _data.replace(/^data:text\/plain;/, 'data:application/javascript;');
347350
}
348-
else if (/\.css$/.test(filename)) {
351+
else if (/css$/.test(filename)) {
349352
_data = _data.replace(/^data:text\/plain;/, 'data:text/css;');
350353
}
351-
else if (/\.html$|\.htm$/.test(filename)) {
354+
else if (/html$|htm$/.test(filename)) {
352355
_data = _data.replace(/^data:text\/plain;/, 'data:text/html;');
353356
}
354-
else if (/\.pdf$/.test(filename)) {
357+
else if (/pdf$/.test(filename)) {
355358
_data = _data.replace(/^data:text\/plain;/, 'data:text/html;');
356359
}
360+
else {
361+
const kkk = _data;
362+
}
357363
html = html.replace(regex, _data);
358364
}
359365
};
@@ -363,11 +369,13 @@ const _appScript = {
363369
});
364370
self.png(data.img);
365371
const htmlBolb = new Blob([html], { type: 'text/html' });
366-
const url = window.URL.createObjectURL(htmlBolb);
367-
self.urlPool.push(url);
368-
//_view.showLanguageSelect ( false )
372+
const _url = window.URL.createObjectURL(htmlBolb);
373+
const fileReader = new FileReader();
374+
fileReader.onloadend = evt => {
375+
return window.URL.revokeObjectURL(_url);
376+
};
369377
self.showLoading(false);
370-
self.htmlIframe(url);
378+
self.htmlIframe(_url);
371379
});
372380
});
373381
}
@@ -379,9 +387,6 @@ const _appScript = {
379387
this.showImgPage(false);
380388
this.showHtmlCodePage(false);
381389
this.png(null);
382-
this.urlPool.forEach(n => {
383-
window.URL.revokeObjectURL(n);
384-
});
385390
this.exit();
386391
}
387392
imgClick() {
@@ -523,6 +528,7 @@ const _appScript = {
523528
},
524529
search_form: (self, event) => {
525530
const search_text = self.searchInputText();
531+
self.showSearchesRelated(false);
526532
self.showInputLoading(true);
527533
const width = window.innerWidth;
528534
const height = window.outerHeight;
@@ -555,34 +561,6 @@ const _appScript = {
555561
*
556562
* test Unit
557563
*/
558-
setTimeout(() => {
559-
/** test error */
560-
/*
561-
return errorProcess ( 'eee ' )
562-
/** */
563-
/** Test response from Local host */
564-
/** test status */
565-
/*
566-
setTimeout (() => {
567-
self.loadingGetResponse ( false )
568-
return self.conetResponse ( true )
569-
}, 2000 )
570-
return self.loadingGetResponse ( true )
571-
/** */
572-
/** test normail result */
573-
/*
574-
self.showInputLoading ( false )
575-
self.loadingGetResponse ( false )
576-
self.conetResponse ( false )
577-
578-
const args = googleSearchResult1[0]
579-
self.searchInputTextShow ( search_text )
580-
self.searchItemsArray ( args.param )
581-
self.returnSearchResultItemsInit ( args.param )
582-
return self.showResultItems ( self, args.param )
583-
/** */
584-
}, 2000);
585-
/** */
586564
return _view.keyPairCalss.emitRequest(com, (err, com) => {
587565
if (err) {
588566
return errorProcess(err);
@@ -736,21 +714,6 @@ const _appScript = {
736714
break;
737715
}
738716
}
739-
/** TEST unit */
740-
setTimeout(() => {
741-
/** Error Test */
742-
/*
743-
return showError ( 'dd' )
744-
/** */
745-
/** Status Test */
746-
/*
747-
setTimeout (() => {
748-
self.nextButtonLoadingGetResponse ( false )
749-
self.nextButtonConetResponse ( true )
750-
}, 2000 )
751-
return self.nextButtonLoadingGetResponse ( true )
752-
/** */
753-
}, 2000);
754717
/** */
755718
return _view.keyPairCalss.emitRequest(com, (err, com) => {
756719
if (err) {
@@ -996,6 +959,10 @@ const _appScript = {
996959
self.showSnapshop(false);
997960
}));
998961
},
962+
searchesRelatedSelect: (self, index) => {
963+
self.searchInputText(self.searchItem().searchesRelated[index].text);
964+
self.showSearchesRelated(false);
965+
},
999966
closeSimilarImagesResult: (self) => {
1000967
self.searchSimilarImagesList([]);
1001968
self.showMain(true);
@@ -1060,11 +1027,10 @@ const _appScript = {
10601027
const _media = Buffer.from(media[1], 'base64');
10611028
const ret = {
10621029
total_bytes: media[1].length,
1063-
media_type: type,
1030+
media_type: 'image/png',
10641031
rawData: media[1],
10651032
media_id_string: null
10661033
};
1067-
const uploadDataPool = [];
10681034
//if ( mediaData.length > maxImageLength) {
10691035
const exportImage = (_type, img) => {
10701036
return img.getBuffer(_type, (err, _buf) => {
@@ -1081,25 +1047,16 @@ const _appScript = {
10811047
return CallBack(err);
10821048
}
10831049
const uu = image.bitmap;
1084-
if (uu.height > uu.width) {
1085-
image.resize(Jimp.AUTO, imageMaxHeight);
1086-
}
1087-
else {
1088-
image.resize(imageMaxWidth, Jimp.AUTO);
1089-
}
1090-
if (/\/PNG/i.test(type)) {
1091-
return image.deflateStrategy(1, () => {
1092-
return exportImage(type, image);
1093-
});
1094-
}
1095-
if (/\/(JPEG|JPG)/i.test(type)) {
1096-
return image.quality(100, () => {
1097-
return exportImage(type, image);
1098-
});
1050+
if (uu.height + uu.width > imageMaxHeight + imageMaxWidth) {
1051+
if (uu.height > uu.widt) {
1052+
image.resize(Jimp.AUTO, imageMaxHeight);
1053+
}
1054+
else {
1055+
image.resize(imageMaxWidth, Jimp.AUTO);
1056+
}
10991057
}
1100-
// BMP and all other to PNG
1101-
ret.media_type = 'image/png';
1102-
return image.deflateStrategy(4, () => {
1058+
// to PNG
1059+
return image.deflateStrategy(2, () => {
11031060
return exportImage(ret.media_type, image);
11041061
});
11051062
});
@@ -1131,7 +1088,7 @@ const _appScript = {
11311088
if (err) {
11321089
return errorProcess(err);
11331090
}
1134-
const uuid = uuid_generate();
1091+
const uuid = uuid_generate() + '.png';
11351092
return _view.keyPairCalss.encrypt(data.rawData, (err, textData) => {
11361093
if (err) {
11371094
return errorProcess(err);
@@ -1221,7 +1178,7 @@ class appsManager {
12211178
};
12221179
const com = {
12231180
command: 'mainPage',
1224-
Args: null,
1181+
Args: [''],
12251182
error: null,
12261183
subCom: null
12271184
};

0 commit comments

Comments
 (0)