()
| 17 | |
| 18 | panelComponent() { |
| 19 | const DebuggerPanelComp = () => { |
| 20 | const [port, setPort] = useState(null as null | number); |
| 21 | |
| 22 | useEffect(() => { |
| 23 | (async () => { |
| 24 | const port = await getWhistlePort(this.coreAPI); |
| 25 | setPort(port); |
| 26 | })(); |
| 27 | }, []); |
| 28 | |
| 29 | useEffect(() => { |
| 30 | CoreAPI.eventEmmitter.emit('weinre-enter'); |
| 31 | return function() { |
| 32 | CoreAPI.eventEmmitter.emit('weinre-exit'); |
| 33 | }; |
| 34 | }, []); |
| 35 | |
| 36 | function changeIframeStyle() { |
| 37 | const iframeDocumentHead = document.querySelector('iframe')?.contentDocument?.querySelector('head'); |
| 38 | if (iframeDocumentHead) { |
| 39 | const customStyle = document.createElement('style'); |
| 40 | customStyle.textContent = `.content-header { |
| 41 | background: #f5f5f5; |
| 42 | border: none; |
| 43 | } |
| 44 | |
| 45 | `; |
| 46 | iframeDocumentHead.appendChild(customStyle); |
| 47 | |
| 48 | const container = document.querySelector('iframe')?.contentDocument?.querySelector('.description'); |
| 49 | if (container) { |
| 50 | container.innerHTML = `<div> |
| 51 | 通过代理访问带有 lightproxy=true 参数的页面开始调试 |
| 52 | </div>`; |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | return ( |
| 58 | <div className="lightproxy-network-panel no-drag"> |
| 59 | {port ? ( |
| 60 | <iframe |
| 61 | src={`http://127.0.0.1:${port}/plugin.chii-internal/`} |
| 62 | className="lightproxy-network-iframe" |
| 63 | onLoad={changeIframeStyle} |
| 64 | ></iframe> |
| 65 | ) : ( |
| 66 | <div className="lightproxy-tip">代理未启动</div> |
| 67 | )} |
| 68 | </div> |
| 69 | ); |
| 70 | }; |
| 71 | |
| 72 | return DebuggerPanelComp; |
| 73 | } |
nothing calls this directly
no test coverage detected