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
1566733f
Commit
1566733f
authored
Aug 10, 2021
by
wanli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✨
feat(view/api.py): 新增支持多个evue文件解析为字节码文件
parent
4c27f841
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
139 additions
and
33 deletions
+139
-33
backend/executable.bc
backend/executable.bc
+0
-0
backend/view/api.py
backend/view/api.py
+40
-33
frontend/src/views/system/evue.vue
frontend/src/views/system/evue.vue
+99
-0
No files found.
backend/executable.bc
View file @
1566733f
No preview for this file type
backend/view/api.py
View file @
1566733f
...
...
@@ -150,9 +150,12 @@ def action_build():
# 解析这个evue文件,分别生成3个文件:index.html.bc/index.css.bc/index.js.bc
# 对这三个进行zip压缩,将压缩后的zip链接返回给前端
binfile
=
request
.
files
.
get
(
"binfile"
)
if
not
binfile
:
return
response_result
(
ResponseCode
.
REQUEST_ERROR
,
msg
=
"upload field name error"
)
# binfile = request.files.get("binfile")
# if not binfile:
# return response_result(ResponseCode.REQUEST_ERROR, msg="upload field name error")
if
len
(
request
.
files
.
getlist
(
'binfile'
))
<
0
:
return
response_result
(
ResponseCode
.
REQUEST_ERROR
,
msg
=
"upload file is null"
)
target_path
=
Path
(
config
.
get
(
"UPLOAD_PATH"
))
.
joinpath
(
config
.
get
(
"BYTECODE_DIR"
))
if
not
target_path
.
exists
():
...
...
@@ -162,36 +165,40 @@ def action_build():
if
not
target_path
.
exists
():
target_path
.
mkdir
()
target
=
target_path
.
joinpath
(
binfile
.
filename
)
with
open
(
target
.
resolve
()
.
as_posix
(),
"wb+"
)
as
fd
:
fd
.
write
(
binfile
.
stream
.
read
())
content
=
vbuild
.
render
(
target
.
resolve
()
.
as_posix
())
if
content
:
files
=
[
(
target
.
parent
.
joinpath
(
"{}.hml"
.
format
(
Path
(
binfile
.
filename
)
.
stem
))
.
resolve
()
.
as_posix
(),
content
.
html
),
(
target
.
parent
.
joinpath
(
"{}.css"
.
format
(
Path
(
binfile
.
filename
)
.
stem
))
.
resolve
()
.
as_posix
(),
content
.
style
),
(
target
.
parent
.
joinpath
(
"{}.js"
.
format
(
Path
(
binfile
.
filename
)
.
stem
))
.
resolve
()
.
as_posix
(),
content
.
script
)
]
dst_files
=
[]
for
item
in
files
:
file
,
text
=
item
with
open
(
file
,
"w+"
)
as
fd
:
fd
.
write
(
text
)
result
=
subprocess
.
call
(
"./executable -c {file}"
.
format
(
file
=
file
),
shell
=
True
)
logger
.
info
(
result
)
t
=
Path
(
file
)
res
=
t
.
rename
(
"{}.{}"
.
format
(
t
.
name
,
"bc"
))
dst_files
.
append
(
res
)
zip_filepath
=
target_path
.
joinpath
(
"{}.zip"
.
format
(
target_path
.
name
))
.
resolve
()
.
as_posix
()
z
=
zipfile
.
ZipFile
(
zip_filepath
,
'w'
)
for
file
in
dst_files
:
z
.
write
(
file
.
resolve
()
.
as_posix
(),
arcname
=
file
.
name
)
shutil
.
move
(
file
.
resolve
()
.
as_posix
(),
target_path
.
joinpath
(
file
.
name
)
.
resolve
()
.
as_posix
())
z
.
close
()
dst_files
=
[]
zip_filepath
=
target_path
.
joinpath
(
"{}.zip"
.
format
(
target_path
.
name
))
.
resolve
()
.
as_posix
()
z
=
zipfile
.
ZipFile
(
zip_filepath
,
'w'
)
for
f
in
request
.
files
.
getlist
(
'binfile'
):
target
=
target_path
.
joinpath
(
f
.
filename
)
with
open
(
target
.
resolve
()
.
as_posix
(),
"wb+"
)
as
fd
:
fd
.
write
(
f
.
stream
.
read
())
content
=
vbuild
.
render
(
target
.
resolve
()
.
as_posix
())
if
content
:
files
=
[
(
target
.
parent
.
joinpath
(
"{}.hml"
.
format
(
Path
(
f
.
filename
)
.
stem
))
.
resolve
()
.
as_posix
(),
content
.
html
),
(
target
.
parent
.
joinpath
(
"{}.css"
.
format
(
Path
(
f
.
filename
)
.
stem
))
.
resolve
()
.
as_posix
(),
content
.
style
),
(
target
.
parent
.
joinpath
(
"{}.js"
.
format
(
Path
(
f
.
filename
)
.
stem
))
.
resolve
()
.
as_posix
(),
content
.
script
)
]
for
item
in
files
:
file
,
text
=
item
with
open
(
file
,
"w+"
)
as
fd
:
fd
.
write
(
text
)
result
=
subprocess
.
call
(
"./executable -c {file}"
.
format
(
file
=
file
),
shell
=
True
)
logger
.
info
(
result
)
t
=
Path
(
file
)
res
=
t
.
rename
(
"{}.{}"
.
format
(
t
.
name
,
"bc"
))
dst_files
.
append
(
res
)
for
file
in
dst_files
:
z
.
write
(
file
.
resolve
()
.
as_posix
(),
arcname
=
file
.
name
)
shutil
.
move
(
file
.
resolve
()
.
as_posix
(),
target_path
.
joinpath
(
file
.
name
)
.
resolve
()
.
as_posix
())
# 压缩
z
.
close
()
result
=
Path
(
zip_filepath
)
.
resolve
()
.
relative_to
(
Path
(
config
.
get
(
"UPLOAD_PATH"
)))
.
as_posix
()
return
response_result
(
ResponseCode
.
OK
,
data
=
result
)
...
...
frontend/src/views/system/evue.vue
0 → 100644
View file @
1566733f
<
template
>
<div
class=
"app-container"
>
<el-alert
title=
"代码混淆工具"
type=
"success"
></el-alert>
<div
style=
"margin: 10px 0px"
>
<el-form>
<el-form-item>
<el-upload
class=
"upload-demo"
action=
"/api/v1/evm_store/build"
name=
"binfile"
:on-success=
"handleUploaded"
:file-list=
"fileList"
>
<el-button
size=
"small"
type=
"primary"
>
点击上传
</el-button>
<div
slot=
"tip"
class=
"el-upload__tip"
>
上传C源文件,转换完成后会自动下载
</div>
</el-upload>
</el-form-item>
<el-form-item>
<el-button
type=
"success"
@
click=
"getConvertString"
>
转换
</el-button>
</el-form-item>
</el-form>
</div>
</div>
</
template
>
<
script
>
import
{
actionOpqcp
}
from
"
@/api/app-store
"
;
export
default
{
name
:
"
Opqcp
"
,
data
()
{
return
{
fileList
:
[],
inputString
:
null
,
outputString
:
null
,
filename
:
"
app.js
"
,
};
},
methods
:
{
createFile
(
content
,
filename
)
{
const
a
=
document
.
createElement
(
"
a
"
);
const
blob
=
new
Blob
([
content
]);
const
url
=
window
.
URL
.
createObjectURL
(
blob
);
a
.
href
=
url
;
a
.
download
=
filename
;
a
.
click
();
window
.
URL
.
revokeObjectURL
(
url
);
},
handleUploaded
(
response
)
{
if
(
response
.
code
==
200
)
{
this
.
filename
=
response
.
data
.
filename
actionOpqcp
({
filename
:
response
.
data
.
filepath
})
.
then
((
res
)
=>
{
this
.
$message
.
success
(
res
.
message
);
// const a = document.createElement("a");
// a.href = url;
// a.download = filename;
// a.click();
})
.
catch
((
err
)
=>
{
this
.
$message
.
error
(
err
.
message
);
});
}
console
.
log
(
response
)
},
downloadFile
()
{
this
.
$prompt
(
"
请输入文件名
"
,
"
提示
"
,
{
confirmButtonText
:
"
确定
"
,
cancelButtonText
:
"
取消
"
,
inputValue
:
this
.
filename
,
inputErrorMessage
:
"
文件名格式不正确
"
,
})
.
then
(({
value
})
=>
{
if
(
value
)
this
.
filename
=
value
;
this
.
createFile
(
this
.
outputString
,
this
.
filename
);
})
.
catch
(()
=>
{
this
.
$message
({
type
:
"
info
"
,
message
:
"
取消输入
"
,
});
});
},
getConvertString
()
{
},
},
mounted
()
{},
created
()
{},
};
</
script
>
<
style
lang=
"scss"
scoped
>
.app-container
{
&
>
div
.page-wrapper
{
margin
:
10px
0px
;
}
}
</
style
>
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