mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-16 23:27:35 +08:00
Fixed: image-size bug && change config all to settings
This commit is contained in:
@@ -29,8 +29,8 @@ if (!db.has('picBed').value()) {
|
||||
}).write()
|
||||
}
|
||||
|
||||
if (!db.has('shortKey').value()) {
|
||||
db.set('shortKey', {
|
||||
if (!db.has('settings.shortKey').value()) {
|
||||
db.set('settings.shortKey', {
|
||||
upload: 'CommandOrControl+Shift+P'
|
||||
}).write()
|
||||
}
|
||||
|
||||
@@ -93,10 +93,10 @@ function createTray () {
|
||||
{
|
||||
label: '打开更新助手',
|
||||
type: 'checkbox',
|
||||
checked: db.get('picBed.showUpdateTip').value(),
|
||||
checked: db.get('settings.showUpdateTip').value(),
|
||||
click () {
|
||||
const value = db.read().get('picBed.showUpdateTip').value()
|
||||
db.read().set('picBed.showUpdateTip', !value).write()
|
||||
const value = db.read().get('settings.showUpdateTip').value()
|
||||
db.read().set('settings.showUpdateTip', !value).write()
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -153,7 +153,7 @@ function createTray () {
|
||||
})
|
||||
|
||||
tray.on('drop-files', async (event, files) => {
|
||||
const pasteStyle = db.read().get('picBed.pasteStyle').value() || 'markdown'
|
||||
const pasteStyle = db.read().get('settings.pasteStyle').value() || 'markdown'
|
||||
const imgs = await uploader(files, 'imgFromPath', window.webContents)
|
||||
if (imgs !== false) {
|
||||
for (let i in imgs) {
|
||||
@@ -360,7 +360,7 @@ const uploadClipboardFiles = async () => {
|
||||
img = await uploader(uploadImg, 'imgFromClipboard', win.webContents)
|
||||
if (img !== false) {
|
||||
if (img.length > 0) {
|
||||
const pasteStyle = db.read().get('picBed.pasteStyle').value() || 'markdown'
|
||||
const pasteStyle = db.read().get('settings.pasteStyle').value() || 'markdown'
|
||||
clipboard.writeText(pasteTemplate(pasteStyle, img[0].imgUrl))
|
||||
const notification = new Notification({
|
||||
title: '上传成功',
|
||||
@@ -409,7 +409,7 @@ picgoCoreIPC(app, ipcMain)
|
||||
ipcMain.on('uploadClipboardFiles', async (evt, file) => {
|
||||
const img = await uploader(file, 'imgFromClipboard', window.webContents)
|
||||
if (img !== false) {
|
||||
const pasteStyle = db.read().get('picBed.pasteStyle').value() || 'markdown'
|
||||
const pasteStyle = db.read().get('settings.pasteStyle').value() || 'markdown'
|
||||
clipboard.writeText(pasteTemplate(pasteStyle, img[0].imgUrl))
|
||||
const notification = new Notification({
|
||||
title: '上传成功',
|
||||
@@ -439,7 +439,7 @@ ipcMain.on('uploadChoosedFiles', async (evt, files) => {
|
||||
const input = files.map(item => item.path)
|
||||
const imgs = await uploader(input, 'imgFromUploader', evt.sender)
|
||||
if (imgs !== false) {
|
||||
const pasteStyle = db.read().get('picBed.pasteStyle').value() || 'markdown'
|
||||
const pasteStyle = db.read().get('settings.pasteStyle').value() || 'markdown'
|
||||
let pasteText = ''
|
||||
for (let i in imgs) {
|
||||
pasteText += pasteTemplate(pasteStyle, imgs[i].imgUrl) + '\r\n'
|
||||
@@ -468,7 +468,7 @@ ipcMain.on('uploadChoosedFiles', async (evt, files) => {
|
||||
ipcMain.on('updateShortKey', (evt, oldKey) => {
|
||||
globalShortcut.unregisterAll()
|
||||
for (let key in oldKey) {
|
||||
globalShortcut.register(db.read().get('shortKey').value()[key], () => {
|
||||
globalShortcut.register(db.read().get('settings.shortKey').value()[key], () => {
|
||||
return shortKeyHash[key]()
|
||||
})
|
||||
}
|
||||
@@ -557,7 +557,7 @@ app.on('ready', () => {
|
||||
}
|
||||
updateChecker()
|
||||
|
||||
globalShortcut.register(db.read().get('shortKey.upload').value(), () => {
|
||||
globalShortcut.register(db.read().get('settings.shortKey.upload').value(), () => {
|
||||
uploadClipboardFiles()
|
||||
})
|
||||
})
|
||||
@@ -582,7 +582,7 @@ app.on('will-quit', () => {
|
||||
})
|
||||
|
||||
app.setLoginItemSettings({
|
||||
openAtLogin: db.read().get('picBed.autoStart').value() || false
|
||||
openAtLogin: db.read().get('settings.autoStart').value() || false
|
||||
})
|
||||
|
||||
/**
|
||||
|
||||
@@ -65,7 +65,8 @@ export default (app, ipcMain) => {
|
||||
config: handleConfigWithFunction(getConfig(uploaderName, 'transformer', picgo))
|
||||
}
|
||||
},
|
||||
enabled: picgo.getConfig(`plugins.${pluginList[i]}`)
|
||||
enabled: picgo.getConfig(`plugins.${pluginList[i]}`),
|
||||
pkg: pluginPKG
|
||||
}
|
||||
list.push(obj)
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@ const release = 'https://api.github.com/repos/Molunerfinn/PicGo/releases/latest'
|
||||
const downloadUrl = 'https://github.com/Molunerfinn/PicGo/releases/latest'
|
||||
|
||||
const checkVersion = async () => {
|
||||
let showTip = db.read().get('picBed.showUpdateTip').value()
|
||||
let showTip = db.read().get('settings.showUpdateTip').value()
|
||||
if (showTip === undefined) {
|
||||
db.read().set('picBed.showUpdateTip', true).write()
|
||||
db.read().set('settings.showUpdateTip', true).write()
|
||||
showTip = true
|
||||
}
|
||||
if (showTip) {
|
||||
@@ -29,7 +29,7 @@ const checkVersion = async () => {
|
||||
if (res === 0) { // if selected yes
|
||||
shell.openExternal(downloadUrl)
|
||||
}
|
||||
db.read().set('picBed.showUpdateTip', !checkboxChecked).write()
|
||||
db.read().set('settings.showUpdateTip', !checkboxChecked).write()
|
||||
})
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -85,8 +85,8 @@ const uploader = (img, type, webContents) => {
|
||||
|
||||
picgo.helper.beforeUploadPlugins.register('renameFn', {
|
||||
handle: async ctx => {
|
||||
const rename = picgo.getConfig('picBed.rename')
|
||||
const autoRename = picgo.getConfig('picBed.autoRename')
|
||||
const rename = picgo.getConfig('settings.rename')
|
||||
const autoRename = picgo.getConfig('settings.autoRename')
|
||||
await Promise.all(ctx.output.map(async item => {
|
||||
let name
|
||||
let fileName
|
||||
@@ -102,13 +102,12 @@ const uploader = (img, type, webContents) => {
|
||||
name = await waitForRename(window, window.webContents.id)
|
||||
}
|
||||
item.fileName = name || fileName
|
||||
console.log(item)
|
||||
}))
|
||||
}
|
||||
})
|
||||
|
||||
picgo.on('beforeTransform', ctx => {
|
||||
if (ctx.getConfig('picBed.uploadNotification')) {
|
||||
if (ctx.getConfig('settings.uploadNotification')) {
|
||||
const notification = new Notification({
|
||||
title: '上传进度',
|
||||
body: '正在上传'
|
||||
|
||||
@@ -155,7 +155,7 @@ export default {
|
||||
this.idx = null
|
||||
},
|
||||
copy (url) {
|
||||
const style = this.$db.read().get('picBed.pasteStyle').value() || 'markdown'
|
||||
const style = this.$db.read().get('settings.pasteStyle').value() || 'markdown'
|
||||
const copyLink = pasteStyle(style, url)
|
||||
const obj = {
|
||||
title: '复制链接成功',
|
||||
@@ -254,7 +254,7 @@ export default {
|
||||
multiCopy () {
|
||||
if (Object.values(this.choosedList).some(item => item)) {
|
||||
let copyString = ''
|
||||
const style = this.$db.read().get('picBed.pasteStyle').value() || 'markdown'
|
||||
const style = this.$db.read().get('settings.pasteStyle').value() || 'markdown'
|
||||
Object.keys(this.choosedList).forEach(key => {
|
||||
if (this.choosedList[key]) {
|
||||
copyString += pasteStyle(style, this.$db.read().get('uploaded').getById(key).value().imgUrl) + '\n'
|
||||
|
||||
@@ -180,7 +180,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import db from '../../../datastore'
|
||||
// import db from '../../../datastore'
|
||||
import keyDetect from 'utils/key-binding'
|
||||
import pkg from '../../../../package.json'
|
||||
const release = 'https://api.github.com/repos/Molunerfinn/PicGo/releases/latest'
|
||||
@@ -206,23 +206,23 @@ export default {
|
||||
}
|
||||
return {
|
||||
form: {
|
||||
updateHelper: this.$db.get('picBed.showUpdateTip').value(),
|
||||
updateHelper: this.$db.read().get('settings.showUpdateTip').value(),
|
||||
showPicBedList: [],
|
||||
autoStart: this.$db.get('picBed.autoStart').value() || false,
|
||||
rename: this.$db.get('picBed.rename').value() || false,
|
||||
autoRename: this.$db.get('picBed.autoRename').value() || false,
|
||||
uploadNotification: this.$db.get('picBed.uploadNotification').value() || false,
|
||||
miniWindowOntop: db.read().get('miniWindowOntop').value() || false
|
||||
autoStart: this.$db.read().get('settings.autoStart').value() || false,
|
||||
rename: this.$db.read().get('settings.rename').value() || false,
|
||||
autoRename: this.$db.read().get('settings.autoRename').value() || false,
|
||||
uploadNotification: this.$db.read().get('settings.uploadNotification').value() || false,
|
||||
miniWindowOntop: this.$db.read().get('settings.miniWindowOntop').value() || false
|
||||
},
|
||||
picBed: this.$picBed,
|
||||
keyBindingVisible: false,
|
||||
customLinkVisible: false,
|
||||
checkUpdateVisible: false,
|
||||
customLink: {
|
||||
value: db.read().get('customLink').value() || '$url'
|
||||
value: this.$db.read().get('settings.customLink').value() || '$url'
|
||||
},
|
||||
shortKey: {
|
||||
upload: db.read().get('shortKey.upload').value()
|
||||
upload: this.$db.read().get('settings.shortKey.upload').value()
|
||||
},
|
||||
rules: {
|
||||
value: [
|
||||
@@ -246,22 +246,22 @@ export default {
|
||||
},
|
||||
cancelKeyBinding () {
|
||||
this.keyBindingVisible = false
|
||||
this.shortKey = db.read().get('shortKey').value()
|
||||
this.shortKey = this.$db.read().get('settings.shortKey').value()
|
||||
},
|
||||
confirmKeyBinding () {
|
||||
const oldKey = db.read().get('shortKey').value()
|
||||
db.read().set('shortKey', this.shortKey).write()
|
||||
const oldKey = this.$db.read().get('settings.shortKey').value()
|
||||
this.db.read().set('settings.shortKey', this.shortKey).write()
|
||||
this.keyBindingVisible = false
|
||||
this.$electron.ipcRenderer.send('updateShortKey', oldKey)
|
||||
},
|
||||
cancelCustomLink () {
|
||||
this.customLinkVisible = false
|
||||
this.customLink.value = db.read().get('customLink').value() || '$url'
|
||||
this.customLink.value = this.$db.read().get('settings.customLink').value() || '$url'
|
||||
},
|
||||
confirmCustomLink () {
|
||||
this.$refs.customLink.validate((valid) => {
|
||||
if (valid) {
|
||||
db.read().set('customLink', this.customLink.value).write()
|
||||
this.db.read().set('settings.customLink', this.customLink.value).write()
|
||||
this.customLinkVisible = false
|
||||
this.$electron.ipcRenderer.send('updateCustomLink')
|
||||
} else {
|
||||
@@ -270,7 +270,7 @@ export default {
|
||||
})
|
||||
},
|
||||
updateHelperChange (val) {
|
||||
this.$db.read().set('picBed.showUpdateTip', val).write()
|
||||
this.$db.read().set('settings.showUpdateTip', val).write()
|
||||
},
|
||||
handleShowPicBedListChange (val) {
|
||||
const list = this.picBed.map(item => {
|
||||
@@ -284,14 +284,14 @@ export default {
|
||||
this.$db.read().set('picBed.list', list).write()
|
||||
},
|
||||
handleAutoStartChange (val) {
|
||||
this.$db.read().set('picBed.autoStart', val).write()
|
||||
this.$db.read().set('settings.autoStart', val).write()
|
||||
this.$electron.ipcRenderer.send('autoStart', val)
|
||||
},
|
||||
handleRename (val) {
|
||||
this.$db.read().set('picBed.rename', val).write()
|
||||
this.$db.read().set('settings.rename', val).write()
|
||||
},
|
||||
handleAutoRename (val) {
|
||||
this.$db.read().set('picBed.autoRename', val).write()
|
||||
this.$db.read().set('settings.autoRename', val).write()
|
||||
},
|
||||
compareVersion2Update (current, latest) {
|
||||
const currentVersion = current.split('.').map(item => parseInt(item))
|
||||
@@ -326,15 +326,12 @@ export default {
|
||||
this.checkUpdateVisible = false
|
||||
},
|
||||
handleUploadNotification (val) {
|
||||
this.$db.read().set('picBed.uploadNotification', val).write()
|
||||
this.$db.read().set('settings.uploadNotification', val).write()
|
||||
},
|
||||
handleMiniWindowOntop (val) {
|
||||
this.$db.read().set('miniWindowOntop', val).write()
|
||||
this.$db.read().set('settings.miniWindowOntop', val).write()
|
||||
this.$message('需要重启生效')
|
||||
}
|
||||
},
|
||||
beforeDestroy () {
|
||||
this.$electron.ipcRenderer.removeAllListeners('autoStart')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -124,10 +124,10 @@ export default {
|
||||
this.$electron.ipcRenderer.send('uploadChoosedFiles', sendFiles)
|
||||
},
|
||||
getPasteStyle () {
|
||||
this.pasteStyle = this.$db.read().get('picBed.pasteStyle').value() || 'markdown'
|
||||
this.pasteStyle = this.$db.read().get('settings.pasteStyle').value() || 'markdown'
|
||||
},
|
||||
handlePasteStyleChange (val) {
|
||||
this.$db.read().set('picBed.pasteStyle', val)
|
||||
this.$db.read().set('settings.pasteStyle', val)
|
||||
.write()
|
||||
},
|
||||
uploadClipboardFiles () {
|
||||
|
||||
@@ -75,7 +75,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() || 'markdown'
|
||||
const pasteStyle = this.$db.read().get('settings.pasteStyle').value() || 'markdown'
|
||||
this.$electron.clipboard.writeText(pasteTemplate(pasteStyle, item.imgUrl))
|
||||
myNotification.onclick = () => {
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user