Commit 84822239 authored by wanli's avatar wanli

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

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