From 96371f1475a9f706417d55ebe99dfa0dba211a7c Mon Sep 17 00:00:00 2001 From: shangbin Date: Wed, 24 Nov 2021 10:20:38 +0800 Subject: [PATCH 1/8] update: readme --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 7acae0d..4d8776e 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,22 @@ npm run serve [【拖拽式Vue组件代码生成平台(LCG)介绍视频-哔哩哔哩】https://b23.tv/FInuZ8](https://b23.tv/FInuZ8) [【LCG近期功能更新介绍-哔哩哔哩】https://b23.tv/SAHwVq](https://b23.tv/SAHwVq) +## 贡献 + +1. Fork 仓库 +2. 创建分支 (`git checkout -b my-new-feature`) +3. 提交修改 (`git commit -am 'Add some feature'`) +4. 推送 (`git push origin my-new-feature`) +5. 创建 PR + +## 欢迎 fork 和反馈 + +如有建议或意见,欢迎在 github [issues](https://github.com/sahadev/vue-component-creater-ui/issues) 区提问 + +## 协议 + +本仓库遵循 [MIT 协议](http://www.opensource.org/licenses/MIT) + ## 有疑问? 可以通过sahadev@foxmail.com给我发送邮件,我会及时回复的。 From d9fdb1a18878036cadb014fe9024aacf1b6226ce Mon Sep 17 00:00:00 2001 From: shangbin Date: Thu, 25 Nov 2021 14:25:00 +0800 Subject: [PATCH 2/8] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0star=E9=93=BE?= =?UTF-8?q?=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 13 +++++++++++++ package.json | 1 + src/components-v2/ToolsBar.vue | 9 +++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6b0a86b..b0e3394 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6351,6 +6351,11 @@ "assert-plus": "^1.0.0" } }, + "github-buttons": { + "version": "2.20.1", + "resolved": "https://r.cnpmjs.org/github-buttons/download/github-buttons-2.20.1.tgz", + "integrity": "sha512-UQpZJP7uVtbjy9vXuIMktmtoH9REy0V50iQnFQ56cyOqzDE8e/9WGedTMD8qVwp593Kyn+EKo2e4IKshoXBeZQ==" + }, "glob": { "version": "7.2.0", "resolved": "https://r.cnpmjs.org/glob/download/glob-7.2.0.tgz", @@ -12807,6 +12812,14 @@ } } }, + "vue-github-button": { + "version": "1.3.0", + "resolved": "https://r.cnpmjs.org/vue-github-button/download/vue-github-button-1.3.0.tgz", + "integrity": "sha1-pNoxejuT0Fgkdos5FqDSL6kWA74=", + "requires": { + "github-buttons": "^2.8.0" + } + }, "vue-hot-reload-api": { "version": "2.3.4", "resolved": "https://r.cnpmjs.org/vue-hot-reload-api/download/vue-hot-reload-api-2.3.4.tgz", diff --git a/package.json b/package.json index e897940..bbe2f3c 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ "view-design": "^4.3.2", "vue": "^2.6.14", "vue-codemirror": "^4.0.6", + "vue-github-button": "^1.3.0", "vue-nestable": "^2.6.0", "vue-router": "^3.4.9", "vuex": "^3.1.2" diff --git a/src/components-v2/ToolsBar.vue b/src/components-v2/ToolsBar.vue index cc8ef51..52fd648 100644 --- a/src/components-v2/ToolsBar.vue +++ b/src/components-v2/ToolsBar.vue @@ -1,7 +1,7 @@ - - - diff --git a/src/utils/get-imports.js b/src/utils/get-imports.js deleted file mode 100644 index 046931d..0000000 --- a/src/utils/get-imports.js +++ /dev/null @@ -1,18 +0,0 @@ -export default function(code, { imports }) { - return { - name: 'get-imports', - - visitor: { - ImportDeclaration(path) { - imports.push({ - variables: path.node.specifiers.map(spec => ({ - local: spec.local.name, - imported: spec.imported ? spec.imported.name : 'default' - })), - module: path.node.source.value - }); - path.remove(); - } - } - }; -} diff --git a/src/utils/get-pkgs.js b/src/utils/get-pkgs.js deleted file mode 100644 index 4b95956..0000000 --- a/src/utils/get-pkgs.js +++ /dev/null @@ -1,40 +0,0 @@ -import parsePackageName from 'parse-package-name'; - -export default async function(code, imports, scripts) { - const replacements = []; - - for (const [index, item] of imports.entries()) { - const moduleName = `__npm_module_${index}`; - const pkg = parsePackageName(item.module); - const version = pkg.version || 'latest'; - scripts.push({ - path: pkg.path ? `/${pkg.path}` : '', - name: moduleName, - module: - pkg.name === 'vue' && !pkg.path - ? `vue@${version}/dist/vue.esm.js` - : `${pkg.name}@${version}` - }); - let replacement = '\n'; - for (const variable of item.variables) { - if (variable.imported === 'default') { - replacement += `var ${ - variable.local - } = ${moduleName}.default || ${moduleName};\n`; - } else { - replacement += `var ${variable.local} = ${moduleName}.${ - variable.imported - };\n`; - } - } - if (replacement) { - replacements.push(replacement); - } - } - - if (replacements.length > 0) { - code = replacements.join('\n') + code; - } - - return code; -} diff --git a/src/utils/iframe.js b/src/utils/iframe.js deleted file mode 100644 index 3079425..0000000 --- a/src/utils/iframe.js +++ /dev/null @@ -1,59 +0,0 @@ -/** - * From: https://github.com/egoist/codepan/blob/2c22bb3d7a7a4e31fd99fc640d320f7ec24d2951/src/utils/iframe.js - */ -import { Loading } from 'element-ui'; -class Iframe { - constructor({ container, el, sandboxAttributes = [] }) { - if (!el) { - throw new Error('Expect "el" to mount iframe to!'); - } - this.$container = container; - this.$el = el; - this.sandboxAttributes = sandboxAttributes; - } - - setHTML(obj) { - let html; - - if (typeof obj === 'string') { - html = obj; - } else { - const { head = '', body = '' } = obj; - html = `${head}${body}`; - } - - // 关闭上一个实例引起的loading - if (this.loadingInstance) { - this.loadingInstance.close(); - } - - this.loadingInstance = Loading.service({ - target: this.$container, - text: '渲染中,请稍后...' - }); - - const iframe = this.createIframe(); - iframe.addEventListener('load', () => { - this.loadingInstance.close(); - }) - - this.$el.parentNode.replaceChild(iframe, this.$el); - iframe.contentWindow.document.open(); - iframe.contentWindow.document.write(html); - iframe.contentWindow.document.close(); - - this.$el = iframe; - } - - createIframe() { - const iframe = document.createElement('iframe'); - iframe.setAttribute('sandbox', this.sandboxAttributes.join(' ')); - iframe.setAttribute('scrolling', 'yes'); - iframe.style.width = '100%'; - iframe.style.height = '100%'; - iframe.style.border = '0'; - return iframe; - } -} - -export default (...args) => new Iframe(...args); diff --git a/src/utils/params.js b/src/utils/params.js deleted file mode 100644 index d04db44..0000000 --- a/src/utils/params.js +++ /dev/null @@ -1,55 +0,0 @@ -import qs from 'query-string'; -import deepmerge from 'deepmerge'; - -const DEFAULT_PARAMS = { - pkgs: ['https://static.imonkey.xueersi.com/vue-code-creater/resource/vue.js', 'https://static.imonkey.xueersi.com/vue-code-creater/resource/element-ui/index.js'], - css: ['https://static.imonkey.xueersi.com/vue-code-creater/resource/element-ui/index.css'], -}; - -let params = DEFAULT_PARAMS; - -function getArr(str) { - if (Array.isArray(str)) { - return str; - } - if (typeof str === 'string') { - return str.split(','); - } - return []; -} - -export function clear() { - params = DEFAULT_PARAMS; -} - -export function parse(str) { - try { - merge(JSON.parse(str)); - } catch (e) { - console.error('error', e.message); - } -} - -export function queryParse(str) { - const query = qs.parse(str); - const pkgs = getArr(query.pkg); - const css = getArr(query.css); - const options = { pkgs, css }; - - if (query.cdn) { - options.cdn = query.cdn; - } - if (query.vue) { - options.vue = query.vue; - } - - merge(options); -} - -export function get() { - return deepmerge(DEFAULT_PARAMS, params); -} - -export function merge(opts) { - params = deepmerge(params, opts); -}