oipage 1.0.0-alpha.1 → 1.0.0-beta.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 CHANGED
@@ -1,58 +1,19 @@
1
- v0.1.0:
2
- date:2024-09-21
3
- changes:
4
- - 初始化版本
5
- 1、命令
6
- (包括:help、server、version、config、delete、copy、pick、move、network、get、post、cat、run)
7
- 2、corejs
8
- * animation 动画
9
- * throttle 节流函数
10
- 3、browserjs
11
- * getStyle 获取节点样式
12
- * onReady 解析完执行
13
- 4、nodejs
14
- * server 服务器
15
- * options 命令行参数解析
16
- * file 文件相关操作
17
- * console 控制台打印
18
- (包括:log、warn、error、linelog、deeplog)
19
- * ajax 网络请求
20
- * network 网络信息等
21
- * data 资源数据
22
- * image 图片相关操作
23
- * loader 文件解析
24
- (simpleScss、xhtml)
25
- 5、stylecss
26
- * 统一浏览器样式 normalize.css
27
- * 十二栅格化 rasterize.css
28
- * 架屏动画 skeleton.css
29
- v0.2.0:
30
- date:2024-12-01
31
- changes:
32
- - 优化改造
33
- 1、nodejs
34
- * linelog新增清除行记录重置功能
35
- * deeplog新增清除行记录重置功能
36
- - 新增功能
37
- 1、nodejs
38
- * plain 读取文本内容
39
- * form 表单录入
40
- (包括:input输入框、select列表选择)
41
- * server hander方法补充api
42
- (包括:getFileInfo()、filePath)
43
1
  v1.0.0:
44
2
  date:
45
3
  changes:
46
4
  - 原v0.x的功能将独立一个分支继续维护:https://github.com/oi-contrib/OIPage/blob/v0.x/CHANGELOG
47
5
  (v0.x保持对零碎方法这种形式的支持和维护,此版本开始将作为一个框架或一个系统的工具箱以提供更高效的使用方式,这是一次彻底的非兼容改造)
48
6
  - 初始化版本(v1.x)
49
- 1、API模块
7
+ 1、API功能(浏览器)
50
8
  * animation 动画
51
- * deeplog 进度打印
52
9
  * getStyle 获取节点样式
53
- * linglog 单行打印
54
- * onReady 等待DOM加载完毕执行
55
10
  * setStyle 设置节点样式
11
+ * onReady 加载完毕执行
12
+ * throttle 节流函数
13
+ 2、API功能(Node.js)
14
+ * animation 动画
15
+ * deeplog 进度打印
16
+ * linglog 单行打印
56
17
  * throttle 节流函数
57
- 2、命令
18
+ 3、命令(oipage-cli)
58
19
  * serve 开发服务器
package/README.md CHANGED
@@ -1,5 +1,6 @@
1
- # [OIPage](https://github.com/oi-contrib/OIPage)
2
- 前端网页或应用快速开发助手,包括开发服务器、辅助命令、实用API等
1
+ - 💘 开源不易,去 <i>[Github给个Star](https://github.com/oi-contrib/OIPage) </i>吧!
2
+
3
+ <img src='https://oi-contrib.github.io/OIPage/images/logo.png' height='100px'/>
3
4
 
4
5
  <p>
5
6
  <a href="https://zxl20070701.github.io/toolbox/#/npm-download?packages=oipage&interval=7">
@@ -7,14 +8,69 @@
7
8
  </a>
8
9
  <a href="https://www.npmjs.com/package/oipage">
9
10
  <img src="https://img.shields.io/npm/v/oipage.svg" alt="npm">
11
+ </a>
12
+ <a href="https://github.com/oi-contrib/OIPage/issues">
13
+ <img src="https://img.shields.io/github/issues/oi-contrib/OIPage" alt="issue">
10
14
  </a>
11
15
  <a href="https://github.com/oi-contrib/OIPage" target='_blank'>
12
16
  <img alt="GitHub repo stars" src="https://img.shields.io/github/stars/oi-contrib/OIPage?style=social">
13
17
  </a>
18
+ <a href="https://gitee.com/oi-contrib/OIPage" target='_blank'>
19
+ <img alt="Gitee repo stars" src="https://gitee.com/oi-contrib/OIPage/badge/star.svg">
20
+ </a>
21
+ <a href="https://gitee.com/oi-contrib/OIPage">
22
+ <img src="https://gitee.com/oi-contrib/OIPage/badge/fork.svg" alt="forks">
23
+ </a>
14
24
  </p>
15
25
 
16
26
  <img src="https://nodei.co/npm/oipage.png?downloads=true&amp;downloadRank=true&amp;stars=true" alt="NPM">
17
27
 
28
+ # [OIPage](https://github.com/oi-contrib/OIPage)
29
+ 前端网页或应用快速开发助手,包括开发服务器、辅助命令、实用API等。官网地址:[https://oi-contrib.github.io/OIPage](https://oi-contrib.github.io/OIPage)
30
+
31
+ ## 如何使用?
32
+
33
+ 你可以作为一个命令行使用,那么你需要全局安装:
34
+
35
+ ```shell
36
+ npm install -g oipage
37
+ ```
38
+
39
+ 也可以作为项目开发中的一个功能加强,在 package.json 中配置命令或nodejs文件中引入需要的模块使用,那么就在项目中执行安装命令:
40
+
41
+ ```shell
42
+ npm install oipage --save
43
+ ```
44
+
45
+ 全局安装后,就可以直接作为命令行使用了。你可以打印帮助查看:
46
+
47
+ ```shell
48
+ oipage-cli
49
+ ```
50
+
51
+ 比如会出现下列内容:
52
+
53
+ ```
54
+ OIPage@v1.0.0
55
+
56
+ 可以使用的命令如下:
57
+
58
+ 【1】oipage-cli serve 开发服务器
59
+ --port|-p 端口号
60
+ --baseUrl 服务器根目录(相对命令行)
61
+ ......
62
+ ```
63
+
64
+ 根据提示我们知道,比如第一个命令,其提供了一个快速访问本地资源服务器的功能,比如执行:
65
+
66
+ ```shell
67
+ oipage-cli serve -p 8080
68
+ ```
69
+
70
+ 启动成功后,直接访问: http://localhost:8080/ 即可。
71
+
72
+ 如果你需要在项目中使用,我们也提供了一些有用的API,具体可以访问[ 在线文档 ](https://oi-contrib.github.io/OIPage)进行了解。
73
+
18
74
  ## 版权
19
75
 
20
76
  MIT License
package/bin/format.js ADDED
@@ -0,0 +1,51 @@
1
+
2
+ // 把字节转换成更可读的内容
3
+ exports.formatByte = function (value) {
4
+ if (value < 1024) return value + "Byte";
5
+
6
+ let kb = value / 1024;
7
+ if (kb < 1024) return kb.toFixed(1) + "KB";
8
+
9
+ let mb = kb / 1024;
10
+ if (mb < 1024) return mb.toFixed(1) + "MB";
11
+
12
+ let gb = mb / 1024;
13
+ return gb.toFixed(1) + "GB";
14
+ };
15
+
16
+ // 把时间变成更可读的格式
17
+ exports.formatTime = function (value) {
18
+ let year = value.getFullYear();
19
+ let month = value.getMonth() + 1;
20
+ let day = value.getDate();
21
+
22
+ let hour = value.getHours();
23
+ let minutes = value.getMinutes();
24
+
25
+ let today = new Date();
26
+ if (year == today.getFullYear() && month == today.getMonth() + 1 && day == today.getDate()) {
27
+ return "今天 " + hour + ":" + minutes;
28
+ } else {
29
+ return year + "年" + month + "月" + day + "日 " + hour + ":" + minutes;
30
+ }
31
+ };
32
+
33
+ exports.formatArgv = function (argvs, shorts) {
34
+ let result = {};
35
+
36
+ let keyName = "args", value = [];
37
+ for (let index = 3; index < argvs.length; index++) {
38
+ let argv = argvs[index];
39
+
40
+ if (/^\-/.test(argv)) {
41
+ result[keyName] = value;
42
+ keyName = shorts[argv] || argv;
43
+ value = [];
44
+ } else {
45
+ value.push(argv);
46
+ }
47
+ }
48
+ result[keyName] = value;
49
+
50
+ return result;
51
+ };
package/bin/help.js ADDED
@@ -0,0 +1,16 @@
1
+ const packageValue = require("../package.json");
2
+
3
+ module.exports = function () {
4
+ console.log(`\x1b[36m
5
+ OIPage@v${packageValue.version}
6
+
7
+ 可以使用的命令如下:
8
+
9
+ 【1】oipage-cli serve 开发服务器
10
+ --port|-p 端口号
11
+ --baseUrl 服务器根目录(相对命令行)
12
+
13
+ Powered by https://github.com/zxl20070701
14
+ \x1b[0m`);
15
+
16
+ };
package/bin/resolve404.js CHANGED
@@ -1,78 +1,82 @@
1
- const { readdirSync, lstatSync, readFileSync } = require("fs");
1
+ const { readdirSync, lstatSync, readFileSync, statSync } = require("fs");
2
2
  const { join } = require("path");
3
+ const { formatByte, formatTime } = require("./format");
4
+ const mineTypes = require("./mineTypes.json");
3
5
 
4
6
  const img_folder = "data:image/png;base64," + readFileSync(join(__dirname, "../images/folder.png")).toString('base64');
5
7
  const img_file = "data:image/png;base64," + readFileSync(join(__dirname, "../images/file.png")).toString('base64');
6
- const img_goback = "data:image/png;base64," + readFileSync(join(__dirname, "../images/goback.png")).toString('base64');
7
8
 
8
- module.exports = function (filePath) {
9
+ const template_404 = readFileSync(join(__dirname, "../template/404.html"), {
10
+ encoding: "utf8"
11
+ })
12
+ .replace("${img_folder}", img_folder)
13
+ .replace("${img_file}", img_file);
14
+
15
+ module.exports = function (filePath, url) {
9
16
 
10
17
  let subItems = [];
11
18
 
12
19
  try {
13
20
  subItems = readdirSync(filePath);
21
+ console.log("<i> \x1b[1m\x1b[32m[OIPage-dev-server] Read Folder: " + url + '\x1b[0m ' + new Date().toLocaleString());
14
22
  } catch (e) {
23
+ console.log("<i> \x1b[1m\x1b[32m[OIPage-dev-server] Read " + (/\/$/.test(url) ? "Folder" : "File") + ": \x1b[35m" + url + ' 404 Not Found\x1b[0m ' + new Date().toLocaleString());
15
24
  try {
16
25
  filePath = join(filePath, "../");
17
26
  subItems = readdirSync(filePath);
18
27
  } catch (e) { }
19
28
  }
20
29
 
21
- let template = "<a class='goback' href='../'>返回</a>";
30
+ let template = "";
22
31
  for (let i in subItems) {
23
32
  let isDirectory = lstatSync(join(filePath, subItems[i])).isDirectory();
24
- template += "<a class='" + (isDirectory ? "folder" : "file") + "' href='./" + subItems[i] + (isDirectory ? "/" : "") + "'>" + subItems[i] + "</a>";
33
+ let statObj = statSync(join(filePath, subItems[i]));
34
+
35
+ // 文件夹
36
+ if (isDirectory) {
37
+ template += `<tr class="folder">
38
+ <th class="name">
39
+ <a href='./${subItems[i]}/'>${subItems[i]}</a>
40
+ </th>
41
+ <th>
42
+ ${formatTime(statObj.mtime)}
43
+ </th>
44
+ <th>
45
+ 文件夹
46
+ </th>
47
+ <th>
48
+ -
49
+ </th>
50
+ <th>
51
+ <a href='./${subItems[i]}/' class="btn">打开</a>
52
+ </th>
53
+ </tr>`;
54
+ }
55
+
56
+ // 文件
57
+ else {
58
+ let dotName = /\./.test(subItems[i]) ? subItems[i].match(/\.([^.]+)$/)[1] : "";
59
+
60
+ template += `<tr class="file">
61
+ <th class="name">
62
+ <a href='./${subItems[i]}'>${subItems[i]}</a>
63
+ </th>
64
+ <th>
65
+ ${formatTime(statObj.mtime)}
66
+ </th>
67
+ <th>
68
+ ${mineTypes[dotName] || "text/plain"}
69
+ </th>
70
+ <th>
71
+ ${formatByte(statObj.size)}
72
+ </th>
73
+ <th>
74
+ <a href='./${subItems[i]}' class="btn">访问</a>
75
+ <a href='./${subItems[i]}' class="btn" download='${subItems[i]}'>下载</a>
76
+ </th>
77
+ </tr>`;
78
+ }
25
79
  }
26
80
 
27
- return `<!DOCTYPE html>
28
- <html lang="zh-cn">
29
-
30
- <head>
31
- <meta charset="UTF-8">
32
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
33
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
34
- <title>404 Not Found</title>
35
- <style>
36
- body{
37
- margin: 0px;
38
- background-color:#fcfcfc;
39
- display: flex;
40
- flex-wrap:wrap;
41
- padding:100px;
42
- }
43
- body>a{
44
- text-decoration: none;
45
- padding:10px;
46
- color:#000000;
47
- text-align:center;
48
- width:100px;
49
- background-repeat: no-repeat;
50
- background-position: center 0px;
51
- padding-top: 65px;
52
- margin-top: 50px;
53
- font-size:12px;
54
- background-size: 55% auto;
55
- }
56
- body>a:hover{
57
- outline:1px solid #55b9e6;
58
- }
59
- body>a.folder{
60
- background-image:url('${img_folder}');
61
- }
62
- body>a.file{
63
- background-image:url('${img_file}');
64
- }
65
- body>a.goback{
66
- background-image:url('${img_goback}');
67
- }
68
- </style>
69
- </head>
70
-
71
- <body>
72
-
73
- ${template}
74
-
75
- </body>
76
-
77
- </html>`;
81
+ return template_404.replace("${current}", filePath).replace("${template}", template);
78
82
  };
package/bin/run CHANGED
@@ -4,14 +4,24 @@
4
4
 
5
5
  process.title = 'OIPage';
6
6
 
7
+ const { formatArgv } = require("./format");
8
+ const doServe = require("./serve");
9
+ const doHelp = require("./help");
10
+
7
11
  // 开发服务器
8
12
  if (process.argv[2] == "serve") {
9
- require("./serve")({
10
-
13
+
14
+ let argvObj = formatArgv(process.argv, {
15
+ "-p": "--port"
16
+ });
17
+
18
+ doServe({
19
+ port: (argvObj["--port"] || [])[0] || 8080,
20
+ baseUrl: (argvObj["--baseUrl"] || [])[0] || "./",
11
21
  });
12
22
  }
13
23
 
14
24
  // 默认,帮助
15
25
  else {
16
-
26
+ doHelp();
17
27
  }
package/bin/serve.js CHANGED
@@ -10,8 +10,8 @@ const resolve404 = require("./resolve404.js");
10
10
  module.exports = function (config) {
11
11
  let startTime = new Date().valueOf();
12
12
 
13
- const port = config.port || 8080; // 端口号
14
- const basePath = join(process.cwd(), "./"); // 服务器根路径
13
+ const port = config.port; // 端口号
14
+ const basePath = join(process.cwd(), config.baseUrl); // 服务器根路径
15
15
 
16
16
  let Server = createServer(function (request, response) {
17
17
 
@@ -34,6 +34,8 @@ module.exports = function (config) {
34
34
  });
35
35
  response.write(readFileSync(filePath));
36
36
  response.end();
37
+
38
+ console.log("<i> \x1b[1m\x1b[32m[OIPage-dev-server] Read File: " + url + '\x1b[0m ' + new Date().toLocaleString());
37
39
  }
38
40
 
39
41
  // 否则就是404
@@ -43,7 +45,7 @@ module.exports = function (config) {
43
45
  'Access-Control-Allow-Origin': '*',
44
46
  'Server': 'Powered by OIPage-dev-server@' + packageValue.version
45
47
  });
46
- response.write(resolve404(filePath));
48
+ response.write(resolve404(filePath, url));
47
49
  response.end();
48
50
  }
49
51
 
@@ -56,9 +58,9 @@ module.exports = function (config) {
56
58
 
57
59
  // 打印成功提示
58
60
  console.log('<i> \x1b[1m\x1b[32m[OIPage-dev-server] Project is running at:\x1b[0m');
59
- console.log('<i> \x1b[1m\x1b[32m[OIPage-dev-server] Loopback: \x1b[36mhttp://localhost:/' + port + '\x1b[0m');
61
+ console.log('<i> \x1b[1m\x1b[32m[OIPage-dev-server] Loopback: \x1b[36mhttp://localhost:' + port + '/\x1b[0m');
60
62
  for (let ipv4Item of networkValue.IPv4) console.log('<i> \x1b[1m\x1b[32m[OIPage-dev-server] On Your Network (IPv4):\x1b[36m http://' + ipv4Item.address + ':' + port + '/\x1b[0m');
61
63
  for (let ipv6Item of networkValue.IPv6) console.log('<i> \x1b[1m\x1b[32m[OIPage-dev-server] On Your Network (IPv6): \x1b[36mhttp://[' + ipv6Item.address + ']:' + port + '/\x1b[0m');
62
64
  console.log('<i> \x1b[1m\x1b[32m[OIPage-dev-server] Content not from OIPage is served from \x1b[36m"' + basePath + '" \x1b[0mdirectory');
63
- console.log('\nOIPage ' + packageValue.version + ' compiled \x1b[1m\x1b[32msuccessfully\x1b[0m in ' + (new Date().valueOf() - startTime) + ' ms')
65
+ console.log('\nOIPage ' + packageValue.version + ' compiled \x1b[1m\x1b[32msuccessfully\x1b[0m in ' + (new Date().valueOf() - startTime) + ' ms\n')
64
66
  };
package/images/file.png CHANGED
Binary file
package/images/folder.png CHANGED
Binary file
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * animation of OIPage v1.0.0-alpha.0
2
+ * animation of OIPage v1.0.0-beta.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -92,14 +92,16 @@ function animation(doback, duration, callback) {
92
92
  doback(deep);
93
93
  }, duration, callback);
94
94
 
95
- // 返回一个函数
96
- // 用于在动画结束前结束动画
97
- return function () {
98
- var i;
99
- for (i in $timers) {
100
- if ($timers[i].id == id) {
101
- $timers[i].id = void 0;
102
- return;
95
+ return {
96
+ // 一个函数
97
+ // 用于在动画结束前结束动画
98
+ stop: function () {
99
+ var i;
100
+ for (i in $timers) {
101
+ if ($timers[i].id == id) {
102
+ $timers[i].id = void 0;
103
+ return;
104
+ }
103
105
  }
104
106
  }
105
107
  };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * 单行打印
3
+ * @param stream 打印的内容
4
+ */
5
+ export interface linelogType {
6
+ (stream: string): void
7
+ }
8
+
9
+ export let linelog: linelogType
10
+
11
+ /**
12
+ * 进度打印
13
+ * @param percentum 进度0-100
14
+ * @param stream 说明文字,可选
15
+ */
16
+ export interface deeplogType {
17
+ (percentum: number, stream?: string): void
18
+ }
19
+
20
+ export let deeplog: deeplogType
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * linelog of OIPage v1.0.0-alpha.0
2
+ * cmdlog of OIPage v1.0.0-beta.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -8,6 +8,11 @@ const MOVE_LEFT = Buffer.from('1b5b3130303044', 'hex').toString();
8
8
  const MOVE_UP = Buffer.from('1b5b3141', 'hex').toString();
9
9
  const CLEAR_LINE = Buffer.from('1b5b304b', 'hex').toString();
10
10
 
11
+ // 计算字符串长度的方法
12
+ const stringwidth = function (str) {
13
+ return str.length;
14
+ };
15
+
11
16
  /**
12
17
  * 不换行打印
13
18
  * @param {string} stream 打印的内容
@@ -43,5 +48,35 @@ let linelog = (function (stream) {
43
48
 
44
49
  };
45
50
  })(process.stdout);
46
-
51
+
52
+ /**
53
+ * 进度打印
54
+ *
55
+ * @param {number} percentum 进度0-100
56
+ * @param {string} stream 说明文字,可选
57
+ */
58
+ function deeplog (percentum, stream) {
59
+ if (arguments.length == 0) {
60
+ linelog();
61
+ return;
62
+ }
63
+
64
+ if (arguments.length <= 1) stream = "";
65
+
66
+ let txt = "",
67
+ i = 0;
68
+
69
+ // 补充已经有的进度
70
+ for (; i <= percentum && i <= 100; i += 5) {
71
+ txt += "█";
72
+ }
73
+
74
+ // 补充余下的空白
75
+ for (; i <= 100; i += 5) {
76
+ txt += "░";
77
+ }
78
+
79
+ linelog(percentum.toFixed(2) + "%[" + txt + "]" + stream);
80
+ };
47
81
  exports.linelog = linelog;
82
+ exports.deeplog = deeplog;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * throttle of OIPage v1.0.0-alpha.0
2
+ * throttle of OIPage v1.0.0-beta.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
package/package.json CHANGED
@@ -1,13 +1,12 @@
1
1
  {
2
2
  "name": "oipage",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-beta.0",
4
4
  "description": "前端网页或应用快速开发助手,包括开发服务器、辅助命令、实用API等",
5
5
  "sideEffects": false,
6
6
  "scripts": {
7
7
  "dev": "node ./build/index.js watch",
8
8
  "build": "node ./build/index.js",
9
- "serve": "node ./bin/run serve",
10
- "doc": ""
9
+ "serve": "node ./bin/run serve -p 20000"
11
10
  },
12
11
  "bin": {
13
12
  "oipage-cli": "bin/run"
@@ -34,7 +33,7 @@
34
33
  "bugs": {
35
34
  "url": "https://github.com/oi-contrib/OIPage/issues"
36
35
  },
37
- "homepage": "https://github.com/oi-contrib/OIPage",
36
+ "homepage": "https://oi-contrib.github.io/OIPage",
38
37
  "devDependencies": {
39
38
  "oipage": "^0.2.0"
40
39
  }
@@ -0,0 +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
+
172
+ </html>
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * animation of OIPage v1.0.0-alpha.0
2
+ * animation of OIPage v1.0.0-beta.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -18,7 +18,7 @@ var $timerId;
18
18
  *
19
19
  * @returns {function} 返回一个函数,调用该函数,可以提前结束动画
20
20
  */
21
- function animation(doback, duration, callback) {
21
+ export function animation(doback, duration, callback) {
22
22
  if (arguments.length < 2) duration = 400;
23
23
  if (arguments.length < 3) callback = function () { };
24
24
 
@@ -92,17 +92,18 @@ function animation(doback, duration, callback) {
92
92
  doback(deep);
93
93
  }, duration, callback);
94
94
 
95
- // 返回一个函数
96
- // 用于在动画结束前结束动画
97
- return function () {
98
- var i;
99
- for (i in $timers) {
100
- if ($timers[i].id == id) {
101
- $timers[i].id = void 0;
102
- return;
95
+ return {
96
+ // 一个函数
97
+ // 用于在动画结束前结束动画
98
+ stop: function () {
99
+ var i;
100
+ for (i in $timers) {
101
+ if ($timers[i].id == id) {
102
+ $timers[i].id = void 0;
103
+ return;
104
+ }
103
105
  }
104
106
  }
105
107
  };
106
108
 
107
- };
108
- export let animation = animation;
109
+ };
@@ -1,14 +1,13 @@
1
1
  /*!
2
- * onReady of OIPage v1.0.0-alpha.0
2
+ * onReady of OIPage v1.0.0-beta.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
6
- function onReady(callback) {
6
+ export function onReady(callback) {
7
7
  var readyState = document.readyState;
8
8
  if (readyState === 'interactive' || readyState === 'complete') {
9
9
  callback();
10
10
  } else {
11
11
  window.addEventListener("DOMContentLoaded", callback);
12
12
  }
13
- };
14
- export let onReady = onReady;
13
+ };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * 设置节点样式
3
+ */
4
+ export interface setStyleType {
5
+ (el: HTMLElement, styles: {
6
+ [key: string]: string | number
7
+ }): void
8
+ }
9
+
10
+ export let setStyle: setStyleType
11
+
12
+ /**
13
+ * 获取节点样式
14
+ */
15
+ export interface getStyleType {
16
+ (el: HTMLElement, name: string): string
17
+ (el: HTMLElement): {
18
+ [key: string]: string
19
+ }
20
+ }
21
+
22
+ export let getStyle: getStyleType
@@ -1,9 +1,15 @@
1
1
  /*!
2
- * getStyle of OIPage v1.0.0-alpha.0
2
+ * style of OIPage v1.0.0-beta.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
6
- function getStyle(el, name) {
6
+ export function setStyle(el, styles) {
7
+ for (var key in styles) {
8
+ el.style[key] = styles[key];
9
+ }
10
+ };
11
+
12
+ export function getStyle(el, name) {
7
13
 
8
14
  // 获取结点的全部样式
9
15
  var allStyle = document.defaultView && document.defaultView.getComputedStyle ?
@@ -15,5 +21,4 @@ function getStyle(el, name) {
15
21
  allStyle.getPropertyValue(name) :
16
22
  allStyle;
17
23
 
18
- };
19
- export let getStyle = getStyle;
24
+ };
@@ -1,9 +1,9 @@
1
1
  /*!
2
- * throttle of OIPage v1.0.0-alpha.0
2
+ * throttle of OIPage v1.0.0-beta.0
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
6
- function throttle(callback, _option) {
6
+ export function throttle(callback, _option) {
7
7
 
8
8
  // 缺省值
9
9
  var option = {
@@ -52,5 +52,4 @@ function throttle(callback, _option) {
52
52
  }
53
53
 
54
54
  };
55
- };
56
- export let throttle = throttle;
55
+ };
package/images/goback.png DELETED
Binary file
@@ -1,10 +0,0 @@
1
- /**
2
- * 进度打印
3
- * @param percentum 进度0-100
4
- * @param stream 说明文字,可选
5
- */
6
- export interface deeplogType {
7
- (percentum: number, stream?: string): void
8
- }
9
-
10
- export let deeplog: deeplogType
@@ -1,35 +0,0 @@
1
- /*!
2
- * deeplog of OIPage v1.0.0-alpha.0
3
- * git+https://github.com/oi-contrib/OIPage.git
4
- */
5
- const {linelog} = require("../linelog/index.js");
6
- /**
7
- * 进度打印
8
- *
9
- * @param {number} percentum 进度0-100
10
- * @param {string} stream 说明文字,可选
11
- */
12
- function deeplog (percentum, stream) {
13
- if (arguments.length == 0) {
14
- linelog();
15
- return;
16
- }
17
-
18
- if (arguments.length <= 1) stream = "";
19
-
20
- let txt = "",
21
- i = 0;
22
-
23
- // 补充已经有的进度
24
- for (; i <= percentum && i <= 100; i += 5) {
25
- txt += "█";
26
- }
27
-
28
- // 补充余下的空白
29
- for (; i <= 100; i += 5) {
30
- txt += "░";
31
- }
32
-
33
- linelog(percentum.toFixed(2) + "%[" + txt + "]" + stream);
34
- };
35
- exports.deeplog = deeplog;
@@ -1,9 +0,0 @@
1
- /**
2
- * 单行打印
3
- * @param stream 打印的内容
4
- */
5
- export interface linelogType {
6
- (stream: string): void
7
- }
8
-
9
- export let linelog: linelogType
@@ -1,11 +0,0 @@
1
- /**
2
- * 获取节点样式
3
- */
4
- export interface getStyleType {
5
- (el: HTMLElement, name: string): string
6
- (el: HTMLElement): {
7
- [key: string]: string
8
- }
9
- }
10
-
11
- export let getStyle: getStyleType
@@ -1,10 +0,0 @@
1
- /**
2
- * 设置节点样式
3
- */
4
- export interface setStyleType {
5
- (el: HTMLElement, styles: {
6
- [key: string]: string | number
7
- }): void
8
- }
9
-
10
- export let setStyle: setStyleType
@@ -1,11 +0,0 @@
1
- /*!
2
- * setStyle of OIPage v1.0.0-alpha.0
3
- * git+https://github.com/oi-contrib/OIPage.git
4
- */
5
-
6
- function setStyle(el, styles) {
7
- for (var key in styles) {
8
- el.style[key] = styles[key];
9
- }
10
- };
11
- export let setStyle = setStyle;