diff --git a/package.json b/package.json index 7614eae..83f4bb4 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "@ionic/core": "^4.11.10", "@ionic/vue": "0.0.4", "axios": "0.18.1", + "clipboard": "^2.0.6", "e-vue-contextmenu": "^0.1.3", "element-ui": "2.13.0", "highlightjs-line-numbers.js": "^2.7.0", diff --git a/src/api/upload-api.js b/src/api/upload-api.js index 0e1989c..372a0bb 100644 --- a/src/api/upload-api.js +++ b/src/api/upload-api.js @@ -120,4 +120,20 @@ export default { data: data }) }, + // 生成分享链接 + generate: function(data) { + return request({ + url: 'share/generate', + method: 'post', + data: data + }) + }, + // 访问分享链接 + accessShare: function(data) { + return request({ + url: 'public/access-share', + method: 'get', + data: data + }) + }, } diff --git a/src/permission.js b/src/permission.js index 58fc470..0cb07ae 100644 --- a/src/permission.js +++ b/src/permission.js @@ -8,7 +8,7 @@ import getPageTitle from '@/utils/get-page-title' NProgress.configure({ showSpinner: false }) // NProgress Configuration -const whiteList = ['/login','/public/articles','/public/articles/article','/share'] // no redirect whitelist +const whiteList = ['/login','/public/articles','/s','/public/articles/article','/share'] // no redirect whitelist router.beforeEach(async(to, from, next) => { // start progress bar diff --git a/src/router/index.js b/src/router/index.js index c61be34..d4f2a7e 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -150,6 +150,18 @@ export const constantRoutes = [ ] }, + { + path: '/s', + component: Layout, + children: [ + { + path: '', + name: 'share', + component: () => import('@/views/public/share/shareList'), + } + ] + }, + // { // path: '/example', // component: Layout, diff --git a/src/styles/home-index.scss b/src/styles/home-index.scss index cd48bc3..0da41b7 100644 --- a/src/styles/home-index.scss +++ b/src/styles/home-index.scss @@ -313,4 +313,23 @@ margin: 0; } } +/deep/ .grid-divider { + display: block; + height: 1px; + width: 500px; + margin: 24px auto; + color: #bcbcbc; + .el-icon-folder-opened { + color: #bcbcbc; + } + .el-divider__text { + font-weight: 100; + font-size: 12px; + } +} +.share-dialog-footer { + text-align: center; + height: 60px; + margin: 20px; +} diff --git a/src/views/home/index.vue b/src/views/home/index.vue index 3d8c3af..a5f09e7 100644 --- a/src/views/home/index.vue +++ b/src/views/home/index.vue @@ -117,6 +117,16 @@ + + +
+ + +
+
+ @@ -267,6 +277,7 @@ +  {{summaries}} { + if (res.data) { + this.shareLink = 'http://'+window.location.host+'/s?s='+res.data + this.generateShareLinkLoading = false + console.log(window.location.host, this.$route) + } + }) + break case 'favorite': console.log('operation', '收藏') this.favoriteOperating(true) @@ -1378,7 +1412,7 @@ export default { console.log('edit', '编辑') this.$router.push(`/markdown/editor?id=${this.rowContextData.id}`) break - case 'open': + case 'open':d console.log('open', '打开') this.fileClick(this.rowContextData) break @@ -1556,6 +1590,30 @@ export default { ); } }, + // 复制分享链接 + copyShareLink() { + var clipboard = new Clipboard('.tag-share-link') + clipboard.on('success', e => { + this.$message({ + message: '复制成功', + type: 'success', + duration: 1000 + }); + this.shareDialog = false + // 释放内存 + clipboard.destroy() + }) + clipboard.on('error', e => { + // 不支持复制 + this.$message({ + message: '该浏览器不支持自动复制', + type: 'warning', + duration: 1000 + }); + // 释放内存 + clipboard.destroy() + }) + }, downloadFile() { let totalSize = 0 this.selectRowData.forEach(item => { diff --git a/src/views/public/share/shareList.vue b/src/views/public/share/shareList.vue new file mode 100644 index 0000000..1ff923e --- /dev/null +++ b/src/views/public/share/shareList.vue @@ -0,0 +1,1751 @@ + + + + + +