Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
夜猫逐梦
1024程序员开源挑战赛
提交
36a955e1
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看板
提交
36a955e1
编写于
11月 07, 2021
作者:
B
baiy
提交者:
ninecents
10月 23, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#93 优化代码格式化功能
上级
763636b9
变更
24
展开全部
隐藏空白更改
内联
并排
Showing
24 changed file
with
14345 addition
and
154 deletion
+14345
-154
package-lock.json
package-lock.json
+1283
-84
package.json
package.json
+14
-3
src/tool/config.js
src/tool/config.js
+0
-9
src/views/tool/code.vue
src/views/tool/code.vue
+1
-0
src/views/tool/components/codeEditor.vue
src/views/tool/components/codeEditor.vue
+3
-3
src/views/tool/library/formatter.js
src/views/tool/library/formatter.js
+0
-55
src/views/tool/library/formatter/angular.js
src/views/tool/library/formatter/angular.js
+14
-0
src/views/tool/library/formatter/css.js
src/views/tool/library/formatter/css.js
+20
-0
src/views/tool/library/formatter/graphql.js
src/views/tool/library/formatter/graphql.js
+13
-0
src/views/tool/library/formatter/html.js
src/views/tool/library/formatter/html.js
+34
-0
src/views/tool/library/formatter/index.js
src/views/tool/library/formatter/index.js
+53
-0
src/views/tool/library/formatter/javascript.js
src/views/tool/library/formatter/javascript.js
+32
-0
src/views/tool/library/formatter/json.js
src/views/tool/library/formatter/json.js
+11
-0
src/views/tool/library/formatter/less.js
src/views/tool/library/formatter/less.js
+13
-0
src/views/tool/library/formatter/markdown.js
src/views/tool/library/formatter/markdown.js
+14
-0
src/views/tool/library/formatter/php.js
src/views/tool/library/formatter/php.js
+13
-0
src/views/tool/library/formatter/scss.js
src/views/tool/library/formatter/scss.js
+13
-0
src/views/tool/library/formatter/sql.js
src/views/tool/library/formatter/sql.js
+17
-0
src/views/tool/library/formatter/typescript.js
src/views/tool/library/formatter/typescript.js
+13
-0
src/views/tool/library/formatter/uglify.js
src/views/tool/library/formatter/uglify.js
+12702
-0
src/views/tool/library/formatter/vue.js
src/views/tool/library/formatter/vue.js
+14
-0
src/views/tool/library/formatter/xml.js
src/views/tool/library/formatter/xml.js
+21
-0
src/views/tool/library/formatter/yaml.js
src/views/tool/library/formatter/yaml.js
+14
-0
vue.config.js
vue.config.js
+33
-0
未找到文件。
package-lock.json
浏览文件 @
36a955e1
此差异已折叠。
点击以展开。
package.json
浏览文件 @
36a955e1
...
@@ -5,23 +5,27 @@
...
@@ -5,23 +5,27 @@
"scripts"
:
{
"scripts"
:
{
"serve"
:
"vue-cli-service serve --port 8081"
,
"serve"
:
"vue-cli-service serve --port 8081"
,
"build"
:
"vue-cli-service build"
,
"build"
:
"vue-cli-service build"
,
"report"
:
"vue-cli-service build --report"
,
"lint"
:
"vue-cli-service lint"
"lint"
:
"vue-cli-service lint"
},
},
"dependencies"
:
{
"dependencies"
:
{
"
@babel/parser
"
:
"
^7.16.2
"
,
"
@prettier/plugin-php
"
:
"
^0.17.6
"
,
"
@typescript-eslint/typescript-estree
"
:
"
^5.3.0
"
,
"
angular-html-parser
"
:
"
^1.8.0
"
,
"
axios
"
:
"
^0.21.4
"
,
"
axios
"
:
"
^0.21.4
"
,
"
babel-runtime
"
:
"
^6.26.0
"
,
"
babel-runtime
"
:
"
^6.26.0
"
,
"
bignumber.js
"
:
"
^9.0.1
"
,
"
bignumber.js
"
:
"
^9.0.1
"
,
"
code-formatter
"
:
"
0.0.1
"
,
"
code-formatter
"
:
"
0.0.1
"
,
"
codemirror
"
:
"
^5.63.3
"
,
"
codemirror
"
:
"
^5.63.3
"
,
"
codemirror-graphql
"
:
"
^1.
0.3
"
,
"
codemirror-graphql
"
:
"
^1.
1.0
"
,
"
cron-parser
"
:
"
^2.16.3
"
,
"
cron-parser
"
:
"
^2.16.3
"
,
"
cronstrue
"
:
"
^1.122.0
"
,
"
cronstrue
"
:
"
^1.122.0
"
,
"
crypto-js
"
:
"
^3.3.0
"
,
"
crypto-js
"
:
"
^3.3.0
"
,
"
diff-match-patch
"
:
"
^1.0.5
"
,
"
diff-match-patch
"
:
"
^1.0.5
"
,
"
file
"
:
"
^0.2.2
"
,
"
file
"
:
"
^0.2.2
"
,
"
graphql
"
:
"
^16.0.1
"
,
"
graphql
"
:
"
15.5.0
"
,
"
ipinyinjs
"
:
"
^1.0.0
"
,
"
ipinyinjs
"
:
"
^1.0.0
"
,
"
is-url
"
:
"
^1.2.4
"
,
"
jian_fan
"
:
"
^1.0.3
"
,
"
jian_fan
"
:
"
^1.0.3
"
,
"
js-base64
"
:
"
^2.6.4
"
,
"
js-base64
"
:
"
^2.6.4
"
,
"
js-htmlencode
"
:
"
^0.3.0
"
,
"
js-htmlencode
"
:
"
^0.3.0
"
,
...
@@ -38,6 +42,11 @@
...
@@ -38,6 +42,11 @@
"
moment
"
:
"
^2.29.1
"
,
"
moment
"
:
"
^2.29.1
"
,
"
php-array-reader
"
:
"
^1.3.2
"
,
"
php-array-reader
"
:
"
^1.3.2
"
,
"
phparr
"
:
"
^0.2.0
"
,
"
phparr
"
:
"
^0.2.0
"
,
"
postcss
"
:
"
^8.3.11
"
,
"
postcss-less
"
:
"
^5.0.0
"
,
"
postcss-scss
"
:
"
^4.0.2
"
,
"
prettier
"
:
"
^2.4.1
"
,
"
prettier-plugin-sql
"
:
"
^0.3.0
"
,
"
properties-to-json
"
:
"
^0.1.7
"
,
"
properties-to-json
"
:
"
^0.1.7
"
,
"
qrcode
"
:
"
^1.4.4
"
,
"
qrcode
"
:
"
^1.4.4
"
,
"
qrcode-parser
"
:
"
^1.2.0
"
,
"
qrcode-parser
"
:
"
^1.2.0
"
,
...
@@ -45,6 +54,8 @@
...
@@ -45,6 +54,8 @@
"
serialize-php
"
:
"
^1.1.2
"
,
"
serialize-php
"
:
"
^1.1.2
"
,
"
sm-crypto
"
:
"
^0.1.4
"
,
"
sm-crypto
"
:
"
^0.1.4
"
,
"
system
"
:
"
^2.0.1
"
,
"
system
"
:
"
^2.0.1
"
,
"
typescript
"
:
"
^4.4.4
"
,
"
uglify-js
"
:
"
3.14.3
"
,
"
uuid
"
:
"
^8.3.2
"
,
"
uuid
"
:
"
^8.3.2
"
,
"
view-design
"
:
"
^4.6.1
"
,
"
view-design
"
:
"
^4.6.1
"
,
"
vue
"
:
"
^2.6.14
"
,
"
vue
"
:
"
^2.6.14
"
,
...
...
src/tool/config.js
浏览文件 @
36a955e1
...
@@ -33,15 +33,6 @@ const setUserCommon = function (tools) {
...
@@ -33,15 +33,6 @@ const setUserCommon = function (tools) {
cache
.
setNoVersion
(
'
user_common
'
,
tools
)
cache
.
setNoVersion
(
'
user_common
'
,
tools
)
}
}
const
getToolTitle
=
function
(
name
)
{
for
(
let
i
=
0
;
i
<
tool
.
length
;
i
++
)
{
if
(
tool
[
i
].
name
===
name
)
{
return
__
()
}
}
return
''
}
const
getToolDefaultCategory
=
function
(
name
)
{
const
getToolDefaultCategory
=
function
(
name
)
{
for
(
let
i
=
0
;
i
<
tool
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
tool
.
length
;
i
++
)
{
if
(
tool
[
i
].
name
===
name
)
{
if
(
tool
[
i
].
name
===
name
)
{
...
...
src/views/tool/code.vue
浏览文件 @
36a955e1
...
@@ -68,6 +68,7 @@ export default {
...
@@ -68,6 +68,7 @@ export default {
this
.
$saveToolData
(
this
.
current
);
this
.
$saveToolData
(
this
.
current
);
return
this
.
$Message
.
success
(
`
${
this
.
current
.
isCompress
?
"
压缩
"
:
"
格式化
"
}
完成`
);
return
this
.
$Message
.
success
(
`
${
this
.
current
.
isCompress
?
"
压缩
"
:
"
格式化
"
}
完成`
);
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
e
)
return
this
.
$Modal
.
error
({
return
this
.
$Modal
.
error
({
title
:
"
格式化错误
"
,
title
:
"
格式化错误
"
,
content
:
`
${
e
.
message
}
`
content
:
`
${
e
.
message
}
`
...
...
src/views/tool/components/codeEditor.vue
浏览文件 @
36a955e1
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
<div
ref=
"container"
class=
"code-editor"
:style=
"`height:$
{containerHeight};width:${width}`">
</div>
<div
ref=
"container"
class=
"code-editor"
:style=
"`height:$
{containerHeight};width:${width}`">
</div>
</
template
>
</
template
>
<
script
>
<
script
>
import
{
compress
,
format
}
from
"
../library/formatter
"
;
import
{
format
}
from
"
../library/formatter
"
;
import
{
create
}
from
"
../library/editor
"
;
import
{
create
}
from
"
../library/editor
"
;
export
default
{
export
default
{
...
@@ -71,10 +71,10 @@ export default {
...
@@ -71,10 +71,10 @@ export default {
return
this
.
editor
return
this
.
editor
},
},
format
(
lang
,
option
=
{})
{
format
(
lang
,
option
=
{})
{
this
.
$emit
(
'
input
'
,
format
(
this
.
editor
.
getValue
(),
lang
,
option
))
this
.
$emit
(
'
input
'
,
format
(
this
.
editor
.
getValue
(),
lang
,
false
,
option
))
},
},
compress
(
lang
)
{
compress
(
lang
)
{
this
.
$emit
(
'
input
'
,
compress
(
this
.
editor
.
getValue
(),
lang
))
this
.
$emit
(
'
input
'
,
format
(
this
.
editor
.
getValue
(),
lang
,
true
))
}
}
}
}
};
};
...
...
src/views/tool/library/formatter.js
已删除
100644 → 0
浏览文件 @
763636b9
import
prettier
from
"
prettier/standalone
"
;
import
parser
from
"
prettier/parser-babel
"
;
import
parserJson5
from
"
prettier/parser-babel
"
;
import
parserTypeScript
from
"
prettier/parser-typescript
"
;
import
parserGraphql
from
"
prettier/parser-graphql
"
;
import
parserMarkdown
from
"
prettier/parser-markdown
"
;
import
parserCss
from
"
prettier/parser-postcss
"
;
import
parserYaml
from
"
prettier/parser-yaml
"
;
import
parserHtml
from
"
prettier/parser-html
"
;
import
parserJava
from
"
prettier-plugin-java
"
;
import
parserSql
from
"
prettier-plugin-sql
"
;
import
parserPhp
from
"
@prettier/plugin-php
"
;
import
parserXml
from
"
@prettier/plugin-xml
"
;
//https://github.com/prettier/prettier/issues/6264#issuecomment-507535391
const
options
=
{
js
:
{
parser
:
"
babel
"
,
plugins
:
[
parser
]},
ts
:
{
parser
:
"
typescript
"
,
plugins
:
[
parserTypeScript
]},
vue
:
{
parser
:
"
vue
"
,
plugins
:
[
parserHtml
]},
graphql
:
{
parser
:
"
graphql
"
,
plugins
:
[
parserGraphql
]},
markdown
:
{
parser
:
"
markdown
"
,
plugins
:
[
parserMarkdown
]},
css
:
{
parser
:
"
css
"
,
plugins
:
[
parserCss
]},
less
:
{
parser
:
"
less
"
,
plugins
:
[
parserCss
]},
scss
:
{
parser
:
"
scss
"
,
plugins
:
[
parserCss
]},
yaml
:
{
parser
:
"
yaml
"
,
plugins
:
[
parserYaml
]},
html
:
{
parser
:
"
html
"
,
plugins
:
[
parserHtml
]},
angular
:
{
parser
:
"
angular
"
,
plugins
:
[
parserHtml
]},
json
:
{
parser
:
"
json5
"
,
plugins
:
[
parserJson5
],
quoteProps
:
"
preserve
"
,
trailingComma
:
"
none
"
},
xml
:
{
parser
:
"
xml
"
,
plugins
:
[
parserXml
]},
sql
:
{
parser
:
"
sql
"
,
plugins
:
[
parserSql
]},
php
:
{
parser
:
"
php
"
,
plugins
:
[
parserPhp
]},
java
:
{
parser
:
"
java
"
,
plugins
:
[
parserJava
]},
};
const
format
=
(
code
,
lang
,
formatOptions
=
{})
=>
{
if
(
!
(
lang
in
options
))
{
throw
new
Error
(
`
${
lang
}
can't format`
);
}
let
tab
=
"
tab
"
in
formatOptions
?
formatOptions
.
tab
:
4
;
let
langOption
=
options
[
lang
];
langOption
.
tabWidth
=
tab
if
(
"
printWidth
"
in
formatOptions
){
langOption
.
printWidth
=
formatOptions
.
printWidth
}
if
(
"
proseWrap
"
in
formatOptions
){
langOption
.
proseWrap
=
formatOptions
.
proseWrap
}
return
prettier
.
format
(
code
,
langOption
);
};
export
default
format
export
const
jsonFormatter
=
(
code
)
=>
{
return
format
(
code
,
'
json
'
,
{
printWidth
:
2
,
proseWrap
:
"
never
"
})
}
src/views/tool/library/formatter/angular.js
0 → 100644
浏览文件 @
36a955e1
import
prettier
from
"
prettier/standalone
"
;
import
parserHtml
from
"
prettier/parser-html
"
;
export
const
beautify
=
(
code
,
option
=
{})
=>
{
return
prettier
.
format
(
code
,
{
plugins
:
[
parserHtml
],
parser
:
"
angular
"
,
tabWidth
:
"
tab
"
in
option
?
option
.
tab
:
4
});
}
export
default
{
beautify
}
src/views/tool/library/formatter/css.js
0 → 100644
浏览文件 @
36a955e1
import
prettier
from
"
prettier/standalone
"
;
import
parserCss
from
"
prettier/parser-postcss
"
;
export
const
beautify
=
(
code
,
option
=
{})
=>
{
return
prettier
.
format
(
code
,
{
plugins
:
[
parserCss
],
parser
:
"
css
"
,
tabWidth
:
"
tab
"
in
option
?
option
.
tab
:
4
});
}
// eslint-disable-next-line no-unused-vars
export
const
compress
=
(
code
,
options
=
{})
=>
{
return
code
// .replace(/\/\*([^*]|[\r\n]|(\*+([^*\/]|[\r\n])))*\*+\//g, "") // 移除注释
.
replace
(
/
\s
+/g
,
"
"
).
replace
(
/{
\s
+/g
,
"
{
"
).
replace
(
/}
\s
+/g
,
"
}
"
).
replace
(
/;
\s
+/g
,
"
;
"
).
replace
(
/
\/\*\s
+/g
,
"
/*
"
).
replace
(
/
\*\/\s
+/g
,
"
*/
"
)
}
export
default
{
beautify
,
compress
}
src/views/tool/library/formatter/graphql.js
0 → 100644
浏览文件 @
36a955e1
import
prettier
from
"
prettier/standalone
"
;
import
parserGraphql
from
"
prettier/parser-graphql
"
;
export
const
beautify
=
(
code
,
option
=
{})
=>
{
return
prettier
.
format
(
code
,
{
plugins
:
[
parserGraphql
],
parser
:
"
graphql
"
,
tabWidth
:
"
tab
"
in
option
?
option
.
tab
:
4
});
}
export
default
{
beautify
}
src/views/tool/library/formatter/html.js
0 → 100644
浏览文件 @
36a955e1
import
prettier
from
"
prettier/standalone
"
;
import
parserHtml
from
"
prettier/parser-html
"
;
export
const
beautify
=
(
code
,
option
=
{})
=>
{
return
prettier
.
format
(
code
,
{
plugins
:
[
parserHtml
],
parser
:
"
html
"
,
tabWidth
:
"
tab
"
in
option
?
option
.
tab
:
4
});
}
// eslint-disable-next-line no-unused-vars
export
const
compress
=
(
code
,
options
=
{})
=>
{
let
headHTML
=
""
;
code
=
code
.
replace
(
/
(\r\n
|
\n
|
\r
|
\t)
/gm
,
""
);
code
=
code
.
replace
(
/
\s
+/g
,
"
"
);
code
=
code
.
replace
(
new
RegExp
(
"
</HEAD
"
,
"
gi
"
),
'
</head
'
);
code
=
code
.
replace
(
new
RegExp
(
"
</head
"
,
"
gi
"
),
'
</head
'
);
let
bodySplit
=
"
</head>
"
;
let
i
=
code
.
indexOf
(
bodySplit
)
!==
-
1
;
if
(
i
===
true
)
{
let
tempo
=
code
.
split
(
new
RegExp
(
bodySplit
,
'
i
'
));
headHTML
=
tempo
[
0
];
code
=
tempo
[
1
];
}
else
{
bodySplit
=
""
;
}
code
=
code
.
replace
(
/
(\r\n
|
\n
|
\r
|
\t)
/gm
,
""
);
code
=
code
.
replace
(
/
\s
+/g
,
"
"
);
return
headHTML
+
bodySplit
+
'
\n
'
+
code
;
}
export
default
{
beautify
,
compress
}
src/views/tool/library/formatter/index.js
0 → 100644
浏览文件 @
36a955e1
import
js
from
"
./javascript
"
import
json
from
"
./json
"
import
ts
from
"
./typescript
"
import
css
from
"
./css
"
import
html
from
"
./html
"
import
sql
from
"
./sql
"
import
xml
from
"
./xml
"
import
php
from
"
./php
"
import
yaml
from
"
./yaml
"
import
markdown
from
"
./markdown
"
import
graphql
from
"
./graphql
"
import
vue
from
"
./vue
"
import
less
from
"
./less
"
import
scss
from
"
./scss
"
import
angular
from
"
./angular
"
const
methods
=
{
js
,
json
,
ts
,
vue
,
graphql
,
markdown
,
css
,
less
,
scss
,
yaml
,
html
,
angular
,
xml
,
php
,
sql
};
// 代码格式化
export
const
format
=
(
code
,
lang
,
isCompress
=
false
,
options
=
{})
=>
{
if
(
!
(
lang
in
methods
)){
throw
new
Error
(
`
${
lang
}
not support`
);
}
let
method
=
isCompress
?
"
compress
"
:
"
beautify
"
;
if
(
!
(
method
in
methods
[
lang
])){
throw
new
Error
(
`
${
lang
}
not support
${
method
}
`
);
}
return
methods
[
lang
][
method
](
code
,
options
)
};
export
const
jsonFormatter
=
(
code
)
=>
{
return
format
(
code
,
'
json
'
)
}
export
default
format
src/views/tool/library/formatter/javascript.js
0 → 100644
浏览文件 @
36a955e1
import
prettier
from
"
prettier/standalone
"
;
import
parser
from
"
prettier/parser-babel
"
;
// https://github.com/mishoo/UglifyJS/issues/4878
// eslint-disable-next-line import/no-unresolved, import/extensions, import/no-webpack-loader-syntax
import
UglifyJS
from
'
./uglify
'
;
export
const
beautify
=
(
code
,
option
=
{})
=>
{
return
prettier
.
format
(
code
,
{
plugins
:
[
parser
],
parser
:
"
babel
"
,
tabWidth
:
"
tab
"
in
option
?
option
.
tab
:
4
});
}
// eslint-disable-next-line no-unused-vars
export
const
compress
=
(
code
,
options
=
{})
=>
{
let
result
=
UglifyJS
.
minify
(
code
,
{
keep_fnames
:
true
,
compress
:
false
,
mangle
:
false
,
output
:
{
beautify
:
false
,
}
})
if
(
!
(
"
code
"
in
result
)
||
!
result
.
code
){
throw
new
Error
(
"
compress error:
"
+
JSON
.
stringify
(
result
.
error
))
}
return
result
.
code
}
export
default
{
beautify
,
compress
}
src/views/tool/library/formatter/json.js
0 → 100644
浏览文件 @
36a955e1
export
const
beautify
=
(
code
,
option
=
{})
=>
{
return
JSON
.
stringify
(
JSON
.
parse
(
code
.
trim
()),
null
,
"
tab
"
in
option
?
option
.
tab
:
4
)
}
// eslint-disable-next-line no-unused-vars
export
const
compress
=
(
code
,
options
=
{})
=>
{
return
JSON
.
stringify
(
JSON
.
parse
(
code
.
trim
()),
null
,
0
)
}
export
default
{
beautify
,
compress
}
src/views/tool/library/formatter/less.js
0 → 100644
浏览文件 @
36a955e1
import
prettier
from
"
prettier/standalone
"
;
import
parserCss
from
"
prettier/parser-postcss
"
;
export
const
beautify
=
(
code
,
option
=
{})
=>
{
return
prettier
.
format
(
code
,
{
plugins
:
[
parserCss
],
parser
:
"
less
"
,
tabWidth
:
"
tab
"
in
option
?
option
.
tab
:
4
});
}
export
default
{
beautify
}
src/views/tool/library/formatter/markdown.js
0 → 100644
浏览文件 @
36a955e1
import
prettier
from
"
prettier/standalone
"
;
import
parser
from
"
prettier/parser-markdown
"
;
export
const
beautify
=
(
code
,
option
=
{})
=>
{
return
prettier
.
format
(
code
,
{
plugins
:
[
parser
],
parser
:
"
markdown
"
,
tabWidth
:
"
tab
"
in
option
?
option
.
tab
:
4
});
}
export
default
{
beautify
}
src/views/tool/library/formatter/php.js
0 → 100644
浏览文件 @
36a955e1
import
prettier
from
"
prettier/standalone
"
;
import
phpPlugin
from
"
@prettier/plugin-php/standalone
"
;
export
const
beautify
=
(
code
,
option
=
{})
=>
{
return
prettier
.
format
(
code
,
{
plugins
:
[
phpPlugin
],
parser
:
"
php
"
,
tabWidth
:
"
tab
"
in
option
?
option
.
tab
:
4
});
}
export
default
{
beautify
}
src/views/tool/library/formatter/scss.js
0 → 100644
浏览文件 @
36a955e1
import
prettier
from
"
prettier/standalone
"
;
import
parserCss
from
"
prettier/parser-postcss
"
;
export
const
beautify
=
(
code
,
option
=
{})
=>
{
return
prettier
.
format
(
code
,
{
plugins
:
[
parserCss
],
parser
:
"
scss
"
,
tabWidth
:
"
tab
"
in
option
?
option
.
tab
:
4
});
}
export
default
{
beautify
}
src/views/tool/library/formatter/sql.js
0 → 100644
浏览文件 @
36a955e1
import
prettier
from
"
prettier/standalone
"
;
import
parserSql
from
"
prettier-plugin-sql
"
;
export
const
beautify
=
(
code
,
option
=
{})
=>
{
return
prettier
.
format
(
code
,
{
plugins
:
[
parserSql
],
parser
:
"
sql
"
,
tabWidth
:
"
tab
"
in
option
?
option
.
tab
:
4
});
}
// eslint-disable-next-line no-unused-vars
export
const
compress
=
(
code
,
options
=
{})
=>
{
return
code
.
replace
(
/
\s
+/g
,
"
"
).
replace
(
/
\s
+
\(
/
,
"
(
"
).
replace
(
/
\s
+
\)
/
,
"
)
"
)
}
export
default
{
beautify
,
compress
}
src/views/tool/library/formatter/typescript.js
0 → 100644
浏览文件 @
36a955e1
import
prettier
from
"
prettier/standalone
"
;
import
parserTypeScript
from
"
prettier/parser-typescript
"
;
export
const
beautify
=
(
code
,
option
=
{})
=>
{
return
prettier
.
format
(
code
,
{
plugins
:
[
parserTypeScript
],
parser
:
"
typescript
"
,
tabWidth
:
"
tab
"
in
option
?
option
.
tab
:
4
});
}
export
default
{
beautify
}
src/views/tool/library/formatter/uglify.js
0 → 100644
浏览文件 @
36a955e1
此差异已折叠。
点击以展开。
src/views/tool/library/formatter/vue.js
0 → 100644
浏览文件 @
36a955e1
import
prettier
from
"
prettier/standalone
"
;
import
parserHtml
from
"
prettier/parser-html
"
;
export
const
beautify
=
(
code
,
option
=
{})
=>
{
return
prettier
.
format
(
code
,
{
plugins
:
[
parserHtml
],
parser
:
"
vue
"
,
tabWidth
:
"
tab
"
in
option
?
option
.
tab
:
4
});
}
export
default
{
beautify
}
src/views/tool/library/formatter/xml.js
0 → 100644
浏览文件 @
36a955e1
import
xmlFormatter
from
"
xml-formatter
"
export
const
beautify
=
(
code
,
option
=
{})
=>
{
return
xmlFormatter
(
code
,
{
indentation
:
"
"
.
repeat
(
"
tab
"
in
option
?
option
.
tab
:
4
),
collapseContent
:
true
,
lineSeparator
:
'
\n
'
});
}
// eslint-disable-next-line no-unused-vars
export
const
compress
=
(
code
,
options
=
{})
=>
{
return
xmlFormatter
(
code
,
{
indentation
:
''
,
collapseContent
:
true
,
lineSeparator
:
''
});
}
export
default
{
beautify
,
compress
}
src/views/tool/library/formatter/yaml.js
0 → 100644
浏览文件 @
36a955e1
import
prettier
from
"
prettier/standalone
"
;
import
parser
from
"
prettier/parser-yaml
"
;
export
const
beautify
=
(
code
,
option
=
{})
=>
{
return
prettier
.
format
(
code
,
{
plugins
:
[
parser
],
parser
:
"
yaml
"
,
tabWidth
:
"
tab
"
in
option
?
option
.
tab
:
4
});
}
export
default
{
beautify
}
vue.config.js
浏览文件 @
36a955e1
const
adapter
=
require
(
'
./src/tool/adapter
'
);
const
adapter
=
require
(
'
./src/tool/adapter
'
);
const
IS_PROD
=
process
.
env
.
NODE_ENV
===
'
production
'
const
pages
=
{
const
pages
=
{
tool
:
{
tool
:
{
entry
:
'
src/tool.js
'
,
entry
:
'
src/tool.js
'
,
...
@@ -24,7 +25,39 @@ const config = {
...
@@ -24,7 +25,39 @@ const config = {
});
});
return
args
return
args
})
})
if
(
IS_PROD
){
// 独立打包js 防止js文件过大 影响相关平台审核
config
.
optimization
.
splitChunks
({
cacheGroups
:
{
prettierParserTypescript
:
{
test
:
/
[\\/]
node_modules
[\\/]
prettier
[\\/]
parser-typescript
\.
js/
,
name
:
'
prettier-parser-typescript
'
,
chunks
:
'
all
'
,
priority
:
100
,
reuseExistingChunk
:
true
,
enforce
:
true
},
i18n
:
{
test
:
/
[\\/]
src
[\\/]
i18n
[\\/]
index
\.
js/
,
name
:
'
i18n
'
,
chunks
:
'
initial
'
,
priority
:
100
,
enforce
:
true
},
uglify
:
{
test
:
/
[\\/]
src
[\\/]
views
[\\/]
tool
[\\/]
library
[\\/]
formatter
[\\/]
uglify
\.
js/
,
name
:
'
uglify
'
,
chunks
:
'
all
'
,
priority
:
100
,
enforce
:
true
}
}
})
}
},
},
configureWebpack
:
config
=>
{
}
};
};
adapter
.
initialize
()
adapter
.
initialize
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录