Commit 79ef165c authored by ali's avatar ali

feat: 新增 'openDevTools' 打开控制台配置

parent 3d9e9744
......@@ -55,9 +55,9 @@ export default class IPCs {
})
win.webContents.on('did-frame-finish-load', (): void => {
// if (Constants.IS_DEV_ENV) {
win.webContents.openDevTools()
// }
if (Constants.IS_DEV_ENV) {
win.webContents.openDevTools()
}
})
await win.loadURL(url)
......@@ -71,5 +71,26 @@ export default class IPCs {
return win
}
)
ipcMain.on('openDevTools', async (
event,
isOpen: boolean
) => {
if (isOpen) {
window.webContents.openDevTools();
IPCs.browserWindows.forEach((wins) => {
wins.forEach(w => {
!w.isDestroyed() && w.webContents.openDevTools()
})
})
} else {
window.webContents.closeDevTools();
IPCs.browserWindows.forEach((wins) => {
wins.forEach(w => {
!w.isDestroyed() && w.webContents.closeDevTools()
})
})
}
})
}
}
import { contextBridge, ipcRenderer } from 'electron'
// Whitelist of valid channels used for IPC communication (Send message from Renderer to Main)
const mainAvailChannels: string[] = ['msgRequestGetVersion', 'msgOpenExternalLink', 'openWindow']
const mainAvailChannels: string[] = ['msgRequestGetVersion', 'msgOpenExternalLink', 'openWindow', 'openDevTools']
const rendererAvailChannels: string[] = ['msgReceivedVersion']
contextBridge.exposeInMainWorld('mainApi', {
......
......@@ -60,6 +60,11 @@ async function changeVoskModel(){
}
changeVoskModel();
async function changeOpenDevTools() {
await window.mainApi.send('openDevTools', setting.isOpenDevTools.value);
}
</script>
<template>
<v-app-bar color="#d71b1b" density="compact" class="header">
......@@ -148,6 +153,15 @@ changeVoskModel();
color="primary"
:label="`是否打开全屏: ${setting.isFullscreen.value}`"
></v-switch>
<v-switch
v-model="setting.isOpenDevTools.value"
hide-details
color="primary"
:label="`是否打开 devTool: ${setting.isOpenDevTools.value}`"
@update:model-value="changeOpenDevTools"
></v-switch>
</v-form>
</v-sheet>
......
......@@ -21,7 +21,8 @@ export type ISettings = {
sex: 1 | 0
}[]
selectSource: string
isFullscreen: 'yes' | 'no'
isFullscreen: 'yes' | 'no',
isOpenDevTools: boolean
}
const useSettingsStore = defineStore('settings', {
......@@ -49,7 +50,8 @@ const useSettingsStore = defineStore('settings', {
ttsHost: 'https://beta.laihua.com',
source: [],
selectSource: '',
isFullscreen: 'no'
isFullscreen: 'no',
isOpenDevTools: false
}) as ISettings,
getters: {},
actions: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment