mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-11 18:10:32 +08:00
Fixed: sync picbed status
This commit is contained in:
@@ -52,6 +52,9 @@ function createTray () {
|
||||
checked: db.read().get('picBed.current').value() === item.type,
|
||||
click () {
|
||||
db.read().set('picBed.current', item.type).write()
|
||||
if (settingWindow) {
|
||||
settingWindow.webContents.send('syncPicBed')
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -354,6 +357,22 @@ const uploadClipboardFiles = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const updateDefaultPicBed = () => {
|
||||
if (process.platform === 'darwin' || process.platform === 'win32') {
|
||||
const types = picBed.map(item => item.type)
|
||||
let submenuItem = contextMenu.items[2].submenu.items
|
||||
submenuItem.forEach((item, index) => {
|
||||
const result = db.read().get('picBed.current').value() === types[index]
|
||||
if (result) {
|
||||
item.click() // It's a bug which can not set checked status
|
||||
return true
|
||||
}
|
||||
})
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
ipcMain.on('uploadClipboardFiles', async (evt, file) => {
|
||||
const img = await uploader(file, 'imgFromClipboard', window.webContents)
|
||||
if (img !== false) {
|
||||
@@ -422,21 +441,6 @@ ipcMain.on('updateCustomLink', (evt, oldLink) => {
|
||||
notification.show()
|
||||
})
|
||||
|
||||
ipcMain.on('updateDefaultPicBed', (evt) => {
|
||||
if (process.platform === 'darwin' || process.platform === 'win32') {
|
||||
const types = picBed.map(item => item.type)
|
||||
let submenuItem = contextMenu.items[2].submenu.items
|
||||
submenuItem.forEach((item, index) => {
|
||||
const result = db.read().get('picBed.current').value() === types[index]
|
||||
if (result) {
|
||||
item.click() // It's a bug which can not set checked status
|
||||
}
|
||||
})
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.on('autoStart', (evt, val) => {
|
||||
app.setLoginItemSettings({
|
||||
openAtLogin: val
|
||||
@@ -461,6 +465,19 @@ ipcMain.on('openMiniWindow', (evt) => {
|
||||
settingWindow.hide()
|
||||
})
|
||||
|
||||
// update
|
||||
ipcMain.on('updateDefaultPicBed', (evt) => {
|
||||
updateDefaultPicBed()
|
||||
})
|
||||
|
||||
// from mini window
|
||||
ipcMain.on('syncPicBed', (evt) => {
|
||||
if (settingWindow) {
|
||||
settingWindow.webContents.send('syncPicBed')
|
||||
}
|
||||
updateDefaultPicBed()
|
||||
})
|
||||
|
||||
const shortKeyHash = {
|
||||
upload: uploadClipboardFiles
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
</template>
|
||||
<script>
|
||||
import mixin from './mixin'
|
||||
import picBed from '../../datastore/pic-bed.js'
|
||||
export default {
|
||||
name: 'mini-page',
|
||||
mixins: [mixin],
|
||||
@@ -107,6 +108,16 @@ export default {
|
||||
if (e.button === 0) { // left mouse
|
||||
this.openUplodWindow()
|
||||
} else {
|
||||
let _this = this
|
||||
const types = picBed.map(item => item.type)
|
||||
let submenuItem = this.menu.items[1].submenu.items
|
||||
submenuItem.forEach((item, index) => {
|
||||
const result = _this.$db.read().get('picBed.current').value() === types[index]
|
||||
if (result) {
|
||||
item.click()
|
||||
return true
|
||||
}
|
||||
})
|
||||
this.openContextMenu()
|
||||
}
|
||||
}
|
||||
@@ -116,6 +127,17 @@ export default {
|
||||
},
|
||||
buildMenu () {
|
||||
const _this = this
|
||||
const submenu = picBed.map(item => {
|
||||
return {
|
||||
label: item.name,
|
||||
type: 'radio',
|
||||
checked: this.$db.read().get('picBed.current').value() === item.type,
|
||||
click () {
|
||||
_this.$db.read().set('picBed.current', item.type).write()
|
||||
_this.$electron.ipcRenderer.send('syncPicBed')
|
||||
}
|
||||
}
|
||||
})
|
||||
const template = [
|
||||
{
|
||||
label: '打开详细窗口',
|
||||
@@ -123,6 +145,11 @@ export default {
|
||||
_this.$electron.ipcRenderer.send('openSettingWindow')
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '选择默认图床',
|
||||
type: 'submenu',
|
||||
submenu
|
||||
},
|
||||
{
|
||||
label: '剪贴板图片上传',
|
||||
click () {
|
||||
|
||||
@@ -79,6 +79,9 @@ export default {
|
||||
})
|
||||
this.getPasteStyle()
|
||||
this.getDefaultPicBed()
|
||||
this.$electron.ipcRenderer.on('syncPicBed', () => {
|
||||
this.getDefaultPicBed()
|
||||
})
|
||||
},
|
||||
watch: {
|
||||
progress (val) {
|
||||
@@ -95,6 +98,7 @@ export default {
|
||||
},
|
||||
beforeDestroy () {
|
||||
this.$electron.ipcRenderer.removeAllListeners('uploadProgress')
|
||||
this.$electron.ipcRenderer.removeAllListeners('syncPicBed')
|
||||
},
|
||||
methods: {
|
||||
onDrop (e) {
|
||||
|
||||
Reference in New Issue
Block a user