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
796e9b1b
Commit
796e9b1b
authored
Jul 16, 2021
by
wanli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✨
feat(): 打通应用添加前后端
parent
be326b71
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
159 additions
and
165 deletions
+159
-165
tools/build_out/application/app.py
tools/build_out/application/app.py
+1
-8
tools/build_out/controllers/app.py
tools/build_out/controllers/app.py
+19
-8
tools/build_out/models/app.py
tools/build_out/models/app.py
+17
-10
tools/build_out/models/package.py
tools/build_out/models/package.py
+3
-1
tools/build_out/views/app.py
tools/build_out/views/app.py
+42
-20
tools/config.json
tools/config.json
+12
-10
tools/frontend/src/utils/request.js
tools/frontend/src/utils/request.js
+41
-70
tools/frontend/src/views/Application/Form.vue
tools/frontend/src/views/Application/Form.vue
+22
-37
tools/frontend/src/views/User/Login.vue
tools/frontend/src/views/User/Login.vue
+2
-1
No files found.
tools/build_out/application/app.py
View file @
796e9b1b
...
@@ -60,14 +60,7 @@ def _custom_abort(http_status_code, **kwargs):
...
@@ -60,14 +60,7 @@ def _custom_abort(http_status_code, **kwargs):
自定义abort 400响应数据格式
自定义abort 400响应数据格式
"""
"""
if
http_status_code
==
400
:
if
http_status_code
==
400
:
message
=
kwargs
.
get
(
'msg'
)
return
abort
(
jsonify
(
response_result
(
ResponseCode
.
HTTP_INVAILD_REQUEST
,
data
=
kwargs
)))
if
isinstance
(
message
,
dict
):
param
,
info
=
list
(
message
.
items
())[
0
]
data
=
'{}:{}!'
.
format
(
param
,
info
)
return
abort
(
jsonify
(
response_result
(
ResponseCode
.
HTTP_INVAILD_REQUEST
,
data
=
data
)))
else
:
return
abort
(
jsonify
(
response_result
(
ResponseCode
.
HTTP_INVAILD_REQUEST
,
data
=
message
)))
# return { 'code': http_status_code, 'msg': kwargs.get('message') }
return
abort
(
http_status_code
)
return
abort
(
http_status_code
)
def
_access_control
(
response
):
def
_access_control
(
response
):
...
...
tools/build_out/controllers/app.py
View file @
796e9b1b
...
@@ -5,6 +5,7 @@ import os
...
@@ -5,6 +5,7 @@ import os
import
re
import
re
import
json
import
json
import
shutil
import
shutil
from
pathlib
import
Path
from
datetime
import
datetime
from
datetime
import
datetime
from
sqlalchemy
import
func
,
distinct
from
sqlalchemy
import
func
,
distinct
from
application.app
import
db
from
application.app
import
db
...
@@ -157,7 +158,9 @@ class AppResource(object):
...
@@ -157,7 +158,9 @@ class AppResource(object):
# result = Apps.select(app_name=data.get("app_name"), is_delete=False).count()
# result = Apps.select(app_name=data.get("app_name"), is_delete=False).count()
# if result < 1:
# if result < 1:
# return False, "app_name has been exists."
# return False, "app_name has been exists."
algorithm
=
params
.
get
(
'algorithm'
)
if
algorithm
:
params
.
pop
(
"algorithm"
)
params
.
update
({
params
.
update
({
'app_icon'
:
params
[
"app_icon"
]
.
replace
(
config
.
UPLOAD_ROOT_DIR
,
""
),
'app_icon'
:
params
[
"app_icon"
]
.
replace
(
config
.
UPLOAD_ROOT_DIR
,
""
),
'create_by'
:
user
.
id
,
'create_by'
:
user
.
id
,
...
@@ -167,39 +170,47 @@ class AppResource(object):
...
@@ -167,39 +170,47 @@ class AppResource(object):
})
})
app_files
=
[]
app_files
=
[]
epk_path
=
""
epk_path
=
Path
(
""
)
if
params
.
get
(
"fileList"
):
if
params
.
get
(
"fileList"
):
app_files
=
params
.
get
(
"fileList"
)
app_files
=
params
.
get
(
"fileList"
)
params
.
pop
(
"fileList"
)
params
.
pop
(
"fileList"
)
epk_path
=
params
.
get
(
"epk_path"
)
epk_path
=
params
.
get
(
"epk_path"
)
params
.
pop
(
"epk_path"
)
params
.
pop
(
"epk_path"
)
if
params
.
get
(
"logo"
):
params
.
pop
(
"logo"
)
app
=
AppModel
(
**
params
)
app
=
AppModel
(
**
params
)
db
.
session
.
add
(
app
)
db
.
session
.
add
(
app
)
db
.
session
.
commit
()
db
.
session
.
commit
()
# 在EPK目录下生成JSON文件
# 在EPK目录下生成JSON文件
with
open
(
os
.
sep
.
join
([
os
.
path
.
dirname
(
epk_path
),
"epk.json"
]),
"w"
)
as
f
:
epk_path
.
joinpath
(
"epk.json"
)
.
write_text
(
json
.
dumps
(
app
.
to_dict
()),
encoding
=
"utf-8"
)
json
.
dump
(
app
.
to_dict
(),
f
)
# with open(os.sep.join([os.path.dirname(epk_path), "epk.json"]), "w") as f:
# json.dump(app.to_dict(), f)
logger
.
info
(
app_files
)
for
a
in
app_files
:
for
a
in
app_files
:
res
=
AnnexModel
(
app
=
app
,
title
=
os
.
path
.
basename
(
a
),
path
=
a
,
size
=
os
.
path
.
getsize
(
a
),
create_by
=
user
,
create_at
=
datetime
.
now
(),
update_by
=
user
,
update_at
=
datetime
.
now
())
res
=
AnnexModel
(
app
=
app
.
id
,
title
=
os
.
path
.
basename
(
a
),
path
=
a
,
size
=
os
.
path
.
getsize
(
a
),
create_by
=
user
.
id
,
create_at
=
datetime
.
now
(),
update_by
=
user
.
id
,
update_at
=
datetime
.
now
())
db
.
session
.
add
(
res
)
db
.
session
.
add
(
res
)
db
.
session
.
flush
()
db
.
session
.
flush
()
db
.
session
.
commit
()
db
.
session
.
commit
()
app_info
=
{}
app_info
=
{}
params
=
{
'appName'
:
app
.
app_name
,
'appDir'
:
epk_path
,
'appVersion'
:
app
.
app_version
,
'output'
:
os
.
path
.
dirname
(
epk_path
)
}
params
=
{
'appName'
:
app
.
app_name
,
'appDir'
:
epk_path
.
resolve
()
.
as_posix
(),
'appVersion'
:
app
.
app_version
,
'output'
:
epk_path
.
parent
.
resolve
()
.
as_posix
(
)
}
if
user
.
role
==
"administrator"
or
user
.
role
==
"community"
:
if
user
.
role
==
"administrator"
or
user
.
role
==
"community"
:
params
[
'algorithm'
]
=
"h"
params
[
'algorithm'
]
=
"h"
if
algorithm
:
params
[
'algorithm'
]
=
algorithm
epk
=
EpkApp
(
**
params
)
epk
=
EpkApp
(
**
params
)
app_info
=
epk
.
pack
()
app_info
=
epk
.
pack
()
epk_filename
=
os
.
sep
.
join
([
os
.
path
.
dirname
(
epk_path
)
.
replace
(
config
.
UPLOAD_ROOT_DIR
,
""
),
"{}.epk"
.
format
(
app
.
app_name
)])
.
replace
(
'
\\
'
,
'/'
)
epk_filename
=
epk_path
.
relative_to
(
config
.
UPLOAD_ROOT_DIR
)
.
joinpath
(
"{}.epk"
.
format
(
app
.
app_name
))
.
resolve
()
.
as_posix
(
)
if
app_info
:
if
app_info
:
app_info
[
'md5'
]
=
str
(
app_info
[
'md5'
])
app_info
[
'md5'
]
=
str
(
app_info
[
'md5'
])
package
=
PackageModel
(
app
=
app
,
file_path
=
epk_filename
,
app_version
=
params
.
get
(
"app_version"
),
package_info
=
app_info
,
source
=
1
,
create_by
=
user
,
create_at
=
datetime
.
now
(),
update_by
=
user
,
update_at
=
datetime
.
now
(
))
package
=
PackageModel
(
app
=
app
.
id
,
file_path
=
epk_filename
,
app_version
=
params
.
get
(
"appVersion"
),
package_info
=
json
.
dumps
(
app_info
),
source
=
1
,
create_by
=
user
.
id
,
create_at
=
datetime
.
now
(),
update_by
=
user
.
id
,
update_at
=
datetime
.
now
(),
remarks
=
json
.
dumps
(
params
))
db
.
session
.
add
(
package
)
db
.
session
.
add
(
package
)
db
.
session
.
commit
()
db
.
session
.
commit
()
...
...
tools/build_out/models/app.py
View file @
796e9b1b
...
@@ -10,20 +10,20 @@ class AppModel(PrimaryModel):
...
@@ -10,20 +10,20 @@ class AppModel(PrimaryModel):
app_name
=
db
.
Column
(
db
.
String
(
70
),
index
=
True
,
nullable
=
False
)
app_name
=
db
.
Column
(
db
.
String
(
70
),
index
=
True
,
nullable
=
False
)
app_icon
=
db
.
Column
(
db
.
String
(
200
),
nullable
=
False
)
app_icon
=
db
.
Column
(
db
.
String
(
200
),
nullable
=
False
)
app_version
=
db
.
Column
(
db
.
String
(
20
),
nullable
=
False
)
app_version
=
db
.
Column
(
db
.
String
(
20
),
nullable
=
False
)
category
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
category
=
db
.
Column
(
db
.
String
(
50
)
,
nullable
=
False
)
category_2th
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
category_2th
=
db
.
Column
(
db
.
String
(
50
)
,
nullable
=
False
)
developer
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
developer
=
db
.
Column
(
db
.
String
(
50
)
,
nullable
=
False
)
download_url
=
db
.
Column
(
db
.
String
(
20
),
nullable
=
False
,
default
=
''
)
download_url
=
db
.
Column
(
db
.
String
(
20
0
),
nullable
=
False
,
default
=
''
)
app_file_size
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
app_file_size
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
app_screen_size
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
app_screen_size
=
db
.
Column
(
db
.
String
(
20
)
,
nullable
=
False
)
app_arch
=
db
.
Column
(
db
.
String
(
20
),
nullable
=
False
,
default
=
''
)
app_arch
=
db
.
Column
(
db
.
String
(
20
),
nullable
=
False
,
default
=
''
)
app_review
=
db
.
Column
(
db
.
String
(
100
),
nullable
=
False
,
default
=
''
)
app_review
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
,
default
=
0
)
# __table_args__ = (
# __table_args__ = (
# db.Index('idx_xxx', 'xxx', mysql_using='btree'),
# db.Index('idx_xxx', 'xxx', mysql_using='btree'),
# )
# )
def
__init__
(
self
,
app_name
,
app_icon
,
app_version
,
category
=
0
,
category_2th
=
0
,
developer
=
0
,
download_url
=
''
,
app_file_size
=
0
,
app_screen_size
=
0
,
app_arch
=
''
,
app_review
=
''
):
def
__init__
(
self
,
app_name
,
app_icon
,
app_version
,
category
=
''
,
category_2th
=
''
,
developer
=
0
,
download_url
=
''
,
app_file_size
=
0
,
app_screen_size
=
''
,
app_arch
=
''
,
app_review
=
0
,
create_by
=
None
,
create_at
=
None
,
update_by
=
None
,
update_at
=
None
,
remarks
=
""
):
self
.
app_name
=
app_name
self
.
app_name
=
app_name
self
.
app_icon
=
app_icon
self
.
app_icon
=
app_icon
self
.
app_version
=
app_version
self
.
app_version
=
app_version
...
@@ -35,11 +35,16 @@ class AppModel(PrimaryModel):
...
@@ -35,11 +35,16 @@ class AppModel(PrimaryModel):
self
.
app_screen_size
=
app_screen_size
self
.
app_screen_size
=
app_screen_size
self
.
app_arch
=
app_arch
self
.
app_arch
=
app_arch
self
.
app_review
=
app_review
self
.
app_review
=
app_review
self
.
create_by
=
create_by
self
.
create_at
=
create_at
self
.
update_by
=
update_by
self
.
update_at
=
update_at
self
.
remarks
=
remarks
def
__repr__
(
self
):
def
__repr__
(
self
):
return
'<AppModel
%
r>'
%
(
self
.
app_name
)
return
'<AppModel
%
r>'
%
(
self
.
app_name
)
def
to_
json
(
self
):
def
to_
dict
(
self
):
return
{
return
{
'app_name'
:
self
.
app_name
,
'app_name'
:
self
.
app_name
,
'app_icon'
:
self
.
app_icon
,
'app_icon'
:
self
.
app_icon
,
...
@@ -62,14 +67,16 @@ class PostAppSchema(ma.SQLAlchemySchema):
...
@@ -62,14 +67,16 @@ class PostAppSchema(ma.SQLAlchemySchema):
model
=
AppModel
model
=
AppModel
app_name
=
ma
.
auto_field
()
app_name
=
ma
.
auto_field
()
app_icon
=
ma
.
auto_field
(
)
app_icon
=
fields
.
String
(
required
=
False
)
app_version
=
ma
.
auto_field
()
app_version
=
ma
.
auto_field
()
category
=
ma
.
auto_field
()
category
=
ma
.
auto_field
()
category_2th
=
fields
.
String
(
required
=
False
)
category_2th
=
fields
.
String
(
required
=
False
)
developer
=
fields
.
String
(
required
=
False
)
developer
=
fields
.
String
(
required
=
False
)
app_screen_size
=
ma
.
auto_field
()
app_screen_size
=
ma
.
auto_field
()
app_arch
=
ma
.
auto_field
()
app_arch
=
ma
.
auto_field
()
app_review
=
ma
.
auto_field
()
app_review
=
ma
.
auto_field
(
required
=
False
)
logo
=
fields
.
Raw
(
required
=
False
)
fileList
=
fields
.
Raw
(
required
=
False
)
postAppSchema
=
PostAppSchema
()
postAppSchema
=
PostAppSchema
()
...
...
tools/build_out/models/package.py
View file @
796e9b1b
...
@@ -24,7 +24,7 @@ class PackageModel(PrimaryModel):
...
@@ -24,7 +24,7 @@ class PackageModel(PrimaryModel):
# db.Index('idx_xxx', 'xxx', mysql_using='btree'),
# db.Index('idx_xxx', 'xxx', mysql_using='btree'),
# )
# )
def
__init__
(
self
,
app
,
app_version
,
package_info
,
algorithm
=
'zlib'
,
file_path
=
''
,
source
=
0
,
user_agent
=
''
,
download_url
=
''
,
ip
=
'127.0.0.1'
,
geo_location
=
''
,
operator
=
''
,
create_by
=
None
,
create_at
=
None
,
update_by
=
None
,
update_at
=
None
):
def
__init__
(
self
,
app
,
app_version
,
package_info
,
algorithm
=
'zlib'
,
file_path
=
''
,
source
=
0
,
user_agent
=
''
,
download_url
=
''
,
ip
=
'127.0.0.1'
,
geo_location
=
''
,
operator
=
''
,
create_by
=
None
,
create_at
=
None
,
update_by
=
None
,
update_at
=
None
,
remarks
=
""
):
self
.
app
=
app
self
.
app
=
app
self
.
app_version
=
app_version
self
.
app_version
=
app_version
self
.
package_info
=
package_info
self
.
package_info
=
package_info
...
@@ -40,6 +40,7 @@ class PackageModel(PrimaryModel):
...
@@ -40,6 +40,7 @@ class PackageModel(PrimaryModel):
self
.
create_at
=
create_at
self
.
create_at
=
create_at
self
.
update_by
=
update_by
self
.
update_by
=
update_by
self
.
update_at
=
update_at
self
.
update_at
=
update_at
self
.
remarks
=
remarks
def
__repr__
(
self
):
def
__repr__
(
self
):
return
'<PackageModel
%
r>'
%
(
self
.
app
)
return
'<PackageModel
%
r>'
%
(
self
.
app
)
...
@@ -56,6 +57,7 @@ class PackageModel(PrimaryModel):
...
@@ -56,6 +57,7 @@ class PackageModel(PrimaryModel):
'ip'
:
self
.
ip
,
'ip'
:
self
.
ip
,
'geo_location'
:
self
.
geo_location
,
'geo_location'
:
self
.
geo_location
,
'operator'
:
self
.
operator
,
'operator'
:
self
.
operator
,
'remarks'
:
self
.
remarks
}
}
...
...
tools/build_out/views/app.py
View file @
796e9b1b
import
os
import
os
import
traceback
from
pathlib
import
Path
from
datetime
import
datetime
from
datetime
import
datetime
from
flask
import
current_app
,
jsonify
,
request
from
flask
import
current_app
,
jsonify
,
request
from
flask_restful
import
Resource
from
flask_restful
import
Resource
from
flask_restful.reqparse
import
RequestParser
from
flask_restful.reqparse
import
RequestParser
from
flask_jwt_extended
import
(
jwt_required
,
get_jwt_identity
)
from
flask_jwt_extended
import
(
jwt_required
,
get_jwt_identity
)
from
werkzeug.datastructures
import
FileStorage
from
werkzeug.utils
import
secure_filename
from
werkzeug.utils
import
secure_filename
from
application.config
import
config
from
application.config
import
config
from
application.signal_manager
import
signalManager
from
application.signal_manager
import
signalManager
...
@@ -13,9 +16,8 @@ from webcreator.response import ResponseCode, response_result
...
@@ -13,9 +16,8 @@ from webcreator.response import ResponseCode, response_result
class
AppResourceList
(
Resource
):
class
AppResourceList
(
Resource
):
def
__init__
(
self
):
def
__init__
(
self
):
pass
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
#
self.parser = RequestParser()
self
.
parser
=
RequestParser
()
def
get
(
self
):
def
get
(
self
):
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
# 特殊参数,即不是从json获取参数的接口,可以将这个注释打开
...
@@ -40,46 +42,65 @@ class AppResourceList(Resource):
...
@@ -40,46 +42,65 @@ class AppResourceList(Resource):
@
jwt_required
(
locations
=
[
"headers"
])
@
jwt_required
(
locations
=
[
"headers"
])
def
post
(
self
):
def
post
(
self
):
self
.
parser
.
add_argument
(
"app_name"
,
type
=
str
,
location
=
"form"
,
required
=
True
)
self
.
parser
.
add_argument
(
"app_version"
,
type
=
str
,
location
=
"form"
,
required
=
True
)
self
.
parser
.
add_argument
(
"category"
,
type
=
str
,
location
=
"form"
,
required
=
True
)
self
.
parser
.
add_argument
(
"app_screen_size"
,
type
=
str
,
location
=
"form"
,
required
=
True
)
self
.
parser
.
add_argument
(
"app_arch"
,
type
=
str
,
location
=
"form"
,
required
=
True
)
self
.
parser
.
add_argument
(
"algorithm"
,
type
=
str
,
location
=
"form"
,
required
=
True
)
self
.
parser
.
add_argument
(
"remarks"
,
type
=
str
,
location
=
"form"
,
required
=
True
)
self
.
parser
.
add_argument
(
"logo"
,
type
=
FileStorage
,
location
=
"files"
,
required
=
True
)
self
.
parser
.
add_argument
(
"fileList"
,
type
=
FileStorage
,
location
=
"files"
,
required
=
True
)
args
=
self
.
parser
.
parse_args
()
try
:
try
:
jwt
=
get_jwt_identity
()
jwt
=
get_jwt_identity
()
# 获取request.files参数
# 获取request.files参数
json_payload
=
request
.
json
#
json_payload = request.json
params
=
postAppSchema
.
load
(
json_payload
)
params
=
postAppSchema
.
load
(
args
)
now_str
=
datetime
.
now
()
.
strftime
(
"
%
Y
%
m
%
d
%
H
%
M
%
S"
)
now_str
=
datetime
.
now
()
.
strftime
(
"
%
Y
%
m
%
d
%
H
%
M
%
S"
)
# 获取相对路径
# 获取相对路径
dirname
=
"{}-{}-{}-{}"
.
format
(
params
[
"app_name"
],
params
[
"app_version"
],
params
[
"category"
],
now_str
)
dirname
=
"{}-{}-{}-{}"
.
format
(
params
[
"app_name"
],
params
[
"app_version"
],
params
[
"category"
],
now_str
)
relative_path
=
os
.
sep
.
join
([
config
.
EPK_DIR
,
dirname
])
relative_path
=
Path
(
config
.
UPLOAD_ROOT_DIR
)
logger
.
info
(
dirname
)
# 获取最终存储的绝对路径
# 获取最终存储的绝对路径
upload_path
=
os
.
path
.
normpath
(
os
.
sep
.
join
([
config
.
UPLOAD_ROOT_DIR
,
relative_path
]))
upload_path
=
Path
(
config
.
EPK_DIR
)
.
joinpath
(
dirname
)
# upload_path = os.path.normpath(os.sep.join([config.UPLOAD_ROOT_DIR, relative_path]))
if
not
os
.
path
.
exists
(
upload_path
):
logger
.
info
(
upload_path
)
os
.
makedirs
(
upload_path
)
if
not
upload_path
.
exists
():
os
.
makedirs
(
upload_path
.
resolve
()
.
as_posix
())
files
=
[]
files
=
[]
# 应用logo
# 应用logo
logo
=
request
.
files
.
get
(
"logo"
)
logo
=
request
.
files
.
get
(
"logo"
)
# args.get('picture')
if
logo
:
if
logo
:
filename
=
secure_filename
(
logo
.
filename
)
filename
=
secure_filename
(
logo
.
filename
)
file_path
=
os
.
sep
.
join
([
upload_path
,
filename
])
logger
.
info
(
filename
)
file_path
=
os
.
path
.
normpath
(
file_path
)
# file_path = os.sep.join([upload_path, filename])
file_path
=
upload_path
.
joinpath
(
filename
)
logo
.
save
(
file_path
)
logo
.
save
(
file_path
)
params
.
update
({
"app_icon"
:
file_path
})
logger
.
info
(
file_path
.
resolve
()
.
as_posix
())
params
.
update
({
"app_icon"
:
file_path
.
resolve
()
.
as_posix
()
})
# 应用源文件
# 应用源文件
fileList
=
request
.
files
.
getlist
(
'fileList'
)
fileList
=
request
.
files
.
getlist
(
'fileList'
)
# args.get('picture')
if
fileList
:
if
fileList
:
upload_path
=
os
.
sep
.
join
([
upload_path
,
"src"
])
# upload_path = os.sep.join([upload_path, "src"])
if
not
os
.
path
.
exists
(
upload_path
):
upload_path
=
upload_path
.
joinpath
(
"src"
)
os
.
mkdir
(
upload_path
)
if
not
upload_path
.
exists
():
logger
.
info
(
upload_path
.
resolve
()
.
as_posix
())
os
.
mkdir
(
upload_path
.
resolve
()
.
as_posix
())
for
f
in
fileList
:
for
f
in
fileList
:
filename
=
secure_filename
(
f
.
filename
)
filename
=
secure_filename
(
f
.
filename
)
file_path
=
os
.
sep
.
join
([
upload_path
,
filename
])
# file_path = os.sep.join([upload_path, filename])
file_path
=
os
.
path
.
normpath
(
file_path
)
# file_path = os.path.normpath(file_path)
f
.
save
(
file_path
)
file_path
=
upload_path
.
joinpath
(
filename
)
files
.
append
(
file_path
)
f
.
save
(
file_path
.
resolve
()
.
as_posix
())
files
.
append
(
file_path
.
resolve
()
.
as_posix
())
# obj = dict()
# obj = dict()
# obj['filename'] = binfile.filename
# obj['filename'] = binfile.filename
...
@@ -92,6 +113,7 @@ class AppResourceList(Resource):
...
@@ -92,6 +113,7 @@ class AppResourceList(Resource):
return
response_result
(
ResponseCode
.
HTTP_SUCCESS
,
data
=
result
,
msg
=
message
)
return
response_result
(
ResponseCode
.
HTTP_SUCCESS
,
data
=
result
,
msg
=
message
)
return
response_result
(
message
)
return
response_result
(
message
)
except
Exception
as
e
:
except
Exception
as
e
:
traceback
.
print_exc
()
current_app
.
logger
.
error
(
e
)
current_app
.
logger
.
error
(
e
)
return
response_result
(
ResponseCode
.
HTTP_SERVER_ERROR
)
return
response_result
(
ResponseCode
.
HTTP_SERVER_ERROR
)
...
...
tools/config.json
View file @
796e9b1b
...
@@ -363,15 +363,17 @@
...
@@ -363,15 +363,17 @@
},
},
{
{
"name"
:
"category"
,
"name"
:
"category"
,
"dataType"
:
"Integer"
,
"dataType"
:
"String"
,
"default"
:
0
,
"default"
:
"''"
,
"length"
:
20
,
"required"
:
true
,
"required"
:
true
,
"toJson"
:
true
"toJson"
:
true
},
},
{
{
"name"
:
"category_2th"
,
"name"
:
"category_2th"
,
"dataType"
:
"Integer"
,
"dataType"
:
"String"
,
"default"
:
0
,
"default"
:
"''"
,
"length"
:
20
,
"required"
:
true
,
"required"
:
true
,
"toJson"
:
true
"toJson"
:
true
},
},
...
@@ -385,7 +387,7 @@
...
@@ -385,7 +387,7 @@
{
{
"name"
:
"download_url"
,
"name"
:
"download_url"
,
"dataType"
:
"String"
,
"dataType"
:
"String"
,
"length"
:
20
,
"length"
:
20
0
,
"required"
:
true
,
"required"
:
true
,
"default"
:
"''"
,
"default"
:
"''"
,
"toJson"
:
true
"toJson"
:
true
...
@@ -399,8 +401,9 @@
...
@@ -399,8 +401,9 @@
},
},
{
{
"name"
:
"app_screen_size"
,
"name"
:
"app_screen_size"
,
"dataType"
:
"Integer"
,
"dataType"
:
"String"
,
"default"
:
0
,
"default"
:
"''"
,
"length"
:
20
,
"required"
:
true
,
"required"
:
true
,
"toJson"
:
true
"toJson"
:
true
},
},
...
@@ -414,10 +417,9 @@
...
@@ -414,10 +417,9 @@
},
},
{
{
"name"
:
"app_review"
,
"name"
:
"app_review"
,
"dataType"
:
"String"
,
"dataType"
:
"Integer"
,
"length"
:
100
,
"required"
:
true
,
"required"
:
true
,
"default"
:
"''"
,
"default"
:
0
,
"toJson"
:
true
"toJson"
:
true
}
}
]
]
...
...
tools/frontend/src/utils/request.js
View file @
796e9b1b
/*
import
axios
from
"
axios
"
;
* @Author: your name
* @Date: 2021-07-15 09:33:39
* @LastEditTime: 2021-07-15 21:15:15
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: \evm-store\tools\frontend\src\utils\request.js
*/
import
axios
from
'
axios
'
;
import
store
from
"
@/store
"
;
import
{
message
}
from
"
ant-design-vue
"
;
import
{
getToken
}
from
"
@/utils/auth
"
;
import
{
getToken
}
from
"
@/utils/auth
"
;
// create an axios instance
// create an axios instance
const
service
=
axios
.
create
({
const
service
=
axios
.
create
({
baseURL
:
process
.
env
.
BASE_URL
,
// api的base_url
baseURL
:
process
.
env
.
BASE_URL
,
// api的base_url
timeout
:
15000
,
// request timeout
timeout
:
15000
,
// request timeout
// responseType: "json",
// responseType: "json",
// crossDomain: true,
// crossDomain: true,
// xhrFields: { withCredentials: true },
// xhrFields: { withCredentials: true },
// headers: { 'X-Requested-With': 'XMLHttpRequest' },
// headers: { 'X-Requested-With': 'XMLHttpRequest' },
// headers: {
// headers: {
// "Content-Type": "application/x-www-form-urlencoded;charset=utf-8"
// "Content-Type": "application/x-www-form-urlencoded;charset=utf-8"
// }
// }
})
})
;
// request interceptor
// request interceptor
service
.
interceptors
.
request
.
use
(
config
=>
{
service
.
interceptors
.
request
.
use
(
(
config
)
=>
{
// Do something before request is sent
// Do something before request is sent
if
(
store
.
state
.
frontend
.
login
.
token
)
{
if
(
window
.
sessionStorage
.
getItem
(
"
Authorization
"
)
)
{
// 让每个请求携带token-- ['Authorization']为自定义key 请根据实际情况自行修改
// 让每个请求携带token-- ['Authorization']为自定义key 请根据实际情况自行修改
config
.
headers
[
'
Authorization
'
]
=
'
Bearer
'
+
getToken
()
config
.
headers
[
"
Authorization
"
]
=
"
Bearer
"
+
getToken
();
}
}
return
config
return
config
;
},
error
=>
{
},
(
error
)
=>
{
// Do something with request error
// Do something with request error
// console.log('error', error) // for debug
// console.log('error', error) // for debug
Promise
.
reject
(
error
)
Promise
.
reject
(
error
);
})
}
);
// respone interceptor
// respone interceptor
service
.
interceptors
.
response
.
use
(
service
.
interceptors
.
response
.
use
(
response
=>
{
(
response
)
=>
{
// message.success('数据通讯完成', 1);
const
res
=
response
.
data
;
const
{
data
}
=
response
;
if
(
data
)
{
return
data
}
return
Promise
.
reject
(
response
);
},
error
=>
{
/**
* 下面的注释为通过response自定义code来标示请求状态,当code返回如下情况为权限有问题,登出并返回到登录页
* 如通过xmlhttprequest 状态码标识 逻辑可写在下面error中
*/
// console.log('error', error)
const
res
=
error
.
response
;
if
(
res
&&
res
.
data
)
{
const
{
code
,
msg
}
=
res
.
data
;
// 100401:非法的token; 100412:其他客户端登录了; 100413:Token 过期了;
if
(
code
===
100401
||
code
===
100412
||
code
===
100413
)
{
// MessageBox.confirm('操作失败,原因:' + error + ',可以取消继续留在该页面,或者重新登录', '操作提示', {
// confirmButtonText: '重新登录',
// cancelButtonText: '取消',
// type: 'warning'
// }).then(() => {
// removeCookies(_CONST.TOKEN);
// location.reload();// 为了重新实例化vue-router对象 避免bug
// })
message
.
error
(
msg
,
3
);
}
else
{
let
error
;
if
(
!
error
)
{
error
=
"
请求失败,异常:
"
+
res
.
statusText
+
'
[
'
+
res
.
status
+
'
]
'
;
}
message
.
error
(
error
,
5
);
}
}
else
{
message
.
error
(
"
请求失败,
"
+
error
,
5
);
}
return
Promise
.
reject
(
error
)
})
export
default
service
console
.
log
(
res
)
\ No newline at end of file
// if (res.code === 200) return Promise.resolve(res);
// else if (res.code === 401) {
// store.dispatch("user/removeToken").then(() => {
// window.location.reload();
// });
// } else return Promise.reject(res);
return
res
;
},
(
error
)
=>
{
return
Promise
.
reject
(
error
);
}
);
export
default
service
;
tools/frontend/src/views/Application/Form.vue
View file @
796e9b1b
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
:labelCol=
"
{ span: 7 }"
:labelCol=
"
{ span: 7 }"
:wrapperCol="{ span: 10 }"
:wrapperCol="{ span: 10 }"
>
>
<a-radio-group
v-model=
"post.algorithm"
@
change=
"onChange"
>
<a-radio-group
v-model=
"post.algorithm"
>
<a-radio-button
value=
"zlib"
>
zlib
</a-radio-button>
<a-radio-button
value=
"zlib"
>
zlib
</a-radio-button>
<a-radio-button
value=
"eheatshrink"
>
eheatshrink
</a-radio-button>
<a-radio-button
value=
"eheatshrink"
>
eheatshrink
</a-radio-button>
</a-radio-group>
</a-radio-group>
...
@@ -39,7 +39,6 @@
...
@@ -39,7 +39,6 @@
mode=
"default"
mode=
"default"
style=
"width: 100%"
style=
"width: 100%"
placeholder=
"应用所属类别"
placeholder=
"应用所属类别"
@
change=
"handleChange"
>
>
<a-select-option
v-for=
"item in categoryList"
:key=
"(item.value + 9).toString(36) + item.value"
>
<a-select-option
v-for=
"item in categoryList"
:key=
"(item.value + 9).toString(36) + item.value"
>
{{
item
.
label
}}
{{
item
.
label
}}
...
@@ -57,8 +56,8 @@
...
@@ -57,8 +56,8 @@
list-type=
"picture-card"
list-type=
"picture-card"
class=
"avatar-uploader"
class=
"avatar-uploader"
:show-upload-list=
"false"
:show-upload-list=
"false"
:before-upload=
"before
Logo
Upload"
:before-upload=
"beforeUpload"
@
change=
"handleChange"
@
change=
"handle
Logo
Change"
>
>
<img
v-if=
"imageUrl"
:src=
"imageUrl"
alt=
"avatar"
/>
<img
v-if=
"imageUrl"
:src=
"imageUrl"
alt=
"avatar"
/>
<div
v-else
>
<div
v-else
>
...
@@ -153,6 +152,7 @@ import {
...
@@ -153,6 +152,7 @@ import {
PageHeader
,
PageHeader
,
DatePicker
,
DatePicker
,
InputNumber
,
InputNumber
,
message
}
from
"
ant-design-vue
"
;
}
from
"
ant-design-vue
"
;
import
PageHeaderWrapper
from
"
@/components/PageHeaderWrapper
"
;
import
PageHeaderWrapper
from
"
@/components/PageHeaderWrapper
"
;
import
DescriptionItem
from
"
@/components/DescriptionItem
"
;
import
DescriptionItem
from
"
@/components/DescriptionItem
"
;
...
@@ -237,20 +237,24 @@ export default {
...
@@ -237,20 +237,24 @@ export default {
newFileList
.
splice
(
index
,
1
);
newFileList
.
splice
(
index
,
1
);
this
.
fileList
=
newFileList
;
this
.
fileList
=
newFileList
;
},
},
beforeLogoUpload
(
file
)
{
handleLogoChange
(
file
)
{
this
.
logo
=
file
;
this
.
logo
=
file
;
return
false
;
},
},
beforeUpload
(
file
)
{
beforeUpload
(
file
)
{
if
(
file
.
size
/
1024
/
1024
>
2
)
{
message
.
error
(
"
Image must smaller than 2MB!
"
);
}
return
false
;
},
handleSourceFileChange
(
file
)
{
this
.
fileList
=
[...
this
.
fileList
,
file
];
this
.
fileList
=
[...
this
.
fileList
,
file
];
const
status
=
file
.
file
.
status
;
const
isLt2M
=
file
.
size
/
1024
/
1024
<
2
;
if
(
status
===
'
done
'
)
{
if
(
!
isLt2M
)
{
message
.
success
(
`
${
file
.
file
.
name
}
file uploaded successfully.`
);
this
.
$message
.
error
(
"
Image must smaller than 2MB!
"
);
}
else
if
(
status
===
'
error
'
)
{
message
.
error
(
`
${
file
.
file
.
name
}
file upload failed.`
);
}
}
return
false
;
},
},
handleUpload
()
{
handleUpload
()
{
this
.
uploading
=
true
;
this
.
uploading
=
true
;
...
@@ -268,36 +272,17 @@ export default {
...
@@ -268,36 +272,17 @@ export default {
this
.
postApplication
(
formData
)
this
.
postApplication
(
formData
)
},
},
handleSourceFileChange
(
info
)
{
const
status
=
info
.
file
.
status
;
if
(
status
!==
'
uploading
'
)
{
console
.
log
(
info
.
file
,
info
.
fileList
);
}
if
(
status
===
'
done
'
)
{
this
.
$message
.
success
(
`
${
info
.
file
.
name
}
file uploaded successfully.`
);
}
else
if
(
status
===
'
error
'
)
{
this
.
$message
.
error
(
`
${
info
.
file
.
name
}
file upload failed.`
);
}
},
onChange
(
e
)
{
console
.
log
(
`checked =
${
e
.
target
.
value
}
`
);
},
handleChange
(
value
)
{
console
.
log
(
`selected
${
value
}
`
);
},
postApplication
(
formData
)
{
postApplication
(
formData
)
{
postApplication
(
formData
).
then
(
res
=>
{
postApplication
(
formData
).
then
(
res
=>
{
console
.
log
(
res
)
// this.fileList = [];
this
.
fileList
=
[];
// this.logo = null;
this
.
logo
=
null
;
// this.post.fileList = [];
this
.
post
.
fileList
=
[];
// this.post.logo = null;
this
.
post
.
logo
=
null
;
this
.
uploading
=
false
;
this
.
uploading
=
false
;
this
.
$message
.
success
(
'
upload successfully.
'
);
message
.
success
(
res
.
msg
);
}).
catch
(
err
=>
{
}).
catch
(
err
=>
{
console
.
log
(
err
)
this
.
uploading
=
false
;
this
.
uploading
=
false
;
this
.
$message
.
error
(
'
upload failed.
'
);
message
.
error
(
err
.
msg
);
})
})
},
},
onSumbit
()
{
onSumbit
()
{
...
...
tools/frontend/src/views/User/Login.vue
View file @
796e9b1b
...
@@ -165,7 +165,8 @@ export default {
...
@@ -165,7 +165,8 @@ export default {
.
then
((
res
)
=>
{
.
then
((
res
)
=>
{
this
.
$store
.
commit
(
"
frontend/login/setToken
"
,
res
.
data
.
token
);
this
.
$store
.
commit
(
"
frontend/login/setToken
"
,
res
.
data
.
token
);
this
.
$store
.
commit
(
"
frontend/login/setUserInfo
"
,
{
uuid
:
res
.
data
.
uuid
,
name
:
res
.
data
.
name
});
this
.
$store
.
commit
(
"
frontend/login/setUserInfo
"
,
{
uuid
:
res
.
data
.
uuid
,
name
:
res
.
data
.
name
});
message
.
success
(
res
.
msg
)
message
.
success
(
res
.
msg
);
window
.
sessionStorage
.
setItem
(
"
Authorization
"
,
res
.
data
.
token
)
this
.
$router
.
push
({
path
:
"
/
"
});
this
.
$router
.
push
({
path
:
"
/
"
});
})
})
.
catch
((
err
)
=>
{
.
catch
((
err
)
=>
{
...
...
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