From 7176d879a2732cd9586e00dc0b33f2898a43da3f Mon Sep 17 00:00:00 2001
From: Junyi Ao <125933ajy@gmail.com>
Date: Thu, 28 May 2020 23:57:44 +0800
Subject: [PATCH] =?UTF-8?q?fix=20#71=20=E9=99=84=E4=BB=B6=E5=BA=93?=
=?UTF-8?q?=E6=94=AF=E6=8C=81=E5=8F=B3=E9=94=AE=E5=A4=8D=E5=88=B6=E5=9B=BE?=
=?UTF-8?q?=E7=89=87=E5=9C=B0=E5=9D=80=20(halo-dev/console#180)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* fix issue 71
* 删除class-a,调整label,z-index和minWidth
---
package.json | 4 +-
src/main.js | 2 +
src/views/attachment/AttachmentList.vue | 41 ++++++++++++++++++
.../components/AttachmentDrawer.vue | 42 +++++++++++++++++++
4 files changed, 88 insertions(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 3172b6289..825b5ed8b 100644
--- a/package.json
+++ b/package.json
@@ -28,7 +28,9 @@
"vue-ls": "^3.2.1",
"vue-router": "^3.1.6",
"vuejs-logger": "^1.5.3",
- "vuex": "^3.1.1"
+ "vuex": "^3.1.1",
+ "flv.js": "^1.5.0",
+ "vue-contextmenujs": "^1.3.9"
},
"devDependencies": {
"@babel/polyfill": "^7.4.4",
diff --git a/src/main.js b/src/main.js
index 17d9f0f47..7cabec64e 100644
--- a/src/main.js
+++ b/src/main.js
@@ -2,6 +2,7 @@ import '@babel/polyfill'
import Vue from 'vue'
import App from './App.vue'
import router from './router'
+import Contextmenu from 'vue-contextmenujs'
import store from './store/'
import './logger'
@@ -15,6 +16,7 @@ Vue.config.productionTip = false
Vue.prototype.VERSION = version
Vue.use(router)
+Vue.use(Contextmenu)
new Vue({
router,
diff --git a/src/views/attachment/AttachmentList.vue b/src/views/attachment/AttachmentList.vue
index 03c30139a..67218240a 100644
--- a/src/views/attachment/AttachmentList.vue
+++ b/src/views/attachment/AttachmentList.vue
@@ -132,6 +132,7 @@
:bodyStyle="{ padding: 0 }"
hoverable
@click="handleShowDetailDrawer(item)"
+ @contextmenu.prevent="handleContextMenu($event, item)"
>
当前格式不支持预览
@@ -298,6 +299,46 @@ export default {
this.drawerVisible = true
}
},
+ handleContextMenu(event, item) {
+ this.$contextmenu({
+ items: [
+ {
+ label: '复制图片链接',
+ onClick: () => {
+ const text = `${encodeURI(item.path)}`
+ this.$copyText(text)
+ .then(message => {
+ this.$log.debug('copy', message)
+ this.$message.success('复制成功!')
+ })
+ .catch(err => {
+ this.$log.debug('copy.err', err)
+ this.$message.error('复制失败!')
+ })
+ },
+ divided: true
+ },
+ {
+ label: '复制 Markdown 格式链接',
+ onClick: () => {
+ const text = `![${item.name}](${encodeURI(item.path)})`
+ this.$copyText(text)
+ .then(message => {
+ this.$log.debug('copy', message)
+ this.$message.success('复制成功!')
+ })
+ .catch(err => {
+ this.$log.debug('copy.err', err)
+ this.$message.error('复制失败!')
+ })
+ }
+ }
+ ],
+ event,
+ minWidth: 210
+ })
+ return false
+ },
handlePaginationChange(page, size) {
this.$log.debug(`Current: ${page}, PageSize: ${size}`)
this.pagination.page = page
diff --git a/src/views/attachment/components/AttachmentDrawer.vue b/src/views/attachment/components/AttachmentDrawer.vue
index c1ebd80f1..e1bb1f70f 100644
--- a/src/views/attachment/components/AttachmentDrawer.vue
+++ b/src/views/attachment/components/AttachmentDrawer.vue
@@ -37,6 +37,7 @@
v-for="(item, index) in formattedDatas"
:key="index"
@click="handleShowDetailDrawer(item)"
+ @contextmenu.prevent="handleContextMenu($event, item)"
>
当前格式不支持预览
{
+ const text = `${encodeURI(item.path)}`
+ this.$copyText(text)
+ .then(message => {
+ this.$log.debug('copy', message)
+ this.$message.success('复制成功!')
+ })
+ .catch(err => {
+ this.$log.debug('copy.err', err)
+ this.$message.error('复制失败!')
+ })
+ },
+ divided: true
+ },
+ {
+ label: '复制 Markdown 格式链接',
+ onClick: () => {
+ const text = `![${item.name}](${encodeURI(item.path)})`
+ this.$copyText(text)
+ .then(message => {
+ this.$log.debug('copy', message)
+ this.$message.success('复制成功!')
+ })
+ .catch(err => {
+ this.$log.debug('copy.err', err)
+ this.$message.error('复制失败!')
+ })
+ }
+ }
+ ],
+ event,
+ zIndex: 1001,
+ minWidth: 210
+ })
+ return false
+ },
loadAttachments() {
this.queryParam.page = this.pagination.page - 1
this.queryParam.size = this.pagination.size