oipage 1.6.0 → 1.7.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/FUNDING.yml +11 -11
- package/AUTHORS.txt +6 -6
- package/CHANGELOG +144 -137
- package/LICENSE +20 -20
- package/README.md +95 -95
- package/bin/WebSocket/decodeWsFrame.js +43 -43
- package/bin/WebSocket/encodeWsFrame.js +28 -28
- package/bin/WebSocket/headersToJSON.js +26 -26
- package/bin/WebSocket/index.js +80 -80
- package/bin/data/mineTypes.json +104 -104
- package/bin/disk.js +42 -42
- package/bin/help.js +43 -43
- package/bin/intercept.js +15 -15
- package/bin/network.js +21 -21
- package/bin/run +115 -115
- package/bin/serve.d.ts +55 -55
- package/bin/serve.js +158 -158
- package/bin/template/404.html +186 -186
- package/bin/tools/deleteEmptyFolder.js +23 -23
- package/bin/tools/format.js +75 -75
- package/bin/tools/network.js +42 -42
- package/bin/tools/resolve404.js +83 -83
- package/bin/tools/resolveImport.js +88 -88
- package/bin/website-htmls/components/ui-select-file/index.html +7 -7
- package/bin/website-htmls/components/ui-select-file/index.js +37 -37
- package/bin/website-htmls/components/ui-select-file/index.scss +44 -44
- package/bin/website-htmls/dialogs/imageSize/index.html +54 -54
- package/bin/website-htmls/dialogs/imageSize/index.js +53 -53
- package/bin/website-htmls/dialogs/imageSize/index.scss +138 -138
- package/bin/website-htmls/dialogs/index.js +52 -52
- package/bin/website-htmls/images/addFile.svg +1 -1
- package/bin/website-htmls/images/img-to-pdf.svg +1 -1
- package/bin/website-htmls/index.html +17 -17
- package/bin/website-htmls/main.js +13 -13
- package/bin/website-htmls/pages/App/index.html +6 -6
- package/bin/website-htmls/pages/App/index.js +22 -22
- package/bin/website-htmls/pages/App/index.scss +43 -43
- package/bin/website-htmls/pages/appStore/index.html +24 -24
- package/bin/website-htmls/pages/appStore/index.js +19 -19
- package/bin/website-htmls/pages/appStore/index.scss +41 -41
- package/bin/website-htmls/pages/chart/index.html +8 -8
- package/bin/website-htmls/pages/chart/index.js +72 -72
- package/bin/website-htmls/pages/chart/index.scss +72 -72
- package/bin/website-htmls/pages/image-editor/index.html +27 -27
- package/bin/website-htmls/pages/image-editor/index.js +106 -106
- package/bin/website-htmls/pages/image-editor/index.scss +45 -45
- package/bin/website-htmls/pages/img-to-pdf/index.html +3 -3
- package/bin/website-htmls/pages/img-to-pdf/index.js +44 -44
- package/bin/website-htmls/pages/img-to-pdf/index.scss +4 -4
- package/bin/website-htmls/router.config.js +19 -19
- package/bin/website-htmls/styles/normalize.css +94 -94
- package/bin/website-plugins/intercept/chart.js +33 -33
- package/bin/website-plugins/intercept/head.js +8 -8
- package/bin/website-plugins/intercept/index.js +8 -8
- package/bin/website-plugins/intercept/oipage-vislite-intercept.js +33 -33
- package/bin/website-plugins/intercept/oipage-zipaper-intercept.js +39 -39
- package/bin/website-plugins/loader/index.js +11 -11
- package/bin/website-plugins/loader/oipage-html-loader.js +7 -7
- package/bin/website-plugins/loader/oipage-scss-loader.js +149 -149
- package/nodejs/animation/index.d.ts +19 -19
- package/nodejs/animation/index.js +104 -104
- package/nodejs/cmdlog/index.d.ts +20 -20
- package/nodejs/cmdlog/index.js +75 -75
- package/nodejs/disk/index.d.ts +47 -47
- package/nodejs/disk/index.js +165 -165
- package/nodejs/format/index.d.ts +29 -29
- package/nodejs/format/index.js +107 -107
- package/nodejs/json/index.d.ts +9 -9
- package/nodejs/json/index.js +206 -206
- package/nodejs/logform/index.d.ts +18 -18
- package/nodejs/logform/index.js +94 -94
- package/nodejs/reader/index.d.ts +32 -32
- package/nodejs/reader/index.js +20 -20
- package/nodejs/remote/index.d.ts +32 -0
- package/nodejs/remote/index.js +71 -0
- package/nodejs/throttle/index.d.ts +30 -30
- package/nodejs/throttle/index.js +50 -50
- package/package.json +43 -43
- package/web/XMLHttpRequest/index.d.ts +17 -17
- package/web/XMLHttpRequest/index.js +60 -60
- package/web/animation/index.d.ts +19 -19
- package/web/animation/index.js +104 -104
- package/web/format/index.d.ts +29 -29
- package/web/format/index.js +107 -107
- package/web/json/index.d.ts +9 -9
- package/web/json/index.js +206 -206
- package/web/onReady/index.d.ts +7 -7
- package/web/onReady/index.js +8 -8
- package/web/performChunk/index.d.ts +4 -4
- package/web/performChunk/index.js +19 -19
- package/web/reader/index.d.ts +32 -32
- package/web/reader/index.js +20 -20
- package/web/style/index.d.ts +21 -21
- package/web/style/index.js +19 -19
- package/web/throttle/index.d.ts +30 -30
- package/web/throttle/index.js +50 -50
package/bin/template/404.html
CHANGED
|
@@ -1,187 +1,187 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="zh-cn">
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="UTF-8">
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
-
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
8
|
-
<title>404 Not Found</title>
|
|
9
|
-
<link rel="shortcut icon" href="/_oipage_website_/logo.png">
|
|
10
|
-
<style>
|
|
11
|
-
body {
|
|
12
|
-
margin: 0px;
|
|
13
|
-
background-color: #ffffff;
|
|
14
|
-
display: flex;
|
|
15
|
-
flex-wrap: wrap;
|
|
16
|
-
padding: 100px;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
a {
|
|
20
|
-
text-decoration: none;
|
|
21
|
-
color: #284259;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
a:hover {
|
|
25
|
-
text-decoration: underline;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.fork {
|
|
29
|
-
line-height: 30px;
|
|
30
|
-
position: fixed;
|
|
31
|
-
background-color: #607D8B;
|
|
32
|
-
text-align: center;
|
|
33
|
-
color: white;
|
|
34
|
-
outline: 2px dashed #607D8B;
|
|
35
|
-
width: 200px;
|
|
36
|
-
transform: rotate(45deg);
|
|
37
|
-
right: -45px;
|
|
38
|
-
top: 45px;
|
|
39
|
-
z-index: 1;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.current {
|
|
43
|
-
box-sizing: border-box;
|
|
44
|
-
position: fixed;
|
|
45
|
-
left: 0;
|
|
46
|
-
top: 0;
|
|
47
|
-
line-height: 50px;
|
|
48
|
-
padding-left: 20px;
|
|
49
|
-
font-size: 14px;
|
|
50
|
-
color: #000000;
|
|
51
|
-
font-style: italic;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.filelist {
|
|
55
|
-
box-sizing: border-box;
|
|
56
|
-
position: fixed;
|
|
57
|
-
left: 20px;
|
|
58
|
-
top: 50px;
|
|
59
|
-
outline: 1px solid #9E9E9E;
|
|
60
|
-
width: calc(100vw - 40px);
|
|
61
|
-
|
|
62
|
-
/* 2025年9月17日 于南京 */
|
|
63
|
-
/* 100vh改成100%是为了解决手机端显示问题 */
|
|
64
|
-
height: calc(100% - 100px);
|
|
65
|
-
|
|
66
|
-
overflow: auto;
|
|
67
|
-
padding: 20px;
|
|
68
|
-
border-radius: 5px;
|
|
69
|
-
background-color: #fcfcfc;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
.filelist>table {
|
|
73
|
-
width: 100%;
|
|
74
|
-
text-align: left;
|
|
75
|
-
border-collapse: collapse;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.filelist>table tr>th {
|
|
79
|
-
white-space: nowrap;
|
|
80
|
-
padding: 0 10px;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
.filelist>table>thead>tr>th {
|
|
84
|
-
color: #284259;
|
|
85
|
-
font-size: 13px;
|
|
86
|
-
line-height: 40px;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
.filelist>table>tbody>tr>th {
|
|
90
|
-
text-decoration: none;
|
|
91
|
-
font-size: 12px;
|
|
92
|
-
color: #3c3c3c;
|
|
93
|
-
word-break: break-all;
|
|
94
|
-
font-weight: 400;
|
|
95
|
-
line-height: 30px;
|
|
96
|
-
border-top: 1px solid #e4e4e4;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
.filelist>table>tbody>tr>th>.btn {
|
|
100
|
-
color: white;
|
|
101
|
-
background-color: #2196F3;
|
|
102
|
-
padding: 2px 5px;
|
|
103
|
-
border-radius: 5px;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
.filelist>table>tbody>tr>th.name {
|
|
107
|
-
background-repeat: no-repeat;
|
|
108
|
-
background-position: left center;
|
|
109
|
-
background-size: auto 90%;
|
|
110
|
-
padding-left: 30px;
|
|
111
|
-
color: #000000;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
.filelist>table>tbody>tr>th.name>span {
|
|
115
|
-
white-space: nowrap;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
.filelist>table>tbody>tr.file>th.name {
|
|
119
|
-
background-image: url('${img_file}');
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
.filelist>table>tbody>tr.folder>th.name {
|
|
123
|
-
background-image: url('${img_folder}');
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
.website-link {
|
|
127
|
-
position: fixed;
|
|
128
|
-
bottom: 10px;
|
|
129
|
-
line-height: 30px;
|
|
130
|
-
left: 16px;
|
|
131
|
-
font-size: 14px;
|
|
132
|
-
text-decoration: underline;
|
|
133
|
-
font-weight: 800;
|
|
134
|
-
}
|
|
135
|
-
</style>
|
|
136
|
-
</head>
|
|
137
|
-
|
|
138
|
-
<body>
|
|
139
|
-
<a href="https://github.com/oi-contrib/OIPage" target="_blank" class="fork">
|
|
140
|
-
Fork me on Github
|
|
141
|
-
</a>
|
|
142
|
-
<div class="current">
|
|
143
|
-
当前位置:${current}
|
|
144
|
-
</div>
|
|
145
|
-
<div class="filelist">
|
|
146
|
-
<table>
|
|
147
|
-
<thead>
|
|
148
|
-
<tr>
|
|
149
|
-
<th>
|
|
150
|
-
名称
|
|
151
|
-
</th>
|
|
152
|
-
<th>
|
|
153
|
-
修改日期
|
|
154
|
-
</th>
|
|
155
|
-
<th>
|
|
156
|
-
类型
|
|
157
|
-
</th>
|
|
158
|
-
<th>
|
|
159
|
-
大小
|
|
160
|
-
</th>
|
|
161
|
-
<th>
|
|
162
|
-
操作
|
|
163
|
-
</th>
|
|
164
|
-
</tr>
|
|
165
|
-
</thead>
|
|
166
|
-
<tbody>
|
|
167
|
-
<tr class="folder">
|
|
168
|
-
<th class="name"><a href='../'>..</a></th>
|
|
169
|
-
<th>-</th>
|
|
170
|
-
<th>
|
|
171
|
-
文件夹
|
|
172
|
-
</th>
|
|
173
|
-
<th>-</th>
|
|
174
|
-
<th>
|
|
175
|
-
<a href='../' class="btn">打开</a>
|
|
176
|
-
</th>
|
|
177
|
-
</tr>
|
|
178
|
-
${template}
|
|
179
|
-
</tbody>
|
|
180
|
-
</table>
|
|
181
|
-
</div>
|
|
182
|
-
<a class="website-link" href="/_oipage_website_/index.html">
|
|
183
|
-
打开应用市场
|
|
184
|
-
</a>
|
|
185
|
-
</body>
|
|
186
|
-
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="zh-cn">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="UTF-8">
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
8
|
+
<title>404 Not Found</title>
|
|
9
|
+
<link rel="shortcut icon" href="/_oipage_website_/logo.png">
|
|
10
|
+
<style>
|
|
11
|
+
body {
|
|
12
|
+
margin: 0px;
|
|
13
|
+
background-color: #ffffff;
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-wrap: wrap;
|
|
16
|
+
padding: 100px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
a {
|
|
20
|
+
text-decoration: none;
|
|
21
|
+
color: #284259;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
a:hover {
|
|
25
|
+
text-decoration: underline;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.fork {
|
|
29
|
+
line-height: 30px;
|
|
30
|
+
position: fixed;
|
|
31
|
+
background-color: #607D8B;
|
|
32
|
+
text-align: center;
|
|
33
|
+
color: white;
|
|
34
|
+
outline: 2px dashed #607D8B;
|
|
35
|
+
width: 200px;
|
|
36
|
+
transform: rotate(45deg);
|
|
37
|
+
right: -45px;
|
|
38
|
+
top: 45px;
|
|
39
|
+
z-index: 1;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.current {
|
|
43
|
+
box-sizing: border-box;
|
|
44
|
+
position: fixed;
|
|
45
|
+
left: 0;
|
|
46
|
+
top: 0;
|
|
47
|
+
line-height: 50px;
|
|
48
|
+
padding-left: 20px;
|
|
49
|
+
font-size: 14px;
|
|
50
|
+
color: #000000;
|
|
51
|
+
font-style: italic;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.filelist {
|
|
55
|
+
box-sizing: border-box;
|
|
56
|
+
position: fixed;
|
|
57
|
+
left: 20px;
|
|
58
|
+
top: 50px;
|
|
59
|
+
outline: 1px solid #9E9E9E;
|
|
60
|
+
width: calc(100vw - 40px);
|
|
61
|
+
|
|
62
|
+
/* 2025年9月17日 于南京 */
|
|
63
|
+
/* 100vh改成100%是为了解决手机端显示问题 */
|
|
64
|
+
height: calc(100% - 100px);
|
|
65
|
+
|
|
66
|
+
overflow: auto;
|
|
67
|
+
padding: 20px;
|
|
68
|
+
border-radius: 5px;
|
|
69
|
+
background-color: #fcfcfc;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.filelist>table {
|
|
73
|
+
width: 100%;
|
|
74
|
+
text-align: left;
|
|
75
|
+
border-collapse: collapse;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.filelist>table tr>th {
|
|
79
|
+
white-space: nowrap;
|
|
80
|
+
padding: 0 10px;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.filelist>table>thead>tr>th {
|
|
84
|
+
color: #284259;
|
|
85
|
+
font-size: 13px;
|
|
86
|
+
line-height: 40px;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.filelist>table>tbody>tr>th {
|
|
90
|
+
text-decoration: none;
|
|
91
|
+
font-size: 12px;
|
|
92
|
+
color: #3c3c3c;
|
|
93
|
+
word-break: break-all;
|
|
94
|
+
font-weight: 400;
|
|
95
|
+
line-height: 30px;
|
|
96
|
+
border-top: 1px solid #e4e4e4;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.filelist>table>tbody>tr>th>.btn {
|
|
100
|
+
color: white;
|
|
101
|
+
background-color: #2196F3;
|
|
102
|
+
padding: 2px 5px;
|
|
103
|
+
border-radius: 5px;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.filelist>table>tbody>tr>th.name {
|
|
107
|
+
background-repeat: no-repeat;
|
|
108
|
+
background-position: left center;
|
|
109
|
+
background-size: auto 90%;
|
|
110
|
+
padding-left: 30px;
|
|
111
|
+
color: #000000;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.filelist>table>tbody>tr>th.name>span {
|
|
115
|
+
white-space: nowrap;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.filelist>table>tbody>tr.file>th.name {
|
|
119
|
+
background-image: url('${img_file}');
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.filelist>table>tbody>tr.folder>th.name {
|
|
123
|
+
background-image: url('${img_folder}');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.website-link {
|
|
127
|
+
position: fixed;
|
|
128
|
+
bottom: 10px;
|
|
129
|
+
line-height: 30px;
|
|
130
|
+
left: 16px;
|
|
131
|
+
font-size: 14px;
|
|
132
|
+
text-decoration: underline;
|
|
133
|
+
font-weight: 800;
|
|
134
|
+
}
|
|
135
|
+
</style>
|
|
136
|
+
</head>
|
|
137
|
+
|
|
138
|
+
<body>
|
|
139
|
+
<a href="https://github.com/oi-contrib/OIPage" target="_blank" class="fork">
|
|
140
|
+
Fork me on Github
|
|
141
|
+
</a>
|
|
142
|
+
<div class="current">
|
|
143
|
+
当前位置:${current}
|
|
144
|
+
</div>
|
|
145
|
+
<div class="filelist">
|
|
146
|
+
<table>
|
|
147
|
+
<thead>
|
|
148
|
+
<tr>
|
|
149
|
+
<th>
|
|
150
|
+
名称
|
|
151
|
+
</th>
|
|
152
|
+
<th>
|
|
153
|
+
修改日期
|
|
154
|
+
</th>
|
|
155
|
+
<th>
|
|
156
|
+
类型
|
|
157
|
+
</th>
|
|
158
|
+
<th>
|
|
159
|
+
大小
|
|
160
|
+
</th>
|
|
161
|
+
<th>
|
|
162
|
+
操作
|
|
163
|
+
</th>
|
|
164
|
+
</tr>
|
|
165
|
+
</thead>
|
|
166
|
+
<tbody>
|
|
167
|
+
<tr class="folder">
|
|
168
|
+
<th class="name"><a href='../'>..</a></th>
|
|
169
|
+
<th>-</th>
|
|
170
|
+
<th>
|
|
171
|
+
文件夹
|
|
172
|
+
</th>
|
|
173
|
+
<th>-</th>
|
|
174
|
+
<th>
|
|
175
|
+
<a href='../' class="btn">打开</a>
|
|
176
|
+
</th>
|
|
177
|
+
</tr>
|
|
178
|
+
${template}
|
|
179
|
+
</tbody>
|
|
180
|
+
</table>
|
|
181
|
+
</div>
|
|
182
|
+
<a class="website-link" href="/_oipage_website_/index.html">
|
|
183
|
+
打开应用市场
|
|
184
|
+
</a>
|
|
185
|
+
</body>
|
|
186
|
+
|
|
187
187
|
</html>
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
const { readdirSync, lstatSync, rmdirSync } = require("fs");
|
|
2
|
-
const { join } = require("path");
|
|
3
|
-
|
|
4
|
-
module.exports = function (rootPath) {
|
|
5
|
-
(function deleteEmptyFolder(folderPath) {
|
|
6
|
-
let subItems = readdirSync(folderPath);
|
|
7
|
-
if (subItems.length > 0) {
|
|
8
|
-
for (let i = 0; i < subItems.length; i++) {
|
|
9
|
-
let itemPath = join(folderPath, subItems[i]);
|
|
10
|
-
if (lstatSync(itemPath).isDirectory()) deleteEmptyFolder(itemPath);
|
|
11
|
-
}
|
|
12
|
-
} else {
|
|
13
|
-
rmdirSync(folderPath);
|
|
14
|
-
|
|
15
|
-
folderPath = join(folderPath, "..");
|
|
16
|
-
while (folderPath.length >= rootPath.length) {
|
|
17
|
-
subItems = readdirSync(folderPath);
|
|
18
|
-
if (readdirSync(folderPath).length > 0) break;
|
|
19
|
-
rmdirSync(folderPath);
|
|
20
|
-
folderPath = join(folderPath, "..");
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
})(params.path);
|
|
1
|
+
const { readdirSync, lstatSync, rmdirSync } = require("fs");
|
|
2
|
+
const { join } = require("path");
|
|
3
|
+
|
|
4
|
+
module.exports = function (rootPath) {
|
|
5
|
+
(function deleteEmptyFolder(folderPath) {
|
|
6
|
+
let subItems = readdirSync(folderPath);
|
|
7
|
+
if (subItems.length > 0) {
|
|
8
|
+
for (let i = 0; i < subItems.length; i++) {
|
|
9
|
+
let itemPath = join(folderPath, subItems[i]);
|
|
10
|
+
if (lstatSync(itemPath).isDirectory()) deleteEmptyFolder(itemPath);
|
|
11
|
+
}
|
|
12
|
+
} else {
|
|
13
|
+
rmdirSync(folderPath);
|
|
14
|
+
|
|
15
|
+
folderPath = join(folderPath, "..");
|
|
16
|
+
while (folderPath.length >= rootPath.length) {
|
|
17
|
+
subItems = readdirSync(folderPath);
|
|
18
|
+
if (readdirSync(folderPath).length > 0) break;
|
|
19
|
+
rmdirSync(folderPath);
|
|
20
|
+
folderPath = join(folderPath, "..");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
})(params.path);
|
|
24
24
|
};
|
package/bin/tools/format.js
CHANGED
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 把字节转换成更可读的内容
|
|
3
|
-
* @param {*} value
|
|
4
|
-
* @returns
|
|
5
|
-
*/
|
|
6
|
-
exports.formatByte = function (value) {
|
|
7
|
-
if (value < 1024) return value + "Byte";
|
|
8
|
-
|
|
9
|
-
let kb = value / 1024;
|
|
10
|
-
if (kb < 1024) return kb.toFixed(1) + "KB";
|
|
11
|
-
|
|
12
|
-
let mb = kb / 1024;
|
|
13
|
-
if (mb < 1024) return mb.toFixed(1) + "MB";
|
|
14
|
-
|
|
15
|
-
let gb = mb / 1024;
|
|
16
|
-
return gb.toFixed(1) + "GB";
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* 把时间变成更可读的格式
|
|
21
|
-
* @param {*} value
|
|
22
|
-
* @returns
|
|
23
|
-
*/
|
|
24
|
-
exports.formatTime = function (value) {
|
|
25
|
-
let year = value.getFullYear();
|
|
26
|
-
let month = value.getMonth() + 1;
|
|
27
|
-
let day = value.getDate();
|
|
28
|
-
|
|
29
|
-
let hour = value.getHours();
|
|
30
|
-
let minutes = value.getMinutes();
|
|
31
|
-
|
|
32
|
-
let today = new Date();
|
|
33
|
-
if (year == today.getFullYear() && month == today.getMonth() + 1 && day == today.getDate()) {
|
|
34
|
-
return "今天 " + hour + ":" + minutes;
|
|
35
|
-
} else {
|
|
36
|
-
return year + "年" + month + "月" + day + "日 " + hour + ":" + minutes;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* 命令行参数解析
|
|
42
|
-
* @param {*} argvs
|
|
43
|
-
* @param {*} shorts
|
|
44
|
-
* @param {*} isArray 是否按序号记录
|
|
45
|
-
* @returns
|
|
46
|
-
*/
|
|
47
|
-
exports.formatArgv = function (argvs, shorts, isArray) {
|
|
48
|
-
let result = {}, keyName = "args", value = [];
|
|
49
|
-
if (isArray) result["value"] = [];
|
|
50
|
-
|
|
51
|
-
let pushValue = function () {
|
|
52
|
-
if (isArray && keyName !== "args") {
|
|
53
|
-
result["value"].push({
|
|
54
|
-
name: keyName,
|
|
55
|
-
value
|
|
56
|
-
});
|
|
57
|
-
} else {
|
|
58
|
-
result[keyName] = value;
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
for (let index = 3; index < argvs.length; index++) {
|
|
63
|
-
let argv = argvs[index];
|
|
64
|
-
|
|
65
|
-
if (/^\-/.test(argv)) {
|
|
66
|
-
pushValue();
|
|
67
|
-
keyName = shorts[argv] || argv;
|
|
68
|
-
value = [];
|
|
69
|
-
} else {
|
|
70
|
-
value.push(argv);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
pushValue();
|
|
74
|
-
|
|
75
|
-
return result;
|
|
1
|
+
/**
|
|
2
|
+
* 把字节转换成更可读的内容
|
|
3
|
+
* @param {*} value
|
|
4
|
+
* @returns
|
|
5
|
+
*/
|
|
6
|
+
exports.formatByte = function (value) {
|
|
7
|
+
if (value < 1024) return value + "Byte";
|
|
8
|
+
|
|
9
|
+
let kb = value / 1024;
|
|
10
|
+
if (kb < 1024) return kb.toFixed(1) + "KB";
|
|
11
|
+
|
|
12
|
+
let mb = kb / 1024;
|
|
13
|
+
if (mb < 1024) return mb.toFixed(1) + "MB";
|
|
14
|
+
|
|
15
|
+
let gb = mb / 1024;
|
|
16
|
+
return gb.toFixed(1) + "GB";
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 把时间变成更可读的格式
|
|
21
|
+
* @param {*} value
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
exports.formatTime = function (value) {
|
|
25
|
+
let year = value.getFullYear();
|
|
26
|
+
let month = value.getMonth() + 1;
|
|
27
|
+
let day = value.getDate();
|
|
28
|
+
|
|
29
|
+
let hour = value.getHours();
|
|
30
|
+
let minutes = value.getMinutes();
|
|
31
|
+
|
|
32
|
+
let today = new Date();
|
|
33
|
+
if (year == today.getFullYear() && month == today.getMonth() + 1 && day == today.getDate()) {
|
|
34
|
+
return "今天 " + hour + ":" + minutes;
|
|
35
|
+
} else {
|
|
36
|
+
return year + "年" + month + "月" + day + "日 " + hour + ":" + minutes;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 命令行参数解析
|
|
42
|
+
* @param {*} argvs
|
|
43
|
+
* @param {*} shorts
|
|
44
|
+
* @param {*} isArray 是否按序号记录
|
|
45
|
+
* @returns
|
|
46
|
+
*/
|
|
47
|
+
exports.formatArgv = function (argvs, shorts, isArray) {
|
|
48
|
+
let result = {}, keyName = "args", value = [];
|
|
49
|
+
if (isArray) result["value"] = [];
|
|
50
|
+
|
|
51
|
+
let pushValue = function () {
|
|
52
|
+
if (isArray && keyName !== "args") {
|
|
53
|
+
result["value"].push({
|
|
54
|
+
name: keyName,
|
|
55
|
+
value
|
|
56
|
+
});
|
|
57
|
+
} else {
|
|
58
|
+
result[keyName] = value;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
for (let index = 3; index < argvs.length; index++) {
|
|
63
|
+
let argv = argvs[index];
|
|
64
|
+
|
|
65
|
+
if (/^\-/.test(argv)) {
|
|
66
|
+
pushValue();
|
|
67
|
+
keyName = shorts[argv] || argv;
|
|
68
|
+
value = [];
|
|
69
|
+
} else {
|
|
70
|
+
value.push(argv);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
pushValue();
|
|
74
|
+
|
|
75
|
+
return result;
|
|
76
76
|
};
|
package/bin/tools/network.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
const { networkInterfaces } = require("os");
|
|
2
|
-
|
|
3
|
-
// 网络信息
|
|
4
|
-
module.exports = function (isAll) {
|
|
5
|
-
|
|
6
|
-
let infomation = {
|
|
7
|
-
IPv4: [],
|
|
8
|
-
IPv6: []
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
let networks = networkInterfaces();
|
|
12
|
-
|
|
13
|
-
let IPv4Had = {}, IPv6Had = {};
|
|
14
|
-
|
|
15
|
-
for (let typeName in networks) {
|
|
16
|
-
let network = networks[typeName]
|
|
17
|
-
for (let index = 0; index < network.length; index++) {
|
|
18
|
-
if (network[index].mac != "00:00:00:00:00:00" || isAll) {
|
|
19
|
-
if (network[index].family == 'IPv4') {
|
|
20
|
-
if (!IPv4Had[network[index].mac]) {
|
|
21
|
-
infomation.IPv4.push({
|
|
22
|
-
address: network[index].address,
|
|
23
|
-
mac: network[index].mac
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
IPv4Had[network[index].mac] = true;
|
|
27
|
-
}
|
|
28
|
-
} else if (network[index].family == 'IPv6') {
|
|
29
|
-
if (!IPv6Had[network[index].mac]) {
|
|
30
|
-
infomation.IPv6.push({
|
|
31
|
-
address: network[index].address,
|
|
32
|
-
mac: network[index].mac
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
IPv6Had[network[index].mac] = true;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return infomation;
|
|
1
|
+
const { networkInterfaces } = require("os");
|
|
2
|
+
|
|
3
|
+
// 网络信息
|
|
4
|
+
module.exports = function (isAll) {
|
|
5
|
+
|
|
6
|
+
let infomation = {
|
|
7
|
+
IPv4: [],
|
|
8
|
+
IPv6: []
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
let networks = networkInterfaces();
|
|
12
|
+
|
|
13
|
+
let IPv4Had = {}, IPv6Had = {};
|
|
14
|
+
|
|
15
|
+
for (let typeName in networks) {
|
|
16
|
+
let network = networks[typeName]
|
|
17
|
+
for (let index = 0; index < network.length; index++) {
|
|
18
|
+
if (network[index].mac != "00:00:00:00:00:00" || isAll) {
|
|
19
|
+
if (network[index].family == 'IPv4') {
|
|
20
|
+
if (!IPv4Had[network[index].mac]) {
|
|
21
|
+
infomation.IPv4.push({
|
|
22
|
+
address: network[index].address,
|
|
23
|
+
mac: network[index].mac
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
IPv4Had[network[index].mac] = true;
|
|
27
|
+
}
|
|
28
|
+
} else if (network[index].family == 'IPv6') {
|
|
29
|
+
if (!IPv6Had[network[index].mac]) {
|
|
30
|
+
infomation.IPv6.push({
|
|
31
|
+
address: network[index].address,
|
|
32
|
+
mac: network[index].mac
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
IPv6Had[network[index].mac] = true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return infomation;
|
|
43
43
|
};
|