oipage 1.5.0-alpha.1 → 1.5.0-alpha.3

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.
Files changed (38) hide show
  1. package/CHANGELOG +6 -1
  2. package/README.md +14 -0
  3. package/bin/run +4 -4
  4. package/bin/serve.js +3 -3
  5. package/bin/tools/resolve404.js +2 -2
  6. package/bin/website-htmls/components/ui-select-file/index.html +8 -0
  7. package/bin/website-htmls/components/ui-select-file/index.js +38 -0
  8. package/bin/website-htmls/components/ui-select-file/index.scss +45 -0
  9. package/bin/website-htmls/images/addFile.svg +1 -0
  10. package/bin/website-htmls/images/img-to-pdf.svg +1 -0
  11. package/bin/website-htmls/main.js +2 -0
  12. package/bin/website-htmls/pages/appStore/index.html +6 -0
  13. package/bin/website-htmls/pages/img-to-pdf/index.html +4 -0
  14. package/bin/website-htmls/pages/img-to-pdf/index.js +45 -0
  15. package/bin/website-htmls/pages/img-to-pdf/index.scss +5 -0
  16. package/bin/website-htmls/router.config.js +3 -0
  17. package/bin/website-plugins/intercept/oipage-vislite-intercept.js +1 -1
  18. package/bin/website-plugins/intercept/oipage-zipaper-intercept.js +1 -1
  19. package/nodejs/animation/index.js +1 -1
  20. package/nodejs/cmdlog/index.js +1 -1
  21. package/nodejs/disk/index.js +1 -1
  22. package/nodejs/format/index.js +3 -3
  23. package/nodejs/json/index.js +1 -1
  24. package/nodejs/logform/index.js +1 -1
  25. package/nodejs/reader/index.js +1 -1
  26. package/nodejs/throttle/index.js +1 -1
  27. package/package.json +1 -1
  28. package/snipping/chart.png +0 -0
  29. package/snipping/image-editor.png +0 -0
  30. package/web/XMLHttpRequest/index.js +1 -1
  31. package/web/animation/index.js +1 -1
  32. package/web/format/index.js +3 -3
  33. package/web/json/index.js +1 -1
  34. package/web/onReady/index.js +1 -1
  35. package/web/performChunk/index.js +1 -1
  36. package/web/reader/index.js +1 -1
  37. package/web/style/index.js +1 -1
  38. package/web/throttle/index.js +1 -1
package/CHANGELOG CHANGED
@@ -103,7 +103,12 @@ v1.5.0:
103
103
  - 修复bug
104
104
  1、修复404网站在手机浏览器显示高问题
105
105
  2、服务器响应类型由 Content-type 改为 Content-Type
106
+ 3、修复dateFormat第二个参数无法缺省报错
107
+ 4、修复numberFormat不支持负数问题
108
+ - 优化改造
109
+ 1、优化run命令日志打印
106
110
  - 新增功能
107
111
  1、开发服务器 / 应用市场
108
112
  * 聊天工具
109
- * 图片编辑器
113
+ * 图片编辑器
114
+ * 图片转PDF
package/README.md CHANGED
@@ -74,6 +74,20 @@ oipage-cli serve -p 8080
74
74
 
75
75
  如果你需要在项目中使用,我们也提供了一些有用的API,具体可以访问[ 在线文档 ](https://oi-contrib.github.io/OIPage)进行了解。
76
76
 
77
+ ## 应用市场
78
+
79
+ 为了方便日常使用,内置了一个应用市场网站,比如有如下功能:
80
+
81
+ ### 群聊贴
82
+
83
+ <img src="./snipping/chart.png" />
84
+
85
+ ### 图片编辑器
86
+
87
+ <img src="./snipping/image-editor.png" />
88
+
89
+ 已有功能或更多功能我们将根据实际情况逐步完善和维护,当然,你可以通过 [issue](https://github.com/oi-contrib/VISLite/issues) 给我们留言,告诉我们你的改进意见。
90
+
77
91
  ## 版权
78
92
 
79
93
  MIT License
package/bin/run CHANGED
@@ -72,22 +72,22 @@ else if (process.argv[2] === "run") {
72
72
 
73
73
  // 监听子线程的stdout
74
74
  child.stdout.on('data', (data) => {
75
- console.log(`[${index + 1}] log:${data}`);
75
+ process.stdout.write(`${data}`);
76
76
  });
77
77
 
78
78
  // 监听子线程的stderr
79
79
  child.stderr.on('data', (data) => {
80
- console.error(`[${index + 1}] error:${data}`);
80
+ process.stdout.write(`${data}`);
81
81
  });
82
82
 
83
83
  // 子线程结束处理
84
84
  child.on('close', (code) => {
85
- console.log(`[${index + 1}] 子线程结束,退出码 ${code}`);
85
+ console.log(`子线程${index + 1}结束,退出码 ${code}`);
86
86
  });
87
87
 
88
88
  // 子线程出错处理
89
89
  child.on('error', (error) => {
90
- console.error(`[${index + 1}] 子线程错误: ${error.message}`);
90
+ console.error(`子线程${index + 1}错误: ${error.message}`);
91
91
  });
92
92
  }
93
93
 
package/bin/serve.js CHANGED
@@ -18,13 +18,13 @@ module.exports = function (config) {
18
18
  let startTime = new Date().valueOf();
19
19
 
20
20
  const cache = "cache" in config.devServer ? config.devServer.cache : true;
21
- const port = config.devServer.port; // 端口号
21
+ const port = +config.devServer.port; // 端口号
22
22
  const basePath = (/^\./.test(config.devServer.baseUrl)) ? join(process.cwd(), config.devServer.baseUrl) : config.devServer.baseUrl; // 服务器根路径
23
23
 
24
- const name = (config.name || "OIPage") + "-dev-server";
24
+ const name = (config.name || "OIPage") + "-http-server";
25
25
  const version = config.version || packageValue.version;
26
26
 
27
- const wsHandler = WebSocketClass(port + 1, (config.name || "OIPage") + "-dev-websocket", version);
27
+ const wsHandler = WebSocketClass(port + 1, (config.name || "OIPage") + "-ws-server", version);
28
28
 
29
29
  let Server = createServer(function (request, response) {
30
30
  let headers = request.headers;
@@ -18,9 +18,9 @@ module.exports = function (filePath, url) {
18
18
 
19
19
  try {
20
20
  subItems = readdirSync(filePath);
21
- console.log("<i> \x1b[1m\x1b[32m[OIPage-dev-server] Read Folder: " + url + '\x1b[0m ' + new Date().toLocaleString());
21
+ console.log("<i> \x1b[1m\x1b[32m[OIPage-http-server] Read Folder: " + url + '\x1b[0m ' + new Date().toLocaleString());
22
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());
23
+ console.log("<i> \x1b[1m\x1b[32m[OIPage-http-server] Read " + (/\/$/.test(url) ? "Folder" : "File") + ": \x1b[35m" + url + ' 404 Not Found\x1b[0m ' + new Date().toLocaleString());
24
24
  try {
25
25
  if (!/\/$/.test(url) || url === "/") {
26
26
  filePath = join(filePath, "../");
@@ -0,0 +1,8 @@
1
+ <div class="ui-select-file-view">
2
+ <h2 class="title" z-bind="_props.title"></h2>
3
+ <div class="tips" z-bind="_props.tips"></div>
4
+ <div class="file">
5
+ <input type="file" multiple id="input" z-on:change.stop="doChange" z-bind:accept="accept" />
6
+ <label for="input" z-bind="'选择'+_props.type+'文件'"></label>
7
+ </div>
8
+ </div>
@@ -0,0 +1,38 @@
1
+ import { defineElement } from "zipaper";
2
+ import template from "./index.html";
3
+ import style from "./index.scss";
4
+
5
+ export default defineElement({
6
+ template,
7
+ emits: ["change"],
8
+ props: {
9
+ title: {
10
+ type: String,
11
+ required: true,
12
+ },
13
+ tips: {
14
+ type: String,
15
+ required: true,
16
+ },
17
+ type: {
18
+ type: String,
19
+ required: true,
20
+ },
21
+ },
22
+ data() {
23
+ return {
24
+ accept: {
25
+ pdf: "application/pdf",
26
+ image: "image/*"
27
+ }[this._props.type]
28
+ };
29
+ },
30
+ methods: {
31
+ doChange(event, target) {
32
+ this.$emit("change", target.files);
33
+ }
34
+ },
35
+ style: {
36
+ content: style
37
+ }
38
+ });
@@ -0,0 +1,45 @@
1
+ .ui-select-file-view{
2
+ &>.title {
3
+ text-align: center;
4
+ font-weight: 700;
5
+ color: rgb(26, 26, 26);
6
+ font-size: 36px;
7
+ line-height: 48px;
8
+ padding-top: 30px;
9
+ }
10
+
11
+ &>.tips {
12
+ text-align: center;
13
+ line-height: 30px;
14
+ font-size: 22px;
15
+ color: rgb(26, 26, 26);
16
+ font-weight: 300;
17
+ }
18
+
19
+ &>.file {
20
+ text-align: center;
21
+ margin-top: 30px;
22
+
23
+ input {
24
+ display: none;
25
+ }
26
+
27
+ label {
28
+ line-height: 50px;
29
+ display: inline-block;
30
+ border: 1px solid gray;
31
+ background-image: url("./images/addFile.svg");
32
+ background-repeat: no-repeat;
33
+ background-position: 5px center;
34
+ background-size: auto 70%;
35
+ padding-left: 40px;
36
+ padding-right: 10px;
37
+ border-radius: 5px;
38
+
39
+ &:hover {
40
+ text-decoration: underline;
41
+ cursor: pointer;
42
+ }
43
+ }
44
+ }
45
+ }
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 12v-2h1v2h2v1h-2v2h-1v-2h-2v-1h2zm5 8H6V4H5v17h13v-1zm1 0v2H4V3h2V1h10l5 5v14h-2zM7 2v17h13V6l-4-4H7zm9 0l4 4h-4V2z"></path></svg>
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M0 4C0 1.79086 1.79086 0 4 0H20C22.2091 0 24 1.79086 24 4V20C24 22.2091 22.2091 24 20 24H4C1.79086 24 0 22.2091 0 20V4Z" fill="#FFB700"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M6.99992 8L13.9999 14.5625L16.9544 11.7927L24 17.5625V20L17.0455 14.3589L13.9999 17.2141L6.99992 10.6517L0 17.1875V14.5625L6.99992 8Z" fill="white"></path><circle cx="18" cy="6" r="3" fill="white"></circle></svg>
@@ -3,10 +3,12 @@ import { createApp } from "zipaper"
3
3
  import App from "./pages/App/index.js"
4
4
  import router from "./router.config.js"
5
5
  import dialogs from "./dialogs/index.js"
6
+ import uiSelectFile from "./components/ui-select-file/index.js"
6
7
 
7
8
  // https://oi-contrib.github.io/Zipaper/index.html
8
9
 
9
10
  createApp(App)
10
11
  .use(router) // 路由
11
12
  .use(dialogs) // 弹框
13
+ .component("ui-select-file", uiSelectFile)
12
14
  .mount(document.getElementById("root")) // 挂载到页面
@@ -15,5 +15,11 @@
15
15
  图片编辑器
16
16
  </h2>
17
17
  </li>
18
+ <li z-on:click="goto" tag="img-to-pdf">
19
+ <img src="./images/img-to-pdf.svg" />
20
+ <h2>
21
+ 图片转PDF
22
+ </h2>
23
+ </li>
18
24
  </ul>
19
25
  </div>
@@ -0,0 +1,4 @@
1
+ <div class="img-to-pdf-view">
2
+ <ui-select-file z-on:change="doChange" title="图片转PDF" tips="选择一张或多张图片后,可以把这些图片拼接成一个PDF文件" type="image"></ui-select-file>
3
+ <iframe id="iframe"></iframe>
4
+ </div>
@@ -0,0 +1,45 @@
1
+ import { defineElement, ref } from "zipaper"
2
+ import template from "./index.html"
3
+ import style from "./index.scss"
4
+
5
+ export default defineElement({
6
+ template,
7
+ methods: {
8
+ doChange(event) {
9
+ let files = event.data, promises = [], iframeEl = document.getElementById("iframe");
10
+
11
+ let template = "";
12
+ for (let index = 0; index < files.length; index++) {
13
+ let file = files[index];
14
+
15
+ promises.push(new Promise(function (resolve) {
16
+
17
+ let reader = new FileReader();
18
+
19
+ reader.onload = function () {
20
+
21
+ template += '<div style="display: flex;justify-content: center;align-items: center;height: 100vh;width: 100vw;"><img src="' + reader.result + '" style="max-width: 100vw;max-height: 100vh;"></img></div>';
22
+ resolve("");
23
+ }
24
+ reader.readAsDataURL(file);
25
+ }));
26
+ }
27
+
28
+ Promise.all(promises).then(function () {
29
+ let iframeWindow = iframeEl.contentWindow;
30
+ let iframeDocument = iframeEl.contentWindow?.document;
31
+
32
+ iframeDocument.open();
33
+ iframeDocument.write(`<style>body{margin:0px;}</style>` + template);
34
+ iframeDocument.close();
35
+
36
+ setTimeout(function () {
37
+ iframeWindow.print();
38
+ }, 500);
39
+ });
40
+ }
41
+ },
42
+ style: {
43
+ content: style
44
+ }
45
+ })
@@ -0,0 +1,5 @@
1
+ .img-to-pdf-view {
2
+ iframe {
3
+ display: none;
4
+ }
5
+ }
@@ -13,5 +13,8 @@ export default defineRouter({
13
13
  }, {
14
14
  path: "/image-editor",
15
15
  component: () => import("./pages/image-editor/index.js"),
16
+ }, {
17
+ path: "/img-to-pdf",
18
+ component: () => import("./pages/img-to-pdf/index.js"),
16
19
  }]
17
20
  })
@@ -14,7 +14,7 @@ module.exports = {
14
14
  if (request.headers["if-none-match"] === head["ETag"]) {
15
15
  response.writeHead('304', head);
16
16
  response.end();
17
- console.log("<i> \x1b[1m\x1b[32m[OIPage-dev-server] Cache File: VISLite\x1b[0m " + new Date().toLocaleString() + "\x1b[33m\x1b[1m 304\x1b[0m");;
17
+ console.log("<i> \x1b[1m\x1b[32m[OIPage-http-server] Cache File: VISLite\x1b[0m " + new Date().toLocaleString() + "\x1b[33m\x1b[1m 304\x1b[0m");;
18
18
  return;
19
19
  }
20
20
 
@@ -14,7 +14,7 @@ module.exports = {
14
14
  if (request.headers["if-none-match"] === head["ETag"]) {
15
15
  response.writeHead('304', head);
16
16
  response.end();
17
- console.log("<i> \x1b[1m\x1b[32m[OIPage-dev-server] Cache File: Zipaper\x1b[0m " + new Date().toLocaleString() + "\x1b[33m\x1b[1m 304\x1b[0m");;
17
+ console.log("<i> \x1b[1m\x1b[32m[OIPage-http-server] Cache File: Zipaper\x1b[0m " + new Date().toLocaleString() + "\x1b[33m\x1b[1m 304\x1b[0m");;
18
18
  return;
19
19
  }
20
20
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * animation of OIPage v1.5.0-alpha.1
2
+ * animation of OIPage v1.5.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * cmdlog of OIPage v1.5.0-alpha.1
2
+ * cmdlog of OIPage v1.5.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * disk of OIPage v1.5.0-alpha.1
2
+ * disk of OIPage v1.5.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * format of OIPage v1.5.0-alpha.1
2
+ * format of OIPage v1.5.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -26,12 +26,12 @@ function numberFormat(input) {
26
26
  integerArray.unshift(integerValue.substring(index > 2 ? index - 3 : 0, index));
27
27
  }
28
28
 
29
- return integerArray.join(",") + decimalValue;
29
+ return integerArray.join(",").replace(/^\-,/, "-") + decimalValue;
30
30
  }
31
31
  }
32
32
 
33
33
  function dateFormat(input, option) {
34
- option = option || option;
34
+ option = option || {};
35
35
  var dateObj;
36
36
 
37
37
  // 如果无值,就用当前日期
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * json of OIPage v1.5.0-alpha.1
2
+ * json of OIPage v1.5.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
  const {reader} = require("../reader/index.js");
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * logform of OIPage v1.5.0-alpha.1
2
+ * logform of OIPage v1.5.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
  const {linelog} = require("../cmdlog/index.js");
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * reader of OIPage v1.5.0-alpha.1
2
+ * reader of OIPage v1.5.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * throttle of OIPage v1.5.0-alpha.1
2
+ * throttle of OIPage v1.5.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oipage",
3
- "version": "1.5.0-alpha.1",
3
+ "version": "1.5.0-alpha.3",
4
4
  "description": "前端网页或应用快速开发助手,包括开发服务器、辅助命令、实用API等",
5
5
  "sideEffects": false,
6
6
  "scripts": {
Binary file
Binary file
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * XMLHttpRequest of OIPage v1.5.0-alpha.1
2
+ * XMLHttpRequest of OIPage v1.5.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * animation of OIPage v1.5.0-alpha.1
2
+ * animation of OIPage v1.5.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * format of OIPage v1.5.0-alpha.1
2
+ * format of OIPage v1.5.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -26,12 +26,12 @@ export function numberFormat(input) {
26
26
  integerArray.unshift(integerValue.substring(index > 2 ? index - 3 : 0, index));
27
27
  }
28
28
 
29
- return integerArray.join(",") + decimalValue;
29
+ return integerArray.join(",").replace(/^\-,/, "-") + decimalValue;
30
30
  }
31
31
  }
32
32
 
33
33
  export function dateFormat(input, option) {
34
- option = option || option;
34
+ option = option || {};
35
35
  var dateObj;
36
36
 
37
37
  // 如果无值,就用当前日期
package/web/json/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * json of OIPage v1.5.0-alpha.1
2
+ * json of OIPage v1.5.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
  import {reader} from "../reader/index.js";
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * onReady of OIPage v1.5.0-alpha.1
2
+ * onReady of OIPage v1.5.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * performChunk of OIPage v1.5.0-alpha.1
2
+ * performChunk of OIPage v1.5.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * reader of OIPage v1.5.0-alpha.1
2
+ * reader of OIPage v1.5.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * style of OIPage v1.5.0-alpha.1
2
+ * style of OIPage v1.5.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * throttle of OIPage v1.5.0-alpha.1
2
+ * throttle of OIPage v1.5.0-alpha.3
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5