mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-02-02 11:08:13 -05:00
🐛 Fix: auto-copy option && copy style
auto-copy option not work && clear rules for line breaks when copying
This commit is contained in:
parent
2adff1e788
commit
b6e3adb7af
@ -149,9 +149,9 @@ export function createTray () {
|
|||||||
.setWebContents(trayWindow.webContents)
|
.setWebContents(trayWindow.webContents)
|
||||||
.upload(files)
|
.upload(files)
|
||||||
if (imgs !== false) {
|
if (imgs !== false) {
|
||||||
let pasteText = ''
|
const pasteText: string[] = []
|
||||||
for (let i = 0; i < imgs.length; i++) {
|
for (let i = 0; i < imgs.length; i++) {
|
||||||
pasteText += pasteTemplate(pasteStyle, imgs[i]) + '\r\n'
|
pasteText.push(pasteTemplate(pasteStyle, imgs[i]))
|
||||||
const notification = new Notification({
|
const notification = new Notification({
|
||||||
title: '上传成功',
|
title: '上传成功',
|
||||||
body: imgs[i].imgUrl!,
|
body: imgs[i].imgUrl!,
|
||||||
@ -162,7 +162,7 @@ export function createTray () {
|
|||||||
}, i * 100)
|
}, i * 100)
|
||||||
db.insert('uploaded', imgs[i])
|
db.insert('uploaded', imgs[i])
|
||||||
}
|
}
|
||||||
handleCopyUrl(pasteText)
|
handleCopyUrl(pasteText.join('\n'))
|
||||||
trayWindow.webContents.send('dragFiles', imgs)
|
trayWindow.webContents.send('dragFiles', imgs)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -48,9 +48,9 @@ export const uploadChoosedFiles = async (webContents: WebContents, files: IFileW
|
|||||||
const result = []
|
const result = []
|
||||||
if (imgs !== false) {
|
if (imgs !== false) {
|
||||||
const pasteStyle = db.get('settings.pasteStyle') || 'markdown'
|
const pasteStyle = db.get('settings.pasteStyle') || 'markdown'
|
||||||
let pasteText = ''
|
const pasteText: string[] = []
|
||||||
for (let i = 0; i < imgs.length; i++) {
|
for (let i = 0; i < imgs.length; i++) {
|
||||||
pasteText += pasteTemplate(pasteStyle, imgs[i]) + '\r\n'
|
pasteText.push(pasteTemplate(pasteStyle, imgs[i]))
|
||||||
const notification = new Notification({
|
const notification = new Notification({
|
||||||
title: '上传成功',
|
title: '上传成功',
|
||||||
body: imgs[i].imgUrl!,
|
body: imgs[i].imgUrl!,
|
||||||
@ -62,7 +62,7 @@ export const uploadChoosedFiles = async (webContents: WebContents, files: IFileW
|
|||||||
db.insert('uploaded', imgs[i])
|
db.insert('uploaded', imgs[i])
|
||||||
result.push(imgs[i].imgUrl!)
|
result.push(imgs[i].imgUrl!)
|
||||||
}
|
}
|
||||||
handleCopyUrl(pasteText)
|
handleCopyUrl(pasteText.join('\n'))
|
||||||
windowManager.get(IWindowList.TRAY_WINDOW)!.webContents.send('uploadFiles', imgs)
|
windowManager.get(IWindowList.TRAY_WINDOW)!.webContents.send('uploadFiles', imgs)
|
||||||
if (windowManager.has(IWindowList.SETTING_WINDOW)) {
|
if (windowManager.has(IWindowList.SETTING_WINDOW)) {
|
||||||
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents.send('updateGallery')
|
windowManager.get(IWindowList.SETTING_WINDOW)!.webContents.send('updateGallery')
|
||||||
|
@ -67,9 +67,9 @@ class GuiApi implements IGuiApi {
|
|||||||
const imgs = await uploader.setWebContents(webContents).upload(input)
|
const imgs = await uploader.setWebContents(webContents).upload(input)
|
||||||
if (imgs !== false) {
|
if (imgs !== false) {
|
||||||
const pasteStyle = db.get('settings.pasteStyle') || 'markdown'
|
const pasteStyle = db.get('settings.pasteStyle') || 'markdown'
|
||||||
let pasteText = ''
|
const pasteText: string[] = []
|
||||||
for (let i = 0; i < imgs.length; i++) {
|
for (let i = 0; i < imgs.length; i++) {
|
||||||
pasteText += pasteTemplate(pasteStyle, imgs[i]) + '\r\n'
|
pasteText.push(pasteTemplate(pasteStyle, imgs[i]))
|
||||||
const notification = new Notification({
|
const notification = new Notification({
|
||||||
title: '上传成功',
|
title: '上传成功',
|
||||||
body: imgs[i].imgUrl as string,
|
body: imgs[i].imgUrl as string,
|
||||||
@ -80,7 +80,7 @@ class GuiApi implements IGuiApi {
|
|||||||
}, i * 100)
|
}, i * 100)
|
||||||
db.insert('uploaded', imgs[i])
|
db.insert('uploaded', imgs[i])
|
||||||
}
|
}
|
||||||
handleCopyUrl(pasteText)
|
handleCopyUrl(pasteText.join('\n'))
|
||||||
webContents.send('uploadFiles', imgs)
|
webContents.send('uploadFiles', imgs)
|
||||||
webContents.send('updateGallery')
|
webContents.send('updateGallery')
|
||||||
return imgs
|
return imgs
|
||||||
|
@ -2,7 +2,7 @@ import db from '#/datastore'
|
|||||||
import { clipboard } from 'electron'
|
import { clipboard } from 'electron'
|
||||||
|
|
||||||
export function handleCopyUrl (str: string): void {
|
export function handleCopyUrl (str: string): void {
|
||||||
if (db.get('settings.autoCopy') === true) {
|
if (db.get('settings.autoCopy') !== false) {
|
||||||
clipboard.writeText(str)
|
clipboard.writeText(str)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -383,22 +383,22 @@ export default class extends Vue {
|
|||||||
}
|
}
|
||||||
multiCopy () {
|
multiCopy () {
|
||||||
if (Object.values(this.choosedList).some(item => item)) {
|
if (Object.values(this.choosedList).some(item => item)) {
|
||||||
let copyString = ''
|
const copyString: string[] = []
|
||||||
const style = this.$db.get('settings.pasteStyle') || 'markdown'
|
const style = this.$db.get('settings.pasteStyle') || 'markdown'
|
||||||
// choosedList -> { [id]: true or false }; true means choosed. false means not choosed.
|
// choosedList -> { [id]: true or false }; true means choosed. false means not choosed.
|
||||||
Object.keys(this.choosedList).forEach(key => {
|
Object.keys(this.choosedList).forEach(key => {
|
||||||
if (this.choosedList[key]) {
|
if (this.choosedList[key]) {
|
||||||
const item = this.$db.getById('uploaded', key)
|
const item = this.$db.getById('uploaded', key)
|
||||||
copyString += pasteStyle(style, item) + '\n'
|
copyString.push(pasteStyle(style, item))
|
||||||
this.choosedList[key] = false
|
this.choosedList[key] = false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const obj = {
|
const obj = {
|
||||||
title: '批量复制链接成功',
|
title: '批量复制链接成功',
|
||||||
body: copyString
|
body: copyString.join('\n')
|
||||||
}
|
}
|
||||||
const myNotification = new Notification(obj.title, obj)
|
const myNotification = new Notification(obj.title, obj)
|
||||||
clipboard.writeText(copyString)
|
clipboard.writeText(copyString.join('\n'))
|
||||||
myNotification.onclick = () => {
|
myNotification.onclick = () => {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user