提交 0cf9a73a 编写于 作者: B baiy 提交者: ninecents

添加剪贴板配置项 #33

添加快捷键配置快速入口 #32
上级 e92cddd9
此差异已折叠。
...@@ -58,23 +58,31 @@ ...@@ -58,23 +58,31 @@
<Button type="primary" @click="historyClear">清空历史记录</Button> <Button type="primary" @click="historyClear">清空历史记录</Button>
</div> </div>
</Drawer> </Drawer>
<Drawer title="设置" v-model="settingShow" :width="300">
<setting-block v-if="settingShow"></setting-block>
</Drawer>
</div> </div>
</template> </template>
<script> <script>
import config from './tool/config' import config from './tool/config'
import settingBlock from "./views/setting/block"
import model from './tool/model' import model from './tool/model'
import historyFactory from './tool/history' import historyFactory from './tool/history'
import {setLoadHistoryIndex} from './tool/history' import {setLoadHistoryIndex} from './tool/history'
import { openTab } from './helper' import { openTab } from './helper'
export default { export default {
components: {
"setting-block": settingBlock
},
data () { data () {
return { return {
category: config.category, category: config.category,
currentCategory: '', currentCategory: '',
currentTool: '', currentTool: '',
historyData: [], historyData: [],
settingShow:false,
historyShow: false, historyShow: false,
historyColumns: [ historyColumns: [
{ {
...@@ -134,7 +142,7 @@ export default { ...@@ -134,7 +142,7 @@ export default {
openTab('https://github.com/baiy/Ctool') openTab('https://github.com/baiy/Ctool')
break break
case '_setting': case '_setting':
openTab('/setting.html') this.settingShow = true;
break break
case '_new': case '_new':
openTab(window.location.href) openTab(window.location.href)
...@@ -161,7 +169,19 @@ export default { ...@@ -161,7 +169,19 @@ export default {
return JSON.stringify(value) return JSON.stringify(value)
}, },
historyView(index){ historyView(index){
console.log(historyFactory(this.currentTool).get(index)) this.$Modal.info({
render: (h) => {
return h('Input', {
props: {
type:"textarea",
rows:"10",
value: JSON.stringify(historyFactory(this.currentTool).get(index), null, "\t"),
}
})
},
width:700,
okText:"关闭"
})
}, },
historyClear(){ historyClear(){
historyFactory(this.currentTool).clear() historyFactory(this.currentTool).clear()
......
...@@ -25,30 +25,30 @@ const category = [ ...@@ -25,30 +25,30 @@ const category = [
] ]
const tool = [ const tool = [
{ 'name': 'hash', 'title': '哈希(hash)', cat: ['encryption'] }, { 'name': 'hash', 'title': '哈希(hash)', 'cat': ['encryption'] },
{ 'name': 'encrypt', 'title': '加密/解密', cat: ['encryption'] }, { 'name': 'encrypt', 'title': '加密/解密', 'cat': ['encryption'] },
{ 'name': 'base64', 'title': 'BASE64编码', cat: ['encryption'] }, { 'name': 'base64', 'title': 'BASE64编码', 'cat': ['encryption'] },
{ 'name': 'json', 'title': 'JSON工具', cat: ['conversion', 'json'] }, { 'name': 'json', 'title': 'JSON工具', 'cat': ['conversion', 'json'] },
{ 'name': 'url', 'title': 'URL编码', cat: ['conversion'] }, { 'name': 'url', 'title': 'URL编码', 'cat': ['conversion'] },
{ 'name': 'timestamp', 'title': '时间戳', cat: ['conversion'] }, { 'name': 'timestamp', 'title': '时间戳', 'cat': ['conversion'] },
{ 'name': 'qrCode', 'title': '二维码', cat: ['other'] }, { 'name': 'qrCode', 'title': '二维码', 'cat': ['other'] },
{ 'name': 'pinyin', 'title': '汉字转拼音', cat: ['conversion'] }, { 'name': 'pinyin', 'title': '汉字转拼音', 'cat': ['conversion'] },
{ 'name': 'ip', 'title': 'IP地址查询', cat: ['other'] }, { 'name': 'ip', 'title': 'IP地址查询', 'cat': ['other'] },
{ 'name': 'code', 'title': '代码格式化', cat: ['other'] }, { 'name': 'code', 'title': '代码格式化', 'cat': ['other'] },
{ 'name': 'unicode', 'title': 'Unicode', cat: ['conversion'] }, { 'name': 'unicode', 'title': 'Unicode', 'cat': ['conversion'] },
{ 'name': 'decimalConvert', 'title': '进制转换', cat: ['conversion'] }, { 'name': 'decimalConvert', 'title': '进制转换', 'cat': ['conversion'] },
{ 'name': 'regex', 'title': '正则表达式', cat: ['other'] }, { 'name': 'regex', 'title': '正则表达式', 'cat': ['other'] },
{ 'name': 'randomString', 'title': '随机字符生成', cat: ['other'] }, { 'name': 'randomString', 'title': '随机字符生成', 'cat': ['other'] },
{ {
'name': 'phpArraySerialize', 'name': 'phpArraySerialize',
'title': 'PHP数组/序列化', 'title': 'PHP数组/序列化',
cat: ['conversion', 'json'], 'cat': ['conversion', 'json'],
}, },
{ 'name': 'diffs', 'title': '文本差异化对比', cat: ['other'] }, { 'name': 'diffs', 'title': '文本差异化对比', 'cat': ['other'] },
{ 'name': 'crontab', 'title': 'crontab校验', cat: ['other'] }, { 'name': 'crontab', 'title': 'crontab校验', 'cat': ['other'] },
{ 'name': 'websocket', 'title': 'websocket调试', cat: ['other'] }, { 'name': 'websocket', 'title': 'websocket调试', 'cat': ['other'] },
{ 'name': 'unit', 'title': '单位换算', cat: ['other'] }, { 'name': 'unit', 'title': '单位换算', 'cat': ['other'] },
{ 'name': 'time', 'title': '时间计算器', cat: ['other'] }, { 'name': 'time', 'title': '时间计算器', 'cat': ['other'] },
] ]
// 徽章是否显示 // 徽章是否显示
...@@ -72,11 +72,24 @@ const getToolTitle = function (name) { ...@@ -72,11 +72,24 @@ const getToolTitle = function (name) {
return tool[i].title return tool[i].title
} }
} }
return "" return ''
}
const getSetting = function (name, defaultValue = null) {
let setting = cache.getNoVersion('setting', {})
return !setting.hasOwnProperty(name) ? defaultValue : setting[name]
}
const saveSetting = function (name, value) {
let setting = cache.getNoVersion('setting', {})
setting[name] = value
cache.setNoVersion('setting',setting);
} }
export default { export default {
tool, tool,
saveSetting,
getSetting,
category, category,
setUserCommon, setUserCommon,
getToolTitle, getToolTitle,
......
import config from './config' import config from './config'
import setting from './setting'
import cache from './cache' import cache from './cache'
import history from './history.js' import history from './history.js'
...@@ -44,9 +45,11 @@ export const plugin = { ...@@ -44,9 +45,11 @@ export const plugin = {
install: function (Vue) { install: function (Vue) {
Vue.prototype.$getToolData = function (clipboardField = '') { Vue.prototype.$getToolData = function (clipboardField = '') {
let data = history(model.getCurrentTool()).current() let data = history(model.getCurrentTool()).current()
let paste = clipboardPaste() if (setting.autoReadCopy()){
if (clipboardField && !data[clipboardField] && paste) { let paste = clipboardPaste()
data[clipboardField] = paste if (clipboardField && !data[clipboardField] && paste) {
data[clipboardField] = paste
}
} }
return data return data
} }
...@@ -54,7 +57,7 @@ export const plugin = { ...@@ -54,7 +57,7 @@ export const plugin = {
return history(model.getCurrentTool()).push(data) return history(model.getCurrentTool()).push(data)
} }
Vue.prototype.$clipboardCopy = function (data) { Vue.prototype.$clipboardCopy = function (data) {
if (!data) return if (!setting.autoSaveCopy() || !data) return
document.querySelector( document.querySelector(
'#clipboard').innerHTML = '<textarea id="clipboard-text"></textarea>' '#clipboard').innerHTML = '<textarea id="clipboard-text"></textarea>'
document.querySelector('#clipboard-text').value = data document.querySelector('#clipboard-text').value = data
......
import config from './config'
export default {
autoSaveCopy (value = null) {
if (value === null) {
return config.getSetting('auto_save_copy', true)
}
return config.saveSetting('auto_save_copy', value)
},
autoReadCopy (value = null) {
if (value === null) {
return config.getSetting('auto_read_copy', true)
}
return config.saveSetting('auto_read_copy', value)
},
}
\ No newline at end of file
<template>
<div>
<CellGroup @on-click="open">
<Cell title="常用工具设置" name="setting"/>
<Cell title="快捷键设置" name="shortcuts"/>
</CellGroup>
<CellGroup>
<Cell title="自动复制结果到剪贴板">
<i-switch v-model="auto_save_copy" slot="extra"/>
</Cell>
<Cell title="自动读取剪贴板内容">
<i-switch v-model="auto_read_copy" slot="extra"/>
</Cell>
</CellGroup>
</div>
</template>
<script>
import { openTab } from '../../helper'
import setting from '../../tool/setting'
export default {
data () {
return {
auto_save_copy: true,
auto_read_copy: true,
}
},
created () {
this.auto_save_copy = setting.autoSaveCopy()
this.auto_read_copy = setting.autoReadCopy()
},
beforeDestroy () {
setting.autoSaveCopy(this.auto_save_copy)
setting.autoReadCopy(this.auto_read_copy)
},
methods: {
open (name) {
console.log(name)
switch (name) {
case 'shortcuts':
openTab('chrome://extensions/shortcuts')
break
case 'setting':
openTab('/setting.html')
break
}
},
},
}
</script>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册