te')); return $arr; } /* 遍历用户所有主题 * @param $uid 用户ID * @param int $page 页数 * @param int $pagesize 每页记录条数 * @param bool $desc 排序方式 TRUE降序 FALSE升序 * @param string $key 返回的数组用那一列的值作为 key * @param array $col 查询哪些列 */ function thread_tid_find_by_uid($uid, $page = 1, $pagesize = 1000, $desc = TRUE, $key = 'tid', $col = array()) { if (empty($uid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('uid' => $uid), array('tid' => $orderby), $page, $pagesize, $key, $col); return $arr; } // 遍历栏目下tid 支持数组 $fid = array(1,2,3) function thread_tid_find_by_fid($fid, $page = 1, $pagesize = 1000, $desc = TRUE) { if (empty($fid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('fid' => $fid), array('tid' => $orderby), $page, $pagesize, 'tid', array('tid', 'verify_date')); return $arr; } function thread_tid_delete($tid) { if (empty($tid)) return FALSE; $r = thread_tid__delete(array('tid' => $tid)); return $r; } function thread_tid_count() { $n = thread_tid__count(); return $n; } // 统计用户主题数 大数量下严谨使用非主键统计 function thread_uid_count($uid) { $n = thread_tid__count(array('uid' => $uid)); return $n; } // 统计栏目主题数 大数量下严谨使用非主键统计 function thread_fid_count($fid) { $n = thread_tid__count(array('fid' => $fid)); return $n; } ?>javascript - Dev Tools size and position in Electron - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Dev Tools size and position in Electron - Stack Overflow

programmeradmin3浏览0评论

How can I change the size and position of Dev Tools in different modes in Electron? Currently I use simple function in my main.js to open dev tools at app start, that's basically just one line:

mainWindow.webContents.openDevTools({ mode: 'bottom' });

or

mainWindow.webContents.openDevTools({ mode: 'detach' });

to open my dev tools either in separate window or as part of the main app window. What I need is:

  • For detached mode Dev Tools window to appear next to my app window instead of on top of it or under it. I'd like to declare it's initial position.

  • For both bottom/right and detached mode Dev Tools to have exactly the size I need. In detached mode it would be the window size and in right/bottom modes this would be how much of the window do Dev Tools take. I can do all that manually after Dev Tools open so there has to be a way to make it start in correct position and size from the beginning, yet I'm unable to find out how.

UPDATE: Half of the question answered (my own answer below), but for the sake of pleteness answer regarding Dev Tools in "right" or "bottom" mode is still up for grabs.

How can I change the size and position of Dev Tools in different modes in Electron? Currently I use simple function in my main.js to open dev tools at app start, that's basically just one line:

mainWindow.webContents.openDevTools({ mode: 'bottom' });

or

mainWindow.webContents.openDevTools({ mode: 'detach' });

to open my dev tools either in separate window or as part of the main app window. What I need is:

  • For detached mode Dev Tools window to appear next to my app window instead of on top of it or under it. I'd like to declare it's initial position.

  • For both bottom/right and detached mode Dev Tools to have exactly the size I need. In detached mode it would be the window size and in right/bottom modes this would be how much of the window do Dev Tools take. I can do all that manually after Dev Tools open so there has to be a way to make it start in correct position and size from the beginning, yet I'm unable to find out how.

UPDATE: Half of the question answered (my own answer below), but for the sake of pleteness answer regarding Dev Tools in "right" or "bottom" mode is still up for grabs.

Share Improve this question edited Dec 8, 2018 at 23:23 Nec Xelos asked Dec 8, 2018 at 0:35 Nec XelosNec Xelos 4093 silver badges12 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 15

I managed to solve half of my problem using answer from: How to set the devTools window position in electron Now I am able to pletely control Dev Tools in detached mode using this code:

function DTon(){
    devtools = new BrowserWindow();
    mainWindow.webContents.setDevToolsWebContents(devtools.webContents);
    mainWindow.webContents.openDevTools({ mode: 'detach' });
    mainWindow.webContents.once('did-finish-load', function () {
        var windowBounds = mainWindow.getBounds();
        devtools.setPosition(windowBounds.x + windowBounds.width, windowBounds.y);
        devtools.setSize(windowBounds.width/2, windowBounds.height);
    });
    mainWindow.on('move', function () {
        var windowBounds = mainWindow.getBounds();
        devtools.setPosition(windowBounds.x + windowBounds.width, windowBounds.y);
    });
}

It basically behaves like Dev Tools in "right" mode, except for being in separate window.

It might also be useful to note it's possible to edit the Electron configuration file for cases where you can't repile your code.

In Windows, the file is C:\Users\<username>\AppData\Roaming\<electron app name>\Preferences.

Open that in a text editor and you should see some JSON. You can configure the dev tools there. For example, set this to undock dev tools:

"currentDockState":"\"undocked\""
发布评论

评论列表(0)

  1. 暂无评论