diff --git a/build.bat b/build.bat new file mode 100644 index 0000000..3503e48 --- /dev/null +++ b/build.bat @@ -0,0 +1,2 @@ +@echo off +quasar build && powershell -Command "Copy-Item -Recurse -Force plugin/* dist/spa/" && echo Done. diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..ca1ce40 --- /dev/null +++ b/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +quasar build && cp -r plugin/* dist/spa/ && echo Done. diff --git a/public/helps/CHANGELOG.html b/plugin/helps/CHANGELOG.html similarity index 100% rename from public/helps/CHANGELOG.html rename to plugin/helps/CHANGELOG.html diff --git a/public/helps/CHANGELOG.md b/plugin/helps/CHANGELOG.md similarity index 100% rename from public/helps/CHANGELOG.md rename to plugin/helps/CHANGELOG.md diff --git a/public/helps/HELP.html b/plugin/helps/HELP.html similarity index 100% rename from public/helps/HELP.html rename to plugin/helps/HELP.html diff --git a/public/helps/HELP.md b/plugin/helps/HELP.md similarity index 100% rename from public/helps/HELP.md rename to plugin/helps/HELP.md diff --git a/public/helps/axios.html b/plugin/helps/axios.html similarity index 100% rename from public/helps/axios.html rename to plugin/helps/axios.html diff --git a/public/helps/quickcommand.html b/plugin/helps/quickcommand.html similarity index 100% rename from public/helps/quickcommand.html rename to plugin/helps/quickcommand.html diff --git a/public/helps/quickcommand.md b/plugin/helps/quickcommand.md similarity index 100% rename from public/helps/quickcommand.md rename to plugin/helps/quickcommand.md diff --git a/public/lib/picture-compressor.js b/plugin/lib/picture-compressor.js similarity index 97% rename from public/lib/picture-compressor.js rename to plugin/lib/picture-compressor.js index 875c9e6..217597a 100644 --- a/public/lib/picture-compressor.js +++ b/plugin/lib/picture-compressor.js @@ -1,132 +1,132 @@ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - (global = global || self, global.pictureCompress = factory()); -}(this, function () { 'use strict'; - - /** - * 将图片压缩为对应尺寸 - * @param {Object} options - * @param {String} options.img 图片的url或者base64数据 - * @param {Number} options.width 目标图片的宽度 - * @param {Number} options.height 目标图片的高度 - * @param {Number} options.quality 生成目标图片质量 - * @param {String} options.fit 图片压缩填充模式默认 scale:按比例缩放,可选 fill:按使用目标尺寸 - * @param {String} options.type 图片压缩类型默认 jpg,可选 png - * @param {Number} options.rotate 图片旋转,由于手机拍照的角度和我们使用的头像不一致,需要旋转 默认0 仅支持 90 180 -90 - * @returns {Promise} then {width,height,img} - */ - function pictureCompress(options) { - return new Promise(function (resolve, reject) { - if (!options.img) { - reject(new Error('need img')); - return; - } - - var imgSrc = options.img, - width = options.width || 640, - height = options.height || 640, - type = options.type || 'jpg', - quality = options.quality || 0.92, - fit = options.fit || 'scale', - rotate = options.rotate || 0; - - if (width <= 0 || height <= 0) { - reject(new Error('dist width or height need > 0')); - return; - } - - if (!/jpg|png|jpeg/.test(type)) { - reject(new Error('type need jpg or png!')); - return; - } - - if (rotate !== 90 && rotate !== -90 && rotate !== 0 && rotate !== 180) { - reject(new Error('rotate mast be 0 90 -90 180!')); - return; - } - - var changeWidthAndHeight = rotate === 90 || rotate === -90; - var image = new Image(); - image.src = imgSrc; - - image.onload = function () { - var distSize = getDistSize({ - width: changeWidthAndHeight ? this.naturalHeight : this.naturalWidth, - height: changeWidthAndHeight ? this.naturalWidth : this.naturalHeight - }, { - width: changeWidthAndHeight ? height : width, - height: changeWidthAndHeight ? width : height - }, fit); - var imgData = compress(this, distSize.width, distSize.height, type, quality, rotate); - resolve({ - width: distSize.width, - height: distSize.height, - img: imgData - }); - }; - - image.onerror = function (err) { - reject(err); - }; - }); - } - /** - * 将图片转换为固定尺寸的 - * @param {Image} img 图片数据 - * @param {Number} width 转换之后的图片宽度 - * @param {Number} height 转换之后的图片高度 - * @param {String} type base64的图片类型 jpg png - * @param {Number} quality 转换之后的图片质量 - */ - - - function compress(img, width, height, type, quality, rotate) { - var canvas = document.createElement('canvas'); - var ctx = canvas.getContext('2d'); - var types = { - 'jpg': 'image/jpeg', - 'jpeg': 'image/jpeg', - 'png': 'image/png' - }; - canvas.width = width; - canvas.height = height; - - if (rotate === 90) { - ctx.translate(width, 0); - ctx.rotate(90 * Math.PI / 180); - ctx.drawImage(img, 0, 0, height, width); - } else if (rotate === -90) { - ctx.translate(0, height); - ctx.rotate(-90 * Math.PI / 180); - ctx.drawImage(img, 0, 0, height, width); - } else if (rotate === 180) { - ctx.translate(width, height); - ctx.rotate(180 * Math.PI / 180); - ctx.drawImage(img, 0, 0, width, height); - } else { - ctx.drawImage(img, 0, 0, width, height); - } - - return canvas.toDataURL(types[type], quality); - } - /** - * 选择源尺寸与目标尺寸比例中较小的那个,保证图片可以完全显示 - * 最大值不超过1,如果图片源尺寸小于目标尺寸,则不做处理,返回图片原尺寸 - * @param {Object} source 源图片的宽高 - * @param {Object} dist 目标图片的宽高 - */ - - - function getDistSize(source, dist, fit) { - if (fit === 'fill') return dist; - var scale = Math.min(dist.width / source.width, dist.height / source.height, 1); - return { - width: Math.round(source.width * scale), - height: Math.round(source.height * scale) - }; - } - - return pictureCompress; - -})); +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global = global || self, global.pictureCompress = factory()); +}(this, function () { 'use strict'; + + /** + * 将图片压缩为对应尺寸 + * @param {Object} options + * @param {String} options.img 图片的url或者base64数据 + * @param {Number} options.width 目标图片的宽度 + * @param {Number} options.height 目标图片的高度 + * @param {Number} options.quality 生成目标图片质量 + * @param {String} options.fit 图片压缩填充模式默认 scale:按比例缩放,可选 fill:按使用目标尺寸 + * @param {String} options.type 图片压缩类型默认 jpg,可选 png + * @param {Number} options.rotate 图片旋转,由于手机拍照的角度和我们使用的头像不一致,需要旋转 默认0 仅支持 90 180 -90 + * @returns {Promise} then {width,height,img} + */ + function pictureCompress(options) { + return new Promise(function (resolve, reject) { + if (!options.img) { + reject(new Error('need img')); + return; + } + + var imgSrc = options.img, + width = options.width || 640, + height = options.height || 640, + type = options.type || 'jpg', + quality = options.quality || 0.92, + fit = options.fit || 'scale', + rotate = options.rotate || 0; + + if (width <= 0 || height <= 0) { + reject(new Error('dist width or height need > 0')); + return; + } + + if (!/jpg|png|jpeg/.test(type)) { + reject(new Error('type need jpg or png!')); + return; + } + + if (rotate !== 90 && rotate !== -90 && rotate !== 0 && rotate !== 180) { + reject(new Error('rotate mast be 0 90 -90 180!')); + return; + } + + var changeWidthAndHeight = rotate === 90 || rotate === -90; + var image = new Image(); + image.src = imgSrc; + + image.onload = function () { + var distSize = getDistSize({ + width: changeWidthAndHeight ? this.naturalHeight : this.naturalWidth, + height: changeWidthAndHeight ? this.naturalWidth : this.naturalHeight + }, { + width: changeWidthAndHeight ? height : width, + height: changeWidthAndHeight ? width : height + }, fit); + var imgData = compress(this, distSize.width, distSize.height, type, quality, rotate); + resolve({ + width: distSize.width, + height: distSize.height, + img: imgData + }); + }; + + image.onerror = function (err) { + reject(err); + }; + }); + } + /** + * 将图片转换为固定尺寸的 + * @param {Image} img 图片数据 + * @param {Number} width 转换之后的图片宽度 + * @param {Number} height 转换之后的图片高度 + * @param {String} type base64的图片类型 jpg png + * @param {Number} quality 转换之后的图片质量 + */ + + + function compress(img, width, height, type, quality, rotate) { + var canvas = document.createElement('canvas'); + var ctx = canvas.getContext('2d'); + var types = { + 'jpg': 'image/jpeg', + 'jpeg': 'image/jpeg', + 'png': 'image/png' + }; + canvas.width = width; + canvas.height = height; + + if (rotate === 90) { + ctx.translate(width, 0); + ctx.rotate(90 * Math.PI / 180); + ctx.drawImage(img, 0, 0, height, width); + } else if (rotate === -90) { + ctx.translate(0, height); + ctx.rotate(-90 * Math.PI / 180); + ctx.drawImage(img, 0, 0, height, width); + } else if (rotate === 180) { + ctx.translate(width, height); + ctx.rotate(180 * Math.PI / 180); + ctx.drawImage(img, 0, 0, width, height); + } else { + ctx.drawImage(img, 0, 0, width, height); + } + + return canvas.toDataURL(types[type], quality); + } + /** + * 选择源尺寸与目标尺寸比例中较小的那个,保证图片可以完全显示 + * 最大值不超过1,如果图片源尺寸小于目标尺寸,则不做处理,返回图片原尺寸 + * @param {Object} source 源图片的宽高 + * @param {Object} dist 目标图片的宽高 + */ + + + function getDistSize(source, dist, fit) { + if (fit === 'fill') return dist; + var scale = Math.min(dist.width / source.width, dist.height / source.height, 1); + return { + width: Math.round(source.width * scale), + height: Math.round(source.height * scale) + }; + } + + return pictureCompress; + +})); diff --git a/public/lib/vm2/index.js b/plugin/lib/vm2/index.js similarity index 100% rename from public/lib/vm2/index.js rename to plugin/lib/vm2/index.js diff --git a/public/lib/vm2/lib/cli.js b/plugin/lib/vm2/lib/cli.js similarity index 100% rename from public/lib/vm2/lib/cli.js rename to plugin/lib/vm2/lib/cli.js diff --git a/public/lib/vm2/lib/contextify.js b/plugin/lib/vm2/lib/contextify.js similarity index 100% rename from public/lib/vm2/lib/contextify.js rename to plugin/lib/vm2/lib/contextify.js diff --git a/public/lib/vm2/lib/fixasync.js b/plugin/lib/vm2/lib/fixasync.js similarity index 100% rename from public/lib/vm2/lib/fixasync.js rename to plugin/lib/vm2/lib/fixasync.js diff --git a/public/lib/vm2/lib/helpers.js b/plugin/lib/vm2/lib/helpers.js similarity index 100% rename from public/lib/vm2/lib/helpers.js rename to plugin/lib/vm2/lib/helpers.js diff --git a/public/lib/vm2/lib/main.js b/plugin/lib/vm2/lib/main.js similarity index 100% rename from public/lib/vm2/lib/main.js rename to plugin/lib/vm2/lib/main.js diff --git a/public/lib/vm2/lib/sandbox.js b/plugin/lib/vm2/lib/sandbox.js similarity index 100% rename from public/lib/vm2/lib/sandbox.js rename to plugin/lib/vm2/lib/sandbox.js diff --git a/public/logo.png b/plugin/logo.png similarity index 100% rename from public/logo.png rename to plugin/logo.png diff --git a/public/package-lock.json b/plugin/package-lock.json similarity index 100% rename from public/package-lock.json rename to plugin/package-lock.json diff --git a/public/package.json b/plugin/package.json similarity index 100% rename from public/package.json rename to plugin/package.json diff --git a/public/plugin.json b/plugin/plugin.json similarity index 100% rename from public/plugin.json rename to plugin/plugin.json diff --git a/public/preload.js b/plugin/preload.js similarity index 100% rename from public/preload.js rename to plugin/preload.js diff --git a/public/logo/applescript.png b/public/logo/applescript.png index 979b022..ff10b29 100644 Binary files a/public/logo/applescript.png and b/public/logo/applescript.png differ diff --git a/public/logo/c.png b/public/logo/c.png index 922682b..b9b25e2 100644 Binary files a/public/logo/c.png and b/public/logo/c.png differ diff --git a/public/logo/cmd.png b/public/logo/cmd.png index ca0b4cc..7c5dff2 100644 Binary files a/public/logo/cmd.png and b/public/logo/cmd.png differ diff --git a/public/logo/csharp.png b/public/logo/csharp.png index 7f02eb8..7d81e01 100644 Binary files a/public/logo/csharp.png and b/public/logo/csharp.png differ diff --git a/public/logo/custom.png b/public/logo/custom.png index b9193d0..dc8b5a4 100644 Binary files a/public/logo/custom.png and b/public/logo/custom.png differ diff --git a/public/logo/go.png b/public/logo/go.png index d162551..dd959f3 100644 Binary files a/public/logo/go.png and b/public/logo/go.png differ diff --git a/public/logo/javascript.png b/public/logo/javascript.png index cf2f7e1..e11ef1f 100644 Binary files a/public/logo/javascript.png and b/public/logo/javascript.png differ diff --git a/public/logo/lua.png b/public/logo/lua.png index e8a177c..12fded9 100644 Binary files a/public/logo/lua.png and b/public/logo/lua.png differ diff --git a/public/logo/perl.png b/public/logo/perl.png index aff6279..142ecdd 100644 Binary files a/public/logo/perl.png and b/public/logo/perl.png differ diff --git a/public/logo/php.png b/public/logo/php.png index d1da6e9..8c722f4 100644 Binary files a/public/logo/php.png and b/public/logo/php.png differ diff --git a/public/logo/powershell.png b/public/logo/powershell.png index e038142..0372501 100644 Binary files a/public/logo/powershell.png and b/public/logo/powershell.png differ diff --git a/public/logo/python.png b/public/logo/python.png index b328fd4..1b09666 100644 Binary files a/public/logo/python.png and b/public/logo/python.png differ diff --git a/public/logo/quickcommand.png b/public/logo/quickcommand.png index 7c48809..e088170 100644 Binary files a/public/logo/quickcommand.png and b/public/logo/quickcommand.png differ diff --git a/public/logo/quickpanel.png b/public/logo/quickpanel.png index 687f6d4..97bf1b9 100644 Binary files a/public/logo/quickpanel.png and b/public/logo/quickpanel.png differ diff --git a/public/logo/ruby.png b/public/logo/ruby.png index 10bf090..23dfba9 100644 Binary files a/public/logo/ruby.png and b/public/logo/ruby.png differ diff --git a/public/logo/shell.png b/public/logo/shell.png index d6f4bef..194f7d0 100644 Binary files a/public/logo/shell.png and b/public/logo/shell.png differ