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

#54 添加`读取剪贴板内容过滤首尾不可见字符`设置选项

上级 9a430404
{
"name": "c-tool",
"version": "1.6.3",
"version": "1.6.4",
"private": true,
"scripts": {
"serve": "vue-cli-service serve --port 8081",
......
......@@ -58,7 +58,7 @@
<Button type="primary" @click="historyClear">清空历史记录</Button>
</div>
</Drawer>
<Drawer title="设置" v-model="settingShow" :width="300">
<Drawer title="设置" v-model="settingShow" :width="400">
<setting-block v-if="settingShow"></setting-block>
</Drawer>
</div>
......
......@@ -55,15 +55,26 @@ const getToolDefaultCategory = function (name) {
return ''
}
/**
* @param name
* @param defaultValue
* @return {any}
*/
const getSetting = function (name, defaultValue = null) {
let setting = cache.getNoVersion('setting', {})
return !setting.hasOwnProperty(name) ? defaultValue : setting[name]
}
/**
* @param name
* @param value
* @return {boolean}
*/
const saveSetting = function (name, value) {
let setting = cache.getNoVersion('setting', {})
setting[name] = value
cache.setNoVersion('setting', setting);
return true
}
export default {
......
......@@ -65,6 +65,9 @@ export const plugin = {
} else if (setting.autoReadCopy()) {
let paste = clipboardPaste()
if (!data[clipboardField] && paste) {
if (setting.autoReadCopyFilter()){
paste = paste.trim()
}
data[clipboardField] = paste
}
}
......
import config from './config'
export default {
/**
* @param value
* @return {boolean}
*/
autoSaveCopy (value = null) {
if (value === null) {
return config.getSetting('auto_save_copy', true)
}
return config.saveSetting('auto_save_copy', value)
},
/**
* @param value
* @return {boolean}
*/
autoReadCopy (value = null) {
if (value === null) {
return config.getSetting('auto_read_copy', true)
}
return config.saveSetting('auto_read_copy', value)
},
/**
* @param value
* @return {boolean}
*/
autoReadCopyFilter (value = null) {
if (value === null) {
return config.getSetting('auto_read_copy_filter', false)
}
return config.saveSetting('auto_read_copy_filter', value)
},
}
\ No newline at end of file
......@@ -12,6 +12,9 @@
<Cell title="自动读取剪贴板内容">
<i-switch v-model="auto_read_copy" slot="extra"/>
</Cell>
<Cell title="读取剪贴板内容过滤首尾不可见字符">
<i-switch v-model="auto_read_copy_filter" slot="extra"/>
</Cell>
</CellGroup>
</div>
<Drawer title="设置" placement="left" v-model="settingShow" :width="90">
......@@ -34,6 +37,7 @@ export default {
settingShow: false,
auto_save_copy: true,
auto_read_copy: true,
auto_read_copy_filter: false,
is_chrome: isChrome,
is_utools: isUtools,
}
......@@ -41,10 +45,12 @@ export default {
created() {
this.auto_save_copy = setting.autoSaveCopy()
this.auto_read_copy = setting.autoReadCopy()
this.auto_read_copy_filter = setting.autoReadCopyFilter()
},
beforeDestroy() {
setting.autoSaveCopy(this.auto_save_copy)
setting.autoReadCopy(this.auto_read_copy)
setting.autoReadCopyFilter(this.auto_read_copy_filter)
},
methods: {
open(name) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册