Skip to content

Commit

Permalink
Add toggle dev tools menu item in the config menu.
Browse files Browse the repository at this point in the history
  • Loading branch information
oldj committed May 29, 2021
1 parent fe75125 commit 0e401bb
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/common/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default {
show_sudo_password_input: 'show_sudo_password_input',
system_hosts_updated: 'system_hosts_updated',
toggle_comment: 'toggle_comment',
toggle_developer_tools: 'toggle_developer_tools',
toggle_item: 'toggle_item',
toggle_left_pannel: 'toggle_left_pannel',
tray_list_updated: 'tray:list_updated',
Expand Down
11 changes: 11 additions & 0 deletions src/main/actions/cmd/toggleDevTools.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* @author: oldj
* @homepage: https://oldj.net
*/

export default () => {
let win = global.main_win
if (!win) return

win.webContents.toggleDevTools()
}
1 change: 1 addition & 0 deletions src/main/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export { default as cmdGetHistoryList } from './cmd/getHistoryList'
export { default as cmdDeleteHistory } from './cmd/deleteHistory'
export { default as cmdClearHistory } from './cmd/clearHistory'
export { default as cmdFocusMainWindow } from './cmd/focusMainWindow'
export { default as cmdToggleDevTools } from './cmd/toggleDevTools'

export { default as openUrl } from './openUrl'
export { default as showItemInFolder } from './showItemInFolder'
Expand Down
1 change: 0 additions & 1 deletion src/main/ui/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/

import { findShow } from '@main/actions'
import isDev from '@main/libs/isDev'
import events from '@root/common/events'
import { BrowserWindow, Menu, MenuItem, MenuItemConstructorOptions, shell } from 'electron'
import { I18N, LocaleName } from '@root/common/i18n'
Expand Down
26 changes: 14 additions & 12 deletions src/renderer/components/Pref/General.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ import {
Box,
Checkbox,
FormControl,
FormLabel,
FormHelperText,
FormLabel,
HStack,
Radio,
RadioGroup,
Select,
VStack,
} from '@chakra-ui/react'
import { agent } from '@renderer/core/agent'
import { http_api_port } from '@root/common/constants'
import { ConfigsType, ThemeType } from '@root/common/default_configs'
import { LocaleName } from '@root/common/i18n'
import React from 'react'
import { http_api_port } from '@root/common/constants'

interface IProps {
data: ConfigsType;
Expand Down Expand Up @@ -113,16 +113,18 @@ const General = (props: IProps) => {
</HStack>
</FormControl>

<FormControl>
<HStack>
<Checkbox
isChecked={data.hide_dock_icon}
onChange={e => onChange({ hide_dock_icon: e.target.checked })}
>
{lang.hide_dock_icon}
</Checkbox>
</HStack>
</FormControl>
{agent.platform === 'darwin' ? (
<FormControl>
<HStack>
<Checkbox
isChecked={data.hide_dock_icon}
onChange={e => onChange({ hide_dock_icon: e.target.checked })}
>
{lang.hide_dock_icon}
</Checkbox>
</HStack>
</FormControl>
) : null}

<FormControl>
<VStack align="left">
Expand Down
10 changes: 10 additions & 0 deletions src/renderer/components/TopBar/ConfigMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
BiMessageDetail,
BiRefresh,
BiSliderAlt,
BiWrench,
} from 'react-icons/bi'
import styles from './ConfigMenu.less'

Expand Down Expand Up @@ -155,6 +156,15 @@ const ConfigMenu = (props: Props) => {
>
{lang.preferences}
</MenuItem>
<MenuItem
icon={<BiWrench/>}
onClick={() => actions.cmdToggleDevTools()}
>
{lang.toggle_developer_tools}
</MenuItem>

<MenuDivider/>

<MenuItem
icon={<BiExit/>}
onClick={() => actions.quit()}
Expand Down

0 comments on commit 0e401bb

Please sign in to comment.