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

fix issue 71 附件库支持右键复制图片地址 #180

Merged
merged 4 commits into from
May 28, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
43 changes: 43 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,48 @@ 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格式链接',
ruibaby marked this conversation as resolved.
Show resolved Hide resolved
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,
customClass: 'class-a',
ruibaby marked this conversation as resolved.
Show resolved Hide resolved
zIndex: 3,
minWidth: 230
})
return false
},
handlePaginationChange(page, size) {
this.$log.debug(`Current: ${page}, PageSize: ${size}`)
this.pagination.page = page
Expand Down
44 changes: 44 additions & 0 deletions src/views/attachment/components/AttachmentDrawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
:width="isMobile()?'100%':'480'"
closable
:visible="visible"
:z-index="1005"
destroyOnClose
@close="onClose"
>
Expand Down Expand Up @@ -37,6 +38,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 +167,48 @@ 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格式链接',
ruibaby marked this conversation as resolved.
Show resolved Hide resolved
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,
customClass: 'class-a',
ruibaby marked this conversation as resolved.
Show resolved Hide resolved
zIndex: 1006,
minWidth: 230
})
return false
},
loadAttachments() {
this.queryParam.page = this.pagination.page - 1
this.queryParam.size = this.pagination.size
Expand Down