提交 d25ae5f6 编写于 作者: B baiy 提交者: ninecents

utools 窗口关闭支持 开发者工具显示

上级 369a2779
此差异已折叠。
{
"name": "c-tool",
"version": "1.4.4",
"version": "1.4.5",
"private": true,
"scripts": {
"serve": "vue-cli-service serve --port 8081",
......
......@@ -9,23 +9,35 @@
<body>
</body>
<script>
function setToolCode(name){
function setToolCode(name) {
let data = utools.db.get("_current_tool_");
let rev = data ? {'_rev':data._rev} : {}
let rev = data ? {'_rev': data._rev} : {}
utools.db.put({
'_id':'_current_tool_',
'data':name,
'_id': '_current_tool_',
'data': name,
...rev
})
}
window.utools.onPluginEnter(({code})=>{
window.utools.onPluginEnter(({code}) => {
let tool = "";
if (code.indexOf('ctool-') !== -1){
if (code.indexOf('ctool-') !== -1) {
tool = code.replace(/ctool-/g, "")
}
setToolCode(tool)
window.utools.createBrowserWindow('tool.html',{width: 1200})
window.utools.createBrowserWindow(
'tool.html',
{
width: 1200,
minWidth: 900,
minHeight: 650,
height: 650,
webPreferences: {
preload: 'utools_preload.js'
}
}
)
window.utools.hideMainWindow()
window.utools.outPlugin()
})
......
const {remote} = require("electron");
const browserWindow = remote.getCurrentWindow()
browserWindow.webContents.on('before-input-event', (event, input) => {
// mac 关闭支持
if (process.platform === "darwin") {
if (input.meta && (['q', 'w'].includes(input.key.toLowerCase()))) {
event.preventDefault()
browserWindow.blur()
browserWindow.close()
}
}
})
window.ctool = {}
window.ctool.isDevToolsOpened = function () {
return browserWindow.webContents.isDevToolsOpened();
}
window.ctool.toggleDevTools = function () {
if (window.ctool.isDevToolsOpened) {
return browserWindow.webContents.closeDevTools();
}
return browserWindow.webContents.openDevTools();
}
......@@ -9,8 +9,5 @@
"pluginSetting": {
"single": true
},
"features": "##features##",
"development": {
"main": "http://localhost:8081/utools.html"
}
"features": "##features##"
}
\ No newline at end of file
......@@ -32,6 +32,7 @@ Vue.component('option-block', optionBlock);
page.style.width = 'auto'
page.style.padding = '0 50px'
page.style.height = 'auto'
page.style.minHeight = '600px'
}
})()
new Vue({
......
......@@ -3,7 +3,7 @@
<div>
<CellGroup @on-click="open">
<Cell title="常用工具设置" name="setting"/>
<Cell v-if="isChrome" title="快捷键设置" name="shortcuts"/>
<Cell v-if="is_chrome" title="快捷键设置" name="shortcuts"/>
</CellGroup>
<CellGroup>
<Cell title="自动复制结果到剪贴板">
......@@ -12,6 +12,9 @@
<Cell title="自动读取剪贴板内容">
<i-switch v-model="auto_read_copy" slot="extra"/>
</Cell>
<Cell v-if="is_utools" title="页面开发者工具">
<i-switch v-model="is_dev_tools_opened" slot="extra" @on-change="toggleDevTools"/>
</Cell>
</CellGroup>
</div>
<Drawer title="设置" placement="left" v-model="settingShow" :width="90">
......@@ -21,7 +24,7 @@
</template>
<script>
import { openTab,isChrome } from '../../helper'
import {isChrome, isUtools, openTab} from '../../helper'
import setting from '../../tool/setting'
import settingBlock from './setting'
......@@ -29,25 +32,29 @@ export default {
components: {
"setting-block": settingBlock
},
data () {
data() {
return {
settingShow:false,
settingShow: false,
auto_save_copy: true,
is_dev_tools_opened: false,
auto_read_copy: true,
isChrome: isChrome,
is_chrome: isChrome,
is_utools: isUtools,
}
},
created () {
created() {
if (isUtools) {
this.is_dev_tools_opened = window.ctool.isDevToolsOpened();
}
this.auto_save_copy = setting.autoSaveCopy()
this.auto_read_copy = setting.autoReadCopy()
},
beforeDestroy () {
beforeDestroy() {
setting.autoSaveCopy(this.auto_save_copy)
setting.autoReadCopy(this.auto_read_copy)
},
methods: {
open (name) {
console.log(name)
open(name) {
switch (name) {
case 'shortcuts':
openTab('chrome://extensions/shortcuts')
......@@ -57,6 +64,11 @@ export default {
break
}
},
toggleDevTools() {
if (isUtools) {
window.ctool.toggleDevTools()
}
}
},
}
</script>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册