oipage 1.4.1 → 1.5.0-alpha.1

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 (56) hide show
  1. package/CHANGELOG +11 -1
  2. package/bin/WebSocket/decodeWsFrame.js +43 -0
  3. package/bin/WebSocket/encodeWsFrame.js +28 -0
  4. package/bin/WebSocket/headersToJSON.js +26 -0
  5. package/bin/WebSocket/index.js +80 -0
  6. package/bin/intercept.js +2 -2
  7. package/bin/serve.js +14 -10
  8. package/bin/template/404.html +5 -2
  9. package/bin/website-htmls/dialogs/imageSize/index.html +55 -0
  10. package/bin/website-htmls/dialogs/imageSize/index.js +53 -0
  11. package/bin/website-htmls/dialogs/imageSize/index.scss +139 -0
  12. package/bin/website-htmls/dialogs/index.js +29 -19
  13. package/bin/website-htmls/images/chart.png +0 -0
  14. package/bin/website-htmls/images/image-editor.png +0 -0
  15. package/bin/website-htmls/images/lock.png +0 -0
  16. package/bin/website-htmls/images/mosaic.png +0 -0
  17. package/bin/website-htmls/images/size.png +0 -0
  18. package/bin/website-htmls/index.html +1 -1
  19. package/bin/website-htmls/main.js +2 -0
  20. package/bin/website-htmls/pages/App/index.html +4 -1
  21. package/bin/website-htmls/pages/App/index.scss +6 -5
  22. package/bin/website-htmls/pages/appStore/index.html +19 -6
  23. package/bin/website-htmls/pages/appStore/index.js +3 -1
  24. package/bin/website-htmls/pages/appStore/index.scss +38 -23
  25. package/bin/website-htmls/pages/chart/index.html +9 -0
  26. package/bin/website-htmls/pages/chart/index.js +73 -0
  27. package/bin/website-htmls/pages/chart/index.scss +73 -0
  28. package/bin/website-htmls/pages/image-editor/index.html +28 -0
  29. package/bin/website-htmls/pages/image-editor/index.js +107 -0
  30. package/bin/website-htmls/pages/image-editor/index.scss +46 -0
  31. package/bin/website-htmls/router.config.js +6 -0
  32. package/bin/website-htmls/styles/common.css +0 -3
  33. package/bin/website-plugins/intercept/chart.js +34 -0
  34. package/bin/website-plugins/intercept/head.js +1 -1
  35. package/bin/website-plugins/intercept/index.js +5 -1
  36. package/bin/website-plugins/intercept/oipage-vislite-intercept.js +34 -0
  37. package/bin/website-plugins/intercept/oipage-zipaper-intercept.js +2 -2
  38. package/nodejs/animation/index.js +1 -1
  39. package/nodejs/cmdlog/index.js +1 -1
  40. package/nodejs/disk/index.js +1 -1
  41. package/nodejs/format/index.js +1 -1
  42. package/nodejs/json/index.js +1 -1
  43. package/nodejs/logform/index.js +1 -1
  44. package/nodejs/reader/index.js +1 -1
  45. package/nodejs/throttle/index.js +1 -1
  46. package/package.json +2 -2
  47. package/web/XMLHttpRequest/index.js +1 -1
  48. package/web/animation/index.js +1 -1
  49. package/web/format/index.js +1 -1
  50. package/web/json/index.js +1 -1
  51. package/web/onReady/index.js +1 -1
  52. package/web/performChunk/index.js +1 -1
  53. package/web/reader/index.js +1 -1
  54. package/web/style/index.js +1 -1
  55. package/web/throttle/index.js +1 -1
  56. /package/bin/website-htmls/{logo.png → images/logo.png} +0 -0
package/CHANGELOG CHANGED
@@ -96,4 +96,14 @@ v1.4.1:
96
96
  date:2025-09-02
97
97
  changes:
98
98
  - 修复bug
99
- 1、修复开发服务器大文件丢失文件大小问题
99
+ 1、修复开发服务器大文件丢失文件大小问题
100
+ v1.5.0:
101
+ date:
102
+ changes:
103
+ - 修复bug
104
+ 1、修复404网站在手机浏览器显示高问题
105
+ 2、服务器响应类型由 Content-type 改为 Content-Type
106
+ - 新增功能
107
+ 1、开发服务器 / 应用市场
108
+ * 聊天工具
109
+ * 图片编辑器
@@ -0,0 +1,43 @@
1
+
2
+ // 处理收到的数据
3
+ module.exports = function decodeWsFrame(data) {
4
+ let start = 0;
5
+ let frame = {
6
+ isFinal: (data[start] & 0x80) === 0x80,
7
+ opcode: data[start++] & 0xF,
8
+ masked: (data[start] & 0x80) === 0x80,
9
+ payloadLen: data[start++] & 0x7F,
10
+ maskingKey: '',
11
+ payloadData: null
12
+ };
13
+
14
+ if (frame.payloadLen === 126) {
15
+ frame.payloadLen = (data[start++] << 8) + data[start++];
16
+ } else if (frame.payloadLen === 127) {
17
+ frame.payloadLen = 0;
18
+ for (let i = 7; i >= 0; --i) {
19
+ frame.payloadLen += (data[start++] << (i * 8));
20
+ }
21
+ }
22
+
23
+ if (frame.payloadLen) {
24
+ if (frame.masked) {
25
+ const maskingKey = [
26
+ data[start++],
27
+ data[start++],
28
+ data[start++],
29
+ data[start++]
30
+ ];
31
+
32
+ frame.maskingKey = maskingKey;
33
+
34
+ frame.payloadData = data
35
+ .slice(start, start + frame.payloadLen)
36
+ .map((byte, idx) => byte ^ maskingKey[idx % 4]);
37
+ } else {
38
+ frame.payloadData = data.slice(start, start + frame.payloadLen);
39
+ }
40
+ }
41
+
42
+ return frame;
43
+ };
@@ -0,0 +1,28 @@
1
+
2
+ // 处理发出的数据
3
+ module.exports = function encodeWsFrame(data) {
4
+ const isFinal = data.isFinal !== undefined ? data.isFinal : true,
5
+ opcode = data.opcode !== undefined ? data.opcode : 1,
6
+ payloadData = data.payloadData ? Buffer.from(data.payloadData) : null,
7
+ payloadLen = payloadData ? payloadData.length : 0;
8
+
9
+ let frame = [];
10
+
11
+ if (isFinal) frame.push((1 << 7) + opcode);
12
+ else frame.push(opcode);
13
+
14
+ if (payloadLen < 126) {
15
+ frame.push(payloadLen);
16
+ } else if (payloadLen < 65536) {
17
+ frame.push(126, payloadLen >> 8, payloadLen & 0xFF);
18
+ } else {
19
+ frame.push(127);
20
+ for (let i = 7; i >= 0; --i) {
21
+ frame.push((payloadLen & (0xFF << (i * 8))) >> (i * 8));
22
+ }
23
+ }
24
+
25
+ frame = payloadData ? Buffer.concat([Buffer.from(frame), payloadData]) : Buffer.from(frame);
26
+
27
+ return frame;
28
+ };
@@ -0,0 +1,26 @@
1
+ module.exports = function (headersStr) {
2
+
3
+ let headersArray = headersStr.split(/\r{0,1}\n/);
4
+ let headersJSON = {};
5
+
6
+ // 第一行的内容:GET / HTTP/1.1
7
+ let firstLine = headersArray.shift().split(' ');
8
+ headersJSON.method = firstLine[0];
9
+ headersJSON.url = firstLine[1];
10
+ headersJSON.protocol = firstLine[2];
11
+
12
+ for (let item of headersArray) {
13
+ let temp = item.split(':');
14
+
15
+ if (temp.length > 1) {
16
+
17
+ let key = temp.shift();
18
+ let value = temp.join(':');
19
+
20
+ headersJSON[key] = value.trim();
21
+
22
+ }
23
+ }
24
+
25
+ return headersJSON;
26
+ };
@@ -0,0 +1,80 @@
1
+ const net = require('net');
2
+ const crypto = require('crypto');
3
+
4
+ const headersToJSON = require('./headersToJSON');
5
+ const decodeWsFrame = require('./decodeWsFrame');
6
+ const encodeWsFrame = require('./encodeWsFrame');
7
+
8
+ module.exports = function (port, name, version) {
9
+ let sockets = [];
10
+
11
+ let handler = {
12
+ notifyBrowser: (msg) => {
13
+ for (let socket of sockets) {
14
+ socket.write(encodeWsFrame(msg));
15
+ }
16
+ }
17
+ };
18
+
19
+ const server = net.createServer(socket => {
20
+
21
+ // 错误
22
+ socket.on('error', (error) => {
23
+ console.log('Connection error:', error.message);
24
+ });
25
+
26
+ // 数据
27
+ socket.on('data', buffer => {
28
+ console.log('Connection data:' + (decodeWsFrame(buffer).payloadData?.toString() || "断开连接......"));
29
+ });
30
+
31
+ // 连接
32
+ socket.once('data', buffer => {
33
+
34
+ // 把请求头变成容易操作的json
35
+ const headers = headersToJSON(buffer.toString());
36
+
37
+ // 如果是ws请求
38
+ // 就需要建立连接
39
+ if (headers.Upgrade == 'websocket') {
40
+
41
+ if (headers['Sec-WebSocket-Version'] !== '13') {
42
+ console.log('\r\n警告:当前WebSocket版本为' + headers['Sec-WebSocket-Version'] + ",可能存在兼容问题~\r\n");
43
+ }
44
+
45
+ // 开始连接
46
+ /*
47
+ 协议中规定的校验用GUID,可参考如下链接:
48
+ https://tools.ietf.org/html/rfc6455#section-5.5.2
49
+ https://stackoverflow.com/questions/13456017/what-does-258eafa5-e914-47da-95ca-c5ab0dc85b11-means-in-websocket-protocol
50
+ */
51
+ const GUID = '258EAFA5-E914-47DA-95CA-C5AB0DC85B11';
52
+ const key = headers['Sec-WebSocket-Key'];
53
+ const hash = crypto.createHash('sha1'); // 创建一个签名算法为sha1的哈希对象
54
+
55
+ hash.update(`${key}${GUID}`); // 将key和GUID连接后,更新到hash
56
+ const result = hash.digest('base64'); // 生成base64字符串
57
+ const header = `HTTP/1.1 101 Switching Protocols\r\nServer: Powered by ${name}@${version}\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-Websocket-Accept: ${result}\r\n\r\n`; // 生成供前端校验用的请求头
58
+
59
+ socket.write(header); // 返回HTTP头,告知客户端校验结果,HTTP状态码101表示切换协议:https://httpstatuses.com/101。
60
+ // 若客户端校验结果正确,在控制台的Network模块可以看到HTTP请求的状态码变为101 Switching Protocols,同时客户端的ws.onopen事件被触发。
61
+
62
+ sockets.push(socket);
63
+ }
64
+
65
+ // 否则就普通的,
66
+ // 普通的由http服务器提供支持
67
+ else {
68
+ socket.end();
69
+
70
+ }
71
+ });
72
+ });
73
+
74
+ // 启动
75
+ server.listen(port);
76
+
77
+ console.log('<i> \x1b[1m\x1b[32m[' + name + '] Loopback: \x1b[36mws://localhost:' + port + '/\x1b[0m\n');
78
+
79
+ return handler;
80
+ };
package/bin/intercept.js CHANGED
@@ -1,7 +1,7 @@
1
- exports.doIntercept = function (url, intercept, request, response) {
1
+ exports.doIntercept = function (url, intercept, request, response, wsHandler) {
2
2
  for (let item of intercept) {
3
3
  if (item.test.test(url)) {
4
- item.handler(request, response);
4
+ item.handler(request, response, wsHandler);
5
5
  return true;
6
6
  }
7
7
  }
package/bin/serve.js CHANGED
@@ -8,8 +8,10 @@ const resolve404 = require("./tools/resolve404.js");
8
8
  const resolveImportFactory = require("./tools/resolveImport.js");
9
9
  const { doIntercept } = require("./intercept.js");
10
10
 
11
- const webisteIntercept = require("./website-plugins/intercept/index.js");
12
- const webisteLoader = require("./website-plugins/loader/index.js");
11
+ const websiteIntercept = require("./website-plugins/intercept/index.js");
12
+ const websiteLoader = require("./website-plugins/loader/index.js");
13
+
14
+ const WebSocketClass = require("./WebSocket/index.js");
13
15
 
14
16
  // 开发服务器
15
17
  module.exports = function (config) {
@@ -19,9 +21,11 @@ module.exports = function (config) {
19
21
  const port = config.devServer.port; // 端口号
20
22
  const basePath = (/^\./.test(config.devServer.baseUrl)) ? join(process.cwd(), config.devServer.baseUrl) : config.devServer.baseUrl; // 服务器根路径
21
23
 
22
- const name = (config.name || "OIPage") + "-http-server";
24
+ const name = (config.name || "OIPage") + "-dev-server";
23
25
  const version = config.version || packageValue.version;
24
26
 
27
+ const wsHandler = WebSocketClass(port + 1, (config.name || "OIPage") + "-dev-websocket", version);
28
+
25
29
  let Server = createServer(function (request, response) {
26
30
  let headers = request.headers;
27
31
  let url = decodeURIComponent(request.url);
@@ -40,7 +44,7 @@ module.exports = function (config) {
40
44
  }
41
45
 
42
46
  // 请求拦截
43
- if (doIntercept(url.replace(/^\/_oipage_website_/, "").replace(/^\/@modules\//, ""), isWebsite ? webisteIntercept : config.devServer.intercept, request, response)) {
47
+ if (doIntercept(url.replace(/^\/_oipage_website_/, "").replace(/^\/@modules\//, ""), isWebsite ? websiteIntercept : config.devServer.intercept, request, response, wsHandler)) {
44
48
  console.log("<i> \x1b[1m\x1b[32m[" + name + "] intercept: " + url + '\x1b[0m ' + new Date().toLocaleString());
45
49
  }
46
50
 
@@ -54,7 +58,7 @@ module.exports = function (config) {
54
58
  let fileModifiedTime = new Date(fileInfo.mtime).toGMTString();
55
59
 
56
60
  let responseHeader = {
57
- 'Content-type': (fileType || "text/plain") + ";charset=utf-8",
61
+ 'Content-Type': (fileType || "text/plain") + ";charset=utf-8",
58
62
  'Access-Control-Allow-Origin': '*',
59
63
  'Server': 'Powered by ' + name + '@' + version,
60
64
  'Cache-Control': 'no-cache',
@@ -78,13 +82,13 @@ module.exports = function (config) {
78
82
 
79
83
  // 如果文件小于10M,认为不大,直接读取
80
84
  if (fileInfo.size < 10 * 1024 * 1024) {
81
- let { source, resolveImport } = resolveImportFactory(basePath, filePath, entry, isWebsite ? webisteIntercept : config.devServer.intercept, urlArray[1] === "download", isWebsite)
85
+ let { source, resolveImport } = resolveImportFactory(basePath, filePath, entry, isWebsite ? websiteIntercept : config.devServer.intercept, urlArray[1] === "download", isWebsite)
82
86
 
83
87
  // 只处理非下载文件
84
88
  // 过大的也不进行处理
85
- // (对webiste无效)
89
+ // (对website无效)
86
90
  if (urlArray[1] !== "download") {
87
- let loaders = isWebsite ? webisteLoader : config.module;
91
+ let loaders = isWebsite ? websiteLoader : config.module;
88
92
 
89
93
  for (let i = 0; i < loaders.rules.length; i++) {
90
94
  if (loaders.rules[i].test.test(filePath)) {
@@ -94,7 +98,7 @@ module.exports = function (config) {
94
98
  entry, // 是否是浏览器地址栏直接访问
95
99
  setFileType(_fileType) { // 设置文件类型
96
100
  fileType = _fileType;
97
- responseHeader['Content-type'] = _fileType + ";charset=utf-8";
101
+ responseHeader['Content-Type'] = _fileType + ";charset=utf-8";
98
102
  }
99
103
  }, source);
100
104
  break;
@@ -125,7 +129,7 @@ module.exports = function (config) {
125
129
  // 否则就是404
126
130
  else {
127
131
  response.writeHead(404, {
128
- 'Content-type': "text/html;charset=utf-8",
132
+ 'Content-Type': "text/html;charset=utf-8",
129
133
  'Access-Control-Allow-Origin': '*',
130
134
  'Server': 'Powered by ' + name + '@' + version
131
135
  });
@@ -26,7 +26,6 @@
26
26
  }
27
27
 
28
28
  .fork {
29
- width: 160px;
30
29
  line-height: 30px;
31
30
  position: fixed;
32
31
  background-color: #607D8B;
@@ -59,7 +58,11 @@
59
58
  top: 50px;
60
59
  outline: 1px solid #9E9E9E;
61
60
  width: calc(100vw - 40px);
62
- height: calc(100vh - 100px);
61
+
62
+ /* 2025年9月17日 于南京 */
63
+ /* 100vh改成100%是为了解决手机端显示问题 */
64
+ height: calc(100% - 100px);
65
+
63
66
  overflow: auto;
64
67
  padding: 20px;
65
68
  border-radius: 5px;
@@ -0,0 +1,55 @@
1
+ <h2 z-bind="title"></h2>
2
+ <div class="right-btn">
3
+ <div>
4
+ <fieldset>
5
+ <legend>
6
+ 当前大小
7
+ </legend>
8
+ <ul z-bind:lock="title=='图像大小'?'yes':'no'">
9
+ <li>
10
+ <label>宽度:</label>
11
+ <span z-bind="width"></span>px
12
+ </li>
13
+ <li>
14
+ <label>宽度:</label>
15
+ <span z-bind="height"></span>px
16
+ </li>
17
+ </ul>
18
+ </fieldset>
19
+ <fieldset>
20
+ <legend>
21
+ 新建大小
22
+ </legend>
23
+ <ul z-bind:lock="title=='图像大小'?'yes':'no'">
24
+ <li>
25
+ <label>宽度(W):</label>
26
+ <input type="text" z-model="newWidth" z-on:input="calcHeight">
27
+ px
28
+ </li>
29
+ <li>
30
+ <label>高度(H):</label>
31
+ <input type="text" z-model="newHeight" z-on:input="calcWidth">
32
+ px
33
+ </li>
34
+ <li z-bind:active="title=='画布大小'?'yes':'no'">
35
+ <label>定位:</label>
36
+ <div class="change-type" z-bind:type="changeType">
37
+ <span z-on:click="doChangeType" val="left-top"></span>
38
+ <span z-on:click="doChangeType" val="center-top"></span>
39
+ <span z-on:click="doChangeType" val="right-top"></span>
40
+ <span z-on:click="doChangeType" val="left-middle"></span>
41
+ <span z-on:click="doChangeType" val="center-middle"></span>
42
+ <span z-on:click="doChangeType" val="right-middle"></span>
43
+ <span z-on:click="doChangeType" val="left-bottom"></span>
44
+ <span z-on:click="doChangeType" val="center-bottom"></span>
45
+ <span z-on:click="doChangeType" val="right-bottom"></span>
46
+ </div>
47
+ </li>
48
+ </ul>
49
+ </fieldset>
50
+ </div>
51
+ <div>
52
+ <button z-on:click="doSubmit">确定</button>
53
+ <button z-on:click="doClose">取消</button>
54
+ </div>
55
+ </div>
@@ -0,0 +1,53 @@
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
+ data() {
8
+ return {
9
+ title: this._props.title,
10
+ width: this._props.width,
11
+ height: this._props.height,
12
+
13
+ newWidth: ref(this._props.width),
14
+ newHeight: ref(this._props.height),
15
+
16
+ changeType: ref('center-middle')
17
+ }
18
+ },
19
+ methods: {
20
+ calcHeight() {
21
+ if (this.title == '图像大小') {
22
+ this.newHeight = +(this.newWidth * this.height / this.width).toFixed(0);
23
+ }
24
+ },
25
+
26
+ calcWidth() {
27
+ if (this.title == '图像大小') {
28
+ this.newWidth = +(this.newHeight * this.width / this.height).toFixed(0);
29
+ }
30
+ },
31
+
32
+ doChangeType: function (event, target) {
33
+ this.changeType = target.getAttribute('val');
34
+ },
35
+
36
+ // 确定
37
+ doSubmit: function () {
38
+ this.$closeDialog({
39
+ width: +this.newWidth,
40
+ height: +this.newHeight,
41
+ changeType: this.changeType
42
+ });
43
+ },
44
+
45
+ // 取消
46
+ doClose: function () {
47
+ this.$closeDialog();
48
+ }
49
+ },
50
+ style: {
51
+ content: style
52
+ }
53
+ })
@@ -0,0 +1,139 @@
1
+ #dialog-root>.content.imageSize {
2
+ border: 1px solid gray;
3
+ min-height: 300px;
4
+ width: 300px;
5
+ background-color: white;
6
+
7
+ &>h2 {
8
+ font-size: 12px;
9
+ padding-left: 30px;
10
+ background-image: url('./images/image-editor.png');
11
+ background-size: auto 80%;
12
+ background-repeat: no-repeat;
13
+ background-position: 3px center;
14
+ border-bottom: 1px solid gray;
15
+ line-height: 30px;
16
+ height: 30px;
17
+ user-select: none;
18
+ }
19
+
20
+ &>div.right-btn {
21
+ display: flex;
22
+
23
+ &>div {
24
+ &:first-child {
25
+ flex-grow: 1;
26
+ padding: 10px 0 10px 10px;
27
+ }
28
+
29
+ &:last-child {
30
+ text-align: center;
31
+ flex-grow: 0;
32
+ flex-shrink: 0;
33
+ flex-basis: 70px;
34
+
35
+ &>button {
36
+ height: 30px;
37
+ border-radius: 15px;
38
+ width: 50px;
39
+ margin-top: 10px;
40
+
41
+ &:hover {
42
+ background-color: rgb(127, 131, 131);
43
+ cursor: pointer;
44
+ }
45
+ }
46
+
47
+ }
48
+ }
49
+ }
50
+
51
+ fieldset {
52
+ margin-top: 10px;
53
+ font-size: 12px;
54
+ }
55
+
56
+ ul {
57
+
58
+ &[lock='yes'] {
59
+ background-image: url('./images/lock.png');
60
+ background-repeat: no-repeat;
61
+ background-position: right;
62
+ }
63
+
64
+ &>li {
65
+ line-height: 2em;
66
+ margin-top: 5px;
67
+
68
+ &[active='no'] {
69
+ display: none;
70
+ }
71
+
72
+ &>label {
73
+ width: 70px;
74
+ display: inline-block;
75
+ text-align: right;
76
+ }
77
+
78
+ &>input {
79
+ width: 50px;
80
+ margin-right: 5px;
81
+ }
82
+
83
+ .change-type {
84
+ font-size: 0;
85
+ width: 90px;
86
+ display: inline-block;
87
+ line-height: 0;
88
+ vertical-align: top;
89
+ background-image: url('./images/size.png');
90
+ background-size: 100% auto;
91
+ background-repeat: no-repeat;
92
+
93
+ &>span {
94
+ display: inline-block;
95
+ width: 30px;
96
+ height: 30px;
97
+ cursor: pointer;
98
+ outline: 1px solid #dedede;
99
+ }
100
+
101
+ &[type='left-top'] {
102
+ background-position: -29px -32px;
103
+ }
104
+
105
+ &[type='center-top'] {
106
+ background-position: 1px -32px;
107
+ }
108
+
109
+ &[type='right-top'] {
110
+ background-position: 30px -32px;
111
+ }
112
+
113
+ &[type='left-middle'] {
114
+ background-position: -29px -1px;
115
+ }
116
+
117
+ &[type='center-middle'] {
118
+ background-position: 1px -1px;
119
+ }
120
+
121
+ &[type='right-middle'] {
122
+ background-position: 30px -1px;
123
+ }
124
+
125
+ &[type='left-bottom'] {
126
+ background-position: -29px 30px;
127
+ }
128
+
129
+ &[type='center-bottom'] {
130
+ background-position: 1px 30px;
131
+ }
132
+
133
+ &[type='right-bottom'] {
134
+ background-position: 30px 30px;
135
+ }
136
+ }
137
+ }
138
+ }
139
+ }
@@ -1,43 +1,53 @@
1
- import { createApp } from "zipaper"
1
+ import { createApp } from "zipaper";
2
2
 
3
3
  const dialogs = {
4
+ imageSize: () => import("./imageSize/index.js")
5
+ };
4
6
 
5
- // xxx
6
- xxx: () => import("./xxx/index.js")
7
- }
8
-
9
- let dialogsResolve = []
7
+ let dialogsResolve = [];
10
8
  export default {
11
9
  install(Zipaper) {
12
10
 
13
11
  // 打开弹框
14
- Zipaper.prototype.$openDialog = function (dialogName, callback) {
15
- let el = document.createElement("div")
12
+ Zipaper.prototype.$openDialog = function (dialogName, data) {
13
+ let el = document.createElement("div");
16
14
 
17
15
  dialogs[dialogName]().then(App => {
18
16
 
19
17
  // 准备好挂载点
20
- el.setAttribute("class", "content " + dialogName)
18
+ el.setAttribute("class", "content " + dialogName);
21
19
 
22
20
  // 创建并挂载
23
- document.getElementById("dialog-root").appendChild(el)
24
- createApp(App.default).mount(el)
25
- if (callback) callback()
26
- })
21
+ document.getElementById("dialog-root").appendChild(el);
22
+
23
+ if (data) {
24
+ let props = {};
25
+ for (let key in data) {
26
+ props[key] = {
27
+ default: data[key]
28
+ };
29
+ }
30
+ App.default.props = props;
31
+ } else {
32
+ App.default.props = {};
33
+ }
34
+
35
+ createApp(App.default).mount(el);
36
+ });
27
37
 
28
38
  return new Promise((resolve) => {
29
39
  dialogsResolve.push({
30
40
  resolve,
31
41
  el
32
- })
33
- })
34
- }
42
+ });
43
+ });
44
+ };
35
45
 
36
46
  // 关闭弹框
37
47
  Zipaper.prototype.$closeDialog = function (data) {
38
- let dialog = dialogsResolve.pop()
48
+ let dialog = dialogsResolve.pop();
39
49
  dialog.el.parentNode.removeChild(dialog.el);
40
- dialog.resolve(data)
41
- }
50
+ dialog.resolve(data);
51
+ };
42
52
  }
43
53
  }
@@ -5,7 +5,7 @@
5
5
  <meta charset="UTF-8">
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
7
  <title>OIPage 应用市场</title>
8
- <link rel="shortcut icon" href="./logo.png">
8
+ <link rel="shortcut icon" href="./images/logo.png">
9
9
  <link rel="stylesheet" href="./styles/normalize.css">
10
10
  <link rel="stylesheet" href="./styles/common.css">
11
11
  </head>
@@ -4,6 +4,8 @@ import App from "./pages/App/index.js"
4
4
  import router from "./router.config.js"
5
5
  import dialogs from "./dialogs/index.js"
6
6
 
7
+ // https://oi-contrib.github.io/Zipaper/index.html
8
+
7
9
  createApp(App)
8
10
  .use(router) // 路由
9
11
  .use(dialogs) // 弹框
@@ -1,4 +1,7 @@
1
1
  <router></router>
2
2
  <div id="dialog-root">
3
3
  <div class="mask" z-on:click="closeDialog"></div>
4
- </div>
4
+ </div>
5
+ <a class="fork" href="https://github.com/oi-contrib/OIPage" target="_blank">
6
+ Fork me on Github
7
+ </a>