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
9c04fa93
Commit
9c04fa93
authored
Mar 25, 2021
by
wanli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增重新打包功能,删除无用代码
parent
1c54c989
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
116 additions
and
34 deletions
+116
-34
backend/controller/apps_manager.py
backend/controller/apps_manager.py
+63
-7
backend/controller/build_logs_manager.py
backend/controller/build_logs_manager.py
+16
-12
frontend/src/api/app-store.js
frontend/src/api/app-store.js
+8
-0
frontend/src/views/app-store/index.vue
frontend/src/views/app-store/index.vue
+29
-15
No files found.
backend/controller/apps_manager.py
View file @
9c04fa93
...
...
@@ -26,7 +26,7 @@ logger = logging.getLogger("AppsManager")
@
ThreadMaker
def
build_application
(
user
,
uuid
):
signalManager
.
actionAddBuildLog
.
emit
(
user
,
uuid
)
signalManager
.
actionAddBuildLog
.
emit
(
user
,
uuid
,
isMove
=
False
)
class
AppsManager
(
object
):
def
__init__
(
self
):
...
...
@@ -94,8 +94,6 @@ class AppsManager(object):
app_info
[
'md5'
]
=
str
(
app_info
[
'md5'
])
app_info
.
update
({
"epk_size"
:
os
.
path
.
getsize
(
os
.
sep
.
join
([
config
.
get
(
"UPLOAD_PATH"
),
epk_filename
]))
})
result
=
BuildLogs
(
app
=
app
,
app_path
=
epk_filename
,
app_info
=
app_info
,
create_by
=
editor
,
create_at
=
datetime
.
now
(),
update_by
=
editor
,
update_at
=
datetime
.
now
())
commit
()
AppLogs
(
app_name
=
app
.
app_name
,
app_path
=
epk_filename
,
app_version
=
data
.
get
(
"app_version"
),
app_info
=
app_info
,
create_by
=
editor
,
create_at
=
datetime
.
now
())
...
...
@@ -116,10 +114,68 @@ class AppsManager(object):
return
result
,
"delete app {}."
.
format
(
"success"
if
result
else
"fail"
)
def
get
(
self
,
user
,
data
):
result
=
Apps
.
get
(
**
data
)
if
result
:
result
=
result
.
to_dict
(
only
=
[
"uuid"
,
"name"
,
"create_at"
,
"update_at"
])
return
result
,
"get app {}."
.
format
(
"success"
if
result
else
"no data"
)
# 重新打包
if
not
data
.
get
(
"uuid"
):
return
False
,
"app uuid can not be null"
with
db_session
:
editor
=
User
.
get
(
id
=
user
)
if
not
editor
:
return
False
,
"current user is not exists"
# 根据app查询应用,获取应用有哪些文件
# 按格式创建文件夹,将这些文件移动到这个文件夹
# 将这些零散文件进行打包
# 更新数据库对应文件的路径
app
=
Apps
.
get
(
uuid
=
data
.
get
(
"uuid"
))
if
not
app
:
return
None
,
"app not found"
source_files
=
Annex
.
select
()
.
filter
(
app
=
app
)
if
not
source_files
:
return
None
,
"apps file not found"
dir_format
=
"{}-{}-{}"
.
format
(
app
.
app_name
,
app
.
app_version
,
datetime
.
now
()
.
strftime
(
"
%
Y
%
m
%
d
%
H
%
M
%
S"
))
upload_dir
=
os
.
sep
.
join
([
config
.
get
(
"UPLOAD_PATH"
),
config
.
get
(
"UPLOAD_DIR"
),
"evueapps"
])
target_dir
=
os
.
sep
.
join
([
upload_dir
,
editor
.
account
,
dir_format
])
dest_dir
=
os
.
sep
.
join
([
target_dir
,
"src"
])
if
not
os
.
path
.
exists
(
dest_dir
):
os
.
makedirs
(
dest_dir
)
app_files
=
[]
for
sf
in
source_files
:
target_file
=
os
.
sep
.
join
([
config
.
get
(
"UPLOAD_PATH"
),
sf
.
path
])
filename
=
os
.
path
.
basename
(
target_file
)
name
,
suffix
=
os
.
path
.
splitext
(
filename
)
name
=
re
.
sub
(
r"_\d{14}$"
,
""
,
name
)
dst_file
=
os
.
path
.
normpath
(
os
.
sep
.
join
([
dest_dir
,
name
+
suffix
]))
shutil
.
copy
(
os
.
path
.
normpath
(
target_file
),
dst_file
)
app_files
.
append
([
sf
.
id
,
dst_file
])
# 这里面存在一个逻辑问题,就是将文件拷贝过去之后,需要在Annex表重新生成有感这个EPK文件所有资源文件的记录
# 否则会在下次重新打包时候,找不到相关资源文件报错
# 打包成EPK文件
epk
=
EpkApp
(
appName
=
app
.
app_name
,
appDir
=
dest_dir
,
appVersion
=
app
.
app_version
,
output
=
target_dir
)
app_info
=
epk
.
pack
()
app_info
[
'md5'
]
=
str
(
app_info
[
'md5'
])
# 更新数据库对应文件路径
# 将文件拷贝过去后,需要重新更新数据库文件记录
epk_path
=
os
.
sep
.
join
([
target_dir
.
replace
(
config
.
get
(
"UPLOAD_PATH"
),
""
),
"{}.epk"
.
format
(
app
.
app_name
)])
.
replace
(
'
\\
'
,
'/'
)
build
=
BuildLogs
.
get
(
app
=
app
)
if
build
:
build
.
set
(
app_path
=
epk_path
,
app_info
=
app_info
,
update_by
=
editor
,
update_at
=
datetime
.
now
())
commit
()
# 新增一条AppLogs
AppLogs
(
app_name
=
app
.
app_name
,
app_path
=
epk_path
,
app_version
=
app
.
app_version
,
app_info
=
app_info
,
create_by
=
editor
,
create_at
=
datetime
.
now
())
commit
()
return
{
'app_name'
:
app
.
app_name
,
'app_path'
:
epk_path
},
"rebuild app {}."
.
format
(
"success"
if
app_info
else
"fail"
)
def
getList
(
self
,
user
,
data
):
if
not
data
or
len
(
data
)
<=
0
:
...
...
backend/controller/build_logs_manager.py
View file @
9c04fa93
...
...
@@ -17,6 +17,7 @@ from app.setting import config
from
model
import
fullStackDB
from
model.apps
import
Apps
from
model.annex
import
Annex
from
model.app_logs
import
AppLogs
from
model.build_logs
import
BuildLogs
from
model.user
import
User
from
utils
import
sql_filter
...
...
@@ -56,9 +57,7 @@ class BuildLogsManager(object):
app_files
=
[]
for
sf
in
source_files
:
parsed_result
=
urlparse
(
sf
.
path
)
target_file
=
os
.
sep
.
join
([
config
.
get
(
"UPLOAD_PATH"
),
parsed_result
.
path
.
replace
(
'
\\
'
,
' / '
)])
target_file
=
os
.
sep
.
join
([
config
.
get
(
"UPLOAD_PATH"
),
sf
.
path
])
filename
=
os
.
path
.
basename
(
target_file
)
name
,
suffix
=
os
.
path
.
splitext
(
filename
)
name
=
re
.
sub
(
r"_\d{14}$"
,
""
,
name
)
...
...
@@ -66,14 +65,10 @@ class BuildLogsManager(object):
shutil
.
move
(
os
.
path
.
normpath
(
target_file
),
dst_file
)
app_files
.
append
([
sf
.
id
,
dst_file
])
try
:
# 打包成EPK文件
epk
=
EpkApp
(
appName
=
app
.
app_name
,
appDir
=
dest_dir
,
appVersion
=
app
.
app_version
,
output
=
target_dir
)
app_info
=
epk
.
pack
()
except
Exception
as
e
:
logger
.
error
(
e
)
traceback
.
print_exc
()
return
False
,
e
app_info
[
'md5'
]
=
str
(
app_info
[
'md5'
])
# 更新数据库对应文件路径
for
sf
in
source_files
:
...
...
@@ -86,10 +81,19 @@ class BuildLogsManager(object):
epk_path
=
os
.
sep
.
join
([
target_dir
.
replace
(
config
.
get
(
"UPLOAD_PATH"
),
""
),
"{}.epk"
.
format
(
app
.
app_name
)])
.
replace
(
'
\\
'
,
'/'
)
app_info
[
'md5'
]
=
str
(
app_info
[
'md5'
])
# build = BuildLogs.get(app=app)
# if build:
# build.delete()
# commit()
# 新增一条BuildLogs
result
=
BuildLogs
(
app
=
app
,
app_path
=
epk_path
,
app_info
=
app_info
,
create_by
=
editor
,
create_at
=
datetime
.
now
(),
update_by
=
editor
,
update_at
=
datetime
.
now
())
commit
()
# 新增一条AppLogs
AppLogs
(
app_name
=
app
.
app_name
,
app_path
=
epk_path
,
app_version
=
app
.
app_version
,
app_info
=
app_info
,
create_by
=
editor
,
create_at
=
datetime
.
now
())
commit
()
return
epk_path
,
"add build_logs {}."
.
format
(
"success"
if
result
else
"fail"
)
def
delete
(
self
,
user
,
uuid
):
...
...
frontend/src/api/app-store.js
View file @
9c04fa93
...
...
@@ -38,6 +38,14 @@ export function getBuildApp(id) {
})
}
export
function
rebuildApp
(
params
)
{
return
request
({
url
:
"
/api/v1/evm_store/apps/get
"
,
method
:
"
post
"
,
data
:
params
,
});
}
export
function
buildApp
(
id
)
{
return
request
({
url
:
`/api/v1/evm_store/apps/build/
${
id
}
`
,
...
...
frontend/src/views/app-store/index.vue
View file @
9c04fa93
...
...
@@ -73,10 +73,16 @@
<el-table-column
label=
"操作"
align=
"center"
min-width=
"
18
0"
min-width=
"
26
0"
fixed=
"right"
>
<template
slot-scope=
"scope"
>
<el-button
size=
"mini"
type=
"success"
@
click=
"handleRebuild(scope.$index, scope.row)"
>
重新打包
</el-button
>
<el-button
size=
"mini"
type=
"primary"
...
...
@@ -249,6 +255,7 @@ import {
getAppsList
,
deleteApp
,
addApp
,
rebuildApp
,
updateApp
,
getBuildApp
,
addFramework
,
...
...
@@ -315,7 +322,7 @@ export default {
this
.
list
=
res
.
data
.
map
((
item
)
=>
{
if
(
item
.
app_build_log
&&
item
.
app_build_log
.
app_info
)
item
.
epk_size
=
(
item
.
app_build_log
.
app_info
.
epk_size
/
1024
).
toFixed
(
2
)
+
"
KB
"
;
(
item
.
app_build_log
.
app_info
.
buff_length
/
1024
).
toFixed
(
2
)
+
"
KB
"
;
else
item
.
epk_size
=
""
;
return
item
;
});
...
...
@@ -335,16 +342,22 @@ export default {
this
.
form
.
pagenum
=
e
;
this
.
fetchData
(
mapTrim
(
this
.
form
));
},
handleBuild
(
index
,
row
)
{
console
.
log
(
index
);
getBuildApp
(
row
.
uuid
)
.
then
((
res
)
=>
{
download
(
`
${
res
.
data
.
app_name
}
.epk`
,
res
.
data
.
app_path
);
this
.
$message
.
success
(
res
.
message
);
handleRebuild
(
index
,
row
)
{
console
.
log
(
index
)
rebuildApp
({
uuid
:
row
.
uuid
}).
then
(
res
=>
{
download
(
`
${
res
.
data
.
app_name
}
.epk`
,
res
.
data
.
app_path
)
this
.
$message
.
success
(
res
.
message
)
}).
catch
(
err
=>
{
this
.
$message
.
error
(
err
.
message
)
})
.
catch
((
err
)
=>
{
console
.
log
(
err
);
this
.
$message
.
error
(
err
.
message
);
},
handleBuild
(
index
,
row
)
{
console
.
log
(
index
)
getBuildApp
(
row
.
uuid
).
then
((
res
)
=>
{
download
(
`
${
res
.
data
.
app_name
}
.epk`
,
res
.
data
.
app_path
)
this
.
$message
.
success
(
res
.
message
)
}).
catch
((
err
)
=>
{
this
.
$message
.
error
(
err
.
message
)
});
},
handleEdit
(
index
,
row
)
{
...
...
@@ -460,14 +473,15 @@ export default {
});
},
onAddFramework
()
{
this
.
frameworkDialog
=
true
;
this
.
frameworkDialog
=
true
},
onAdd
()
{
setTimeout
(()
=>
{
this
.
clear
();
},
100
);
this
.
dialogTitle
=
"
添加
"
;
this
.
dialogVisible
=
true
;
},
100
)
this
.
post
.
sort
=
this
.
form
.
pagesize
*
(
this
.
form
.
pagenum
-
1
)
+
this
.
list
.
length
+
1
this
.
dialogTitle
=
"
添加
"
this
.
dialogVisible
=
true
},
onSubmit
()
{
this
.
form
.
pagenum
=
1
;
...
...
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