Commit 84822239 authored by wanli's avatar wanli

:sparkles: feat(view/api.py):增加单文件解析

parent 253e2f1f
......@@ -171,29 +171,37 @@ def action_build():
for f in request.files.getlist('binfile'):
target = target_path.joinpath(f.filename)
if target.suffix != ".evue":
if target.suffix not in [".evue", ".js", ".css", ".hml", ".json"]:
continue
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)
]
files = []
if target.suffix == ".evue":
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)
]
else:
files = [(target.resolve().as_posix(), True)]
for item in files:
file, text = item
if not text:
continue
for item in files:
file, text = item
if not isinstance(text, bool):
with open(file, "w+") as fd:
fd.write(text)
result = subprocess.call("./executable -c {file}".format(file=file), shell=True)
new_name = "{}.{}".format(Path(file).name, "bc")
os.rename(os.sep.join([os.getcwd(), "executable.bc"]), os.sep.join([os.getcwd(), new_name]))
dst_files.append(Path(os.getcwd()).joinpath(new_name))
result = subprocess.call("./executable -c {file}".format(file=file), shell=True)
new_name = "{}.{}".format(Path(file).name, "bc")
os.rename(os.sep.join([os.getcwd(), "executable.bc"]), os.sep.join([os.getcwd(), new_name]))
dst_files.append(Path(os.getcwd()).joinpath(new_name))
for file in dst_files:
z.write(file.resolve().as_posix(), arcname=file.name)
......
......@@ -47,8 +47,11 @@ export default {
window.URL.revokeObjectURL(url);
},
handleUploaded(response) {
console.log(response);
this.downloadFile(response)
if (response.code === 200) {
this.downloadFile(response)
} else {
this.$message.warning(response.message)
}
},
downloadFile(result) {
const a = document.createElement("a");
......
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