oipage 1.0.0 → 1.1.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.
- package/CHANGELOG +10 -0
- package/bin/serve.js +9 -4
- package/nodejs/animation/index.js +2 -2
- package/nodejs/cmdlog/index.js +2 -2
- package/nodejs/disk/index.d.ts +26 -0
- package/nodejs/disk/index.js +9 -0
- package/nodejs/logform/index.d.ts +19 -0
- package/nodejs/logform/index.js +100 -0
- package/nodejs/throttle/index.js +2 -2
- package/package.json +1 -1
- package/web/animation/index.js +2 -2
- package/web/onReady/index.js +2 -2
- package/web/style/index.js +3 -3
- package/web/throttle/index.js +2 -2
package/CHANGELOG
CHANGED
package/bin/serve.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { join } = require("path");
|
|
2
|
-
const { existsSync, lstatSync, readFileSync } = require("fs");
|
|
2
|
+
const { existsSync, lstatSync, readFileSync, createReadStream } = require("fs");
|
|
3
3
|
const { createServer } = require('http');
|
|
4
4
|
const packageValue = require("../package.json");
|
|
5
5
|
const network = require("./network");
|
|
@@ -11,7 +11,7 @@ module.exports = function (config) {
|
|
|
11
11
|
let startTime = new Date().valueOf();
|
|
12
12
|
|
|
13
13
|
const port = config.port; // 端口号
|
|
14
|
-
const basePath = join(process.cwd(), config.baseUrl); // 服务器根路径
|
|
14
|
+
const basePath = (/^\./.test(config.baseUrl)) ? join(process.cwd(), config.baseUrl) : config.baseUrl; // 服务器根路径
|
|
15
15
|
|
|
16
16
|
let Server = createServer(function (request, response) {
|
|
17
17
|
|
|
@@ -32,8 +32,13 @@ module.exports = function (config) {
|
|
|
32
32
|
'Access-Control-Allow-Origin': '*',
|
|
33
33
|
'Server': 'Powered by OIPage-dev-server@' + packageValue.version
|
|
34
34
|
});
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
|
|
36
|
+
// 方式一
|
|
37
|
+
// response.write(readFileSync(filePath));
|
|
38
|
+
// response.end();
|
|
39
|
+
|
|
40
|
+
// 方式二
|
|
41
|
+
createReadStream(filePath).pipe(response);
|
|
37
42
|
|
|
38
43
|
console.log("<i> \x1b[1m\x1b[32m[OIPage-dev-server] Read File: " + url + '\x1b[0m ' + new Date().toLocaleString());
|
|
39
44
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* animation of OIPage v1.0.0
|
|
2
|
+
* animation of OIPage v1.1.0-alpha.0
|
|
3
3
|
* git+https://github.com/oi-contrib/OIPage.git
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -106,5 +106,5 @@ function animation(doback, duration, callback) {
|
|
|
106
106
|
}
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
-
}
|
|
109
|
+
}
|
|
110
110
|
exports.animation = animation;
|
package/nodejs/cmdlog/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* cmdlog of OIPage v1.0.0
|
|
2
|
+
* cmdlog of OIPage v1.1.0-alpha.0
|
|
3
3
|
* git+https://github.com/oi-contrib/OIPage.git
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -77,6 +77,6 @@ function deeplog (percentum, stream) {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
linelog(percentum.toFixed(2) + "%[" + txt + "]" + stream);
|
|
80
|
-
}
|
|
80
|
+
}
|
|
81
81
|
exports.linelog = linelog;
|
|
82
82
|
exports.deeplog = deeplog;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 删除文件或文件夹
|
|
3
|
+
*/
|
|
4
|
+
export interface deleteDiskType {
|
|
5
|
+
(diskPath: string): void
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export let deleteDisk: deleteDiskType
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 复制文件或文件夹
|
|
12
|
+
*/
|
|
13
|
+
export interface copyDiskType {
|
|
14
|
+
(sourcePath: string, targetPath: string): void
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export let copyDisk: copyDiskType
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 移动文件或文件夹
|
|
21
|
+
*/
|
|
22
|
+
export interface moveDiskType {
|
|
23
|
+
(sourcePath: string, targetPath: string): void
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export let moveDisk: moveDiskType
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface inputType {
|
|
2
|
+
type: string
|
|
3
|
+
label: string
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface selectType extends inputType {
|
|
7
|
+
value: Array<string>
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 表单输入
|
|
12
|
+
* @param form 表单内容
|
|
13
|
+
* @returns 返回一个结果数组
|
|
14
|
+
*/
|
|
15
|
+
export interface logformType {
|
|
16
|
+
(config: Array<inputType | selectType>): Promise<Array<string | number>>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export let deeplog: logformType
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* logform of OIPage v1.1.0-alpha.0
|
|
3
|
+
* git+https://github.com/oi-contrib/OIPage.git
|
|
4
|
+
*/
|
|
5
|
+
const {linelog} = require("../cmdlog/index.js");
|
|
6
|
+
let getTitle = function (title) {
|
|
7
|
+
return "➤ " + title;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
let closeForm = function () {
|
|
11
|
+
process.removeAllListeners("keypress");
|
|
12
|
+
rl.close();
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
let selectView = (title, list, index) => {
|
|
16
|
+
let txtArray = [];
|
|
17
|
+
for (let i = 0; i < list.length; i++) {
|
|
18
|
+
txtArray.push(" " + (i == index ? "●" : "○") + " " + list[i]);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
linelog(`${title}\n${txtArray.join("\n")}\n`);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
function logform(config) {
|
|
25
|
+
const rl = require("readline").createInterface({
|
|
26
|
+
input: process.stdin,
|
|
27
|
+
output: process.stdout
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
return new Promise(function (resolve, reject) {
|
|
31
|
+
let result = [], keyback = () => { };
|
|
32
|
+
|
|
33
|
+
console.log("");
|
|
34
|
+
|
|
35
|
+
process.stdin.on("keypress", (_str, key) => {
|
|
36
|
+
keyback(key.name);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
let getResult = (index) => {
|
|
40
|
+
if (index >= config.length) {
|
|
41
|
+
closeForm();
|
|
42
|
+
resolve(result);
|
|
43
|
+
} else {
|
|
44
|
+
let item = config[index];
|
|
45
|
+
|
|
46
|
+
// 文本输入
|
|
47
|
+
if (item.type == "input") {
|
|
48
|
+
|
|
49
|
+
rl.question(getTitle(item.label), (answer) => {
|
|
50
|
+
result.push(answer);
|
|
51
|
+
setTimeout(() => {
|
|
52
|
+
console.log("");
|
|
53
|
+
getResult(index + 1);
|
|
54
|
+
}, 50);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// 列表选择
|
|
60
|
+
else if (item.type == "select") {
|
|
61
|
+
let title = getTitle(item.label);
|
|
62
|
+
|
|
63
|
+
let selectIndex = 0;
|
|
64
|
+
selectView(title, item.value, selectIndex);
|
|
65
|
+
keyback = (keyname) => {
|
|
66
|
+
if (keyname == "return") {
|
|
67
|
+
result.push(selectIndex);
|
|
68
|
+
keyback = () => { };
|
|
69
|
+
linelog();
|
|
70
|
+
setTimeout(() => {
|
|
71
|
+
getResult(index + 1);
|
|
72
|
+
}, 50);
|
|
73
|
+
} else {
|
|
74
|
+
if (keyname == "left" || keyname == "up") {
|
|
75
|
+
if (selectIndex > 0) selectIndex -= 1;
|
|
76
|
+
else selectIndex = item.value.length - 1;
|
|
77
|
+
} else if (keyname == "right" || keyname == "down") {
|
|
78
|
+
if (selectIndex < item.value.length - 1) selectIndex += 1;
|
|
79
|
+
else selectIndex = 0;
|
|
80
|
+
} else {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
selectView(title, item.value, selectIndex);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// 非法类型
|
|
90
|
+
else {
|
|
91
|
+
closeForm();
|
|
92
|
+
reject(new Error("Illegal type!"));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
};
|
|
97
|
+
getResult(0);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
exports.logform = logform;
|
package/nodejs/throttle/index.js
CHANGED
package/package.json
CHANGED
package/web/animation/index.js
CHANGED
package/web/onReady/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* onReady of OIPage v1.0.0
|
|
2
|
+
* onReady of OIPage v1.1.0-alpha.0
|
|
3
3
|
* git+https://github.com/oi-contrib/OIPage.git
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -10,4 +10,4 @@ export function onReady(callback) {
|
|
|
10
10
|
} else {
|
|
11
11
|
window.addEventListener("DOMContentLoaded", callback);
|
|
12
12
|
}
|
|
13
|
-
}
|
|
13
|
+
}
|
package/web/style/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* style of OIPage v1.0.0
|
|
2
|
+
* style of OIPage v1.1.0-alpha.0
|
|
3
3
|
* git+https://github.com/oi-contrib/OIPage.git
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -7,7 +7,7 @@ export function setStyle(el, styles) {
|
|
|
7
7
|
for (var key in styles) {
|
|
8
8
|
el.style[key] = styles[key];
|
|
9
9
|
}
|
|
10
|
-
}
|
|
10
|
+
}
|
|
11
11
|
|
|
12
12
|
export function getStyle(el, name) {
|
|
13
13
|
|
|
@@ -21,4 +21,4 @@ export function getStyle(el, name) {
|
|
|
21
21
|
allStyle.getPropertyValue(name) :
|
|
22
22
|
allStyle;
|
|
23
23
|
|
|
24
|
-
}
|
|
24
|
+
}
|