Skip to content

Commit 0e401bb

Browse files
committed
Add toggle dev tools menu item in the config menu.
1 parent fe75125 commit 0e401bb

File tree

6 files changed

+37
-13
lines changed

6 files changed

+37
-13
lines changed

src/common/events.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export default {
2727
show_sudo_password_input: 'show_sudo_password_input',
2828
system_hosts_updated: 'system_hosts_updated',
2929
toggle_comment: 'toggle_comment',
30+
toggle_developer_tools: 'toggle_developer_tools',
3031
toggle_item: 'toggle_item',
3132
toggle_left_pannel: 'toggle_left_pannel',
3233
tray_list_updated: 'tray:list_updated',
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* @author: oldj
3+
* @homepage: https://oldj.net
4+
*/
5+
6+
export default () => {
7+
let win = global.main_win
8+
if (!win) return
9+
10+
win.webContents.toggleDevTools()
11+
}

src/main/actions/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export { default as cmdGetHistoryList } from './cmd/getHistoryList'
3939
export { default as cmdDeleteHistory } from './cmd/deleteHistory'
4040
export { default as cmdClearHistory } from './cmd/clearHistory'
4141
export { default as cmdFocusMainWindow } from './cmd/focusMainWindow'
42+
export { default as cmdToggleDevTools } from './cmd/toggleDevTools'
4243

4344
export { default as openUrl } from './openUrl'
4445
export { default as showItemInFolder } from './showItemInFolder'

src/main/ui/menu.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*/
55

66
import { findShow } from '@main/actions'
7-
import isDev from '@main/libs/isDev'
87
import events from '@root/common/events'
98
import { BrowserWindow, Menu, MenuItem, MenuItemConstructorOptions, shell } from 'electron'
109
import { I18N, LocaleName } from '@root/common/i18n'

src/renderer/components/Pref/General.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ import {
99
Box,
1010
Checkbox,
1111
FormControl,
12-
FormLabel,
1312
FormHelperText,
13+
FormLabel,
1414
HStack,
1515
Radio,
1616
RadioGroup,
1717
Select,
1818
VStack,
1919
} from '@chakra-ui/react'
2020
import { agent } from '@renderer/core/agent'
21+
import { http_api_port } from '@root/common/constants'
2122
import { ConfigsType, ThemeType } from '@root/common/default_configs'
2223
import { LocaleName } from '@root/common/i18n'
2324
import React from 'react'
24-
import { http_api_port } from '@root/common/constants'
2525

2626
interface IProps {
2727
data: ConfigsType;
@@ -113,16 +113,18 @@ const General = (props: IProps) => {
113113
</HStack>
114114
</FormControl>
115115

116-
<FormControl>
117-
<HStack>
118-
<Checkbox
119-
isChecked={data.hide_dock_icon}
120-
onChange={e => onChange({ hide_dock_icon: e.target.checked })}
121-
>
122-
{lang.hide_dock_icon}
123-
</Checkbox>
124-
</HStack>
125-
</FormControl>
116+
{agent.platform === 'darwin' ? (
117+
<FormControl>
118+
<HStack>
119+
<Checkbox
120+
isChecked={data.hide_dock_icon}
121+
onChange={e => onChange({ hide_dock_icon: e.target.checked })}
122+
>
123+
{lang.hide_dock_icon}
124+
</Checkbox>
125+
</HStack>
126+
</FormControl>
127+
) : null}
126128

127129
<FormControl>
128130
<VStack align="left">

src/renderer/components/TopBar/ConfigMenu.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
BiMessageDetail,
2222
BiRefresh,
2323
BiSliderAlt,
24+
BiWrench,
2425
} from 'react-icons/bi'
2526
import styles from './ConfigMenu.less'
2627

@@ -155,6 +156,15 @@ const ConfigMenu = (props: Props) => {
155156
>
156157
{lang.preferences}
157158
</MenuItem>
159+
<MenuItem
160+
icon={<BiWrench/>}
161+
onClick={() => actions.cmdToggleDevTools()}
162+
>
163+
{lang.toggle_developer_tools}
164+
</MenuItem>
165+
166+
<MenuDivider/>
167+
158168
<MenuItem
159169
icon={<BiExit/>}
160170
onClick={() => actions.quit()}

0 commit comments

Comments
 (0)