@oipage/cli 0.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/.github/FUNDING.yml +12 -0
- package/.mailmap +1 -0
- package/AUTHORS.txt +6 -0
- package/CHANGELOG +5 -0
- package/LICENSE +21 -0
- package/README.md +184 -0
- package/bin/WebSocket/decodeWsFrame.js +43 -0
- package/bin/WebSocket/encodeWsFrame.js +28 -0
- package/bin/WebSocket/headersToJSON.js +26 -0
- package/bin/WebSocket/index.js +80 -0
- package/bin/data/mineTypes.json +105 -0
- package/bin/disk.js +43 -0
- package/bin/help.js +51 -0
- package/bin/images/file.png +0 -0
- package/bin/images/folder.png +0 -0
- package/bin/intercept.js +16 -0
- package/bin/network.js +22 -0
- package/bin/proxy.js +75 -0
- package/bin/run +134 -0
- package/bin/serve.js +189 -0
- package/bin/template/404.html +185 -0
- package/bin/tools/deleteEmptyFolder.js +34 -0
- package/bin/tools/format.js +76 -0
- package/bin/tools/network.js +43 -0
- package/bin/tools/openBrowser.js +26 -0
- package/bin/tools/resolve404.js +84 -0
- package/bin/tools/resolveImport.js +89 -0
- package/bin/website-htmls/components/ui-select-file/index.html +9 -0
- package/bin/website-htmls/components/ui-select-file/index.js +43 -0
- package/bin/website-htmls/components/ui-select-file/index.scss +45 -0
- package/bin/website-htmls/dialogs/imageSize/index.html +55 -0
- package/bin/website-htmls/dialogs/imageSize/index.js +53 -0
- package/bin/website-htmls/dialogs/imageSize/index.scss +141 -0
- package/bin/website-htmls/dialogs/index.js +53 -0
- package/bin/website-htmls/images/addFile.svg +1 -0
- package/bin/website-htmls/images/chart.png +0 -0
- package/bin/website-htmls/images/image-editor.png +0 -0
- package/bin/website-htmls/images/img-to-pdf.svg +1 -0
- package/bin/website-htmls/images/lock.png +0 -0
- package/bin/website-htmls/images/logo.png +0 -0
- package/bin/website-htmls/images/mosaic.png +0 -0
- package/bin/website-htmls/images/recorder-screen.png +0 -0
- package/bin/website-htmls/images/size.png +0 -0
- package/bin/website-htmls/images/video-player.jpeg +0 -0
- package/bin/website-htmls/index.html +18 -0
- package/bin/website-htmls/main.js +14 -0
- package/bin/website-htmls/pages/App/index.html +7 -0
- package/bin/website-htmls/pages/App/index.js +23 -0
- package/bin/website-htmls/pages/App/index.scss +44 -0
- package/bin/website-htmls/pages/appStore/index.html +6 -0
- package/bin/website-htmls/pages/appStore/index.js +20 -0
- package/bin/website-htmls/pages/appStore/index.scss +44 -0
- package/bin/website-htmls/pages/chart/index.html +9 -0
- package/bin/website-htmls/pages/chart/index.js +73 -0
- package/bin/website-htmls/pages/chart/index.scss +72 -0
- package/bin/website-htmls/pages/home/index.html +20 -0
- package/bin/website-htmls/pages/home/index.js +20 -0
- package/bin/website-htmls/pages/home/index.scss +88 -0
- package/bin/website-htmls/pages/image-editor/index.html +28 -0
- package/bin/website-htmls/pages/image-editor/index.js +107 -0
- package/bin/website-htmls/pages/image-editor/index.scss +70 -0
- package/bin/website-htmls/pages/img-to-pdf/index.html +4 -0
- package/bin/website-htmls/pages/img-to-pdf/index.js +45 -0
- package/bin/website-htmls/pages/img-to-pdf/index.scss +10 -0
- package/bin/website-htmls/pages/recorder-screen/index.html +16 -0
- package/bin/website-htmls/pages/recorder-screen/index.js +228 -0
- package/bin/website-htmls/pages/recorder-screen/index.scss +53 -0
- package/bin/website-htmls/router.config.js +30 -0
- package/bin/website-htmls/styles/common.css +44 -0
- package/bin/website-htmls/styles/normalize.css +95 -0
- package/bin/website-plugins/intercept/chart.js +34 -0
- package/bin/website-plugins/intercept/getPackage.js +18 -0
- package/bin/website-plugins/intercept/head.js +9 -0
- package/bin/website-plugins/intercept/index.js +9 -0
- package/bin/website-plugins/intercept/oipage-vislite-intercept.js +31 -0
- package/bin/website-plugins/intercept/oipage-zipaper-intercept.js +37 -0
- package/bin/website-plugins/loader/index.js +12 -0
- package/bin/website-plugins/loader/oipage-html-loader.js +8 -0
- package/bin/website-plugins/loader/oipage-scss-loader.js +150 -0
- package/package.json +43 -0
- package/types/index.d.ts +77 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const { networkInterfaces } = require("os");
|
|
2
|
+
|
|
3
|
+
// 网络信息
|
|
4
|
+
module.exports = function (isAll) {
|
|
5
|
+
|
|
6
|
+
let infomation = {
|
|
7
|
+
IPv4: [],
|
|
8
|
+
IPv6: []
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
let networks = networkInterfaces();
|
|
12
|
+
|
|
13
|
+
let IPv4Had = {}, IPv6Had = {};
|
|
14
|
+
|
|
15
|
+
for (let typeName in networks) {
|
|
16
|
+
let network = networks[typeName]
|
|
17
|
+
for (let index = 0; index < network.length; index++) {
|
|
18
|
+
if (network[index].mac != "00:00:00:00:00:00" || isAll) {
|
|
19
|
+
if (network[index].family == 'IPv4') {
|
|
20
|
+
if (!IPv4Had[network[index].mac]) {
|
|
21
|
+
infomation.IPv4.push({
|
|
22
|
+
address: network[index].address,
|
|
23
|
+
mac: network[index].mac
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
IPv4Had[network[index].mac] = true;
|
|
27
|
+
}
|
|
28
|
+
} else if (network[index].family == 'IPv6') {
|
|
29
|
+
if (!IPv6Had[network[index].mac]) {
|
|
30
|
+
infomation.IPv6.push({
|
|
31
|
+
address: network[index].address,
|
|
32
|
+
mac: network[index].mac
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
IPv6Had[network[index].mac] = true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return infomation;
|
|
43
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const { exec } = require('child_process');
|
|
2
|
+
const os = require('os');
|
|
3
|
+
|
|
4
|
+
module.exports = function (url) {
|
|
5
|
+
const platform = os.platform();
|
|
6
|
+
let command;
|
|
7
|
+
|
|
8
|
+
switch (platform) {
|
|
9
|
+
case 'win32': // Windows
|
|
10
|
+
command = `start ${url}`;
|
|
11
|
+
break;
|
|
12
|
+
case 'darwin': // macOS
|
|
13
|
+
command = `open ${url}`;
|
|
14
|
+
break;
|
|
15
|
+
default: // Linux及其他
|
|
16
|
+
command = `xdg-open ${url}`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
exec(command, (error) => {
|
|
20
|
+
if (error) {
|
|
21
|
+
console.error(`无法打开浏览器: ${error}`);
|
|
22
|
+
} else {
|
|
23
|
+
// todo
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
const { readdirSync, lstatSync, readFileSync, statSync } = require("fs");
|
|
2
|
+
const { join } = require("path");
|
|
3
|
+
const { formatByte, formatTime } = require("./format");
|
|
4
|
+
const mineTypes = require("../data/mineTypes.json");
|
|
5
|
+
|
|
6
|
+
const img_folder = "data:image/png;base64," + readFileSync(join(__dirname, "../images/folder.png")).toString('base64');
|
|
7
|
+
const img_file = "data:image/png;base64," + readFileSync(join(__dirname, "../images/file.png")).toString('base64');
|
|
8
|
+
|
|
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, website) {
|
|
16
|
+
|
|
17
|
+
let subItems = [];
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
subItems = readdirSync(filePath);
|
|
21
|
+
console.log("<i> \x1b[1m\x1b[32m[OIPage-http-server] Read Folder: " + url + '\x1b[0m ' + new Date().toLocaleString());
|
|
22
|
+
} catch (e) {
|
|
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
|
+
try {
|
|
25
|
+
if (!/\/$/.test(url) || url === "/") {
|
|
26
|
+
filePath = join(filePath, "../");
|
|
27
|
+
subItems = readdirSync(filePath);
|
|
28
|
+
}
|
|
29
|
+
} catch (e) { }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let template = "";
|
|
33
|
+
for (let i in subItems) {
|
|
34
|
+
let isDirectory = lstatSync(join(filePath, subItems[i])).isDirectory();
|
|
35
|
+
let statObj = statSync(join(filePath, subItems[i]));
|
|
36
|
+
|
|
37
|
+
// 文件夹
|
|
38
|
+
if (isDirectory) {
|
|
39
|
+
template += `<tr class="folder">
|
|
40
|
+
<th class="name">
|
|
41
|
+
<a href='./${subItems[i]}/'>${subItems[i]}</a>
|
|
42
|
+
</th>
|
|
43
|
+
<th>
|
|
44
|
+
${formatTime(statObj.mtime)}
|
|
45
|
+
</th>
|
|
46
|
+
<th>
|
|
47
|
+
文件夹
|
|
48
|
+
</th>
|
|
49
|
+
<th>
|
|
50
|
+
-
|
|
51
|
+
</th>
|
|
52
|
+
<th>
|
|
53
|
+
<a href='./${subItems[i]}/' class="btn">打开</a>
|
|
54
|
+
</th>
|
|
55
|
+
</tr>`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// 文件
|
|
59
|
+
else {
|
|
60
|
+
let dotName = /\./.test(subItems[i]) ? subItems[i].match(/\.([^.]+)$/)[1] : "";
|
|
61
|
+
|
|
62
|
+
template += `<tr class="file">
|
|
63
|
+
<th class="name">
|
|
64
|
+
<a href='./${subItems[i]}'>${subItems[i]}</a>
|
|
65
|
+
</th>
|
|
66
|
+
<th>
|
|
67
|
+
${formatTime(statObj.mtime)}
|
|
68
|
+
</th>
|
|
69
|
+
<th>
|
|
70
|
+
${mineTypes[dotName] || "text/plain"}
|
|
71
|
+
</th>
|
|
72
|
+
<th>
|
|
73
|
+
${formatByte(statObj.size)}
|
|
74
|
+
</th>
|
|
75
|
+
<th>
|
|
76
|
+
<a href='./${subItems[i]}' class="btn">访问</a>
|
|
77
|
+
<a href='./${subItems[i]}?download' class="btn" download='${subItems[i]}'>下载</a>
|
|
78
|
+
</th>
|
|
79
|
+
</tr>`;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return template_404.replace("${website}", website ? '<a class="website-link" href="/_oipage_cli_website_/index.html">打开应用市场</a>' : '').replace("${current}", filePath).replace("${template}", template);
|
|
84
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
const { readFileSync, existsSync, lstatSync } = require("fs");
|
|
2
|
+
const { join } = require("path");
|
|
3
|
+
const { testIntercept } = require("../intercept.js");
|
|
4
|
+
|
|
5
|
+
module.exports = function (basePath, filePath, entry, intercept, isDownload, isWebsite) {
|
|
6
|
+
basePath = join(basePath, "./");
|
|
7
|
+
|
|
8
|
+
let source = readFileSync(filePath);
|
|
9
|
+
let resolveImport = content => content;
|
|
10
|
+
|
|
11
|
+
let __resolveImport = function (content) {
|
|
12
|
+
return content.replace(/import [^'"]* from (['"])([^'"]*)['"]/sg, function (_importCode, _, _importUrl) {
|
|
13
|
+
if (/^[./]/.test(_importUrl)) {
|
|
14
|
+
return _importCode;
|
|
15
|
+
} else {
|
|
16
|
+
return _importCode.replace(_importUrl, _importUrl.replace(/([^/])+/s, function (npmName) {
|
|
17
|
+
|
|
18
|
+
if (testIntercept(npmName, intercept)) {
|
|
19
|
+
return (isWebsite ? "/_oipage_cli_website_/@modules/" : "/@modules/") + npmName;
|
|
20
|
+
} else {
|
|
21
|
+
|
|
22
|
+
let node_modulesRootPath = join(filePath, "../");
|
|
23
|
+
let prePath = "";
|
|
24
|
+
while (true) {
|
|
25
|
+
let npmBundlePath = join(node_modulesRootPath, "./node_modules/", npmName);
|
|
26
|
+
|
|
27
|
+
// 如果存在
|
|
28
|
+
if (existsSync(npmBundlePath) && lstatSync(npmBundlePath).isDirectory()) {
|
|
29
|
+
let npmNameValue = npmName;
|
|
30
|
+
|
|
31
|
+
// 对于类似 import VISLite from "vislite"
|
|
32
|
+
// 需要把包名解析成具体的文件
|
|
33
|
+
if (!/\//.test(_importUrl)) {
|
|
34
|
+
let bundlePackage = require(join(npmBundlePath, "./package.json"));
|
|
35
|
+
npmNameValue = npmName + "/" + bundlePackage.main;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return (prePath ? prePath : "./") + "node_modules/" + npmNameValue;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (node_modulesRootPath === basePath) {
|
|
42
|
+
|
|
43
|
+
// 如果命令行根目录是一个项目
|
|
44
|
+
let packagePath = join(basePath, "./package.json");
|
|
45
|
+
if (existsSync(packagePath) && !lstatSync(packagePath).isDirectory()) {
|
|
46
|
+
let bundlePackage = require(packagePath);
|
|
47
|
+
if (!/\//.test(_importUrl)) {
|
|
48
|
+
return "/" + bundlePackage.main;
|
|
49
|
+
} else {
|
|
50
|
+
return "/"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return npmName;
|
|
55
|
+
} else {
|
|
56
|
+
node_modulesRootPath = join(node_modulesRootPath, "../");
|
|
57
|
+
prePath = "../" + prePath;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// 如果是下载
|
|
68
|
+
if (isDownload) {
|
|
69
|
+
// todo
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// 如果不是直接访问的
|
|
73
|
+
else if (!entry) {
|
|
74
|
+
source += "";
|
|
75
|
+
resolveImport = (content, notResolve) => notResolve ? content : __resolveImport(content);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// 如果是.html或.htm结尾
|
|
79
|
+
else if (/\.html{0,1}$/.test(filePath)) {
|
|
80
|
+
source = (source + "").replace(/<script type="module">(.*)<\/script>/sg, function (_, _matchCode) {
|
|
81
|
+
return `<script type="module">${__resolveImport(_matchCode)}</script>`;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
source,
|
|
87
|
+
resolveImport
|
|
88
|
+
};
|
|
89
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
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="_props.multiple?'multiple':'none'" id="input" z-on:change.stop="doChange"
|
|
6
|
+
z-bind:accept="accept" />
|
|
7
|
+
<label for="input" z-bind="'选择'+_props.type+'文件'"></label>
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
multiple: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: true
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
data() {
|
|
27
|
+
return {
|
|
28
|
+
accept: {
|
|
29
|
+
pdf: "application/pdf",
|
|
30
|
+
image: "image/*",
|
|
31
|
+
video: "video/*",
|
|
32
|
+
}[this._props.type]
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
methods: {
|
|
36
|
+
doChange(event, target) {
|
|
37
|
+
this.$emit("change", target.files);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
style: {
|
|
41
|
+
content: style
|
|
42
|
+
}
|
|
43
|
+
});
|
|
@@ -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,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,141 @@
|
|
|
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: 60px;
|
|
39
|
+
margin-top: 10px;
|
|
40
|
+
white-space: nowrap;
|
|
41
|
+
padding: 0;
|
|
42
|
+
|
|
43
|
+
&:hover {
|
|
44
|
+
background-color: rgb(127, 131, 131);
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
fieldset {
|
|
54
|
+
margin-top: 10px;
|
|
55
|
+
font-size: 12px;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
ul {
|
|
59
|
+
|
|
60
|
+
&[lock='yes'] {
|
|
61
|
+
background-image: url('./images/lock.png');
|
|
62
|
+
background-repeat: no-repeat;
|
|
63
|
+
background-position: right;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&>li {
|
|
67
|
+
line-height: 2em;
|
|
68
|
+
margin-top: 5px;
|
|
69
|
+
|
|
70
|
+
&[active='no'] {
|
|
71
|
+
display: none;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
&>label {
|
|
75
|
+
width: 70px;
|
|
76
|
+
display: inline-block;
|
|
77
|
+
text-align: right;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
&>input {
|
|
81
|
+
width: 50px;
|
|
82
|
+
margin-right: 5px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.change-type {
|
|
86
|
+
font-size: 0;
|
|
87
|
+
width: 90px;
|
|
88
|
+
display: inline-block;
|
|
89
|
+
line-height: 0;
|
|
90
|
+
vertical-align: top;
|
|
91
|
+
background-image: url('./images/size.png');
|
|
92
|
+
background-size: 100% auto;
|
|
93
|
+
background-repeat: no-repeat;
|
|
94
|
+
|
|
95
|
+
&>span {
|
|
96
|
+
display: inline-block;
|
|
97
|
+
width: 30px;
|
|
98
|
+
height: 30px;
|
|
99
|
+
cursor: pointer;
|
|
100
|
+
outline: 1px solid #dedede;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
&[type='left-top'] {
|
|
104
|
+
background-position: -29px -32px;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
&[type='center-top'] {
|
|
108
|
+
background-position: 1px -32px;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
&[type='right-top'] {
|
|
112
|
+
background-position: 30px -32px;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
&[type='left-middle'] {
|
|
116
|
+
background-position: -29px -1px;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
&[type='center-middle'] {
|
|
120
|
+
background-position: 1px -1px;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
&[type='right-middle'] {
|
|
124
|
+
background-position: 30px -1px;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
&[type='left-bottom'] {
|
|
128
|
+
background-position: -29px 30px;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
&[type='center-bottom'] {
|
|
132
|
+
background-position: 1px 30px;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
&[type='right-bottom'] {
|
|
136
|
+
background-position: 30px 30px;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { createApp } from "zipaper";
|
|
2
|
+
|
|
3
|
+
const dialogs = {
|
|
4
|
+
imageSize: () => import("./imageSize/index.js")
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
let dialogsResolve = [];
|
|
8
|
+
export default {
|
|
9
|
+
install(Zipaper) {
|
|
10
|
+
|
|
11
|
+
// 打开弹框
|
|
12
|
+
Zipaper.prototype.$openDialog = function (dialogName, data) {
|
|
13
|
+
let el = document.createElement("div");
|
|
14
|
+
|
|
15
|
+
dialogs[dialogName]().then(App => {
|
|
16
|
+
|
|
17
|
+
// 准备好挂载点
|
|
18
|
+
el.setAttribute("class", "content " + dialogName);
|
|
19
|
+
|
|
20
|
+
// 创建并挂载
|
|
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
|
+
});
|
|
37
|
+
|
|
38
|
+
return new Promise((resolve) => {
|
|
39
|
+
dialogsResolve.push({
|
|
40
|
+
resolve,
|
|
41
|
+
el
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// 关闭弹框
|
|
47
|
+
Zipaper.prototype.$closeDialog = function (data) {
|
|
48
|
+
let dialog = dialogsResolve.pop();
|
|
49
|
+
dialog.el.parentNode.removeChild(dialog.el);
|
|
50
|
+
dialog.resolve(data);
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -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>
|
|
Binary file
|
|
Binary file
|
|
@@ -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>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|