Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
夜猫逐梦
1024程序员开源挑战赛
提交
04502c8c
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看板
提交
04502c8c
编写于
2月 26, 2021
作者:
B
baiy
提交者:
ninecents
10月 23, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
界面优化
上级
7113e019
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
82 addition
and
82 deletion
+82
-82
src/views/tool/jsonToObject.vue
src/views/tool/jsonToObject.vue
+74
-74
src/views/tool/uuid.vue
src/views/tool/uuid.vue
+8
-8
未找到文件。
src/views/tool/jsonToObject.vue
浏览文件 @
04502c8c
<
template
>
<Row
:gutter=
"10"
>
<Col
span=
"10"
>
<div
class=
"page-option-block"
>
<option-block
style=
"padding: 0 0"
>
<Card
:padding=
"0"
>
<p
slot=
"title"
>
JSON内容
</p>
<codemirror
ref=
"json"
v-model=
"current.json"
:options=
"options('Json')"
></codemirror>
</Card>
<option-block>
<FormItem>
<Input
v-model=
"current.package"
>
<div
slot=
"prepend"
>
namespace/package
</div>
</Input>
</option-block>
<option-block>
</FormItem>
</option-block>
<option-block>
<FormItem>
<Input
v-model=
"current.class"
>
<div
slot=
"prepend"
>
class/struct
</div>
</Input>
</option-block>
</div>
<input-block
top=
"10px"
right=
"10px"
:text=
"$t('jsonToObject_format')"
@
on-default-right-bottom-click=
"format"
>
<heightResize
:append=
"['.page-option-block']"
>
<code-editor
v-model=
"current.input"
:placeholder=
"$t('jsonToObject_input')"
language=
"json"
/>
</heightResize>
</input-block>
</FormItem>
</option-block>
</Col>
<Col
span=
"14"
>
<input-block
top=
"10px"
right=
"10px"
>
<heightResize>
<code-editor
:placeholder=
"$t('jsonToObject_output')"
:value=
"output"
:language=
"languages[current.type]"
/>
</heightResize>
<Card
:padding=
"0"
>
<p
slot=
"title"
>
转换结果
</p>
<template
slot=
"extra"
>
<RadioGroup
v-model=
"current.type"
type=
"button"
button-style=
"solid"
>
<Radio
:label=
"type"
v-for=
"(type) in types"
:key=
"type"
>
<span>
{{
type
}}
</span>
</Radio>
</RadioGroup>
<Button
style=
"margin-right: 5px"
size=
"small"
v-for=
"(item,key) in type"
:key=
"key"
type=
"primary"
@
click=
"handle(item)"
>
转
{{
item
}}
实体
</Button>
</
template
>
</input-block>
<codemirror
ref=
"output"
v-model=
"current.output"
:options=
"options(this.current.type)"
></codemirror>
</Card>
</Col>
</Row>
</template>
<
script
>
import
codeEditor
from
"
./components/codeEditor
"
;
import
json2Go
from
'
./library/json2Go
'
import
jsonFormatter
from
'
./library/formatter/json
'
import
json2CSharp
from
'
./library/json2CSharp
'
import
json2Java
from
'
./library/json2Java
'
import
json2Dart
from
'
./library/json2Dart
'
import
heightResize
from
"
./components/heightResize
"
;
import
{
codemirror
}
from
'
vue-codemirror
'
import
'
codemirror/lib/codemirror.css
'
import
'
codemirror/mode/javascript/javascript.js
'
import
'
codemirror/mode/go/go.js
'
import
'
codemirror/mode/clike/clike.js
'
import
'
codemirror/addon/fold/foldcode.js
'
import
'
codemirror/addon/fold/foldgutter.js
'
import
'
codemirror/addon/fold/brace-fold.js
'
import
'
codemirror/addon/fold/comment-fold.js
'
import
'
codemirror/addon/fold/foldgutter.css
'
export
default
{
components
:
{
codeEditor
,
heightResize
codemirror
,
},
created
()
{
this
.
$initToolData
(
'
input
'
,
(
input
)
=>
{
try
{
require
(
'
jsonlint
'
).
parse
(
input
)
}
catch
(
e
)
{
return
false
}
return
true
})
this
.
current
=
Object
.
assign
(
this
.
current
,
this
.
$getToolData
())
},
computed
:
{
output
()
{
if
(
!
this
.
current
.
input
.
trim
())
{
return
""
;
}
mounted
()
{
this
.
$refs
.
json
.
codemirror
.
setSize
(
null
,
window
.
innerHeight
-
330
)
this
.
$refs
.
output
.
codemirror
.
setSize
(
null
,
window
.
innerHeight
-
230
)
},
methods
:
{
handle
(
type
)
{
try
{
let
result
=
""
;
require
(
'
jsonlint
'
).
parse
(
this
.
current
.
input
)
switch
(
this
.
current
.
type
)
{
require
(
'
jsonlint
'
).
parse
(
this
.
current
.
json
)
if
(
!
this
.
type
.
includes
(
type
))
{
throw
new
Error
(
"
转换类型错误
"
)
}
this
.
current
.
type
=
type
;
switch
(
type
)
{
case
"
Go
"
:
result
=
json2Go
(
this
.
current
.
input
,
this
.
current
.
class
,
this
.
current
.
package
).
go
break
this
.
current
.
output
=
json2Go
(
this
.
current
.
json
,
this
.
current
.
class
,
this
.
current
.
package
).
go
break
;
case
"
Java
"
:
result
=
json2Java
(
JSON
.
parse
(
this
.
current
.
input
),
this
.
current
.
class
,
this
.
current
.
package
)
break
case
"
Dart
"
:
result
=
json2Dart
(
JSON
.
parse
(
this
.
current
.
input
),
this
.
current
.
class
)
break
this
.
current
.
output
=
json2Java
(
JSON
.
parse
(
this
.
current
.
json
),
this
.
current
.
class
,
this
.
current
.
package
)
break
;
case
"
C#
"
:
result
=
json2CSharp
.
convert
(
JSON
.
parse
(
this
.
current
.
input
),
this
.
current
.
class
,
this
.
current
.
package
)
break
default
:
throw
new
Error
(
this
.
$t
(
'
jsonToObject_type_error
'
).
toString
())
this
.
current
.
output
=
json2CSharp
.
convert
(
JSON
.
parse
(
this
.
current
.
json
),
this
.
current
.
class
,
this
.
current
.
package
)
break
;
}
this
.
$saveToolData
(
this
.
current
)
return
result
;
}
catch
(
error
)
{
return
this
.
$t
(
'
jsonToObject_error
'
,
[
error
.
message
]).
toString
()
this
.
$Notice
.
error
({
title
:
'
错误提示
'
,
desc
:
error
.
message
,
})
return
}
this
.
$saveToolData
(
this
.
current
)
},
types
()
{
return
Object
.
keys
(
this
.
languages
)
}
},
methods
:
{
format
()
{
if
(
this
.
current
.
input
.
trim
())
{
this
.
current
.
input
=
jsonFormatter
.
beautify
(
this
.
current
.
input
)
options
(
mode
)
{
return
{
mode
:
this
.
codemirrorMode
[
mode
],
lineWrapping
:
false
,
foldGutter
:
true
,
indentUnit
:
4
,
gutters
:
[
'
CodeMirror-linenumbers
'
,
'
CodeMirror-foldgutter
'
],
}
}
},
data
()
{
return
{
current
:
{
input
:
""
,
json
:
""
,
type
:
"
Java
"
,
package
:
"
pag
"
,
class
:
"
RootName
"
,
output
:
""
,
},
languages
:
{
"
Java
"
:
"
java
"
,
"
Dart
"
:
"
dart
"
,
"
C#
"
:
"
csharp
"
,
"
Go
"
:
"
go
"
type
:
[
"
Java
"
,
"
C#
"
,
"
Go
"
],
codemirrorMode
:
{
"
Json
"
:
"
application/json
"
,
"
Java
"
:
"
text/x-java
"
,
"
C#
"
:
"
text/x-csharp
"
,
"
Go
"
:
"
text/x-go
"
},
}
},
}
</
script
>
</
script
>
\ No newline at end of file
src/views/tool/uuid.vue
浏览文件 @
04502c8c
<
template
>
<div>
<option-block>
<FormItem>
<FormItem
style=
"width: 140px"
>
<Input
v-model=
"current.amount"
>
<div
slot=
"prepend"
style=
"width: 70px"
>
生成数量
</div>
<div
slot=
"prepend"
>
生成数量
</div>
</Input>
</FormItem>
<FormItem>
<FormItem
style=
"width: 140px"
>
<Input
v-model=
"current.delimiter"
>
<div
slot=
"prepend"
style=
"width: 70px"
>
分隔符
</div>
<div
slot=
"prepend"
>
分隔符
</div>
</Input>
</FormItem>
<FormItem>
...
...
@@ -27,11 +27,11 @@
<Button
type=
"primary"
@
click=
"handle()"
>
生成
</Button>
</FormItem>
</option-block>
<Input
v-model=
"current.output"
:rows=
"1
2
"
type=
"textarea"
placeholder=
"结果"
></Input>
<Input
v-model=
"current.output"
:rows=
"1
4
"
type=
"textarea"
placeholder=
"结果"
></Input>
</div>
</
template
>
<
script
>
import
{
v4
as
uuidV4
,
parse
as
uuidParse
}
from
'
uuid
'
;
import
{
parse
as
uuidParse
,
v4
as
uuidV4
}
from
'
uuid
'
;
export
default
{
created
()
{
...
...
@@ -48,8 +48,8 @@ export default {
},
generate
()
{
let
uuid
=
uuidV4
()
if
(
this
.
current
.
uint8Array
)
{
return
"
[
"
+
uuidParse
(
uuid
).
toString
()
+
"
]
"
if
(
this
.
current
.
uint8Array
)
{
return
"
[
"
+
uuidParse
(
uuid
).
toString
()
+
"
]
"
}
if
(
this
.
current
.
filterLine
)
{
uuid
=
uuid
.
replace
(
/-/g
,
""
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录