oipage 0.1.0 → 0.2.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 +18 -15
- package/README.md +9 -3
- package/bin/run +2 -1
- package/nodejs/core/log.js +8 -0
- package/nodejs/form/common.js +3 -0
- package/nodejs/form/index.js +80 -0
- package/nodejs/form/select.js +10 -0
- package/nodejs/index.js +12 -2
- package/nodejs/reader/plain.js +20 -0
- package/package.json +3 -7
package/CHANGELOG
CHANGED
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
v0.1.0:
|
|
2
|
-
date:
|
|
2
|
+
date:2024-09-21
|
|
3
3
|
changes:
|
|
4
4
|
- 初始化版本
|
|
5
5
|
1、命令
|
|
6
|
-
|
|
7
|
-
* --server, -s 启动服务器
|
|
8
|
-
* --version, -v 查看版本
|
|
9
|
-
* --config, -c 启动配置文件
|
|
10
|
-
* --delete 删除文件或文件夹
|
|
11
|
-
* --copy 复制文件或文件夹
|
|
12
|
-
* --pick 提取文件夹文件到指定位置
|
|
13
|
-
* --move 移动文件或文件夹
|
|
14
|
-
* --network 查看网络信息
|
|
15
|
-
* --get 发送get请求
|
|
16
|
-
* --post 发送post请求
|
|
17
|
-
* --cat 查看文本内容
|
|
18
|
-
* --run 多进程运行任务
|
|
6
|
+
(包括:help、server、version、config、delete、copy、pick、move、network、get、post、cat、run)
|
|
19
7
|
2、corejs
|
|
20
8
|
* animation 动画
|
|
21
9
|
* throttle 节流函数
|
|
@@ -27,12 +15,27 @@ v0.1.0:
|
|
|
27
15
|
* options 命令行参数解析
|
|
28
16
|
* file 文件相关操作
|
|
29
17
|
* console 控制台打印
|
|
18
|
+
(包括:log、warn、error、linelog、deeplog)
|
|
30
19
|
* ajax 网络请求
|
|
31
20
|
* network 网络信息等
|
|
32
21
|
* data 资源数据
|
|
33
22
|
* image 图片相关操作
|
|
34
23
|
* loader 文件解析
|
|
24
|
+
(simpleScss、xhtml)
|
|
35
25
|
5、stylecss
|
|
36
26
|
* 统一浏览器样式 normalize.css
|
|
37
27
|
* 十二栅格化 rasterize.css
|
|
38
|
-
* 架屏动画 skeleton.css
|
|
28
|
+
* 架屏动画 skeleton.css
|
|
29
|
+
v0.2.0:
|
|
30
|
+
date:
|
|
31
|
+
changes:
|
|
32
|
+
- 优化改造
|
|
33
|
+
1、nodejs
|
|
34
|
+
* linelog新增清除行记录重置功能
|
|
35
|
+
* deeplog新增清除行记录重置功能
|
|
36
|
+
- 新增功能
|
|
37
|
+
1、nodejs
|
|
38
|
+
* plain 读取文本内容
|
|
39
|
+
* form 表单录入
|
|
40
|
+
(包括:input输入框、select列表选择)
|
|
41
|
+
|
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# [OIPage](https://github.com/oi-contrib/OIPage)
|
|
2
|
-
OI
|
|
2
|
+
OI页面快速开发辅助库,包括核心包、Nodejs、浏览器、样式文件等
|
|
3
3
|
|
|
4
4
|
<p>
|
|
5
5
|
<a href="https://zxl20070701.github.io/toolbox/#/npm-download?packages=oipage&interval=7">
|
|
@@ -70,7 +70,7 @@ oipage-cli -s 8080
|
|
|
70
70
|
对于更复杂的业务,我们推荐使用配置文件的方式。比如我们准备了配置文件 oipage.config.js ,那么就可以:
|
|
71
71
|
|
|
72
72
|
```shell
|
|
73
|
-
|
|
73
|
+
oipage-cli -c ./oipage.config.js
|
|
74
74
|
```
|
|
75
75
|
|
|
76
76
|
配置文件的内容如下:
|
|
@@ -100,7 +100,9 @@ module.exports = {
|
|
|
100
100
|
- [网络信息等](./docs/nodejs/network.md)
|
|
101
101
|
- [资源数据](./docs/nodejs/data.md)
|
|
102
102
|
- [图片相关操作](./docs/nodejs/image.md)
|
|
103
|
-
- [文件解析
|
|
103
|
+
- [文件解析](./docs/nodejs/loader.md)
|
|
104
|
+
- [文件读取](./docs/nodejs/reader.md)
|
|
105
|
+
- [表单录入](./docs/nodejs/form.md)
|
|
104
106
|
|
|
105
107
|
### 浏览器
|
|
106
108
|
|
|
@@ -114,6 +116,10 @@ module.exports = {
|
|
|
114
116
|
- [rasterize 十二栅格化](./docs/stylecss/rasterize.md)
|
|
115
117
|
- [skeleton 骨架屏动画](./docs/stylecss/skeleton.md)
|
|
116
118
|
|
|
119
|
+
### 前端开发框架
|
|
120
|
+
|
|
121
|
+
一个简单易用的用于快速开发前端页面的框架:[前端开发框架](./docs/framework/index.md)
|
|
122
|
+
|
|
117
123
|
## 版权
|
|
118
124
|
|
|
119
125
|
MIT License
|
package/bin/run
CHANGED
|
@@ -6,12 +6,12 @@ process.title = 'OIPage';
|
|
|
6
6
|
|
|
7
7
|
const server = require('../nodejs/core/server');
|
|
8
8
|
const { options, help } = require('./options');
|
|
9
|
-
const path = require('path');
|
|
10
9
|
const { log, error } = require('../nodejs/core/log');
|
|
11
10
|
const { deleteSync, copySync, moveSync, listFileSync, fullPathSync } = require("../nodejs/core/file");
|
|
12
11
|
const network = require("../nodejs/core/network");
|
|
13
12
|
const { get, post } = require("../nodejs/core/remote");
|
|
14
13
|
const fs = require("fs");
|
|
14
|
+
const path = require("path");
|
|
15
15
|
const { exec } = require('child_process');
|
|
16
16
|
|
|
17
17
|
const jsonfile = require("../package.json");
|
|
@@ -26,6 +26,7 @@ for (let key in options) {
|
|
|
26
26
|
const parsed = require("../nodejs/core/options")(shortHands, process.argv);
|
|
27
27
|
|
|
28
28
|
(() => {
|
|
29
|
+
|
|
29
30
|
// 打印版本
|
|
30
31
|
if (Array.isArray(parsed.version)) {
|
|
31
32
|
log("\nOIPage@v" + jsonfile.version + "\n");
|
package/nodejs/core/log.js
CHANGED
|
@@ -32,6 +32,10 @@ const linelog = (function (stream) {
|
|
|
32
32
|
|
|
33
33
|
// 返回实际同行打印的方法
|
|
34
34
|
return function (nextStr) {
|
|
35
|
+
if (arguments.length == 0) {
|
|
36
|
+
prevLineCount = 0;
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
35
39
|
let txt = "";
|
|
36
40
|
|
|
37
41
|
// 清除屏幕
|
|
@@ -62,6 +66,10 @@ exports.linelog = linelog;
|
|
|
62
66
|
* @param {string} stream 说明文字,可选择
|
|
63
67
|
*/
|
|
64
68
|
exports.deeplog = function (percentum, stream) {
|
|
69
|
+
if (arguments.length == 0) {
|
|
70
|
+
linelog();
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
65
73
|
|
|
66
74
|
if (arguments.length <= 1) stream = "";
|
|
67
75
|
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const { getTitle } = require("./common");
|
|
2
|
+
const { logView } = require("./select");
|
|
3
|
+
const { linelog } = require("../core/log");
|
|
4
|
+
|
|
5
|
+
module.exports = function (form) {
|
|
6
|
+
const rl = require("readline").createInterface({
|
|
7
|
+
input: process.stdin,
|
|
8
|
+
output: process.stdout
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
return new Promise(function (resolve, reject) {
|
|
12
|
+
let result = [], keyback = () => { };
|
|
13
|
+
|
|
14
|
+
console.log("");
|
|
15
|
+
|
|
16
|
+
process.stdin.on("keypress", (_str, key) => {
|
|
17
|
+
keyback(key.name);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
let getResult = (index) => {
|
|
21
|
+
if (index >= form.length) {
|
|
22
|
+
process.removeAllListeners("keypress");
|
|
23
|
+
rl.close();
|
|
24
|
+
resolve(result);
|
|
25
|
+
} else {
|
|
26
|
+
let item = form[index];
|
|
27
|
+
|
|
28
|
+
// 文本输入
|
|
29
|
+
if (item.type == "input") {
|
|
30
|
+
|
|
31
|
+
rl.question(getTitle(item.label), (answer) => {
|
|
32
|
+
result.push(answer);
|
|
33
|
+
setTimeout(() => {
|
|
34
|
+
console.log("");
|
|
35
|
+
getResult(index + 1);
|
|
36
|
+
}, 50);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// 列表选择
|
|
42
|
+
else if (item.type == "select") {
|
|
43
|
+
let title = getTitle(item.label);
|
|
44
|
+
|
|
45
|
+
let selectIndex = 0;
|
|
46
|
+
logView(title, item.value, selectIndex);
|
|
47
|
+
keyback = (keyname) => {
|
|
48
|
+
if (keyname == "return") {
|
|
49
|
+
result.push(selectIndex);
|
|
50
|
+
keyback = () => { };
|
|
51
|
+
linelog();
|
|
52
|
+
setTimeout(() => {
|
|
53
|
+
getResult(index + 1);
|
|
54
|
+
}, 50);
|
|
55
|
+
} else {
|
|
56
|
+
if (keyname == "left" || keyname == "up") {
|
|
57
|
+
if (selectIndex > 0) selectIndex -= 1;
|
|
58
|
+
else selectIndex = item.value.length - 1;
|
|
59
|
+
} else if (keyname == "right" || keyname == "down") {
|
|
60
|
+
if (selectIndex < item.value.length - 1) selectIndex += 1;
|
|
61
|
+
else selectIndex = 0;
|
|
62
|
+
} else {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
logView(title, item.value, selectIndex);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// 非法类型
|
|
72
|
+
else {
|
|
73
|
+
throw new Error("Illegal type!");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
};
|
|
78
|
+
getResult(0);
|
|
79
|
+
});
|
|
80
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const { linelog } = require("../core/log");
|
|
2
|
+
|
|
3
|
+
exports.logView = (title, list, index) => {
|
|
4
|
+
let txtArray = [];
|
|
5
|
+
for (let i = 0; i < list.length; i++) {
|
|
6
|
+
txtArray.push(" " + (i == index ? "●" : "○") + " " + list[i]);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
linelog(`${title}\n${txtArray.join("\n")}\n`);
|
|
10
|
+
};
|
package/nodejs/index.js
CHANGED
|
@@ -10,6 +10,10 @@ const { toBase64 } = require('./core/image');
|
|
|
10
10
|
const simpleScss = require('./loader/simpleScss');
|
|
11
11
|
const xhtml = require('./loader/xhtml');
|
|
12
12
|
|
|
13
|
+
const plain = require('./reader/plain');
|
|
14
|
+
|
|
15
|
+
const form = require('./form/index');
|
|
16
|
+
|
|
13
17
|
module.exports = {
|
|
14
18
|
|
|
15
19
|
// 命令行相关
|
|
@@ -43,6 +47,12 @@ module.exports = {
|
|
|
43
47
|
// 服务器
|
|
44
48
|
server,
|
|
45
49
|
|
|
46
|
-
// 文件解析
|
|
47
|
-
simpleScss, xhtml
|
|
50
|
+
// 文件解析
|
|
51
|
+
simpleScss, xhtml,
|
|
52
|
+
|
|
53
|
+
// 文件读取
|
|
54
|
+
plain,
|
|
55
|
+
|
|
56
|
+
// 表单录入
|
|
57
|
+
form
|
|
48
58
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module.exports = function (txt) {
|
|
2
|
+
|
|
3
|
+
let reader = {
|
|
4
|
+
index: -1,
|
|
5
|
+
currentChar: null
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
// 读取下一个字符
|
|
9
|
+
reader.readNext = function () {
|
|
10
|
+
reader.currentChar = reader.index++ < txt.length - 1 ? txt[reader.index] : null;
|
|
11
|
+
return reader.currentChar;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// 获取往后num个值
|
|
15
|
+
reader.getNextN = function (num) {
|
|
16
|
+
return txt.substring(reader.index, num + reader.index > txt.length ? txt.length : num + reader.index);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return reader;
|
|
20
|
+
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oipage",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "OI
|
|
3
|
+
"version": "0.2.0-alpha.0",
|
|
4
|
+
"description": "OI页面快速开发辅助库,包括核心包、Nodejs、浏览器、样式文件等",
|
|
5
5
|
"main": "./nodejs/index.js",
|
|
6
6
|
"typings": "./types/index.d.ts",
|
|
7
7
|
"sideEffects": false,
|
|
8
|
-
"scripts": {},
|
|
9
8
|
"bin": {
|
|
10
9
|
"oipage-cli": "bin/run"
|
|
11
10
|
},
|
|
@@ -31,8 +30,5 @@
|
|
|
31
30
|
"bugs": {
|
|
32
31
|
"url": "https://github.com/oi-contrib/OIPage/issues"
|
|
33
32
|
},
|
|
34
|
-
"homepage": "https://github.com/oi-contrib/OIPage"
|
|
35
|
-
"devDependencies": {
|
|
36
|
-
"vislite": "^1.2.0"
|
|
37
|
-
}
|
|
33
|
+
"homepage": "https://github.com/oi-contrib/OIPage"
|
|
38
34
|
}
|