Skip to content

Commit

Permalink
update frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
imagemlt committed Feb 27, 2020
1 parent 7f1ad98 commit 2698cbe
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"name": "@electron-forge/publisher-github",
"config": {
"repository": {
"owner": "bytedance",
"owner": "imagemlt",
"name": "debugtron"
}
}
Expand Down
15 changes: 14 additions & 1 deletion src/main/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ThunkAction } from 'redux-thunk'
import { Adapter } from './adapter'
import { getApps, getAppStart } from '../reducers/app'
import CDP from 'chrome-remote-interface';
import { ipcMain } from 'electron'


export const fetchPages = (): ThunkAction<any, State, any, any> => async (
Expand Down Expand Up @@ -54,14 +55,26 @@ export const startDebugging = (
`--remote-debugging-port=${windowPort}`,
])


const id = v4()
dispatch(addSession(id, app.id, nodePort, windowPort))

setTimeout(function(){
CDP({port:nodePort},async client => {
let count=0;
let renew=false;

ipcMain.on(`open_devtools_${app.id}`,(event,args)=>{
async function openDev() {
console.log(event);
let res = await client.Runtime.evaluate({
expression: `process.mainModule.require('electron').webContents.fromId(${args.id}).openDevTools()`
});
console.log(res);
}
if(!client.CLOSED)
openDev();
})

let interval=setInterval(async function() {
try{
let length=await client.Runtime.evaluate({
Expand Down
37 changes: 33 additions & 4 deletions src/renderer/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,17 +228,37 @@ export const App: React.FC = () => {

<thead>
<tr>
<th>Id</th>
<th>URL</th>
<th>nodeIntegration</th>
<th>contextIsolation</th>
<th>sandbox</th>
<th>nativeWindowOpen</th>
<th>webSecurity</th>
<th>webPreferences</th>
</tr>
</thead>
<tbody>
{session.webcontents == undefined ? <tr></tr> : session.webcontents.map((webcontent) => (
{session.webcontents == undefined ? <tr></tr> : session.webcontents.map((webcontent) =>webcontent.url.indexOf("chrome") != 0 && (
<tr key={webcontent.id}>
<td
style={{
maxWidth: 200,
wordWrap: 'break-word',
}}
>
<Button
small
icon="share"
onClick={() => {
console.log(session.appId)
ipcRenderer.send(`open_devtools_${session.appId}`, { id: webcontent.id })
}}
>
{webcontent.id}
</Button>

</td>
<td
style={{
maxWidth: 200,
Expand Down Expand Up @@ -285,12 +305,21 @@ export const App: React.FC = () => {
</td>
<td
style={{
maxWidth: 400,
maxWidth: 100,
wordWrap: 'break-word',
overflow: 'auto'
color: webcontent.webPreferences.webSecurity == false ? 'red' : 'black',
}}
>
{webcontent.webPreferences.webSecurity ? "true" : "false"}
</td>
<td
style={{
maxWidth: 400,
//wordWrap: 'break-word',
overflow: 'scroll'
}}
>
{JSON.stringify(webcontent.webPreferences, null, 2)}
{JSON.stringify(webcontent.webPreferences)}
</td>
</tr>
))}
Expand Down

0 comments on commit 2698cbe

Please sign in to comment.