mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-07-21 21:01:45 +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)
|
||||
}
|
||||
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)
|
||||
results.push({
|
||||
base64Image,
|
||||
@@ -105,7 +105,7 @@ const imgFromUploader = async (files) => {
|
||||
name = await waitForRename(window, window.webContents.id)
|
||||
}
|
||||
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)
|
||||
results.push({
|
||||
base64Image,
|
||||
|
||||
@@ -3,6 +3,7 @@ import * as img2Base64 from './img2base64'
|
||||
import db from '../../datastore/index'
|
||||
import { Notification, clipboard } from 'electron'
|
||||
import crypto from 'crypto'
|
||||
import mime from 'mime-types'
|
||||
|
||||
// generate COS signature string
|
||||
const generateSignature = (fileName) => {
|
||||
@@ -67,7 +68,7 @@ const postOptions = (fileName, signature, imgBase64) => {
|
||||
headers: {
|
||||
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}`,
|
||||
contentType: 'multipart/form-data'
|
||||
contentType: mime.lookup(fileName)
|
||||
},
|
||||
body: Buffer.from(imgBase64, 'base64'),
|
||||
resolveWithFullResponse: true
|
||||
|
||||
@@ -15,11 +15,13 @@
|
||||
</el-row>
|
||||
<el-row class="handle-bar" :gutter="16">
|
||||
<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 :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>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
@@ -143,7 +145,7 @@ export default {
|
||||
this.idx = null
|
||||
},
|
||||
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 obj = {
|
||||
title: '复制链接成功',
|
||||
@@ -153,7 +155,7 @@ export default {
|
||||
const myNotification = new window.Notification(obj.title, obj)
|
||||
this.$electron.clipboard.writeText(copyLink)
|
||||
myNotification.onclick = () => {
|
||||
return true
|
||||
console.log(123)
|
||||
}
|
||||
},
|
||||
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 () {
|
||||
this.handleBarActive = !this.handleBarActive
|
||||
}
|
||||
@@ -266,13 +287,20 @@ export default {
|
||||
cursor pointer
|
||||
font-size 13px
|
||||
transition all .2s ease-in-out
|
||||
&.copy
|
||||
cursor not-allowed
|
||||
background #49B1F5
|
||||
&.active
|
||||
cursor pointer
|
||||
background #1B9EF3
|
||||
color #fff
|
||||
&.delete
|
||||
cursor not-allowed
|
||||
background #F47466
|
||||
&.delete.active
|
||||
cursor pointer
|
||||
background #F15140
|
||||
color #fff
|
||||
&.active
|
||||
cursor pointer
|
||||
background #F15140
|
||||
color #fff
|
||||
.long-list
|
||||
width: calc(83.3333333% - 6px)
|
||||
#gallery-view
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
this.notification.body = item.imgUrl
|
||||
this.notification.icon = item.imgUrl
|
||||
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))
|
||||
myNotification.onclick = () => {
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user