Commit 3e256a15 authored by wanli's avatar wanli

🐞 fix: 增加EVM模块生成器

parent ca07dd6a
[submodule "evm_module_tools"]
path = evm_module_tools
url = ssh://git@47.105.117.50:2224/djf/evm_module_tools.git
''' '''
Author: your name Author: your name
Date: 2021-04-14 14:12:18 Date: 2021-04-14 14:12:18
LastEditTime: 2021-07-01 11:39:27 LastEditTime: 2021-11-10 10:20:27
LastEditors: Please set LastEditors LastEditors: Seven
Description: In User Settings Edit Description: In User Settings Edit
FilePath: \evm-store\backend\controller\api_manager.py FilePath: \evm-store\backend\controller\api_manager.py
''' '''
...@@ -86,11 +86,10 @@ class ApiManager(object): ...@@ -86,11 +86,10 @@ class ApiManager(object):
if not os.path.exists(output_path): if not os.path.exists(output_path):
os.makedirs(output_path) os.makedirs(output_path)
print("#######", output_path)
# print(os.path.dirname(os.getcwd()), os.path.abspath("../opqcp/opqcp")) # print(os.path.dirname(os.getcwd()), os.path.abspath("../opqcp/opqcp"))
result = os.system("./opqcp {i} ./out".format(i=os.path.basename(target_file))) result = os.system("./opqcp {i} ./out".format(i=os.path.basename(target_file)))
print(result) logger.debug(result)
# command = ["./opqcp", os.path.basename(target_file), "./"] # command = ["./opqcp", os.path.basename(target_file), "./"]
fname = os.sep.join([os.getcwd(), "out", os.path.basename(target_file)]) fname = os.sep.join([os.getcwd(), "out", os.path.basename(target_file)])
......
...@@ -71,7 +71,7 @@ class Auth(object): ...@@ -71,7 +71,7 @@ class Auth(object):
# result = re.match(r'[+-/*\w]+\.[+-/*\w]+\.[+/*-\w]+', auth_token, re.I) # result = re.match(r'[+-/*\w]+\.[+-/*\w]+\.[+/*-\w]+', auth_token, re.I)
# if not result or not result.group(): # if not result or not result.group():
# return False, "token invaild" # return False, "token invaild"
payload = jwt.decode(auth_token, current_app.config['SECRET_KEY'], verify=True, algorithms=['HS256'], options={'require': ['exp', 'iss', 'sub', 'aud', 'iat', 'data']}, audience="bytecode") payload = jwt.decode(auth_token, current_app.config['SECRET_KEY'], verify=False, algorithms=['HS256'], options={'require': ['exp', 'iss', 'sub', 'aud', 'iat', 'data']}, audience="bytecode")
if payload: if payload:
return True, payload return True, payload
else: else:
......
altgraph==0.17.2
appdirs==1.4.4 appdirs==1.4.4
APScheduler==3.6.3
astroid==2.4.2
autopep8==1.5.4
backcall==0.2.0
certifi==2020.12.5 certifi==2020.12.5
chardet==4.0.0 chardet==4.0.0
click==7.1.2 click==7.1.2
colorama==0.4.4
cx-Freeze==6.6 cx-Freeze==6.6
cx-Logging==3.0 cx-Logging==3.0
Cython==0.29.21
decorator==4.4.2
et-xmlfile==1.1.0
Flask==1.1.2 Flask==1.1.2
Flask-Cors==3.0.10 Flask-Cors==3.0.10
Flask-Login==0.5.0 Flask-Login==0.5.0
freetype-py==2.2.0
fs==2.4.12 fs==2.4.12
future==0.18.2
greenlet==1.1.0 greenlet==1.1.0
idna==2.10 idna==2.10
importlib-metadata==4.0.1 importlib-metadata==4.0.1
ipykernel==5.4.2
ipython==7.19.0
ipython-genutils==0.2.0
isort==5.6.4
itsdangerous==1.1.0 itsdangerous==1.1.0
jedi==0.17.2
Jinja2==2.11.3 Jinja2==2.11.3
jupyter-client==6.1.7
jupyter-core==4.7.0
lazy-object-proxy==1.4.3
MarkupSafe==1.1.1 MarkupSafe==1.1.1
marshmallow==3.10.0 marshmallow==3.10.0
mccabe==0.6.1
nanoid==2.0.0
openpyxl==3.0.9
parso==0.7.1
pefile==2021.9.3
pickleshare==0.7.5
ply==3.11
pony==0.7.14 pony==0.7.14
prompt-toolkit==3.0.8
psutil==5.7.3
pycodestyle==2.6.0
Pygments==2.7.3
pyinstaller==4.4
pyinstaller-hooks-contrib==2021.3
PyJWT==2.0.1 PyJWT==2.0.1
pylint==2.6.0
PyMySQL==0.10.1
python-dateutil==2.8.1
pytz==2021.1 pytz==2021.1
pywin32==300
pywin32-ctypes==0.2.0
pyzmq==20.0.0
requests==2.25.1 requests==2.25.1
robotpy-cppheaderparser==5.0.15
sh==1.14.1
six==1.15.0 six==1.15.0
SQLAlchemy==1.4.22 SQLAlchemy==1.4.22
toml==0.10.2
torch==1.10.0
tornado==6.1 tornado==6.1
traitlets==5.0.5
typing-extensions==3.10.0.0 typing-extensions==3.10.0.0
tzlocal==2.1
urllib3==1.26.4 urllib3==1.26.4
wcwidth==0.2.5
Werkzeug==1.0.1 Werkzeug==1.0.1
wrapt==1.12.1
zipp==3.4.1 zipp==3.4.1
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os
import sys import sys
from pathlib import Path
sys.path.append("..") sys.path.append("..")
from utils import vbuild # from utils import vbuild
content = vbuild.render("./index.evue") # content = vbuild.render("./index.evue")
print(content.html) # print(content.html)
print(content.style) # print(content.style)
print(content.script) # print(content.script)
\ No newline at end of file
if __name__ == "__main__":
target_dir = Path(os.getcwd())
for root, dirs, files in os.walk(target_dir.resolve().as_posix()):
print(root, dirs, files)
\ No newline at end of file
{"off_t": "long", "BYTE": "uint8_t", "FRESULT": "int8_t", "TCHAR": "char", "DSTATUS": "int", "DRESULT": "int", "str_String": "int"}
\ No newline at end of file
...@@ -10,10 +10,8 @@ import time ...@@ -10,10 +10,8 @@ import time
import zipfile import zipfile
from pathlib import Path from pathlib import Path
from datetime import datetime from datetime import datetime
from flask import Blueprint, request, json from flask import Blueprint, request, json
from werkzeug.utils import secure_filename from werkzeug.utils import secure_filename
from app import config, signalManager from app import config, signalManager
from fullstack.log import logger from fullstack.log import logger
from fullstack.login import Auth from fullstack.login import Auth
...@@ -25,6 +23,9 @@ sys.path.append("..") ...@@ -25,6 +23,9 @@ sys.path.append("..")
from utils import vbuild from utils import vbuild
from utils.evuefonttool import EvueFontTool from utils.evuefonttool import EvueFontTool
from utils.mkromfs import mkromfs from utils.mkromfs import mkromfs
sys.path.append("../..")
from evm_module_tools.code import generate_from_list, compress_files
from evm_module_tools.cpp_header_parse import parse_header_file, update_mark_type, get_mark_type_list
api = Blueprint("api", __name__, url_prefix="/api/v1/%s" % config['NAME']) api = Blueprint("api", __name__, url_prefix="/api/v1/%s" % config['NAME'])
...@@ -72,7 +73,6 @@ def get_store(): ...@@ -72,7 +73,6 @@ def get_store():
with open("./apiData.json", "r", encoding="utf-8") as f: with open("./apiData.json", "r", encoding="utf-8") as f:
result = json.loads(f.read()) result = json.loads(f.read())
logger.info(request.args)
# logger.info(request.query_string) # logger.info(request.query_string)
if request.args and request.args.get("category"): if request.args and request.args.get("category"):
res = [] res = []
...@@ -246,8 +246,6 @@ def update_password(): ...@@ -246,8 +246,6 @@ def update_password():
@api.route("/upload", methods=['POST']) # 上传文件 @api.route("/upload", methods=['POST']) # 上传文件
def upload_file(): def upload_file():
try: try:
result = None
binfile = request.files.get("binfile") binfile = request.files.get("binfile")
if not binfile: if not binfile:
return response_result(ResponseCode.REQUEST_ERROR, msg="upload field name error") return response_result(ResponseCode.REQUEST_ERROR, msg="upload field name error")
...@@ -293,7 +291,6 @@ def upload_file(): ...@@ -293,7 +291,6 @@ def upload_file():
def update_db(): def update_db():
result = [] result = []
for index in range(16): for index in range(16):
print(index)
result.append(str(uuid.uuid1())) result.append(str(uuid.uuid1()))
# conn = sqlite3.connect('./app-store.db') # conn = sqlite3.connect('./app-store.db')
...@@ -319,15 +316,10 @@ def generate_font(): ...@@ -319,15 +316,10 @@ def generate_font():
if not sizes: if not sizes:
return response_result(ResponseCode.PARAMETER_ERROR, msg="param sizes can not be null") return response_result(ResponseCode.PARAMETER_ERROR, msg="param sizes can not be null")
# 判断用户输入的字体大小是否合法
logger.info(sizes)
font = request.files.get("font", None) font = request.files.get("font", None)
if not font: if not font:
return response_result(ResponseCode.PARAMETER_ERROR, msg="param font can not be null") return response_result(ResponseCode.PARAMETER_ERROR, msg="param font can not be null")
logger.info(font.content_type)
# 保存字体文件到临时目录 # 保存字体文件到临时目录
random_str = uuid.uuid4().hex random_str = uuid.uuid4().hex
temp_dir = Path(os.path.dirname(os.path.dirname(__file__))).joinpath("temp").joinpath(random_str) temp_dir = Path(os.path.dirname(os.path.dirname(__file__))).joinpath("temp").joinpath(random_str)
...@@ -370,6 +362,152 @@ def generate_font(): ...@@ -370,6 +362,152 @@ def generate_font():
'url': target_dir.joinpath(filename).resolve().relative_to(config.get("UPLOAD_PATH")).as_posix(), 'url': target_dir.joinpath(filename).resolve().relative_to(config.get("UPLOAD_PATH")).as_posix(),
}) })
@api.route("/system/parseCHeader", methods=["POST"])
def parse_header_files():
# 获取上传的文件,另存到uploads文件夹中。文件名命名规则为:时间/源文件内容
# 遍历这些上传的文件,逐个解析
# 获取解析完成后的返回结果
# 如果有错误,则向前端提示错误
# 如果没有错误,则向前端返回下载地址。最终需要打包成压缩文件,放到nginx负载的公网目录下
if len(request.files.getlist('binfile')) < 0:
return response_result(ResponseCode.REQUEST_ERROR, msg="nothing upload")
target_path = Path(config.get("UPLOAD_PATH")).joinpath(config.get("UPLOAD_DIR"))
if not target_path.exists():
target_path.mkdir()
target_path = target_path.joinpath(uuid.uuid1().hex)
if not target_path.exists():
target_path.mkdir()
binfile = request.files.getlist("binfile")
if not binfile:
return response_result(ResponseCode.REQUEST_ERROR, msg="nothing upload...")
files = []
for f in request.files.getlist('binfile'):
target = target_path.joinpath(f.filename)
if target.suffix not in [".h"]:
continue
with open(target.resolve().as_posix(), "wb+") as fd:
fd.write(f.stream.read())
files.append(target)
# 加载系统内置类型映射文件
config_file = "typeconfig.json"
typeconfig = {}
if os.path.exists(config_file):
with open(config_file, "r") as f:
typeconfig = json.loads(f.read())
if len(typeconfig.keys()) > 0:
update_mark_type(typeconfig)
try:
undefined_type = []
error_tips = []
result_list = []
for file in files:
result = parse_header_file(file.resolve().as_posix(), undefined_type, error_tips)
if result != None:
target = target_path.joinpath(".json".format(file.name))
with open(target.resolve().as_posix(), "w+") as f:
f.write(json.dumps(result))
result_list.append(result)
target_dir = Path(config.get("UPLOAD_PATH")).joinpath(config.get("UPLOAD_DIR")).resolve().as_posix()
if len(result_list) > 0:
path_list = generate_from_list(result_list)
target_file = compress_files(path_list, target_dir)
if len(undefined_type) > 0: # 说明有用户自定义的类型,需要用户标注这些类型
return response_result(ResponseCode.REQUEST_ERROR, data={ 'undefined_type': undefined_type, 'dir': target_path.name }, msg=error_tips)
else: # 没啥问题,返回下载地址给前端
target_file = Path(target_file).relative_to(Path(config.get("UPLOAD_PATH"))).as_posix()
return response_result(ResponseCode.OK, data={ "filename": os.path.basename(target_file), "url": target_file })
except Exception as e:
traceback.print_exc()
logger.error(str(e))
return response_result(ResponseCode.SERVER_ERROR, msg=str(e))
@api.route("/system/processParse", methods=['POST'])
def process_parse():
# 校验参数,没有参数则不处理
# 判断目录是否存在
# 获取该目录下所有文件
# 更新标记类型json文件
# 解析头文件
params = request.json
if len(params) <= 0:
return response_result(ResponseCode.PARAMETER_NULL)
target_dir = Path(config.get("UPLOAD_PATH")).joinpath(config.get("UPLOAD_DIR")).joinpath(params["dir"])
if not target_dir.exists():
return response_result(ResponseCode.INVAILD_REQUEST, msg="target directory not exists")
# 加载系统内置类型映射文件
config_file = "typeconfig.json"
typeconfig = {}
if os.path.exists(config_file):
with open(config_file, "r") as f:
typeconfig = json.loads(f.read())
if not typeconfig:
typeconfig = {}
if isinstance(params["type"], dict) and len(params["type"].keys()) > 0:
typeconfig.update(params["type"])
if len(typeconfig.keys()) > 0:
conf = update_mark_type(typeconfig)
with open(config_file, "w") as f:
f.write(json.dumps(conf))
try:
undefined_type = []
error_tips = []
result_list = []
for root, dirs, files in os.walk(target_dir.resolve().as_posix()):
target_file = Path(root)
for file in files:
target_file = target_file.joinpath(file)
if target_file.exists():
result = parse_header_file(target_file.resolve().as_posix(), undefined_type, error_tips)
if result != None:
target = target_file.parent.joinpath("{}.json".format(target_file.name))
with open(target.resolve().as_posix(), "w+") as f:
f.write(json.dumps(result))
result_list.append(result)
target_dir = Path(config.get("UPLOAD_PATH")).joinpath(config.get("UPLOAD_DIR")).resolve().as_posix()
if len(result_list) > 0:
path_list = generate_from_list(result_list)
target_file = compress_files(path_list, target_dir)
if len(undefined_type) <= 0:
target_file = Path(target_file).relative_to(Path(config.get("UPLOAD_PATH"))).as_posix()
return response_result(ResponseCode.OK, data={ "filename": os.path.basename(target_file), "url": target_file })
else:
return response_result(ResponseCode.REQUEST_ERROR, data={ 'undefined_type': undefined_type, 'dir': params["dir"] }, msg=error_tips)
except Exception as e:
traceback.print_exc()
logger.error(str(e))
return response_result(ResponseCode.SERVER_ERROR, msg=str(e))
@api.route("/system/getMarkType", methods=['GET'])
def get_mark_type():
data = get_mark_type_list()
return response_result(ResponseCode.OK, data=data)
@api.route("/system/updateMarkType", methods=['POST'])
def modify_mark_type():
params = request.json
data = update_mark_type(params)
return response_result(ResponseCode.OK, data=data)
@api.route("/system/convertString", methods=['POST']) @api.route("/system/convertString", methods=['POST'])
@validate_schema(ConvertString) @validate_schema(ConvertString)
def convert_string(): def convert_string():
......
Subproject commit 0ec1baa3d93da20ef57c3dd937c19ac80bf9abad
...@@ -32,6 +32,37 @@ export function postByteCodeFile(data) { ...@@ -32,6 +32,37 @@ export function postByteCodeFile(data) {
}); });
} }
export function postCHeaderFile(data) {
return request({
url: "/api/v1/evm_store/system/parseCHeader",
method: "post",
data
});
}
export function processCHeaderFile(data) {
return request({
url: "/api/v1/evm_store/system/processParse",
method: "post",
data
});
}
export function updateMarkType(data) {
return request({
url: "/api/v1/evm_store/system/updateMarkType",
method: "post",
data
});
}
export function getMarkType() {
return request({
url: "/api/v1/evm_store/system/getMarkType",
method: "get",
});
}
export function getWatchList() { export function getWatchList() {
return request({ return request({
url: "/api/v1/evm_store/watch", url: "/api/v1/evm_store/watch",
......
...@@ -50,7 +50,7 @@ export const constantRoutes = [ ...@@ -50,7 +50,7 @@ export const constantRoutes = [
children: [{ children: [{
path: 'index', path: 'index',
name: 'Gallery', name: 'Gallery',
component: () => import('@/views/app-store/gallery'), component: () => import('@/views/store/gallery'),
meta: { title: '商店首页', icon: 'home' } meta: { title: '商店首页', icon: 'home' }
}] }]
}, },
...@@ -61,7 +61,7 @@ export const constantRoutes = [ ...@@ -61,7 +61,7 @@ export const constantRoutes = [
children: [{ children: [{
path: 'index', path: 'index',
name: 'Application', name: 'Application',
component: () => import('@/views/app-store/app'), component: () => import('@/views/store/app'),
meta: { title: '应用详情', icon: 'home' } meta: { title: '应用详情', icon: 'home' }
}] }]
}, },
...@@ -72,7 +72,7 @@ export const constantRoutes = [ ...@@ -72,7 +72,7 @@ export const constantRoutes = [
children: [{ children: [{
path: 'index', path: 'index',
name: 'AppList', name: 'AppList',
component: () => import('@/views/app-store/list'), component: () => import('@/views/store/list'),
meta: { title: '游戏', icon: 'home' } meta: { title: '游戏', icon: 'home' }
}] }]
}, },
...@@ -83,7 +83,7 @@ export const constantRoutes = [ ...@@ -83,7 +83,7 @@ export const constantRoutes = [
children: [{ children: [{
path: 'index', path: 'index',
name: 'AppCategory', name: 'AppCategory',
component: () => import('@/views/app-store/category'), component: () => import('@/views/store/category'),
meta: { title: '应用分类', icon: 'home' } meta: { title: '应用分类', icon: 'home' }
}] }]
}, },
...@@ -94,7 +94,7 @@ export const constantRoutes = [ ...@@ -94,7 +94,7 @@ export const constantRoutes = [
children: [{ children: [{
path: 'index', path: 'index',
name: 'AppRank', name: 'AppRank',
component: () => import('@/views/app-store/rank'), component: () => import('@/views/store/rank'),
meta: { title: '应用排行', icon: 'home' } meta: { title: '应用排行', icon: 'home' }
}] }]
}, },
...@@ -105,7 +105,7 @@ export const constantRoutes = [ ...@@ -105,7 +105,7 @@ export const constantRoutes = [
children: [{ children: [{
path: 'index', path: 'index',
name: 'AppTopic', name: 'AppTopic',
component: () => import('@/views/app-store/topic'), component: () => import('@/views/store/topic'),
meta: { title: '应用排行', icon: 'home' } meta: { title: '应用排行', icon: 'home' }
}] }]
}, },
...@@ -116,7 +116,7 @@ export const constantRoutes = [ ...@@ -116,7 +116,7 @@ export const constantRoutes = [
children: [{ children: [{
path: 'index', path: 'index',
name: 'AppSearch', name: 'AppSearch',
component: () => import('@/views/app-store/search'), component: () => import('@/views/store/search'),
meta: { title: '搜索应用', icon: 'home' } meta: { title: '搜索应用', icon: 'home' }
}] }]
}, },
...@@ -127,7 +127,7 @@ export const constantRoutes = [ ...@@ -127,7 +127,7 @@ export const constantRoutes = [
children: [{ children: [{
path: 'index', path: 'index',
name: 'AppProfile', name: 'AppProfile',
component: () => import('@/views/app-store/profile'), component: () => import('@/views/store/profile'),
meta: { title: '个人中心', icon: 'shangcheng' } meta: { title: '个人中心', icon: 'shangcheng' }
}] }]
}, },
...@@ -138,7 +138,7 @@ export const constantRoutes = [ ...@@ -138,7 +138,7 @@ export const constantRoutes = [
children: [{ children: [{
path: 'index', path: 'index',
name: 'AppAuth', name: 'AppAuth',
component: () => import('@/views/app-store/auth'), component: () => import('@/views/store/auth'),
meta: { title: '账号认证', icon: 'shangcheng' } meta: { title: '账号认证', icon: 'shangcheng' }
}] }]
}, },
...@@ -149,7 +149,7 @@ export const constantRoutes = [ ...@@ -149,7 +149,7 @@ export const constantRoutes = [
children: [{ children: [{
path: 'index', path: 'index',
name: 'Developer', name: 'Developer',
component: () => import('@/views/app-store/developer'), component: () => import('@/views/store/developer'),
meta: { title: '开发者中心', icon: 'home' } meta: { title: '开发者中心', icon: 'home' }
}] }]
}, },
...@@ -160,7 +160,7 @@ export const constantRoutes = [ ...@@ -160,7 +160,7 @@ export const constantRoutes = [
children: [{ children: [{
path: 'index', path: 'index',
name: 'Document', name: 'Document',
component: () => import('@/views/app-store/docs'), component: () => import('@/views/store/docs'),
meta: { title: '开发文档', icon: 'shangcheng' } meta: { title: '开发文档', icon: 'shangcheng' }
}] }]
}, },
...@@ -197,6 +197,17 @@ export const constantRoutes = [ ...@@ -197,6 +197,17 @@ export const constantRoutes = [
meta: { title: '字体转换工具', icon: 'home' } meta: { title: '字体转换工具', icon: 'home' }
}] }]
}, },
{
path: '/tool',
redirect: '/tool/evm-module',
component: Layout,
children: [{
path: 'evm-module',
name: 'EvmModule',
component: () => import('@/views/system/evm-module-tool.vue'),
meta: { title: 'EVM模块注册工具', icon: 'home' }
}]
},
{ {
path: '/tool', path: '/tool',
redirect: '/tool/index', redirect: '/tool/index',
...@@ -292,7 +303,7 @@ export const constantRoutes = [ ...@@ -292,7 +303,7 @@ export const constantRoutes = [
children: [{ children: [{
path: 'index', path: 'index',
name: 'Page404', name: 'Page404',
component: () => import('@/views/error-pages/404'), component: () => import('@/views/error/404'),
meta: { title: '404', icon: 'home' } meta: { title: '404', icon: 'home' }
}] }]
}, },
...@@ -303,7 +314,7 @@ export const constantRoutes = [ ...@@ -303,7 +314,7 @@ export const constantRoutes = [
children: [{ children: [{
path: 'index', path: 'index',
name: 'Page403', name: 'Page403',
component: () => import('@/views/error-pages/403'), component: () => import('@/views/error/403'),
meta: { title: '403', icon: 'home' } meta: { title: '403', icon: 'home' }
}] }]
}, },
...@@ -314,7 +325,7 @@ export const constantRoutes = [ ...@@ -314,7 +325,7 @@ export const constantRoutes = [
children: [{ children: [{
path: 'index', path: 'index',
name: 'NotFound', name: 'NotFound',
component: () => import('@/views/error-pages/not-found'), component: () => import('@/views/error/not-found'),
meta: { title: 'not-found', icon: 'home' } meta: { title: 'not-found', icon: 'home' }
}] }]
}, },
......
...@@ -64,13 +64,6 @@ export default { ...@@ -64,13 +64,6 @@ export default {
icon: "gongzuotai", icon: "gongzuotai",
path: "monitor/index", path: "monitor/index",
}, },
// {
// vue: "system/chart.vue",
// title: "实时曲线",
// name: "AppChart",
// icon: "gongzuotai",
// path: "chart/index",
// },
{ {
vue: "system/font-tool.vue", vue: "system/font-tool.vue",
title: "字体转换工具", title: "字体转换工具",
...@@ -92,6 +85,13 @@ export default { ...@@ -92,6 +85,13 @@ export default {
icon: "gongzuotai", icon: "gongzuotai",
path: "evue/index", path: "evue/index",
}, },
{
vue: "system/evm-module-tool.vue",
title: "EVM模块注册工具",
name: "EvmModule",
icon: "gongzuotai",
path: "tool/evm-module",
},
{ {
vue: "app-store/docs.vue", vue: "app-store/docs.vue",
title: "开发文档", title: "开发文档",
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
</div> </div>
</template> </template>
<script> <script>
import { getTabList, getDataList } from "@/api/app-store"; import { getTabList, getDataList } from "@/api/store";
import { Circle5 } from "vue-loading-spinner"; import { Circle5 } from "vue-loading-spinner";
import StarRating from "vue-star-rating"; import StarRating from "vue-star-rating";
export default { export default {
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
</div> </div>
</template> </template>
<script> <script>
import { getTabList, getDataList } from "@/api/app-store"; import { getTabList, getDataList } from "@/api/store";
import { Circle5 } from "vue-loading-spinner"; import { Circle5 } from "vue-loading-spinner";
import StarRating from "vue-star-rating"; import StarRating from "vue-star-rating";
export default { export default {
......
...@@ -141,7 +141,7 @@ ...@@ -141,7 +141,7 @@
</div> </div>
</template> </template>
<script> <script>
import { getDataList } from "@/api/app-store"; import { getDataList } from "@/api/store";
import StarRating from "vue-star-rating"; import StarRating from "vue-star-rating";
export default { export default {
name: "AppRank", name: "AppRank",
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
</div> </div>
</template> </template>
<script> <script>
import { getTopicList } from "@/api/app-store"; import { getTopicList } from "@/api/store";
export default { export default {
name: "AppTopic", name: "AppTopic",
data() { data() {
......
...@@ -250,7 +250,7 @@ import { ...@@ -250,7 +250,7 @@ import {
rebuildApp, rebuildApp,
updateApp, updateApp,
getBuildApp, getBuildApp,
} from "@/api/app-store"; } from "@/api/store";
import { mapTrim, download } from "@/utils/index"; import { mapTrim, download } from "@/utils/index";
export default { export default {
......
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
</div> </div>
</template> </template>
<script> <script>
import { getAppLogsList } from "@/api/app-store"; import { getAppLogsList } from "@/api/store";
import { mapTrim } from "@/utils/index"; import { mapTrim } from "@/utils/index";
export default { export default {
......
...@@ -29,8 +29,7 @@ ...@@ -29,8 +29,7 @@
</div> </div>
</template> </template>
<script> <script>
import { fetchData } from "@/api/index"; import { postByteCodeFile } from "@/api/store";
import { postByteCodeFile } from "@/api/app-store";
export default { export default {
name: "ByteCodeFile", name: "ByteCodeFile",
...@@ -94,20 +93,9 @@ export default { ...@@ -94,20 +93,9 @@ export default {
this.$message.error(err.message); this.$message.error(err.message);
}); });
}, },
fetchData() {
fetchData()
.then((res) => {
console.log(res);
})
.catch((err) => {
console.log(err);
});
},
}, },
mounted() {}, mounted() {},
created() { created() {},
this.fetchData();
},
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
</div> </div>
</template> </template>
<script> <script>
import { getDeviceList, deleteDevice, addDevice, updateDevice } from '@/api/app-store' import { getDeviceList, deleteDevice, addDevice, updateDevice } from '@/api/store'
import { mapTrim, compareObjectDiff } from '@/utils/index' import { mapTrim, compareObjectDiff } from '@/utils/index'
export default { export default {
......
<template>
<div class="app-container">
<div style="margin: 0px 0px 10px 0px">
<el-alert
title="根据C头文件自动生成EVM模块注册代码"
type="success"
></el-alert>
</div>
<el-tabs v-model="activeName" type="border-card">
<el-tab-pane label="解析文件" name="first">
<div style="margin: 10px 0px">
<el-form>
<el-form-item>
<el-upload
name="binfile"
drag
multiple
ref="upload"
action="null"
:auto-upload="false"
:http-request="handleUploadFile"
:on-remove="handleUploadRemove"
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">
将文件拖到此处,或<em>点击上传</em>
</div>
<div class="el-upload__tip" slot="tip">请选择C头文件</div>
</el-upload>
</el-form-item>
<el-form-item>
<el-button @click="uploadFile">开始上传</el-button>
</el-form-item>
</el-form>
</div>
</el-tab-pane>
<el-tab-pane label="类型管理" name="second">
<el-table :data="markType" size="medium" style="width: 50%">
<el-table-column prop="key" label="typedef类型" min-width="180">
</el-table-column>
<el-table-column prop="value" label="实际类型" min-width="180">
<template slot-scope="scope">
<el-row :gutter="20">
<el-col :span="12">
<el-select
v-model="scope.row.value"
placeholder="请选择C的实际类型"
>
<el-option
v-for="item in baseType"
:key="item.value"
:label="item.label"
:value="item.value"
></el-option>
</el-select>
</el-col>
<el-col :span="12">
<el-button
type="primaey"
size="medium"
@click="updateMarkType(scope.row)"
>更新值</el-button
>
</el-col>
</el-row>
</template>
</el-table-column>
</el-table>
</el-tab-pane>
</el-tabs>
<el-dialog title="提示" width="50%" :visible.sync="dialogVisible">
<el-table :data="error_tips">
<el-table-column
property="file"
label="文件"
min-width="300"
></el-table-column>
<el-table-column
property="line"
label="行数"
min-width="50"
></el-table-column>
<el-table-column
property="func"
label="函数"
min-width="100"
></el-table-column>
<el-table-column
property="type"
label="类型"
min-width="80"
></el-table-column>
<el-table-column label="类型标记" min-width="280">
<template slot-scope="scope">
<el-select
v-model="scope.row.mark"
placeholder="请选择该类型在C语言中所属的基本类型"
>
<el-option
v-for="(item, index) in baseType"
:key="index"
:label="item.label"
:value="item.value"
></el-option>
</el-select>
</template>
</el-table-column>
</el-table>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false">取 消</el-button>
<el-button type="primary" @click="processParse">确 定</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import {
postCHeaderFile,
processCHeaderFile,
getMarkType,
updateMarkType,
} from "@/api/store";
export default {
name: "EvmModule",
data() {
return {
activeName: "first",
fileList: [],
page: "evm-module-tool.vue",
dir: null,
baseType: [
{ label: "整型", value: "int" },
{ label: "单精度浮点型", value: "float" },
{ label: "双精度浮点型", value: "double" },
{ label: "字符串", value: "char *" },
{ label: "指针", value: "void *" },
{ label: "void", value: "void" },
],
undefined_type: [],
error_tips: [],
dialogVisible: false,
markType: [],
};
},
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.downloadFile(response);
} else {
this.$message.warning(response.message);
}
},
handleUploadFile(file) {
this.fileList.push(file);
},
handleUploadRemove(file, fileList) {
console.log(fileList);
for (let i = 0; i < this.fileList.length; i++) {
if (this.fileList[i].uid == file.uid) {
this.fileList.splice(i, 1);
break;
}
}
},
downloadFile(result) {
const a = document.createElement("a");
a.download = result.data.filename;
a.href = result.data.url;
a.target = "";
a.click();
},
updateMarkType(row) {
updateMarkType(row)
.then((res) => {
this.$message.success(res.message);
})
.catch((err) => {
this.$message.error(err.message);
});
},
getMarkType() {
getMarkType()
.then((res) => {
Object.keys(res.data).forEach((k) => {
this.markType.push({ key: k, value: res.data[k] });
});
})
.catch((err) => {
console.log(err);
});
},
uploadFile() {
this.$refs.upload.submit();
let formData = new FormData();
this.fileList.forEach((item) => {
formData.append("binfile", item.file);
});
postCHeaderFile(formData)
.then((res) => {
this.downloadFile(res);
})
.catch((err) => {
if (err.code == 400) {
this.dir = err.data.dir;
this.undefined_type = err.data.undefined_type;
this.error_tips = err.message;
this.dialogVisible = true;
} else {
this.$message.error(err.message);
}
})
.finally(() => {
this.fileList = [];
this.$refs.upload.clearFiles();
});
},
processParse() {
let types = {};
this.error_tips.forEach((item) => {
types[item.type] = item.mark;
});
processCHeaderFile({ dir: this.dir, type: types })
.then((res) => {
this.downloadFile(res);
})
.catch((err) => {
if (err.code == 400) {
this.dir = err.data.dir;
this.undefined_type = err.data.undefined_type;
this.error_tips = err.message;
this.dialogVisible = true;
} else {
this.$message.error(err.message);
}
})
.finally(() => {
this.fileList = [];
this.$refs.upload.clearFiles();
});
},
},
mounted() {},
created() {
this.getMarkType();
},
};
</script>
<style lang="scss" scoped>
.app-container {
& > div.page-wrapper {
margin: 10px 0px;
}
}
</style>
...@@ -29,8 +29,7 @@ ...@@ -29,8 +29,7 @@
</div> </div>
</template> </template>
<script> <script>
import { fetchData } from "@/api/index"; import { postByteCodeFile } from "@/api/store";
import { postByteCodeFile } from "@/api/app-store";
export default { export default {
name: "ByteCodeFile", name: "ByteCodeFile",
...@@ -92,22 +91,10 @@ export default { ...@@ -92,22 +91,10 @@ export default {
.catch((err) => { .catch((err) => {
this.$message.error(err.message); this.$message.error(err.message);
}); });
}, }
fetchData() {
fetchData()
.then((res) => {
console.log("打印来自evue.vue")
console.log(res);
})
.catch((err) => {
console.log(err);
});
},
}, },
mounted() {}, mounted() {},
created() { created() {},
this.fetchData()
},
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
......
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
<script> <script>
import allFonts from "@/assets/all-fonts.json"; import allFonts from "@/assets/all-fonts.json";
import commonFonts from "@/assets/common-used-fonts.json"; import commonFonts from "@/assets/common-used-fonts.json";
import { generateFont } from "@/api/app-store"; import { generateFont } from "@/api/store";
// import { mapTrim } from '@/utils/index' // import { mapTrim } from '@/utils/index'
// 优化:可以取字体差异,POST只发送产生差异的字,比如删除的字、添加的字 // 优化:可以取字体差异,POST只发送产生差异的字,比如删除的字、添加的字
......
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
</template> </template>
<script> <script>
import GithubCorner from '@/components/GithubCorner' import GithubCorner from '@/components/GithubCorner'
import { doLogin, getUser, doRegister } from "@/api/app-store" import { doLogin, getUser, doRegister } from "@/api/store"
import { strTrim } from "@/utils/index" import { strTrim } from "@/utils/index"
let loading = null; let loading = null;
......
...@@ -327,7 +327,7 @@ import { ...@@ -327,7 +327,7 @@ import {
getReport, getReport,
getTemplate, getTemplate,
setTemplate, setTemplate,
} from "@/api/app-store"; } from "@/api/store";
import EvmChart from "./components/EvmChart"; import EvmChart from "./components/EvmChart";
import LvglChart from "./components/LvglChart"; import LvglChart from "./components/LvglChart";
import SystemChart from "./components/SystemChart"; import SystemChart from "./components/SystemChart";
...@@ -872,7 +872,14 @@ export default { ...@@ -872,7 +872,14 @@ export default {
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import "./style.css";
.el-table .warning-row {
background: red;
}
.el-table .success-row {
background: #87e8de;
}
.app-container { .app-container {
& > div.page-wrapper { & > div.page-wrapper {
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
</div> </div>
</template> </template>
<script> <script>
import { actionOpqcp } from "@/api/app-store"; import { actionOpqcp } from "@/api/store";
export default { export default {
name: "Opqcp", name: "Opqcp",
......
.el-table .warning-row {
background: red;
}
.el-table .success-row {
background: #87e8de;
}
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
</div> </div>
</template> </template>
<script> <script>
import { getConvertString } from "@/api/app-store"; import { getConvertString } from "@/api/store";
export default { export default {
name: "AppTool", name: "AppTool",
......
...@@ -17,6 +17,8 @@ from models.menu import MenuModel ...@@ -17,6 +17,8 @@ from models.menu import MenuModel
from webcreator.log import logger from webcreator.log import logger
from webcreator.response import ResponseCode from webcreator.response import ResponseCode
count = 0
class MenuResource(object): class MenuResource(object):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
...@@ -31,6 +33,8 @@ class MenuResource(object): ...@@ -31,6 +33,8 @@ class MenuResource(object):
return return
# group found - print name and find children # group found - print name and find children
print('- ' * tab + group.name) print('- ' * tab + group.name)
global count
count = count + 1
for child_group in group.children: # type: TreeGroup for child_group in group.children: # type: TreeGroup
# new tabulation value for child record # new tabulation value for child record
self.print_tree(child_group.name, tab * 2) self.print_tree(child_group.name, tab * 2)
...@@ -92,7 +96,9 @@ class MenuResource(object): ...@@ -92,7 +96,9 @@ class MenuResource(object):
return True, ResponseCode.HTTP_SUCCESS return True, ResponseCode.HTTP_SUCCESS
def treeList(self, params={}, jwt={}): def treeList(self, params={}, jwt={}):
self.print_tree("home") # self.print_tree("home")
print("global count is ===========> ", count)
filters = [MenuModel.is_delete==False] filters = [MenuModel.is_delete==False]
result = db.session.query(MenuModel).filter(*filters).order_by(MenuModel.sort).order_by(MenuModel.update_at.desc()).all() result = db.session.query(MenuModel).filter(*filters).order_by(MenuModel.sort).order_by(MenuModel.update_at.desc()).all()
......
# !/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time : 2018-09-12 16:32
# @Author : Jackadam
# @Email :jackadam@sina.com
# @File : mptt.py
# @Software: PyCharm
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy_mptt import mptt_sessionmaker
from sqlalchemy import Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy_mptt.mixins import BaseNestedSets
Base = declarative_base()
class Tree(Base, BaseNestedSets):
__tablename__ = "tree"
id = Column(Integer, primary_key=True)
name = Column(String(8))
def __repr__(self):
return "<Node (%s)>" % self.id
engine = create_engine('sqlite:///mptt.db', echo=False)
mptt_ession = mptt_sessionmaker(sessionmaker(bind=engine))
db_session = scoped_session(sessionmaker(autocommit=False,
autoflush=False,
bind=engine))
def print_tree(group_name, tab=1):
"""
:param str group_name:要查找的树的根的名称
:param int tab: 格式化用的-数量
"""
group = db_session.query(Tree).filter_by(name=group_name).one_or_none()
if not group:
return
# group found - print name and find children
print('- ' * tab + group.name)
for child_group in group.children:
# new tabulation value for child record
print_tree(child_group.name, tab * 2)
if __name__ == '__main__':
# Base.metadata.create_all(bind=engine)
# nodes=[]
# node=Tree(name='中国')
# nodes.append(node)
# db_session.add_all(nodes)
# db_session.commit()
# nodes = []
# ref_id=db_session.query(Tree.id).filter_by(name='中国').first()[0]
# print(ref_id)
# new_name=['河南','河北','山东','山西','陕西']
# for i in new_name:
# print(i)
# node=Tree(name=i,parent_id=ref_id)
# nodes.append(node)
# db_session.add_all(nodes)
# db_session.commit()
# nodes = []
# ref_id = db_session.query(Tree.id).filter_by(name='河南').first()[0]
# print(ref_id)
# new_name = ['郑州', '洛阳', '开封', '新乡', '新郑']
# for i in new_name:
# print(i)
# node = Tree(name=i, parent_id=ref_id)
# nodes.append(node)
# db_session.add_all(nodes)
# db_session.commit()
print_tree('中国')
print_tree('河南')
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment