Commit 84822239 authored by wanli's avatar wanli

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

parent 253e2f1f
...@@ -171,12 +171,14 @@ def action_build(): ...@@ -171,12 +171,14 @@ 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())
files = []
if target.suffix == ".evue":
content = vbuild.render(target.resolve().as_posix()) content = vbuild.render(target.resolve().as_posix())
if content: if content:
files = [ files = [
...@@ -184,9 +186,15 @@ def action_build(): ...@@ -184,9 +186,15 @@ def action_build():
(target.parent.joinpath("{}.css".format(Path(f.filename).stem)).resolve().as_posix(), content.style), (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) (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: for item in files:
file, text = item file, text = item
if not text:
continue
if not isinstance(text, bool):
with open(file, "w+") as fd: with open(file, "w+") as fd:
fd.write(text) fd.write(text)
......
...@@ -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