mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-09-05 23:47:43 +08:00
Fixed: #84 && add multi copy
This commit is contained in:
@@ -50,7 +50,7 @@ const imgFromPath = async (imgPath) => {
|
|||||||
name = await waitForRename(window, window.webContents.id)
|
name = await waitForRename(window, window.webContents.id)
|
||||||
}
|
}
|
||||||
let buffer = await fs.readFile(item)
|
let buffer = await fs.readFile(item)
|
||||||
let base64Image = Buffer.from(buffer, 'binary').toString('base64')
|
let base64Image = Buffer.from(buffer).toString('base64')
|
||||||
let imgSize = sizeOf(item)
|
let imgSize = sizeOf(item)
|
||||||
results.push({
|
results.push({
|
||||||
base64Image,
|
base64Image,
|
||||||
@@ -105,7 +105,7 @@ const imgFromUploader = async (files) => {
|
|||||||
name = await waitForRename(window, window.webContents.id)
|
name = await waitForRename(window, window.webContents.id)
|
||||||
}
|
}
|
||||||
let buffer = await fs.readFile(item.path)
|
let buffer = await fs.readFile(item.path)
|
||||||
let base64Image = Buffer.from(buffer, 'binary').toString('base64')
|
let base64Image = Buffer.from(buffer).toString('base64')
|
||||||
let imgSize = sizeOf(item.path)
|
let imgSize = sizeOf(item.path)
|
||||||
results.push({
|
results.push({
|
||||||
base64Image,
|
base64Image,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import * as img2Base64 from './img2base64'
|
|||||||
import db from '../../datastore/index'
|
import db from '../../datastore/index'
|
||||||
import { Notification, clipboard } from 'electron'
|
import { Notification, clipboard } from 'electron'
|
||||||
import crypto from 'crypto'
|
import crypto from 'crypto'
|
||||||
|
import mime from 'mime-types'
|
||||||
|
|
||||||
// generate COS signature string
|
// generate COS signature string
|
||||||
const generateSignature = (fileName) => {
|
const generateSignature = (fileName) => {
|
||||||
@@ -67,7 +68,7 @@ const postOptions = (fileName, signature, imgBase64) => {
|
|||||||
headers: {
|
headers: {
|
||||||
Host: `${options.bucket}.cos.${options.area}.myqcloud.com`,
|
Host: `${options.bucket}.cos.${options.area}.myqcloud.com`,
|
||||||
Authorization: `q-sign-algorithm=sha1&q-ak=${options.secretId}&q-sign-time=${signature.signTime}&q-key-time=${signature.signTime}&q-header-list=host&q-url-param-list=&q-signature=${signature.signature}`,
|
Authorization: `q-sign-algorithm=sha1&q-ak=${options.secretId}&q-sign-time=${signature.signTime}&q-key-time=${signature.signTime}&q-header-list=host&q-url-param-list=&q-signature=${signature.signature}`,
|
||||||
contentType: 'multipart/form-data'
|
contentType: mime.lookup(fileName)
|
||||||
},
|
},
|
||||||
body: Buffer.from(imgBase64, 'base64'),
|
body: Buffer.from(imgBase64, 'base64'),
|
||||||
resolveWithFullResponse: true
|
resolveWithFullResponse: true
|
||||||
|
|||||||
@@ -15,11 +15,13 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
<el-row class="handle-bar" :gutter="16">
|
<el-row class="handle-bar" :gutter="16">
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-input placeholder="搜索" size="mini" v-model="searchText"></el-input>
|
<el-input placeholder="搜索" size="mini" v-model="searchText">
|
||||||
|
<i slot="suffix" class="el-input__icon el-icon-close" v-if="searchText" @click="cleanSearch" style="cursor: pointer"></i>
|
||||||
|
</el-input>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="6">
|
<el-col :span="6">
|
||||||
<div class="item-base" @click="cleanSearch">
|
<div class="item-base copy" :class="{ active: isMultiple(choosedList)}" @click="multiCopy">
|
||||||
清空搜索
|
<i class="el-icon-document"></i> 批量复制
|
||||||
</div>
|
</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="6">
|
<el-col :span="6">
|
||||||
@@ -143,7 +145,7 @@ export default {
|
|||||||
this.idx = null
|
this.idx = null
|
||||||
},
|
},
|
||||||
copy (url) {
|
copy (url) {
|
||||||
const style = this.$db.read().get('picBed.pasteStyle').value()
|
const style = this.$db.read().get('picBed.pasteStyle').value() || 'markdown'
|
||||||
const copyLink = pasteStyle(style, url)
|
const copyLink = pasteStyle(style, url)
|
||||||
const obj = {
|
const obj = {
|
||||||
title: '复制链接成功',
|
title: '复制链接成功',
|
||||||
@@ -153,7 +155,7 @@ export default {
|
|||||||
const myNotification = new window.Notification(obj.title, obj)
|
const myNotification = new window.Notification(obj.title, obj)
|
||||||
this.$electron.clipboard.writeText(copyLink)
|
this.$electron.clipboard.writeText(copyLink)
|
||||||
myNotification.onclick = () => {
|
myNotification.onclick = () => {
|
||||||
return true
|
console.log(123)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
remove (id) {
|
remove (id) {
|
||||||
@@ -239,6 +241,25 @@ export default {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
multiCopy () {
|
||||||
|
let copyString = ''
|
||||||
|
const style = this.$db.read().get('picBed.pasteStyle').value() || 'markdown'
|
||||||
|
Object.keys(this.choosedList).forEach(key => {
|
||||||
|
if (this.choosedList[key]) {
|
||||||
|
console.log(pasteStyle(style, this.$db.read().get('uploaded').getById(key).value().imgUrl), style)
|
||||||
|
copyString += pasteStyle(style, this.$db.read().get('uploaded').getById(key).value().imgUrl) + '\n'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const obj = {
|
||||||
|
title: '复制链接成功',
|
||||||
|
body: copyString
|
||||||
|
}
|
||||||
|
const myNotification = new window.Notification(obj.title, obj)
|
||||||
|
this.$electron.clipboard.writeText(copyString)
|
||||||
|
myNotification.onclick = () => {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
},
|
||||||
toggleHandleBar () {
|
toggleHandleBar () {
|
||||||
this.handleBarActive = !this.handleBarActive
|
this.handleBarActive = !this.handleBarActive
|
||||||
}
|
}
|
||||||
@@ -266,13 +287,20 @@ export default {
|
|||||||
cursor pointer
|
cursor pointer
|
||||||
font-size 13px
|
font-size 13px
|
||||||
transition all .2s ease-in-out
|
transition all .2s ease-in-out
|
||||||
|
&.copy
|
||||||
|
cursor not-allowed
|
||||||
|
background #49B1F5
|
||||||
|
&.active
|
||||||
|
cursor pointer
|
||||||
|
background #1B9EF3
|
||||||
|
color #fff
|
||||||
&.delete
|
&.delete
|
||||||
cursor not-allowed
|
cursor not-allowed
|
||||||
background #F47466
|
background #F47466
|
||||||
&.delete.active
|
&.active
|
||||||
cursor pointer
|
cursor pointer
|
||||||
background #F15140
|
background #F15140
|
||||||
color #fff
|
color #fff
|
||||||
.long-list
|
.long-list
|
||||||
width: calc(83.3333333% - 6px)
|
width: calc(83.3333333% - 6px)
|
||||||
#gallery-view
|
#gallery-view
|
||||||
|
|||||||
@@ -78,7 +78,7 @@
|
|||||||
this.notification.body = item.imgUrl
|
this.notification.body = item.imgUrl
|
||||||
this.notification.icon = item.imgUrl
|
this.notification.icon = item.imgUrl
|
||||||
const myNotification = new window.Notification(this.notification.title, this.notification)
|
const myNotification = new window.Notification(this.notification.title, this.notification)
|
||||||
const pasteStyle = this.$db.read().get('picBed.pasteStyle').value()
|
const pasteStyle = this.$db.read().get('picBed.pasteStyle').value() || 'markdown'
|
||||||
this.$electron.clipboard.writeText(pasteTemplate(pasteStyle, item.imgUrl))
|
this.$electron.clipboard.writeText(pasteTemplate(pasteStyle, item.imgUrl))
|
||||||
myNotification.onclick = () => {
|
myNotification.onclick = () => {
|
||||||
return true
|
return true
|
||||||
|
|||||||
Reference in New Issue
Block a user