feat: add developer tools button in MinApp for development mode
This commit is contained in:
parent
e2d0c3bbce
commit
81a35d129d
@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable react/no-unknown-property */
|
/* eslint-disable react/no-unknown-property */
|
||||||
import { CloseOutlined, ExportOutlined, PushpinOutlined, ReloadOutlined } from '@ant-design/icons'
|
import { CloseOutlined, CodeOutlined, ExportOutlined, PushpinOutlined, ReloadOutlined } from '@ant-design/icons'
|
||||||
import { isMac, isWindows } from '@renderer/config/constant'
|
import { isMac, isWindows } from '@renderer/config/constant'
|
||||||
import { AppLogo } from '@renderer/config/env'
|
import { AppLogo } from '@renderer/config/env'
|
||||||
import { DEFAULT_MIN_APPS } from '@renderer/config/minapps'
|
import { DEFAULT_MIN_APPS } from '@renderer/config/minapps'
|
||||||
@ -42,7 +42,11 @@ const PopupContainer: React.FC<Props> = ({ app, resolve }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MinApp.onClose = onClose
|
MinApp.onClose = onClose
|
||||||
|
const openDevTools = () => {
|
||||||
|
if (webviewRef.current) {
|
||||||
|
webviewRef.current.openDevTools()
|
||||||
|
}
|
||||||
|
}
|
||||||
const onReload = () => {
|
const onReload = () => {
|
||||||
if (webviewRef.current) {
|
if (webviewRef.current) {
|
||||||
webviewRef.current.src = app.url
|
webviewRef.current.src = app.url
|
||||||
@ -60,7 +64,7 @@ const PopupContainer: React.FC<Props> = ({ app, resolve }) => {
|
|||||||
const newPinned = isPinned ? pinned.filter((item) => item.id !== app.id) : [...pinned, app]
|
const newPinned = isPinned ? pinned.filter((item) => item.id !== app.id) : [...pinned, app]
|
||||||
updatePinnedMinapps(newPinned)
|
updatePinnedMinapps(newPinned)
|
||||||
}
|
}
|
||||||
|
const isInDevelopment = process.env.NODE_ENV === 'development'
|
||||||
const Title = () => {
|
const Title = () => {
|
||||||
return (
|
return (
|
||||||
<TitleContainer style={{ justifyContent: 'space-between' }}>
|
<TitleContainer style={{ justifyContent: 'space-between' }}>
|
||||||
@ -79,6 +83,11 @@ const PopupContainer: React.FC<Props> = ({ app, resolve }) => {
|
|||||||
<ExportOutlined />
|
<ExportOutlined />
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
{isInDevelopment && (
|
||||||
|
<Button onClick={openDevTools}>
|
||||||
|
<CodeOutlined />
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
<Button onClick={() => onClose()}>
|
<Button onClick={() => onClose()}>
|
||||||
<CloseOutlined />
|
<CloseOutlined />
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user