Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
夜猫逐梦
1024程序员开源挑战赛
提交
2549b063
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,发现更多精彩内容 >>
提交
2549b063
编写于
9月 07, 2021
作者:
B
baiy
提交者:
ninecents
10月 23, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#66 fix
上级
55d00e1e
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
1412 addition
and
1022 deletion
+1412
-1022
package.json
package.json
+1
-1
src/config.js
src/config.js
+3
-3
src/views/tool/library/unit.js
src/views/tool/library/unit.js
+1257
-862
src/views/tool/unit.vue
src/views/tool/unit.vue
+151
-156
未找到文件。
package.json
浏览文件 @
2549b063
{
"name"
:
"c-tool"
,
"version"
:
"1.7.
3
"
,
"version"
:
"1.7.
4
"
,
"private"
:
true
,
"scripts"
:
{
"serve"
:
"vue-cli-service serve --port 8081"
,
...
...
src/config.js
浏览文件 @
2549b063
...
...
@@ -3,9 +3,9 @@ const TOOL_DATA_EXPIRY = 3600 * 24
// 徽章过期时间(天)
const
BADGE_EXPIRY
=
5
// 分类徽章
const
BADGE_CATEGORY
=
[
'
other
'
]
const
BADGE_CATEGORY
=
[]
// 工具徽章
const
BADGE_TOOL
=
[
'
text
'
,
'
hexString
'
]
const
BADGE_TOOL
=
[]
// 默认常用工具
const
DEFAULT_COMMON_TOOL
=
[
'
hash
'
,
'
encrypt
'
,
'
json
'
,
'
base64
'
,
'
url
'
,
'
timestamp
'
,
...
...
@@ -129,4 +129,4 @@ module.exports = {
badgeCategory
:
BADGE_CATEGORY
,
badgeTool
:
BADGE_TOOL
,
defaultCommonTool
:
DEFAULT_COMMON_TOOL
}
\ No newline at end of file
}
src/views/tool/library/unit.js
浏览文件 @
2549b063
此差异已折叠。
点击以展开。
src/views/tool/unit.vue
浏览文件 @
2549b063
<
template
>
<div>
<option-block
style=
"text-align: center"
>
<FormItem>
<ButtonGroup>
<Button
:type=
"current.type === v.key ? 'info' : 'primary'"
@
click=
"handle(v.key)"
v-for=
"v in unitLists"
style=
"padding: 5px 10px 6px;"
:key=
"v.key"
>
{{
v
.
name
}}
</Button>
</ButtonGroup>
</FormItem>
</option-block>
<option-block
style=
"text-align: center"
>
<FormItem>
<Input
v-model=
"current.input"
type=
"number"
></Input>
</FormItem>
<FormItem>
<Select
v-model=
"current.from"
style=
"width:200px"
>
<template
v-if=
"unitGroup[0].name !== ''"
>
<OptionGroup
:label=
"group.name"
v-for=
"(group,gk) in unitGroup"
:key=
"gk"
>
<Option
v-for=
"(unit,k) in group.list"
:value=
"unit"
:key=
"k"
>
{{
unitFormat
(
unit
)
}}
</Option>
</OptionGroup>
</
template
>
<
template
v-else
>
<Option
v-for=
"(unit,k) in unitGroup[0].list"
:value=
"unit"
:key=
"k"
>
{{
unitFormat
(
unit
)
}}
</Option>
</
template
>
</Select>
</FormItem>
<FormItem>
<Button
icon=
"md-code-working"
@
click=
"exchange()"
></Button>
</FormItem>
<FormItem>
<Select
v-model=
"current.to"
style=
"width:200px"
>
<Option
value=
"all"
>
全部
</Option>
<
template
v-if=
"unitGroup[0].name !== ''"
>
<OptionGroup
:label=
"group.name"
v-for=
"(group,gk) in unitGroup"
:key=
"gk"
>
<Option
v-for=
"(unit,k) in group.list"
:value=
"unit"
:key=
"k"
>
{{
unitFormat
(
unit
)
}}
</Option>
</OptionGroup>
</
template
>
<
template
v-else
>
<Option
v-for=
"(unit,k) in unitGroup[0].list"
:value=
"unit"
:key=
"k"
>
{{
unitFormat
(
unit
)
}}
</Option>
</
template
>
</Select>
</FormItem>
</option-block>
<div
v-if=
"isShowResult"
style=
"padding: 0 30px"
>
<
template
v-if=
"current.to !== 'all' && assignResult"
>
<div
style=
"text-align: center;margin-top: 30px;font-size: 18px;font-weight: bold"
>
<span
style=
"color: red"
>
{{
current
.
input
}}
</span>
{{
unitFormat
(
current
.
from
)
}}
=
<span
style=
"color: red"
>
{{
assignResult
.
num
}}
</span>
{{
unitFormat
(
current
.
to
)
}}
<div>
<option-block
style=
"text-align: center"
>
<FormItem>
<ButtonGroup>
<Button
:type=
"current.type === v.key ? 'info' : 'primary'"
@
click=
"handle(v.key)"
v-for=
"v in unitLists"
style=
"padding: 5px 10px 6px;"
:key=
"v.key"
>
{{
v
.
name
}}
</Button>
</ButtonGroup>
</FormItem>
</option-block>
<option-block
style=
"text-align: center"
>
<FormItem>
<Input
v-model=
"current.input"
type=
"number"
></Input>
</FormItem>
<FormItem>
<Select
v-model=
"current.from"
style=
"width:200px"
>
<template
v-if=
"unitGroup.length > 1"
>
<OptionGroup
:label=
"group.name"
v-for=
"(group,gk) in unitGroup"
:key=
"gk"
>
<Option
v-for=
"(unit,k) in group.list"
:value=
"unit.name"
:key=
"k"
>
{{
unit
.
unit
}}
</Option>
</OptionGroup>
</
template
>
<
template
v-else
>
<Option
v-for=
"(unit,k) in unitGroup[0].list"
:value=
"unit.name"
:key=
"k"
>
{{
unit
.
unit
}}
</Option>
</
template
>
</Select>
</FormItem>
<FormItem>
<Button
icon=
"md-code-working"
@
click=
"exchange()"
></Button>
</FormItem>
<FormItem>
<Select
v-model=
"current.to"
style=
"width:200px"
>
<Option
value=
"all"
>
全部
</Option>
<
template
v-if=
"unitGroup.length > 1"
>
<OptionGroup
:label=
"group.name"
v-for=
"(group,gk) in unitGroup"
:key=
"gk"
>
<Option
v-for=
"(unit,k) in group.list"
:value=
"unit.name"
:key=
"k"
>
{{
unit
.
unit
}}
</Option>
</OptionGroup>
</
template
>
<
template
v-else
>
<Option
v-for=
"(unit,k) in unitGroup[0].list"
:value=
"unit.name"
:key=
"k"
>
{{
unit
.
unit
}}
</Option>
</
template
>
</Select>
</FormItem>
</option-block>
<div
v-if=
"isShowResult"
style=
"padding: 0 30px"
>
<
template
v-if=
"current.to !== 'all' && assignResult"
>
<div
style=
"text-align: center;margin-top: 30px;font-size: 18px;font-weight: bold"
>
<span
style=
"color: red"
>
{{
current
.
input
}}
</span>
{{
current
.
from
}}
=
<span
style=
"color: red"
>
{{
assignResult
.
num
}}
</span>
{{
current
.
to
}}
</div>
</
template
>
<CellGroup
v-if=
"current.to === 'all'"
>
<Row
:gutter=
"16"
>
<Col
span=
"12"
v-for=
"(item,k) in result"
:key=
"k"
>
<Cell
:title=
"item.num"
:extra=
"item.unit"
/>
</Col>
</Row>
</CellGroup>
</div>
</
template
>
<CellGroup
v-if=
"current.to === 'all'"
>
<Row
:gutter=
"16"
>
<Col
span=
"12"
v-for=
"(item,k) in result"
:key=
"k"
>
<Cell
:title=
"item.num"
:extra=
"unitFormat(item.unit)"
/>
</Col>
</Row>
</CellGroup>
</div>
</div>
</template>
<
script
>
import
U
from
'
./library/unit
'
import
U
from
'
./library/unit
'
export
default
{
created
()
{
let
history
=
this
.
$getToolData
()
this
.
current
.
type
=
history
[
'
type
'
]
?
history
[
'
type
'
]
:
'
temperature
'
this
.
getToolData
()
export
default
{
created
()
{
let
history
=
this
.
$getToolData
()
this
.
current
.
type
=
history
[
'
type
'
]
?
history
[
'
type
'
]
:
'
temperature
'
this
.
getToolData
()
},
computed
:
{
unitGroup
()
{
return
U
.
getData
(
this
.
current
.
type
)
},
computed
:
{
unitGroup
()
{
return
U
.
getData
(
this
.
current
.
type
).
group
},
isShowResult
()
{
return
this
.
current
.
from
&&
this
.
current
.
type
&&
this
.
current
.
input
},
result
()
{
let
r
=
[]
if
(
this
.
isShowResult
)
{
this
.
saveToolData
()
this
.
unitGroup
.
forEach
((
Group
)
=>
{
Group
.
list
.
forEach
((
unit
)
=>
{
let
temp
=
U
.
calc
(
this
.
current
.
type
,
this
.
current
.
input
,
this
.
current
.
from
.
split
(
'
_
'
)[
0
],
unit
.
split
(
'
_
'
)[
0
]
)
r
.
push
({
unit
:
unit
,
num
:
temp
.
num
,
})
isShowResult
()
{
return
this
.
current
.
from
&&
this
.
current
.
type
&&
this
.
current
.
input
},
result
()
{
let
r
=
[]
if
(
this
.
isShowResult
)
{
this
.
saveToolData
()
this
.
unitGroup
.
forEach
((
Group
)
=>
{
Group
.
list
.
forEach
((
unit
)
=>
{
let
temp
=
U
.
calc
(
this
.
current
.
type
,
this
.
current
.
input
,
this
.
current
.
from
,
unit
.
name
)
r
.
push
({
unit
:
unit
.
name
,
num
:
temp
.
num
,
})
})
}
return
r
},
assignResult
()
{
if
(
this
.
current
.
to
===
'
all
'
)
{
return
{}
}
let
unit
=
this
.
current
.
to
for
(
let
i
=
0
;
i
<
this
.
result
.
length
;
i
++
)
{
if
(
this
.
result
[
i
].
unit
===
unit
)
{
return
this
.
result
[
i
]
}
}
console
.
log
(
this
.
result
)
console
.
log
(
unit
)
console
.
error
(
'
无对应数据
'
)
return
null
})
}
return
r
},
methods
:
{
handle
(
v
)
{
this
.
current
.
type
=
v
this
.
getToolData
()
},
saveToolData
()
{
let
history
=
this
.
$getToolData
()
history
.
type
=
this
.
current
.
type
history
.
data
=
history
.
data
?
history
.
data
:
{}
history
.
data
[
history
.
type
]
=
{
from
:
this
.
current
.
from
,
to
:
this
.
current
.
to
,
input
:
this
.
current
.
input
,
}
this
.
$saveToolData
(
history
)
},
getToolData
()
{
let
type
=
this
.
current
.
type
let
history
=
this
.
$getToolData
()
let
unitHistory
=
history
[
'
data
'
]
&&
history
[
'
data
'
][
type
]
?
history
[
'
data
'
][
type
]
:
null
this
.
current
.
from
=
unitHistory
?
unitHistory
.
from
:
''
this
.
current
.
to
=
unitHistory
?
unitHistory
.
to
:
'
all
'
this
.
current
.
input
=
unitHistory
?
unitHistory
.
input
:
''
},
unitFormat
(
unit
)
{
return
unit
.
split
(
'
_
'
).
join
(
''
)
},
exchange
()
{
if
(
this
.
current
.
to
===
'
all
'
)
{
return
}
if
(
!
this
.
current
.
from
||
!
this
.
current
.
to
)
{
return
assignResult
()
{
if
(
this
.
current
.
to
===
'
all
'
)
{
return
{}
}
let
unit
=
this
.
current
.
to
for
(
let
i
=
0
;
i
<
this
.
result
.
length
;
i
++
)
{
if
(
this
.
result
[
i
].
unit
===
unit
)
{
return
this
.
result
[
i
]
}
let
temp
=
this
.
current
.
from
this
.
current
.
from
=
this
.
current
.
to
this
.
current
.
to
=
temp
}
return
null
}
},
methods
:
{
handle
(
v
)
{
this
.
current
.
type
=
v
this
.
getToolData
()
},
data
()
{
return
{
current
:
{
type
:
''
,
from
:
''
,
to
:
''
,
input
:
''
,
},
unitLists
:
U
.
list
,
saveToolData
()
{
let
history
=
this
.
$getToolData
()
history
.
type
=
this
.
current
.
type
history
.
data
=
history
.
data
?
history
.
data
:
{}
history
.
data
[
history
.
type
]
=
{
from
:
this
.
current
.
from
,
to
:
this
.
current
.
to
,
input
:
this
.
current
.
input
,
}
this
.
$saveToolData
(
history
)
},
}
</
script
>
\ No newline at end of file
getToolData
()
{
let
type
=
this
.
current
.
type
let
history
=
this
.
$getToolData
()
let
unitHistory
=
history
[
'
data
'
]
&&
history
[
'
data
'
][
type
]
?
history
[
'
data
'
][
type
]
:
null
this
.
current
.
from
=
unitHistory
?
unitHistory
.
from
:
U
.
getMain
(
this
.
current
.
type
)
this
.
current
.
to
=
unitHistory
?
unitHistory
.
to
:
'
all
'
this
.
current
.
input
=
unitHistory
?
unitHistory
.
input
:
''
},
exchange
()
{
if
(
this
.
current
.
to
===
'
all
'
)
{
return
}
if
(
!
this
.
current
.
from
||
!
this
.
current
.
to
)
{
return
}
let
temp
=
this
.
current
.
from
this
.
current
.
from
=
this
.
current
.
to
this
.
current
.
to
=
temp
}
},
data
()
{
return
{
current
:
{
type
:
''
,
from
:
''
,
to
:
''
,
input
:
''
,
},
unitLists
:
U
.
list
(),
}
},
}
</
script
>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录