oipage 1.2.1 → 1.3.0-alpha.0

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.
@@ -1,172 +1,172 @@
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
- <style>
10
- body {
11
- margin: 0px;
12
- background-color: #ffffff;
13
- display: flex;
14
- flex-wrap: wrap;
15
- padding: 100px;
16
- }
17
-
18
- a {
19
- text-decoration: none;
20
- color: #284259;
21
- }
22
-
23
- a:hover {
24
- text-decoration: underline;
25
- }
26
-
27
- .fork {
28
- width: 160px;
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
- height: calc(100vh - 70px);
62
- overflow: auto;
63
- padding: 20px;
64
- border-radius: 5px;
65
- background-color: #fcfcfc;
66
- }
67
-
68
- .filelist>table {
69
- width: 100%;
70
- text-align: left;
71
- }
72
-
73
- .filelist>table tr>th {
74
- white-space: nowrap;
75
- padding: 0 10px;
76
- }
77
-
78
- .filelist>table>thead>tr>th {
79
- color: #284259;
80
- font-size: 13px;
81
- line-height: 40px;
82
- }
83
-
84
- .filelist>table>tbody>tr {
85
- border: 1px solid #cdcdcd00;
86
- }
87
-
88
- .filelist>table>tbody>tr>th {
89
- text-decoration: none;
90
- font-size: 12px;
91
- color: #3c3c3c;
92
- word-break: break-all;
93
- font-weight: 400;
94
- line-height: 30px;
95
- }
96
-
97
- .filelist>table>tbody>tr>th>.btn {
98
- color: white;
99
- background-color: #2196F3;
100
- padding: 2px 5px;
101
- border-radius: 5px;
102
- }
103
-
104
- .filelist>table>tbody>tr>th.name {
105
- background-repeat: no-repeat;
106
- background-position: left center;
107
- background-size: auto 90%;
108
- padding-left: 30px;
109
- color: #000000;
110
- }
111
-
112
- .filelist>table>tbody>tr>th.name>span {
113
- white-space: nowrap;
114
- }
115
-
116
- .filelist>table>tbody>tr.file>th.name {
117
- background-image: url('${img_file}');
118
- }
119
-
120
- .filelist>table>tbody>tr.folder>th.name {
121
- background-image: url('${img_folder}');
122
- }
123
- </style>
124
- </head>
125
-
126
- <body>
127
- <a href="https://github.com/oi-contrib/OIPage" target="_blank" class="fork">
128
- Fork me on Github
129
- </a>
130
- <div class="current">
131
- 当前位置:${current}
132
- </div>
133
- <div class="filelist">
134
- <table>
135
- <thead>
136
- <tr>
137
- <th>
138
- 名称
139
- </th>
140
- <th>
141
- 修改日期
142
- </th>
143
- <th>
144
- 类型
145
- </th>
146
- <th>
147
- 大小
148
- </th>
149
- <th>
150
- 操作
151
- </th>
152
- </tr>
153
- </thead>
154
- <tbody>
155
- <tr class="folder">
156
- <th class="name"><a href='../'>..</a></th>
157
- <th>-</th>
158
- <th>
159
- 文件夹
160
- </th>
161
- <th>-</th>
162
- <th>
163
- <a href='../' class="btn">打开</a>
164
- </th>
165
- </tr>
166
- ${template}
167
- </tbody>
168
- </table>
169
- </div>
170
- </body>
171
-
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
+ <style>
10
+ body {
11
+ margin: 0px;
12
+ background-color: #ffffff;
13
+ display: flex;
14
+ flex-wrap: wrap;
15
+ padding: 100px;
16
+ }
17
+
18
+ a {
19
+ text-decoration: none;
20
+ color: #284259;
21
+ }
22
+
23
+ a:hover {
24
+ text-decoration: underline;
25
+ }
26
+
27
+ .fork {
28
+ width: 160px;
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
+ height: calc(100vh - 70px);
62
+ overflow: auto;
63
+ padding: 20px;
64
+ border-radius: 5px;
65
+ background-color: #fcfcfc;
66
+ }
67
+
68
+ .filelist>table {
69
+ width: 100%;
70
+ text-align: left;
71
+ }
72
+
73
+ .filelist>table tr>th {
74
+ white-space: nowrap;
75
+ padding: 0 10px;
76
+ }
77
+
78
+ .filelist>table>thead>tr>th {
79
+ color: #284259;
80
+ font-size: 13px;
81
+ line-height: 40px;
82
+ }
83
+
84
+ .filelist>table>tbody>tr {
85
+ border: 1px solid #cdcdcd00;
86
+ }
87
+
88
+ .filelist>table>tbody>tr>th {
89
+ text-decoration: none;
90
+ font-size: 12px;
91
+ color: #3c3c3c;
92
+ word-break: break-all;
93
+ font-weight: 400;
94
+ line-height: 30px;
95
+ }
96
+
97
+ .filelist>table>tbody>tr>th>.btn {
98
+ color: white;
99
+ background-color: #2196F3;
100
+ padding: 2px 5px;
101
+ border-radius: 5px;
102
+ }
103
+
104
+ .filelist>table>tbody>tr>th.name {
105
+ background-repeat: no-repeat;
106
+ background-position: left center;
107
+ background-size: auto 90%;
108
+ padding-left: 30px;
109
+ color: #000000;
110
+ }
111
+
112
+ .filelist>table>tbody>tr>th.name>span {
113
+ white-space: nowrap;
114
+ }
115
+
116
+ .filelist>table>tbody>tr.file>th.name {
117
+ background-image: url('${img_file}');
118
+ }
119
+
120
+ .filelist>table>tbody>tr.folder>th.name {
121
+ background-image: url('${img_folder}');
122
+ }
123
+ </style>
124
+ </head>
125
+
126
+ <body>
127
+ <a href="https://github.com/oi-contrib/OIPage" target="_blank" class="fork">
128
+ Fork me on Github
129
+ </a>
130
+ <div class="current">
131
+ 当前位置:${current}
132
+ </div>
133
+ <div class="filelist">
134
+ <table>
135
+ <thead>
136
+ <tr>
137
+ <th>
138
+ 名称
139
+ </th>
140
+ <th>
141
+ 修改日期
142
+ </th>
143
+ <th>
144
+ 类型
145
+ </th>
146
+ <th>
147
+ 大小
148
+ </th>
149
+ <th>
150
+ 操作
151
+ </th>
152
+ </tr>
153
+ </thead>
154
+ <tbody>
155
+ <tr class="folder">
156
+ <th class="name"><a href='../'>..</a></th>
157
+ <th>-</th>
158
+ <th>
159
+ 文件夹
160
+ </th>
161
+ <th>-</th>
162
+ <th>
163
+ <a href='../' class="btn">打开</a>
164
+ </th>
165
+ </tr>
166
+ ${template}
167
+ </tbody>
168
+ </table>
169
+ </div>
170
+ </body>
171
+
172
172
  </html>
@@ -1,89 +1,89 @@
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
- };
77
-
78
- /**
79
- * 请求头解析
80
- * @param {*} rawHeaders
81
- * @returns
82
- */
83
- exports.formatRawHeaders = function (rawHeaders) {
84
- let headers = {};
85
- for (let i = 0; i < rawHeaders.length - 1; i += 2) {
86
- headers[rawHeaders[i]] = rawHeaders[i + 1];
87
- }
88
- return headers;
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
+ };
77
+
78
+ /**
79
+ * 请求头解析
80
+ * @param {*} rawHeaders
81
+ * @returns
82
+ */
83
+ exports.formatRawHeaders = function (rawHeaders) {
84
+ let headers = {};
85
+ for (let i = 0; i < rawHeaders.length - 1; i += 2) {
86
+ headers[rawHeaders[i]] = rawHeaders[i + 1];
87
+ }
88
+ return headers;
89
89
  };
@@ -1,43 +1,43 @@
1
- const { networkInterfaces } = require("os");
2
-
3
- // 网络信息
4
- module.exports = function () {
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") {
19
- if (network[index].family == 'IPv4' && network[index].address != '127.0.0.1') {
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' && network[index].address != '::1') {
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 () {
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") {
19
+ if (network[index].family == 'IPv4' && network[index].address != '127.0.0.1') {
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' && network[index].address != '::1') {
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
  };