Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
evm-store
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanli
evm-store
Commits
44af4162
Commit
44af4162
authored
Nov 11, 2021
by
wanli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✨
feat: 返回数据增加lang字段
parent
ab4625f5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
10 deletions
+22
-10
backend/view/api.py
backend/view/api.py
+20
-2
frontend/src/views/system/evm-module-tool.vue
frontend/src/views/system/evm-module-tool.vue
+2
-8
No files found.
backend/view/api.py
View file @
44af4162
...
...
@@ -33,12 +33,30 @@ api = Blueprint("api", __name__, url_prefix="/api/v1/%s" % config['NAME'])
logger
.
info
(
"/api/v1/
%
s"
%
config
[
'NAME'
])
# 获取文件编码类型
def
get_encoding
(
file
):
def
get_encoding
(
file
:
str
):
# 二进制方式读取,获取字节数据,检测类型
with
open
(
file
,
'rb'
)
as
f
:
data
=
f
.
read
()
return
chardet
.
detect
(
data
)[
'encoding'
]
def
get_program_lang
(
file
:
Path
):
suffix
=
file
.
suffix
lang
=
{
'c'
:
[
".c"
,
"cpp"
,
".h"
,
".hpp"
],
"javascript"
:
[
".js"
],
"json"
:
[
".json"
],
"python"
:
[
".py"
]
}
l
=
"c"
for
key
in
lang
:
if
suffix
in
lang
[
key
]:
l
=
key
break
return
l
@
api
.
route
(
"/system/getFileContent"
,
methods
=
[
"POST"
])
def
get_file_content
():
params
=
request
.
json
...
...
@@ -60,7 +78,7 @@ def get_file_content():
# 判断文件类型
# 将内容以字符串形式返回给前端
return
response_result
(
ResponseCode
.
OK
,
data
=
result
)
return
response_result
(
ResponseCode
.
OK
,
data
=
result
,
lang
=
get_program_lang
(
fpath
)
)
@
api
.
route
(
"/evm"
,
methods
=
[
'GET'
,
'POST'
])
def
hello_evm
():
...
...
frontend/src/views/system/evm-module-tool.vue
View file @
44af4162
...
...
@@ -240,7 +240,6 @@ export default {
console
.
log
(
editor
);
},
onFileChange
(
file
)
{
console
.
log
(
file
,
this
.
form
.
file
);
if
(
!
this
.
result
)
return
;
this
.
getFileContent
(
file
);
},
...
...
@@ -279,7 +278,7 @@ export default {
getFileContent
({
file
:
file
})
.
then
((
res
)
=>
{
this
.
code
=
res
.
data
;
this
.
lang
=
"
c
"
;
this
.
lang
=
res
.
lang
;
this
.
randomkey
=
this
.
createRamdomKey
();
this
.
$message
.
success
(
res
.
message
);
})
...
...
@@ -373,12 +372,7 @@ export default {
});
},
},
mounted
()
{
setTimeout
(()
=>
{
this
.
code
=
"
console.log(123456)
"
;
console
.
log
(
this
.
code
);
},
2000
);
},
mounted
()
{},
created
()
{
this
.
getMarkType
();
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment