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