提交 10cb3724 编写于 作者: B baiy 提交者: ninecents

utools 切换为原生窗口

上级 2f99e78b
......@@ -71,4 +71,4 @@
> 当然项目中还使用很多不知道姓名的大神的代码, 在这里就不一一感谢
## 先睹为快
![](dome.jpg)
![](https://raw.githubusercontent.com/baiy/Ctool/master/dome.jpg)
public/img/icon_utools.png

11.1 KB | W: | H:

public/img/icon_utools.png

14.7 KB | W: | H:

public/img/icon_utools.png
public/img/icon_utools.png
public/img/icon_utools.png
public/img/icon_utools.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -7,7 +7,7 @@
<title>Ctool 程序开发常用工具</title>
</head>
<body>
<div id="page" style="width: 800px;height: 550px;margin: 0 auto;padding: 0 6px;overflow-y:auto;">
<div id="page" style="width: 800px;height: 550px;margin: 0 auto;padding: 0 10px;overflow-y:auto;">
<div id="app"></div>
</div>
<div id="clipboard"></div>
......
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()
}
}
})
browserWindow.once('ready-to-show', () => {
browserWindow.show()
})
window.ctool = {}
window.ctool.isDevToolsOpened = function () {
return browserWindow.webContents.isDevToolsOpened();
}
window.ctool.toggleDevTools = function () {
return browserWindow.webContents.toggleDevTools();
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Ctool 程序开发常用工具</title>
</head>
<body>
</body>
<script>
function setToolCode(name) {
let data = utools.db.get("_current_tool_");
let rev = data ? {'_rev': data._rev} : {}
utools.db.put({
'_id': '_current_tool_',
'data': name,
...rev
})
}
window.utools.onPluginEnter(({code}) => {
let tool = "";
if (code.indexOf('ctool-') !== -1) {
tool = code.replace(/ctool-/g, "")
}
setToolCode(tool)
window.utools.createBrowserWindow(
'tool.html',
{
width: 1200,
height: 650,
show: false,
webPreferences: {
preload: 'tool_preload.js'
}
}
)
window.utools.hideMainWindow()
window.utools.outPlugin()
})
</script>
</html>
\ No newline at end of file
......@@ -3,11 +3,14 @@
"description": "Ctool 程序开发常用工具",
"author": "baiy",
"homepage": "https://github.com/baiy/Ctool",
"main": "utools.html",
"main": "tool.html",
"version": "##version##",
"logo": "img/icon128.png",
"logo": "img/icon_utools.png",
"pluginSetting": {
"single": true
},
"development": {
"main": "http://localhost:8081/tool.html"
},
"features": "##features##"
}
\ No newline at end of file
......@@ -7,8 +7,18 @@ const category = [
]
const tool = [
{'name': 'hash', 'title': '哈希(hash)', 'cat': ['encryption']},
{'name': 'encrypt', 'title': '加密/解密', 'cat': ['encryption']},
{
'name': 'hash',
'title': '哈希(hash)',
'cat': ['encryption'],
'keyword': ['md5', 'sha1', 'sha256', 'sha512', 'sm3']
},
{
'name': 'encrypt',
'title': '加密/解密',
'cat': ['encryption'],
'keyword': ['AES', 'DES', 'RC4', 'Rabbit', 'TripleDes', 'sm2']
},
{'name': 'base64', 'title': 'BASE64编码', 'cat': ['encryption']},
{'name': 'json', 'title': 'JSON工具', 'cat': ['conversion', 'serialize']},
{'name': 'url', 'title': 'URL编码', 'cat': ['conversion']},
......
......@@ -45,6 +45,7 @@ export const stat = function (action, data = {}) {
{
v: env('version'),
a: action,
p:env('platform'),
r: Math.random()
},
data
......
......@@ -3,38 +3,25 @@ import ViewUI from 'view-design'
import 'view-design/dist/styles/iview.css'
import router from './tool.router'
import optionBlock from './components/optionBlock'
import model, {plugin as modelPlugin} from './tool/model'
import {plugin as modelPlugin} from './tool/model'
import App from './tool.vue'
import {isUtools} from './helper'
import config from "./tool/config";
Vue.config.productionTip = false
Vue.use(ViewUI)
Vue.use(modelPlugin)
Vue.component('option-block', optionBlock);
(function () {
if (isUtools) {
let tool = window.utools.db.get("_current_tool_");
if (tool && tool.data) {
let cat = config.getToolDefaultCategory(tool.data);
if (cat) {
model.setCategoryHistory(cat)
model.setToolHistory(cat, tool.data)
}
}
}
if (document.body.clientWidth > 900 || isUtools) {
console.log('调整窗口大小')
const page = document.getElementById('page')
page.style.width = 'auto'
page.style.padding = '0 50px'
page.style.height = 'auto'
page.style.minHeight = '600px'
}
})()
Vue.config.productionTip = false
Vue.use(ViewUI)
Vue.use(modelPlugin)
Vue.component('option-block', optionBlock);
new Vue({
router,
render: h => h(App),
......
......@@ -126,6 +126,24 @@ export default {
},
},
created () {
if (this.isUtools){
window.utools.onPluginEnter(({code}) => {
let tool = "";
if (code.indexOf('ctool-') !== -1) {
tool = code.replace(/ctool-/g, "")
}
if (tool && this.currentTool !== tool) {
let cat = config.getToolDefaultCategory(tool);
if (cat) {
model.setCategoryHistory(cat)
model.setToolHistory(cat, tool)
this.currentCategory = cat;
this.currentTool = tool;
}
}
})
}
this.currentCategory = model.getCategoryHistory()
this.currentTool = model.getToolHistory(this.currentCategory)
this.$Message.config({
......
......@@ -47,10 +47,11 @@ const utoolsConfigWrite = () => {
"cmds": ['ctool', '程序开发常用工具']
},
...toolConfig.tool.map((item) => {
let keyword = item.hasOwnProperty("keyword") ? item['keyword'] : [];
return {
"code": "ctool-" + item.name,
"explain": item.title,
"cmds": [item.name, item.title, "ctool-" + item.name]
"cmds": Array.from(new Set([item.name, item.title, "ctool-" + item.name, ...keyword]))
}
})
]
......
......@@ -12,9 +12,6 @@
<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">
......@@ -36,16 +33,12 @@ export default {
return {
settingShow: false,
auto_save_copy: true,
is_dev_tools_opened: false,
auto_read_copy: true,
is_chrome: isChrome,
is_utools: isUtools,
}
},
created() {
if (isUtools) {
this.is_dev_tools_opened = window.ctool.isDevToolsOpened();
}
this.auto_save_copy = setting.autoSaveCopy()
this.auto_read_copy = setting.autoReadCopy()
},
......@@ -63,11 +56,6 @@ export default {
this.settingShow = true
break
}
},
toggleDevTools() {
if (isUtools) {
window.ctool.toggleDevTools()
}
}
},
}
......
<template>
<div>
<CheckboxGroup v-model="tools" @on-change="toolUpdate" style="line-height: 30px;">
<Checkbox v-for="(t,k) in all" :key="k" :label="t.name">{{$t('main_tool_'+t.name)}}</Checkbox>
<Checkbox v-for="(t,k) in all" :key="k" :label="t.name">{{t.title}}</Checkbox>
</CheckboxGroup>
</div>
</template>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册