Feature: add open devtool option

This commit is contained in:
PiEgg 2021-08-29 19:04:43 +08:00
parent 5895889059
commit 75e3edcd87
4 changed files with 21 additions and 3 deletions

View File

@ -14,7 +14,8 @@ import getPicBeds from '~/main/utils/getPicBeds'
import shortKeyHandler from 'apis/app/shortKey/shortKeyHandler' import shortKeyHandler from 'apis/app/shortKey/shortKeyHandler'
import bus from '@core/bus' import bus from '@core/bus'
import { import {
TOGGLE_SHORTKEY_MODIFIED_MODE TOGGLE_SHORTKEY_MODIFIED_MODE,
OPEN_DEVTOOLS
} from '#/events/constants' } from '#/events/constants'
import { import {
uploadClipboardFiles, uploadClipboardFiles,
@ -141,6 +142,9 @@ export default {
ipcMain.on('updateServer', () => { ipcMain.on('updateServer', () => {
server.restart() server.restart()
}) })
ipcMain.on(OPEN_DEVTOOLS, (event: IpcMainEvent) => {
event.sender.openDevTools()
})
}, },
dispose () {} dispose () {}
} }

View File

@ -159,7 +159,8 @@ import {
import mixin from '@/utils/mixin' import mixin from '@/utils/mixin'
import InputBoxDialog from '@/components/InputBoxDialog.vue' import InputBoxDialog from '@/components/InputBoxDialog.vue'
import { import {
SHOW_PRIVACY_MESSAGE SHOW_PRIVACY_MESSAGE,
OPEN_DEVTOOLS
} from '~/universal/events/constants' } from '~/universal/events/constants'
import { IConfig } from 'picgo/dist/src/types/index' import { IConfig } from 'picgo/dist/src/types/index'
const { Menu, dialog, BrowserWindow } = remote const { Menu, dialog, BrowserWindow } = remote
@ -276,6 +277,12 @@ export default class extends Vue {
click () { click () {
ipcRenderer.send(SHOW_PRIVACY_MESSAGE) ipcRenderer.send(SHOW_PRIVACY_MESSAGE)
} }
},
{
label: '打开调试器',
click () {
ipcRenderer.send(OPEN_DEVTOOLS)
}
} }
] ]
this.menu = Menu.buildFromTemplate(template) this.menu = Menu.buildFromTemplate(template)

View File

@ -23,7 +23,7 @@ import {
IpcRendererEvent, IpcRendererEvent,
remote remote
} from 'electron' } from 'electron'
import { SHOW_PRIVACY_MESSAGE } from '~/universal/events/constants' import { SHOW_PRIVACY_MESSAGE, OPEN_DEVTOOLS } from '~/universal/events/constants'
@Component({ @Component({
name: 'mini-page', name: 'mini-page',
mixins: [mixin] mixins: [mixin]
@ -190,6 +190,12 @@ export default class extends Vue {
remote.app.exit(0) remote.app.exit(0)
} }
}, },
{
label: '打开调试器',
click () {
ipcRenderer.send(OPEN_DEVTOOLS)
}
},
{ {
role: 'quit', role: 'quit',
label: '退出' label: '退出'

View File

@ -13,3 +13,4 @@ export const PICGO_UPDATE_BY_ID_DB = 'PICGO_UPDATE_BY_ID_DB'
export const PICGO_GET_BY_ID_DB = 'PICGO_GET_BY_ID_DB' export const PICGO_GET_BY_ID_DB = 'PICGO_GET_BY_ID_DB'
export const PICGO_REMOVE_BY_ID_DB = 'PICGO_REMOVE_BY_ID_DB' export const PICGO_REMOVE_BY_ID_DB = 'PICGO_REMOVE_BY_ID_DB'
export const PICGO_OPEN_FILE = 'PICGO_OPEN_FILE' export const PICGO_OPEN_FILE = 'PICGO_OPEN_FILE'
export const OPEN_DEVTOOLS = 'OPEN_DEVTOOLS'