Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

Commit

Permalink
fix #71 附件库支持右键复制图片地址 (#180)
Browse files Browse the repository at this point in the history
* fix issue 71

* 删除class-a,调整label,z-index和minWidth
  • Loading branch information
Ajyy authored May 28, 2020
1 parent 5cfe3ea commit 6c626b7
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 1 deletion.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -15,6 +16,7 @@ Vue.config.productionTip = false
Vue.prototype.VERSION = version

Vue.use(router)
Vue.use(Contextmenu)

new Vue({
router,
Expand Down
41 changes: 41 additions & 0 deletions src/views/attachment/AttachmentList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
:bodyStyle="{ padding: 0 }"
hoverable
@click="handleShowDetailDrawer(item)"
@contextmenu.prevent="handleContextMenu($event, item)"
>
<div class="attach-thumb">
<span v-show="!handleJudgeMediaType(item)">当前格式不支持预览</span>
Expand Down Expand Up @@ -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
Expand Down
42 changes: 42 additions & 0 deletions src/views/attachment/components/AttachmentDrawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
v-for="(item, index) in formattedDatas"
:key="index"
@click="handleShowDetailDrawer(item)"
@contextmenu.prevent="handleContextMenu($event, item)"
>
<span v-show="!handleJudgeMediaType(item)">当前格式不支持预览</span>
<img
Expand Down Expand Up @@ -165,6 +166,47 @@ export default {
this.$log.debug('Show detail of', attachment)
this.detailVisible = 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,
zIndex: 1001,
minWidth: 210
})
return false
},
loadAttachments() {
this.queryParam.page = this.pagination.page - 1
this.queryParam.size = this.pagination.size
Expand Down

0 comments on commit 6c626b7

Please sign in to comment.