From 14ff09a414cb7c673f3143e7fc64c92aab793c6c Mon Sep 17 00:00:00 2001 From: "lei.jiang" Date: Sat, 16 Sep 2017 21:44:43 +0800 Subject: [PATCH 001/737] =?UTF-8?q?=E4=BF=AE=E6=94=B9MDinput=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=201.=E4=BD=BF=E4=B9=8B=E8=83=BD=E5=85=BC=E5=AE=B9elem?= =?UTF-8?q?entui=E7=9A=84=E8=A1=A8=E5=8D=95=E9=AA=8C=E8=AF=81=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=202.=E5=A2=9E=E5=8A=A0icon=E5=B1=9E=E6=80=A7=EF=BC=8C?= =?UTF-8?q?=E8=83=BD=E5=A4=9F=E4=BD=BF=E7=94=A8elementui=E7=9A=84=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=203.=E4=BC=98=E5=8C=96=E6=98=BE=E7=A4=BA=E6=95=88?= =?UTF-8?q?=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/MDinput/index.vue | 533 +++++++++++++++---------------- 1 file changed, 265 insertions(+), 268 deletions(-) diff --git a/src/components/MDinput/index.vue b/src/components/MDinput/index.vue index 72658598d62..82c944c4e55 100644 --- a/src/components/MDinput/index.vue +++ b/src/components/MDinput/index.vue @@ -1,297 +1,294 @@ From 8945476c228953170606dc5f7c5c5ebef23f3da9 Mon Sep 17 00:00:00 2001 From: "lei.jiang" Date: Sat, 16 Sep 2017 21:47:04 +0800 Subject: [PATCH 002/737] =?UTF-8?q?=E4=BF=AE=E6=94=B9MDinput=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=201.=E4=BD=BF=E4=B9=8B=E8=83=BD=E5=85=BC=E5=AE=B9elem?= =?UTF-8?q?entui=E7=9A=84=E8=A1=A8=E5=8D=95=E9=AA=8C=E8=AF=81=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=202.=E5=A2=9E=E5=8A=A0icon=E5=B1=9E=E6=80=A7=EF=BC=8C?= =?UTF-8?q?=E8=83=BD=E5=A4=9F=E4=BD=BF=E7=94=A8elementui=E7=9A=84=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=203.=E4=BC=98=E5=8C=96=E6=98=BE=E7=A4=BA=E6=95=88?= =?UTF-8?q?=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/MDinput/index.vue | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/components/MDinput/index.vue b/src/components/MDinput/index.vue index 82c944c4e55..96ef1eeb51c 100644 --- a/src/components/MDinput/index.vue +++ b/src/components/MDinput/index.vue @@ -286,9 +286,6 @@ background: transparent; } } - /*.material-errors { - color: $color-red; - }*/ } } From fde12e8ef99a2c4520af8afd88a1debc778d8f72 Mon Sep 17 00:00:00 2001 From: "lei.jiang" Date: Sat, 16 Sep 2017 22:05:57 +0800 Subject: [PATCH 003/737] =?UTF-8?q?=E4=BF=AE=E6=94=B9MdInput=E7=9A=84demo?= =?UTF-8?q?=EF=BC=8C=E4=BD=BF=E4=B9=8B=E8=83=BD=E5=B1=95=E7=8E=B0=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/components/mixin.vue | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/views/components/mixin.vue b/src/views/components/mixin.vue index f78ab1e0b67..7c35f69bc7c 100644 --- a/src/views/components/mixin.vue +++ b/src/views/components/mixin.vue @@ -1,9 +1,11 @@ \ No newline at end of file diff --git a/src/icons/svg/tuozhuai.svg b/src/icons/svg/drag.svg similarity index 100% rename from src/icons/svg/tuozhuai.svg rename to src/icons/svg/drag.svg diff --git a/src/icons/svg/zonghe.svg b/src/icons/svg/example.svg similarity index 100% rename from src/icons/svg/zonghe.svg rename to src/icons/svg/example.svg diff --git a/src/icons/svg/EXCEL.svg b/src/icons/svg/excel.svg similarity index 100% rename from src/icons/svg/EXCEL.svg rename to src/icons/svg/excel.svg diff --git a/src/icons/svg/yanjing.svg b/src/icons/svg/eye.svg similarity index 100% rename from src/icons/svg/yanjing.svg rename to src/icons/svg/eye.svg diff --git a/src/icons/svg/form.svg b/src/icons/svg/form.svg new file mode 100644 index 00000000000..79716f065d6 --- /dev/null +++ b/src/icons/svg/form.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/from.svg b/src/icons/svg/from.svg deleted file mode 100644 index 7a4bd166612..00000000000 --- a/src/icons/svg/from.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/icons/svg/icons.svg b/src/icons/svg/icon.svg similarity index 100% rename from src/icons/svg/icons.svg rename to src/icons/svg/icon.svg diff --git a/src/icons/svg/quanxian.svg b/src/icons/svg/lock.svg similarity index 100% rename from src/icons/svg/quanxian.svg rename to src/icons/svg/lock.svg diff --git a/src/icons/svg/mima.svg b/src/icons/svg/password.svg similarity index 100% rename from src/icons/svg/mima.svg rename to src/icons/svg/password.svg diff --git a/src/icons/svg/xinrenzhinan.svg b/src/icons/svg/people.svg similarity index 100% rename from src/icons/svg/xinrenzhinan.svg rename to src/icons/svg/people.svg diff --git a/src/icons/svg/QQ.svg b/src/icons/svg/qq.svg similarity index 100% rename from src/icons/svg/QQ.svg rename to src/icons/svg/qq.svg diff --git a/src/icons/svg/shouce.svg b/src/icons/svg/shouce.svg deleted file mode 100644 index 94c68bb6d1e..00000000000 --- a/src/icons/svg/shouce.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/icons/svg/wujiaoxing.svg b/src/icons/svg/star.svg similarity index 100% rename from src/icons/svg/wujiaoxing.svg rename to src/icons/svg/star.svg diff --git a/src/icons/svg/tab.svg b/src/icons/svg/tab.svg index 657057df533..17aa088b737 100644 --- a/src/icons/svg/tab.svg +++ b/src/icons/svg/tab.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/a.svg b/src/icons/svg/trendChart1.svg similarity index 100% rename from src/icons/svg/a.svg rename to src/icons/svg/trendChart1.svg diff --git a/src/icons/svg/b.svg b/src/icons/svg/trendChart2.svg similarity index 100% rename from src/icons/svg/b.svg rename to src/icons/svg/trendChart2.svg diff --git a/src/icons/svg/c.svg b/src/icons/svg/trendChart3.svg similarity index 100% rename from src/icons/svg/c.svg rename to src/icons/svg/trendChart3.svg diff --git a/src/icons/svg/yonghuming.svg b/src/icons/svg/user.svg similarity index 100% rename from src/icons/svg/yonghuming.svg rename to src/icons/svg/user.svg diff --git a/src/icons/svg/weixin.svg b/src/icons/svg/wechat.svg similarity index 100% rename from src/icons/svg/weixin.svg rename to src/icons/svg/wechat.svg diff --git a/src/icons/svg/zujian.svg b/src/icons/svg/zujian.svg deleted file mode 100644 index d183e56c2bd..00000000000 --- a/src/icons/svg/zujian.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/router/index.js b/src/router/index.js index c235005a741..a705a736b5e 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -32,7 +32,7 @@ export const constantRouterMap = [ path: '/introduction', component: Layout, redirect: '/introduction/index', - icon: 'xinrenzhinan', + icon: 'people', noDropdown: true, children: [{ path: 'index', component: _import('introduction/index'), name: '简述' }] } @@ -50,7 +50,7 @@ export const asyncRouterMap = [ component: Layout, redirect: '/permission/index', name: '权限测试', - icon: 'quanxian', + icon: 'lock', meta: { role: ['admin'] }, noDropdown: true, children: [{ path: 'index', component: _import('permission/index'), name: '权限测试页', meta: { role: ['admin'] }}] @@ -58,7 +58,7 @@ export const asyncRouterMap = [ { path: '/icon', component: Layout, - icon: 'icons', + icon: 'icon', noDropdown: true, children: [{ path: 'index', component: _import('svg-icons/index'), name: 'icons' }] }, @@ -67,7 +67,7 @@ export const asyncRouterMap = [ component: Layout, redirect: '/components/index', name: '组件', - icon: 'zujian', + icon: 'component', children: [ { path: 'index', component: _import('components/index'), name: '介绍 ' }, { path: 'tinymce', component: _import('components/tinymce'), name: '富文本编辑器' }, @@ -88,7 +88,7 @@ export const asyncRouterMap = [ component: Layout, redirect: '/charts/index', name: '图表', - icon: 'tubiao', + icon: 'chart', children: [ { path: 'index', component: _import('charts/index'), name: '介绍' }, { path: 'keyboard', component: _import('charts/keyboard'), name: '键盘图表' }, @@ -102,7 +102,7 @@ export const asyncRouterMap = [ component: Layout, redirect: 'noredirect', name: '综合实例', - icon: 'zonghe', + icon: 'example', children: [ { path: '/example/table', @@ -117,8 +117,8 @@ export const asyncRouterMap = [ { path: 'table', component: _import('example/table/table'), name: '综合table' } ] }, - { path: 'form/edit', icon: 'shouce', component: _import('example/form'), name: '编辑Form', meta: { isEdit: true }}, - { path: 'form/create', icon: 'from', component: _import('example/form'), name: '创建Form' }, + { path: 'form/edit', icon: 'form', component: _import('example/form'), name: '编辑Form', meta: { isEdit: true }}, + { path: 'form/create', icon: 'form', component: _import('example/form'), name: '创建Form' }, { path: 'tab/index', icon: 'tab', component: _import('example/tab/index'), name: 'Tab' } ] }, @@ -147,7 +147,7 @@ export const asyncRouterMap = [ component: Layout, redirect: '/excel/download', name: 'excel', - icon: 'EXCEL', + icon: 'excel', children: [ { path: 'download', component: _import('excel/index'), name: '导出excel' }, { path: 'download2', component: _import('excel/selectExcel'), name: '导出已选择项' }, diff --git a/src/views/dashboard/admin/index.vue b/src/views/dashboard/admin/index.vue index 9517c2a4a79..ad657137db1 100644 --- a/src/views/dashboard/admin/index.vue +++ b/src/views/dashboard/admin/index.vue @@ -34,12 +34,12 @@
文章 - +
浏览量 - +
diff --git a/src/views/example/tab/components/tabPane.vue b/src/views/example/tab/components/tabPane.vue index 8a8575e0a04..efb29471409 100644 --- a/src/views/example/tab/components/tabPane.vue +++ b/src/views/example/tab/components/tabPane.vue @@ -29,7 +29,7 @@ diff --git a/src/views/example/table/dragTable.vue b/src/views/example/table/dragTable.vue index 864e2c7b277..64886f60e9a 100644 --- a/src/views/example/table/dragTable.vue +++ b/src/views/example/table/dragTable.vue @@ -29,7 +29,7 @@ @@ -47,7 +47,7 @@ diff --git a/src/views/example/table/inlineEditTable.vue b/src/views/example/table/inlineEditTable.vue index fc07a379ac9..dfd53cc1265 100644 --- a/src/views/example/table/inlineEditTable.vue +++ b/src/views/example/table/inlineEditTable.vue @@ -23,7 +23,7 @@ diff --git a/src/views/example/table/table.vue b/src/views/example/table/table.vue index abfbb35db4a..3b7b8db427b 100644 --- a/src/views/example/table/table.vue +++ b/src/views/example/table/table.vue @@ -60,7 +60,7 @@ diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 1adbc394748..b4923042ba3 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -5,18 +5,18 @@ - + - + 登录 diff --git a/src/views/login/socialsignin.vue b/src/views/login/socialsignin.vue index 71b9d60ac01..70d30917361 100644 --- a/src/views/login/socialsignin.vue +++ b/src/views/login/socialsignin.vue @@ -1,10 +1,10 @@ From db61251d897fe852ece1327baa718ce4ee5edcdb Mon Sep 17 00:00:00 2001 From: Pan Date: Mon, 25 Sep 2017 17:41:03 +0800 Subject: [PATCH 006/737] [release] 2.1.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ae01ad50c9e..073cac84e63 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "juicy", - "version": "2.1.0", + "version": "2.1.1", "description": "A Vue.js admin", "author": "Pan ", "license": "MIT", From 807aa548b261a03952e48c601f31d7fbf1859bc6 Mon Sep 17 00:00:00 2001 From: Pan Date: Tue, 26 Sep 2017 16:08:20 +0800 Subject: [PATCH 007/737] refine:rm duplicate code && split xlsx --- build/webpack.prod.conf.js | 8 ++++++++ src/vendor/Export2Excel.js | 7 ++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/build/webpack.prod.conf.js b/build/webpack.prod.conf.js index 05f848741dd..d69d0e1ddc2 100644 --- a/build/webpack.prod.conf.js +++ b/build/webpack.prod.conf.js @@ -95,6 +95,14 @@ var webpackConfig = merge(baseWebpackConfig, { return context && (context.indexOf('echarts') >= 0 || context.indexOf('zrender') >= 0); } }), + // split xlsx into its own file + new webpack.optimize.CommonsChunkPlugin({ + async: 'xlsx', + minChunks(module) { + var context = module.context; + return context && (context.indexOf('xlsx') >= 0); + } + }), // extract webpack runtime and module manifest to its own file in order to // prevent vendor hash from being updated whenever app bundle is updated new webpack.optimize.CommonsChunkPlugin({ diff --git a/src/vendor/Export2Excel.js b/src/vendor/Export2Excel.js index a121a33a1de..8852064e076 100644 --- a/src/vendor/Export2Excel.js +++ b/src/vendor/Export2Excel.js @@ -1,7 +1,8 @@ /* eslint-disable */ require('script-loader!file-saver'); require('script-loader!vendor/Blob'); -require('script-loader!xlsx/dist/xlsx.core.min'); +import XLSX from 'xlsx' + function generateArray(table) { var out = []; var rows = table.querySelectorAll('tr'); @@ -93,7 +94,6 @@ function s2ab(s) { export function export_table_to_excel(id) { var theTable = document.getElementById(id); - console.log('a') var oo = generateArray(theTable); var ranges = oo[1]; @@ -117,9 +117,6 @@ export function export_table_to_excel(id) { saveAs(new Blob([s2ab(wbout)], {type: "application/octet-stream"}), "test.xlsx") } -function formatJson(jsonData) { - console.log(jsonData) -} export function export_json_to_excel(th, jsonData, defaultTitle) { /* original data */ From fcf7c0ba5036ca7c7e2a95bcf5b17904a0f0b89c Mon Sep 17 00:00:00 2001 From: spiritree Date: Mon, 25 Sep 2017 15:49:51 +0800 Subject: [PATCH 008/737] ignore package-lock.json --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index a5060b02477..bb2a167e60e 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ test/unit/coverage test/e2e/reports selenium-debug.log .idea +package-lock.json From 3cf048e80bf69f82c34dcf7c1d96b8c66609be76 Mon Sep 17 00:00:00 2001 From: spiritree Date: Mon, 25 Sep 2017 16:43:56 +0800 Subject: [PATCH 009/737] add Export2Zip vendor --- package.json | 3 ++- src/vendor/Export2Zip.js | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 src/vendor/Export2Zip.js diff --git a/package.json b/package.json index 073cac84e63..a80852a9c05 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,8 @@ "vue-splitpane": "^1.0.0", "vuedraggable": "2.14.1", "vuex": "2.3.1", - "xlsx": "^0.10.8" + "xlsx": "^0.10.8", + "jszip": "^3.1.4" }, "devDependencies": { "autoprefixer": "7.1.1", diff --git a/src/vendor/Export2Zip.js b/src/vendor/Export2Zip.js new file mode 100644 index 00000000000..4fab8acae25 --- /dev/null +++ b/src/vendor/Export2Zip.js @@ -0,0 +1,22 @@ +/* eslint-disable */ +require('script-loader!file-saver'); +import JSZip from 'jszip' + +export function export_txt_to_zip(th, jsonData, txtName, zipName) { + const zip = new JSZip() + const txt_name = txtName || '文本' + const zip_name = zipName || '压缩包' + const data = jsonData + let txtData = `${th}\r\n` + data.forEach((row) => { + let tempStr = '' + tempStr = row.toString() + txtData += `${tempStr}\r\n` + }) + zip.file(`${txt_name}.txt`, txtData) + zip.generateAsync({type:"blob"}).then(function (blob) { + saveAs(blob, `${zip_name}.zip`) + }, function (err) { + alert('导出失败') + }) +} From a185412446a5bef99151101590a20f5e763a4063 Mon Sep 17 00:00:00 2001 From: spiritree Date: Tue, 26 Sep 2017 13:40:07 +0800 Subject: [PATCH 010/737] add Export2Zip demo --- src/icons/svg/zip.svg | 1 + src/router/index.js | 11 +++++ src/views/zip/index.vue | 74 +++++++++++++++++++++++++++++++++ src/views/zip/select.vue | 88 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 174 insertions(+) create mode 100644 src/icons/svg/zip.svg create mode 100644 src/views/zip/index.vue create mode 100644 src/views/zip/select.vue diff --git a/src/icons/svg/zip.svg b/src/icons/svg/zip.svg new file mode 100644 index 00000000000..e9a9d012d3f --- /dev/null +++ b/src/icons/svg/zip.svg @@ -0,0 +1 @@ + diff --git a/src/router/index.js b/src/router/index.js index a705a736b5e..b50c742624b 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -154,6 +154,17 @@ export const asyncRouterMap = [ { path: 'upload', component: _import('excel/uploadExcel'), name: 'upload excel' } ] }, + { + path: '/zip', + component: Layout, + redirect: '/zip/download', + name: 'zip', + icon: 'zip', + children: [ + { path: 'download', component: _import('zip/index'), name: '导出zip' }, + { path: 'download2', component: _import('zip/select'), name: '导出已选择项' } + ] + }, { path: '/theme', component: Layout, diff --git a/src/views/zip/index.vue b/src/views/zip/index.vue new file mode 100644 index 00000000000..fa32a9832fe --- /dev/null +++ b/src/views/zip/index.vue @@ -0,0 +1,74 @@ + + + diff --git a/src/views/zip/select.vue b/src/views/zip/select.vue new file mode 100644 index 00000000000..fc4ac7fb27e --- /dev/null +++ b/src/views/zip/select.vue @@ -0,0 +1,88 @@ + + + From 8d53ae125973691978ab5f161a094760955133e9 Mon Sep 17 00:00:00 2001 From: Pan Date: Wed, 27 Sep 2017 10:03:42 +0800 Subject: [PATCH 011/737] add:add clipboard --- package.json | 1 + src/directive/clipboard/clipboard.js | 49 ++++++++++++++++++++++++++++ src/directive/clipboard/index.js | 13 ++++++++ src/icons/svg/clipboard.svg | 1 + src/router/index.js | 8 +++++ src/utils/clipboard.js | 36 ++++++++++++++++++++ src/views/clipboard/index.vue | 2 ++ 7 files changed, 110 insertions(+) create mode 100644 src/directive/clipboard/clipboard.js create mode 100644 src/directive/clipboard/index.js create mode 100644 src/icons/svg/clipboard.svg create mode 100644 src/utils/clipboard.js create mode 100644 src/views/clipboard/index.vue diff --git a/package.json b/package.json index a80852a9c05..7eb5f2288df 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ }, "dependencies": { "axios": "0.16.2", + "clipboard": "1.7.1", "codemirror": "5.26.0", "dropzone": "5.1.0", "echarts": "3.6.2", diff --git a/src/directive/clipboard/clipboard.js b/src/directive/clipboard/clipboard.js new file mode 100644 index 00000000000..49c9b391a8f --- /dev/null +++ b/src/directive/clipboard/clipboard.js @@ -0,0 +1,49 @@ +// Inspired by https://github.com/Inndy/vue-clipboard2 +const Clipboard = require('clipboard') +if (!Clipboard) { + throw new Error('you shold npm install `clipboard` --save at first ') +} + +export default { + bind(el, binding) { + if (binding.arg === 'success') { + el._v_clipboard_success = binding.value + } else if (binding.arg === 'error') { + el._v_clipboard_error = binding.value + } else { + const clipboard = new Clipboard(el, { + text() { return binding.value }, + action() { return binding.arg === 'cut' ? 'cut' : 'copy' } + }) + clipboard.on('success', e => { + const callback = el._v_clipboard_success + callback && callback(e) // eslint-disable-line + }) + clipboard.on('error', e => { + const callback = el._v_clipboard_error + callback && callback(e) // eslint-disable-line + }) + el._v_clipboard = clipboard + } + }, + update(el, binding) { + if (binding.arg === 'success') { + el._v_clipboard_success = binding.value + } else if (binding.arg === 'error') { + el._v_clipboard_error = binding.value + } else { + el._v_clipboard.text = function() { return binding.value } + el._v_clipboard.action = function() { return binding.arg === 'cut' ? 'cut' : 'copy' } + } + }, + unbind(el, binding) { + if (binding.arg === 'success') { + delete el._v_clipboard_success + } else if (binding.arg === 'error') { + delete el._v_clipboard_error + } else { + el._v_clipboard.destroy() + delete el._v_clipboard + } + } +} diff --git a/src/directive/clipboard/index.js b/src/directive/clipboard/index.js new file mode 100644 index 00000000000..02c98163f40 --- /dev/null +++ b/src/directive/clipboard/index.js @@ -0,0 +1,13 @@ +import Clipboard from './clipboard' + +const install = function(Vue) { + Vue.directive('Clipboard', Clipboard) +} + +if (window.Vue) { + window.clipboard = Clipboard + Vue.use(install); // eslint-disable-line +} + +Clipboard.install = install +export default Clipboard diff --git a/src/icons/svg/clipboard.svg b/src/icons/svg/clipboard.svg new file mode 100644 index 00000000000..cf1c9b0cf8c --- /dev/null +++ b/src/icons/svg/clipboard.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/router/index.js b/src/router/index.js index b50c742624b..8bc6642bd15 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -174,6 +174,14 @@ export const asyncRouterMap = [ noDropdown: true, children: [{ path: 'index', component: _import('theme/index'), name: '换肤' }] }, + { + path: '/clipboard', + component: Layout, + redirect: 'noredirect', + icon: 'clipboard', + noDropdown: true, + children: [{ path: 'index', component: _import('clipboard/index'), name: 'clipboard' }] + }, { path: '*', redirect: '/404', hidden: true } ] diff --git a/src/utils/clipboard.js b/src/utils/clipboard.js new file mode 100644 index 00000000000..882b1251e7b --- /dev/null +++ b/src/utils/clipboard.js @@ -0,0 +1,36 @@ +import Clipboard from 'clipboard' +import Vue from 'vue' + +function clipboardSuccess() { + Vue.prototype.$message({ + message: '复制成功', + type: 'success', + duration: 1500 + }) +} + +function clipboardError() { + Vue.prototype.$message({ + message: '复制失败', + type: 'error' + }) +} + +export default function handleClipboard(text, event) { + const clipboard = new Clipboard(event.target, { + text: () => text + }) + clipboard.on('success', () => { + clipboardSuccess() + clipboard.off('error') + clipboard.off('success') + clipboard.destroy() + }) + clipboard.on('error', () => { + clipboardError() + clipboard.off('error') + clipboard.off('success') + clipboard.destroy() + }) + clipboard.onClick(event) +} diff --git a/src/views/clipboard/index.vue b/src/views/clipboard/index.vue new file mode 100644 index 00000000000..c1cf0c07d56 --- /dev/null +++ b/src/views/clipboard/index.vue @@ -0,0 +1,2 @@ +