Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
夜猫逐梦
1024程序员开源挑战赛
提交
3c5f9115
1
1024程序员开源挑战赛
项目概览
夜猫逐梦
/
1024程序员开源挑战赛
与 Fork 源项目一致
Fork自
GitCode / 1024程序员开源挑战赛(10.23-11.14)
通知
3
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
1
1024程序员开源挑战赛
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3c5f9115
编写于
12月 21, 2020
作者:
B
baiy
提交者:
ninecents
10月 23, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加剪贴板配置项 #33
添加快捷键配置快速入口 #32
上级
40ffde1f
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
21960 addition
and
8171 deletion
+21960
-8171
package-lock.json
package-lock.json
+21872
-8019
src/tool.vue
src/tool.vue
+22
-2
src/tool/config.js
src/tool/config.js
+34
-21
src/tool/model.js
src/tool/model.js
+7
-4
src/tool/setting.js
src/tool/setting.js
+3
-42
src/views/setting/block.vue
src/views/setting/block.vue
+22
-83
未找到文件。
package-lock.json
浏览文件 @
3c5f9115
此差异已折叠。
点击以展开。
src/tool.vue
浏览文件 @
3c5f9115
...
...
@@ -58,23 +58,31 @@
<Button
type=
"primary"
@
click=
"historyClear"
>
清空历史记录
</Button>
</div>
</Drawer>
<Drawer
title=
"设置"
v-model=
"settingShow"
:width=
"300"
>
<setting-block
v-if=
"settingShow"
></setting-block>
</Drawer>
</div>
</template>
<
script
>
import
config
from
'
./tool/config
'
import
settingBlock
from
"
./views/setting/block
"
import
model
from
'
./tool/model
'
import
historyFactory
from
'
./tool/history
'
import
{
setLoadHistoryIndex
}
from
'
./tool/history
'
import
{
openTab
}
from
'
./helper
'
export
default
{
components
:
{
"
setting-block
"
:
settingBlock
},
data
()
{
return
{
category
:
config
.
category
,
currentCategory
:
''
,
currentTool
:
''
,
historyData
:
[],
settingShow
:
false
,
historyShow
:
false
,
historyColumns
:
[
{
...
...
@@ -134,7 +142,7 @@ export default {
openTab
(
'
https://github.com/baiy/Ctool
'
)
break
case
'
_setting
'
:
openTab
(
'
/setting.html
'
)
this
.
settingShow
=
true
;
break
case
'
_new
'
:
openTab
(
window
.
location
.
href
)
...
...
@@ -161,7 +169,19 @@ export default {
return
JSON
.
stringify
(
value
)
},
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
(){
historyFactory
(
this
.
currentTool
).
clear
()
...
...
src/tool/config.js
浏览文件 @
3c5f9115
...
...
@@ -25,30 +25,30 @@ const category = [
]
const
tool
=
[
{
'
name
'
:
'
hash
'
,
'
title
'
:
'
哈希(hash)
'
,
cat
:
[
'
encryption
'
]
},
{
'
name
'
:
'
encrypt
'
,
'
title
'
:
'
加密/解密
'
,
cat
:
[
'
encryption
'
]
},
{
'
name
'
:
'
base64
'
,
'
title
'
:
'
BASE64编码
'
,
cat
:
[
'
encryption
'
]
},
{
'
name
'
:
'
json
'
,
'
title
'
:
'
JSON工具
'
,
cat
:
[
'
conversion
'
,
'
json
'
]
},
{
'
name
'
:
'
url
'
,
'
title
'
:
'
URL编码
'
,
cat
:
[
'
conversion
'
]
},
{
'
name
'
:
'
timestamp
'
,
'
title
'
:
'
时间戳
'
,
cat
:
[
'
conversion
'
]
},
{
'
name
'
:
'
qrCode
'
,
'
title
'
:
'
二维码
'
,
cat
:
[
'
other
'
]
},
{
'
name
'
:
'
pinyin
'
,
'
title
'
:
'
汉字转拼音
'
,
cat
:
[
'
conversion
'
]
},
{
'
name
'
:
'
ip
'
,
'
title
'
:
'
IP地址查询
'
,
cat
:
[
'
other
'
]
},
{
'
name
'
:
'
code
'
,
'
title
'
:
'
代码格式化
'
,
cat
:
[
'
other
'
]
},
{
'
name
'
:
'
unicode
'
,
'
title
'
:
'
Unicode
'
,
cat
:
[
'
conversion
'
]
},
{
'
name
'
:
'
decimalConvert
'
,
'
title
'
:
'
进制转换
'
,
cat
:
[
'
conversion
'
]
},
{
'
name
'
:
'
regex
'
,
'
title
'
:
'
正则表达式
'
,
cat
:
[
'
other
'
]
},
{
'
name
'
:
'
randomString
'
,
'
title
'
:
'
随机字符生成
'
,
cat
:
[
'
other
'
]
},
{
'
name
'
:
'
hash
'
,
'
title
'
:
'
哈希(hash)
'
,
'
cat
'
:
[
'
encryption
'
]
},
{
'
name
'
:
'
encrypt
'
,
'
title
'
:
'
加密/解密
'
,
'
cat
'
:
[
'
encryption
'
]
},
{
'
name
'
:
'
base64
'
,
'
title
'
:
'
BASE64编码
'
,
'
cat
'
:
[
'
encryption
'
]
},
{
'
name
'
:
'
json
'
,
'
title
'
:
'
JSON工具
'
,
'
cat
'
:
[
'
conversion
'
,
'
json
'
]
},
{
'
name
'
:
'
url
'
,
'
title
'
:
'
URL编码
'
,
'
cat
'
:
[
'
conversion
'
]
},
{
'
name
'
:
'
timestamp
'
,
'
title
'
:
'
时间戳
'
,
'
cat
'
:
[
'
conversion
'
]
},
{
'
name
'
:
'
qrCode
'
,
'
title
'
:
'
二维码
'
,
'
cat
'
:
[
'
other
'
]
},
{
'
name
'
:
'
pinyin
'
,
'
title
'
:
'
汉字转拼音
'
,
'
cat
'
:
[
'
conversion
'
]
},
{
'
name
'
:
'
ip
'
,
'
title
'
:
'
IP地址查询
'
,
'
cat
'
:
[
'
other
'
]
},
{
'
name
'
:
'
code
'
,
'
title
'
:
'
代码格式化
'
,
'
cat
'
:
[
'
other
'
]
},
{
'
name
'
:
'
unicode
'
,
'
title
'
:
'
Unicode
'
,
'
cat
'
:
[
'
conversion
'
]
},
{
'
name
'
:
'
decimalConvert
'
,
'
title
'
:
'
进制转换
'
,
'
cat
'
:
[
'
conversion
'
]
},
{
'
name
'
:
'
regex
'
,
'
title
'
:
'
正则表达式
'
,
'
cat
'
:
[
'
other
'
]
},
{
'
name
'
:
'
randomString
'
,
'
title
'
:
'
随机字符生成
'
,
'
cat
'
:
[
'
other
'
]
},
{
'
name
'
:
'
phpArraySerialize
'
,
'
title
'
:
'
PHP数组/序列化
'
,
cat
:
[
'
conversion
'
,
'
json
'
],
'
cat
'
:
[
'
conversion
'
,
'
json
'
],
},
{
'
name
'
:
'
diffs
'
,
'
title
'
:
'
文本差异化对比
'
,
cat
:
[
'
other
'
]
},
{
'
name
'
:
'
crontab
'
,
'
title
'
:
'
crontab校验
'
,
cat
:
[
'
other
'
]
},
{
'
name
'
:
'
websocket
'
,
'
title
'
:
'
websocket调试
'
,
cat
:
[
'
other
'
]
},
{
'
name
'
:
'
unit
'
,
'
title
'
:
'
单位换算
'
,
cat
:
[
'
other
'
]
},
{
'
name
'
:
'
time
'
,
'
title
'
:
'
时间计算器
'
,
cat
:
[
'
other
'
]
},
{
'
name
'
:
'
diffs
'
,
'
title
'
:
'
文本差异化对比
'
,
'
cat
'
:
[
'
other
'
]
},
{
'
name
'
:
'
crontab
'
,
'
title
'
:
'
crontab校验
'
,
'
cat
'
:
[
'
other
'
]
},
{
'
name
'
:
'
websocket
'
,
'
title
'
:
'
websocket调试
'
,
'
cat
'
:
[
'
other
'
]
},
{
'
name
'
:
'
unit
'
,
'
title
'
:
'
单位换算
'
,
'
cat
'
:
[
'
other
'
]
},
{
'
name
'
:
'
time
'
,
'
title
'
:
'
时间计算器
'
,
'
cat
'
:
[
'
other
'
]
},
]
// 徽章是否显示
...
...
@@ -72,11 +72,24 @@ const getToolTitle = function (name) {
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
{
tool
,
saveSetting
,
getSetting
,
category
,
setUserCommon
,
getToolTitle
,
...
...
src/tool/model.js
浏览文件 @
3c5f9115
import
config
from
'
./config
'
import
setting
from
'
./setting
'
import
cache
from
'
./cache
'
import
history
from
'
./history.js
'
...
...
@@ -44,9 +45,11 @@ export const plugin = {
install
:
function
(
Vue
)
{
Vue
.
prototype
.
$getToolData
=
function
(
clipboardField
=
''
)
{
let
data
=
history
(
model
.
getCurrentTool
()).
current
()
let
paste
=
clipboardPaste
()
if
(
clipboardField
&&
!
data
[
clipboardField
]
&&
paste
)
{
data
[
clipboardField
]
=
paste
if
(
setting
.
autoReadCopy
()){
let
paste
=
clipboardPaste
()
if
(
clipboardField
&&
!
data
[
clipboardField
]
&&
paste
)
{
data
[
clipboardField
]
=
paste
}
}
return
data
}
...
...
@@ -54,7 +57,7 @@ export const plugin = {
return
history
(
model
.
getCurrentTool
()).
push
(
data
)
}
Vue
.
prototype
.
$clipboardCopy
=
function
(
data
)
{
if
(
!
data
)
return
if
(
!
setting
.
autoSaveCopy
()
||
!
data
)
return
document
.
querySelector
(
'
#clipboard
'
).
innerHTML
=
'
<textarea id="clipboard-text"></textarea>
'
document
.
querySelector
(
'
#clipboard-text
'
).
value
=
data
...
...
src/tool/setting.js
浏览文件 @
3c5f9115
import
config
from
'
./config
'
export
default
{
/**
* @param value
* @return {boolean}
*/
autoSaveCopy
(
value
=
null
)
{
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
)
{
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
)
},
/**
* @param value
* @return {boolean}
*/
displayMode
(
value
=
null
)
{
if
(
value
===
null
)
{
return
config
.
getSetting
(
'
display_mode
'
,
'
light
'
)
}
return
config
.
saveSetting
(
'
display_mode
'
,
value
)
},
/**
* @param value
* @return {boolean}
*/
locale
(
value
=
null
)
{
if
(
value
===
null
)
{
return
config
.
getSetting
(
'
locale
'
,
'
_default
'
)
}
return
config
.
saveSetting
(
'
locale
'
,
value
)
},
}
}
\ No newline at end of file
src/views/setting/block.vue
浏览文件 @
3c5f9115
<
template
>
<div>
<div>
<CellGroup
@
on-click=
"open"
>
<Cell
:title=
"$t('main_common_tool')"
name=
"setting"
/>
<Cell
v-if=
"is_chromium || is_firefox"
:title=
"$t('main_keyboard_setting')"
name=
"shortcuts"
/>
<Cell
:title=
"$t('main_display_mode')"
>
<Select
v-model=
"display_mode"
slot=
"extra"
transfer
>
<Option
v-for=
"item in display_mode_list"
:value=
"item"
:key=
"item"
>
{{
$t
(
'
main_display_mode_
'
+
item
)
}}
</Option>
</Select>
</Cell>
<Cell
:title=
"$t('main_setting_language')"
>
<Select
v-model=
"locale"
slot=
"extra"
transfer
>
<Option
v-for=
"item in locales"
:value=
"item.code"
:key=
"item.code"
>
{{
item
.
name
}}
</Option>
</Select>
</Cell>
</CellGroup>
<CellGroup>
<Cell
:title=
"$t('main_copy_results_to_clipboard')"
>
<i-switch
v-model=
"auto_save_copy"
slot=
"extra"
/>
</Cell>
<Cell
:title=
"$t('main_read_content_from_clipboard')"
>
<i-switch
v-model=
"auto_read_copy"
slot=
"extra"
/>
</Cell>
<Cell
:title=
"$t('main_read_clipboard_content_trim')"
>
<i-switch
v-model=
"auto_read_copy_filter"
slot=
"extra"
/>
</Cell>
</CellGroup>
</div>
<Drawer
:title=
"$t('main_ui_setting')"
placement=
"left"
v-model=
"settingShow"
:width=
"90"
>
<setting-block
v-if=
"settingShow"
></setting-block>
</Drawer>
<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
{
isChromium
,
isFirefox
,
isUtools
,
openUrl
,
setDisplayMode
}
from
'
../../helper
'
import
{
LOCALE_LISTS
,
setCurrentLocale
}
from
'
../../i18n
'
import
{
openTab
}
from
'
../../helper
'
import
setting
from
'
../../tool/setting
'
import
settingBlock
from
'
./setting
'
export
default
{
components
:
{
"
setting-block
"
:
settingBlock
},
data
()
{
data
()
{
return
{
settingShow
:
false
,
auto_save_copy
:
true
,
auto_read_copy
:
true
,
display_mode
:
"
light
"
,
auto_read_copy_filter
:
false
,
is_chromium
:
isChromium
,
is_utools
:
isUtools
,
is_firefox
:
isFirefox
,
display_mode_list
:
[
"
light
"
,
"
dark
"
,
"
auto
"
],
locales
:
LOCALE_LISTS
,
locale
:
""
,
}
},
watch
:
{
display_mode
(
value
)
{
setDisplayMode
(
value
)
},
locale
(
value
)
{
setCurrentLocale
(
value
)
}
},
created
()
{
created
()
{
this
.
auto_save_copy
=
setting
.
autoSaveCopy
()
this
.
auto_read_copy
=
setting
.
autoReadCopy
()
this
.
auto_read_copy_filter
=
setting
.
autoReadCopyFilter
()
this
.
display_mode
=
setting
.
displayMode
()
this
.
locale
=
setting
.
locale
()
},
beforeDestroy
()
{
beforeDestroy
()
{
setting
.
autoSaveCopy
(
this
.
auto_save_copy
)
setting
.
autoReadCopy
(
this
.
auto_read_copy
)
setting
.
autoReadCopyFilter
(
this
.
auto_read_copy_filter
)
setting
.
displayMode
(
this
.
display_mode
)
setting
.
locale
(
this
.
locale
)
},
methods
:
{
open
(
name
)
{
open
(
name
)
{
console
.
log
(
name
)
switch
(
name
)
{
case
'
shortcuts
'
:
if
(
this
.
is_firefox
)
{
return
this
.
$Notice
.
success
({
title
:
this
.
$t
(
'
main_keyboard_firefox_1
'
),
render
:
h
=>
{
return
h
(
'
span
'
,
[
this
.
$t
(
'
main_keyboard_firefox_2
'
),
h
(
'
a
'
,
{
attrs
:
{
href
:
'
https://jingyan.baidu.com/article/3ea51489f1d0a713e61bbaff.html
'
,
target
:
'
_blank
'
}
},
this
.
$t
(
'
main_keyboard_firefox_3
'
)),
])
}
});
}
openUrl
(
'
chrome://extensions/shortcuts
'
)
openTab
(
'
chrome://extensions/shortcuts
'
)
break
case
'
setting
'
:
this
.
settingShow
=
true
openTab
(
'
/setting.html
'
)
break
}
}
}
,
},
}
</
script
>
</
script
>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录