Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
C
CharIP-Electron
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ali
CharIP-Electron
Commits
79ef165c
Commit
79ef165c
authored
Nov 29, 2023
by
ali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 新增 'openDevTools' 打开控制台配置
parent
3d9e9744
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
6 deletions
+43
-6
IPCs.ts
src/main/IPCs.ts
+24
-3
index.ts
src/preload/index.ts
+1
-1
HeaderLayout.vue
src/renderer/components/layout/HeaderLayout.vue
+14
-0
settings.ts
src/renderer/store/settings.ts
+4
-2
No files found.
src/main/IPCs.ts
View file @
79ef165c
...
...
@@ -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
()
})
})
}
})
}
}
src/preload/index.ts
View file @
79ef165c
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'
,
{
...
...
src/renderer/components/layout/HeaderLayout.vue
View file @
79ef165c
...
...
@@ -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>
...
...
src/renderer/store/settings.ts
View file @
79ef165c
...
...
@@ -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
:
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment