-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
508 lines (498 loc) · 17.3 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
<!--
* @Author: Letmeouted
* @Email: [email protected]
* @FilePath: \eapp-corp-projectc:\WebProject\SMNFiler\SMNFiler\index.html
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>SMNFiler</title>
<script src="node_modules/mdui/dist/js/mdui.min.js"></script>
<script src="node_modules/screenlog/dist/screenlog.min.js"></script>
<link rel="stylesheet" href="node_modules/mdui/dist/css/mdui.min.css" />
</head>
<body class="mdui-theme-primary-indigo mdui-bottom-nav-fixed">
<div class="mdui-tab mdui-tab-centered mdui-tab-full-width" mdui-tab>
<a href="#tab1" class="mdui-ripple mdui-tab-active" onmousedown="mOver1(this)">
<i id="tab1_icon" class="mdui-icon material-icons"></i></a>
<a href="#tab2" class="mdui-ripple" onmousedown="mOver2(this)">
<i id="tab2_icon" class="mdui-icon material-icons"></i></a>
<a href="#tab3" class="mdui-ripple" onmousedown="mOver3(this)">
<i id="tab3_icon" class="mdui-icon material-icons"></i>
</a>
<!-- <a href="#tab4" class="mdui-ripple" onmousedown="mOver4(this)">
<i id="tab4_icon" class="mdui-icon material-icons"></i>
</a> -->
</div>
<div id="tab1" class="mdui-p-a-1">
<div id="holder"
class="mdui-valign mdui-hoverable mdui-ripple mdui-shadow-1 mdui-m-a-2 mdui-color-theme mdui-img-rounded"
style="height: 200px">
<p class="mdui-center">
<i class="mdui-icon material-icons"></i>文件处理区
</p>
</div>
<div class="mdui-m-x-2 mdui-m-y-4">
<button class="mdui-btn mdui-ripple mdui-color-orange mdui-btn-raised mdui-float-left"
onclick="window.open('https://github.com/NTLx/SMNFiler')">
<i class="mdui-icon material-icons"></i>帮助
</button>
<div class="mdui-valign mdui-float-left" style="height: 15px; margin-left: 18px">
<p class="mdui-center">
<br />注意:文件名当中不能含有空格、特殊符号、中文
</p>
</div>
<button class="mdui-btn mdui-ripple mdui-color-teal mdui-btn-raised mdui-float-right" id="prompt"
onclick="window.close()">
<i class="mdui-icon material-icons"></i>退出
</button>
</div>
</div>
<div id="tab2" class="mdui-p-a-3">
<div class="mdui-valign mdui-col-xs-6 mdui-p-a-2 mdui-center">
<label class="mdui-switch">
<input id="change_chinese" type="checkbox" />
<i class="mdui-switch-icon"></i>
<span class="mdui-m-a-1">设置语言为中文</span>
</label>
</div>
<div class="mdui-valign mdui-col-xs-6 mdui-p-a-2 mdui-center">
<label class="mdui-switch">
<input id="peak_area" type="checkbox" />
<i class="mdui-switch-icon"></i>
<span class="mdui-m-a-1">峰面积代替峰高</span>
</label>
</div>
<div class="mdui-valign mdui-col-xs-6 mdui-p-a-2 mdui-center">
<label class="mdui-switch">
<input id="more_button" type="checkbox" />
<i class="mdui-switch-icon"></i>
<span class="mdui-m-a-1">更多计算结果</span>
</label>
</div>
<div class="mdui-valign mdui-col-xs-6 mdui-p-a-2 mdui-center">
<label class="mdui-switch">
<input id="sample_order" type="checkbox" checked />
<i class="mdui-switch-icon"></i>
<span class="mdui-m-a-1">保持输入样本顺序</span>
</label>
</div>
<div class="mdui-valign mdui-col-xs-6 mdui-p-a-2 mdui-center">
<label class="mdui-switch">
<button class="mdui-m-a-1 mdui-btn mdui-btn-raised mdui-ripple mdui-color-theme"
mdui-dialog="{target:'#dialog'}" id="customer">
自定义样本名
</button>
</label>
</div>
<div class="mdui-valign mdui-p-a-3">
<label>选择输出格式:</label>
</div>
<div class="mdui-valign" style="width: 140px; height: 40px">
<form class="mdui-center mdui-p-a-1">
<label class="mdui-radio mdui-center ">
<input id="utf" type="radio" name="group1" checked />
<i class="mdui-radio-icon"></i>UTF-8
</label>
<label class="mdui-radio mdui-center">
<input id="gbk" type="radio" name="group1" />
<i class="mdui-radio-icon"></i>GBK
</label>
</form>
</div>
<div class="mdui-dialog" id="dialog">
<div class="mdui-dialog-title">请自定义标准品样本名</div>
<div class="mdui-dialog-content">
<input type="text" name="sample" id="samples" />
</div>
<div class="mdui-dialog-actions">
<button class="mdui-btn mdui-ripple" mdui-dialog-cancel>取消</button>
<button class="mdui-btn mdui-ripple" mdui-dialog-confirm>确认</button>
</div>
</div>
</div>
<div id="tab3" class="mdui-p-a-1">
<div class="layout">
<div class="mdui-col-xs-12 panel">日志信息</div>
<div id="restore" class="mdui-col-xs-12 result2"></div>
</div>
</div>
<!-- <div id="tab4" class="mdui-p-a-1">
<div class="layout">
<div class="mdui-col-xs-12 panel">文件处理有误信息</div>
<div id="restderr" class="mdui-col-xs-12 result1">
</div>
</div>
</div> -->
<script>
var $ = mdui.$;
var inst = new mdui.Dialog("#dialog");
var sample_status = "STD";
// method
document
.getElementById("customer")
.addEventListener("click", function () {
mdui.snackbar({ message: "自定义标准品样本名" });
var dialog = document.getElementById("dialog");
dialog.addEventListener("confirm.mdui.dialog", function () {
console.log("confirm");
sample_status1 = document.getElementById("samples").value;
sample_status = sample_status1;
console.log(sample_status);
});
});
var Chinese = "";
var language = function () {
if ($("#change_chinese").is(":checked")) {
console.log("Language is Chinese");
mdui.snackbar({ message: "设置语言为中文" });
Chinese = "-cn";
} else {
console.log("Language is English");
mdui.snackbar({ message: "默认语言为英语" });
Chinese = "";
}
};
var more = "";
var more_status = function () {
if ($("#more_button").is(":checked")) {
console.log("more Calculation results");
mdui.snackbar({ message: "输出显示更多计算结果" });
more = "-v";
} else {
console.log("not more Calculation results");
mdui.snackbar({ message: "无更多计算结果" });
more = "";
}
};
var peak = "";
var peak_status = function () {
if ($("#peak_area").is(":checked")) {
console.log("peak area");
mdui.snackbar({ message: "峰面积代替峰高" });
peak = "-area";
} else {
console.log("peak height");
mdui.snackbar({ message: "峰高" });
peak = "";
}
};
var order = "-k";
var samplename_order = function () {
if ($("#sample_order").is(":checked")) {
console.log("sample_order");
mdui.snackbar({ message: "保持样本输入顺序" });
order = "-k";
} else {
console.log("not sample_order");
mdui.snackbar({ message: "不保持样本输入顺序" });
order = "";
}
};
var Encoding = "UTF8";
var encod_status = function () {
if ($("#gbk").is(":checked")) {
console.log("Output set GBK Encode");
mdui.snackbar({ message: "输出文件将以 GBK 格式编码" });
Encoding = "GBK";
Chinese = "-cn";
}
if ($("#utf").is(":checked")) {
console.log("Output set UTF-8 Encode");
mdui.snackbar({ message: "输出文件将以 UTF-8 格式编码" });
Encoding = "UTF8";
}
};
$("#utf").on("click", encod_status);
$("#gbk").on("click", encod_status);
$("#more_button").on("click", more_status);
$("#peak_area").on("click", peak_status);
$("#change_chinese").on("click", language);
$("#sample_order").on("click", samplename_order)
function mOver1(obj) {
mdui.snackbar({ message: "进入分析面板", timeout: 1000 });
}
function mOver2(obj) {
mdui.snackbar({ message: "进入设置面板", timeout: 1000 });
}
function mOver3(obj) {
mdui.snackbar({ message: "进入运行面板", timeout: 1000 })
}
// child_process.execFile method
var runningLogMessage =document.getElementById('restore').innerHTML
if(runningLogMessage === ""){
document.getElementById('restore').innerHTML += "<p style='text-align:center'>所有日志信息全部位于程序运行日志窗口中</p>"
}
var path = require("path");
var log =require('electron-log');
log.transports.console.level = 'silly';
const { remote } = require('electron');
const app = remote.app;
var filepath = path.join(app.getPath("temp"))
console.log(filepath)
var filename = "SMNFiler.log"
log.transports.file.resolvePath=()=>path.join(filepath,filename)
console.log(log.transports.file.resolvePath)
var exec = require("child_process").execFile;
function start(file_path, Encoding, sample_status, peak, more, Chinese, order) {
console.log("Request handler 'start' was called.");
if (file_path.constructor === Array) {
file_name = file_path[0].trim()
fileName = file_name.substring(file_name.lastIndexOf('\\') + 1)
} else {
file_name = file_path.trim()
fileName = file_name.substring(file_name.lastIndexOf('\\') + 1)
}
var exe_file;
if (process.platform === "darwin") {
exe_file = path.join(__dirname, "analysis.mac");
}
if (process.platform === "win32") {
exe_file = path.join(__dirname, "analysis.exe");
}
exec(
exe_file,
[
"-i",
file_path,
"-e",
Encoding,
"-c",
sample_status,
peak,
more,
Chinese,
order
],
function (error, stdout, stderr) {
if (error || stderr) {
var notice = "[WARNING] 输入文件 " + file_path + " 处理有误";
mdui.snackbar({
message: notice,
position: "left-top",
onClick:function(){
ipc.send('tab3');
}
});
console.warn("stderr:\n" +stderr)
log.warn("\n"+"当前处理文件名为:"+fileName+"\n报错提示:\n"+ stderr)
if(error!==null){
log.error("\n"+"当前处理文件名为:"+fileName+"\n错误提示:\n"+ error)
}
if(document.getElementById('restore').innerHTML === '<p style="text-align:center">所有日志信息全部位于程序运行日志窗口中</p>'){
document.getElementById('restore').innerHTML =""
}
document.getElementById('restore').innerHTML = '<br/>' + "<b style='color:#da242a'>当前处理文件名:</b>" + fileName + '<br/>'
} else if (stdout) {
setTimeout(function () {
var notice = "输入文件 " + file_path + " 处理完成";
mdui.snackbar({ message: notice });
}, 5000)
if(document.getElementById('restore').innerHTML ==='<p style="text-align:center">所有日志信息全部位于程序运行日志窗口中</p>'){
document.getElementById('restore').innerHTML =""
}
log.info("\n"+"当前处理文件名为:"+fileName+"\n处理文件耗时:\n"+stdout)
document.getElementById('restore').innerHTML = '<br/>' + "<b style='color:#67c23a'>当前处理文件名:</b>" + fileName + '<br/>' + "<b style='color:#67c23a'>处理文件耗时:</b>" + stdout + '<br/>'
// console.log(
// "-i",
// file_path,
// "-e",
// Encoding,
// "-c",
// sample_status,
// peak,
// more,
// Chinese,
// order
// );
}
}
);
}
// child_process.spawn method
// var path = require("path");
// function start(file_path, Encoding, sample_status, peak, more, Chinese, order) {
// console.log("Request handler 'start' was called.");
// console.log(file_path)
// if (file_path.constructor === Array) {
// file_name = file_path[0].trim()
// fileName = file_name.substring(file_name.lastIndexOf('\\') + 1)
// } else {
// file_name = file_path.trim()
// fileName = file_name.substring(file_name.lastIndexOf('\\') + 1)
// }
// const { spawn } = require("child_process");
// var exe_file;
// if (process.platform === "darwin") {
// exe_file = path.join(__dirname, "analysis.mac");
// }
// if (process.platform === "win32") {
// exe_file = path.join(__dirname, "analysis.exe");
// }
// var childProcess = spawn(exe_file, [
// "-i",
// file_path,
// "-e",
// Encoding,
// "-c",
// sample_status,
// peak,
// more,
// Chinese,
// order
// ]);
// childProcess.stderr.on("data", (data) => {
// console.log(`stderr: ${data}`);
// var notice = "[WARNING] 输入文件 " + file_path + " 处理有误";
// mdui.snackbar({ message: notice, position: "left-top" });
// document.getElementById('restderr').innerHTML += "*******************************" + "<br/>" + "当前处理文件名:" + fileName + '<br/>'+ "错误提示信息:" + data + '<br/>' + '*******************************' + '<br/>'
// document.getElementById('restore').innerHTML += "*******************************" + "<br/>" + "当前处理文件名:" + fileName + '<br/>' + '*******************************' + '<br/>'
// });
// childProcess.stdout.on("data", (data) => {
// console.log(`stdout: ${data}`);
// setTimeout(function () {
// var notice = "输入文件 " + file_path + " 处理完成";
// mdui.snackbar({ message: notice });
// }, 5000)
// document.getElementById('restore').innerHTML +="*******************************" + "<br/>" + "当前处理文件名:" + fileName + '<br/>' + "处理文件耗时:" + data + '<br/>' + '*******************************' + '<br/>'
// console.log(
// "-i",
// file_path,
// "-e",
// Encoding,
// "-c",
// sample_status,
// peak,
// more,
// Chinese,
// order
// );
// });
// childProcess.on("close", (code) => {
// console.log(`子进程退出码:${code}`);
// });
// }
// event: drag file(s) to window
const holder = document.getElementById("holder");
holder.ondragover = () => {
return false;
};
holder.ondragleave = holder.ondragend = () => {
return false;
};
holder.ondrop = (e) => {
e.preventDefault();
for (let f of e.dataTransfer.files) {
console.log("File(s) you dragged here: ", f.path);
start(f.path, Encoding, sample_status, peak, more, Chinese, order);
}
return false;
};
// event: click to open file manager
const os = require("os");
let default_path = os.homedir();
const { dialog } = require("electron").remote;
const fileManagerBtn = document.getElementById("holder");
fileManagerBtn.addEventListener("click", showOpenDialogHandler);
function showOpenDialogHandler() {
var options = {
defaultPath: default_path,
filters: [{ name: "RawData", extensions: ["txt", "csv"] }],
properties: ["openFile"],
};
dialog
.showOpenDialog(options)
.then((result) => {
console.log("Select file" + result.filePaths);
console.log(result.filePaths);
if (!result.filePaths[0]) {
console.log("No file selected");
mdui.snackbar({ message: "未选择任何文件" });
return;
} else {
start(
result.filePaths,
Encoding,
sample_status,
peak,
more,
Chinese,
order
);
}
})
.catch((err) => {
console.log(err);
console.log("No file selected");
});
}
const tab3 = document.querySelector('#tab3_icon')
const ipc = require('electron').ipcRenderer
tab3.onclick = ()=>{
ipc.send('tab3')
}
</script>
<style>
.body {
overflow-x: hidden;
}
.panel {
text-align: center;
font-size: 16px;
margin-top: 16px;
}
.result1 {
margin-top: 16px;
height: 200px;
overflow-y:auto;
overflow-x: hidden;
padding-left: 36px;
padding-right: 36px;
transition: all .5s;
}
.result2 {
margin-top: 16px;
height: 200px;
overflow-y: auto;
padding-left: 36px;
padding-right: 36px;
}
@media (min-height: 410px) {
.result2 {
height: 200px;
}
}
@media (min-height: 460px) {
.result2 {
height: 320px;
}
}
@media (min-height: 500px) {
.result2 {
height: 360px;
}
}
@media (min-height:600px){
.result2 {
height: 460px;
}
}
@media (min-height: 700px) {
.result2 {
height: 560px;
}
}
@media (min-height:850px){
.result2{
height: 710px;
}
}
@media (min-height: 1000px) {
.result2 {
height: 860px;
}
}
</style>
</body>
</html>