Commit c4c7bf92 authored by wanli's avatar wanli

update

parent ca144cb6
No preview for this file type
...@@ -11,7 +11,7 @@ config = dict( ...@@ -11,7 +11,7 @@ config = dict(
NAME='evm_store', NAME='evm_store',
DEBUG=True, DEBUG=True,
HOST="0.0.0.0", HOST="0.0.0.0",
PORT=5000, PORT=9999,
SECRET_KEY='secret_key_EhuqUkwV', SECRET_KEY='secret_key_EhuqUkwV',
LOGIN_DISABLED=False, LOGIN_DISABLED=False,
BACKUP_DIR=conf.get('application', 'backup_dir'), BACKUP_DIR=conf.get('application', 'backup_dir'),
...@@ -25,7 +25,6 @@ config = dict( ...@@ -25,7 +25,6 @@ config = dict(
}, },
TABLE_PREFIX='evm_store_', TABLE_PREFIX='evm_store_',
MD5_SALT="EhuqUkwV", MD5_SALT="EhuqUkwV",
UPLOAD_SERVER="{}://{}:{}/".format(conf.get('uploads', 'protocol'), conf.get('uploads', 'host'), conf.get('uploads', 'port')),
UPLOAD_PATH=os.getcwd(), UPLOAD_PATH=os.getcwd(),
UPLOAD_DIR=conf.get('uploads', 'upload_dir'), UPLOAD_DIR=conf.get('uploads', 'upload_dir'),
TEMPLATE_PATH=os.path.join(os.getcwd(), "static"), TEMPLATE_PATH=os.path.join(os.getcwd(), "static"),
......
...@@ -80,12 +80,11 @@ class BuildLogsManager(object): ...@@ -80,12 +80,11 @@ class BuildLogsManager(object):
for af in app_files: for af in app_files:
if sf.id == af[0]: if sf.id == af[0]:
t = os.path.normpath(af[1].replace(config.get("UPLOAD_PATH"), "")).replace('\\', '/') t = os.path.normpath(af[1].replace(config.get("UPLOAD_PATH"), "")).replace('\\', '/')
sf.set(path=urljoin(config.get("UPLOAD_SERVER"), t)) sf.set(path=t)
flush() flush()
commit() commit()
epk_path = os.sep.join([target_dir.replace(config.get("UPLOAD_PATH"), ""), "{}.epk".format(dir_format)]) epk_path = os.sep.join([target_dir.replace(config.get("UPLOAD_PATH"), ""), "{}.epk".format(dir_format)]).replace('\\', '/')
epk_path = urljoin(config.get("UPLOAD_SERVER"), epk_path.replace('\\', '/'))
app_info['md5'] = str(app_info['md5']) app_info['md5'] = str(app_info['md5'])
result = BuildLogs(app=app, app_path=epk_path, app_info=app_info, create_by=editor, create_at=datetime.now(), update_by=editor, update_at=datetime.now()) result = BuildLogs(app=app, app_path=epk_path, app_info=app_info, create_by=editor, create_at=datetime.now(), update_by=editor, update_at=datetime.now())
......
...@@ -146,8 +146,8 @@ class UploadManager(object): ...@@ -146,8 +146,8 @@ class UploadManager(object):
return { return {
"uuid": str(uuid.uuid4()), # 附件唯一编号 "uuid": str(uuid.uuid4()), # 附件唯一编号
"filename": obj['filename'], # 附件名称 "filename": obj['filename'], # 附件名称
"filesize": os.path.getsize(saveFile), # 附件大小 "filesize": os.path.getsize(saveFile), # 附件大小
"filepath": parse.urljoin(config.get("UPLOAD_SERVER"), '/'.join(os.path.join(relative_path, filename).split('\\'))), # 附件存储路径 "filepath": os.sep.join([relative_path, filename]).replace("\\", "/"), # 附件存储路径
}, "upload file [%s] successfully!" % obj['filename'] }, "upload file [%s] successfully!" % obj['filename']
except Exception as e: # repr(e) except Exception as e: # repr(e)
traceback.print_exc() traceback.print_exc()
......
...@@ -58,9 +58,9 @@ def update_nginx_conf(): ...@@ -58,9 +58,9 @@ def update_nginx_conf():
lines = src.readlines() lines = src.readlines()
for content in lines: for content in lines:
if content.find(" listen 80;") != -1: if content.find(" listen 80;") != -1:
dst.write(" listen {};\n".format(conf.get('uploads', 'port'))) dst.write(" listen {};\n".format(conf.get('uploads', 'port') or 80))
elif content.find(" server_name localhost;") != -1: elif content.find(" server_name localhost;") != -1:
dst.write(" server_name {};\n".format(conf.get('uploads', 'host'))) dst.write(" server_name {};\n".format(conf.get('uploads', 'host') or "localhost"))
elif content.find(" root html;") != -1: elif content.find(" root html;") != -1:
dst.write(" root {};\n".format(os.getcwd())) dst.write(" root {};\n".format(os.getcwd()))
else: else:
......
...@@ -11,7 +11,6 @@ from fullstack.login import Auth ...@@ -11,7 +11,6 @@ from fullstack.login import Auth
from fullstack.validation import validate_schema from fullstack.validation import validate_schema
from fullstack.response import ResponseCode, response_result from fullstack.response import ResponseCode, response_result
from schema.netdisc import AddSchema, DeleteSchema, QuerySchema, UpdateSchema from schema.netdisc import AddSchema, DeleteSchema, QuerySchema, UpdateSchema
from app.setting import config
from utils import random_string from utils import random_string
logger = logging.getLogger("netdiscApi") logger = logging.getLogger("netdiscApi")
...@@ -136,7 +135,7 @@ def get_list(): ...@@ -136,7 +135,7 @@ def get_list():
try: try:
result, count, message = signalManager.actionGetNetDiscList.emit(request.schema_data) result, count, message = signalManager.actionGetNetDiscList.emit(request.schema_data)
if result: if result:
return response_result(ResponseCode.OK, data=result, msg=message, count=count, url=config.get("UPLOAD_SERVER")) return response_result(ResponseCode.OK, data=result, msg=message, count=count)
else: else:
return response_result(ResponseCode.REQUEST_ERROR, msg=message) return response_result(ResponseCode.REQUEST_ERROR, msg=message)
except Exception as e: except Exception as e:
......
...@@ -294,3 +294,11 @@ export function download(name, url) { ...@@ -294,3 +294,11 @@ export function download(name, url) {
resolve(); resolve();
}); });
} }
export function checkURL(URL) {
var str = URL,
Expression = /http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/,
objExp = new RegExp(Expression);
return objExp.test(str)
}
import utils from "hey-utils";
const rclass = /[\t\r\n\f]/g;
export default utils.extend({}, utils, {
getClass(elem) {
return (elem.getAttribute && elem.getAttribute("class")) || "";
},
hasClass(elem, selector) {
let className;
className = ` ${selector} `;
if (
elem.nodeType === 1 &&
` ${this.getClass(elem)} `.replace(rclass, " ").indexOf(className) > -1
) {
return true;
}
return false;
},
});
function formatNumber(n) { function formatNumber(n) {
n = n.toString(); n = n.toString();
return n[1] ? n : "0" + n; return n[1] ? n : "0" + n;
} }
export function getUTCDateTime(datetime) { export function getUTCDateTime(datetime) {
var year = datetime.getUTCFullYear(); var year = datetime.getUTCFullYear();
var month = datetime.getUTCMonth() + 1; var month = datetime.getUTCMonth() + 1;
var day = datetime.getUTCDate(); var day = datetime.getUTCDate();
var hour = datetime.getUTCHours(); var hour = datetime.getUTCHours();
var minute = datetime.getUTCMinutes(); var minute = datetime.getUTCMinutes();
var second = datetime.getUTCSeconds(); var second = datetime.getUTCSeconds();
return [year, month, day, hour, minute, second].map(formatNumber); return [year, month, day, hour, minute, second].map(formatNumber);
} }
export function formatDateTime( export function formatDateTime(
datetime = [], datetime = [],
format = ["-", "-", " ", ":", ":"] format = ["-", "-", " ", ":", ":"]
) { ) {
let result = ""; let result = "";
datetime.forEach((d, i) => { datetime.forEach((d, i) => {
result += i < 5 ? d + format[i] : d; result += i < 5 ? d + format[i] : d;
}); });
return result; return result;
} }
export function formatUTCDateTime(datetime) { export function formatUTCDateTime(datetime) {
if (!(datetime instanceof Date)) datetime = new Date(datetime); if (!(datetime instanceof Date)) datetime = new Date(datetime);
datetime = getUTCDateTime(datetime); datetime = getUTCDateTime(datetime);
const format = ["-", "-", " ", ":", ":"]; const format = ["-", "-", " ", ":", ":"];
let result = ""; let result = "";
datetime.forEach((d, i) => { datetime.forEach((d, i) => {
result += i < 5 ? d + format[i] : d; result += i < 5 ? d + format[i] : d;
}); });
return result; return result;
} }
...@@ -169,6 +169,7 @@ export default { ...@@ -169,6 +169,7 @@ export default {
const body = document.getElementsByTagName("body")[0]; const body = document.getElementsByTagName("body")[0];
const link = document.createElement("a"); const link = document.createElement("a");
body.appendChild(link); body.appendChild(link);
link.target = "_blank";
link.href = row.app_path; link.href = row.app_path;
link.click(); link.click();
document.body.removeChild(link); document.body.removeChild(link);
......
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
</template> </template>
<script> <script>
import { getFrameworkList, deleteFramework, addFramework, updateFramework } from '@/api/app-store' import { getFrameworkList, deleteFramework, addFramework, updateFramework } from '@/api/app-store'
import { mapTrim, compareObjectDiff } from '@/utils/index' import { mapTrim, compareObjectDiff, checkURL } from '@/utils/index'
import { formatUTCDateTime } from '@/utils/utils' import { formatUTCDateTime } from '@/utils/utils'
export default { export default {
name: "Framework", name: "Framework",
...@@ -169,11 +169,13 @@ export default { ...@@ -169,11 +169,13 @@ export default {
} }
}) })
}, },
handleRemove() { handleRemove() {},
},
handleSuccess(res) { handleSuccess(res) {
this.post.assets.files.push(res.data.filepath) if (res.code == 200) {
if (!checkURL(res.data.filepath))
res.data.filepath = `${window.location.origin}/${res.data.filepath}`
this.post.assets.files.push(res.data.filepath)
}
}, },
submitForm(formName) { submitForm(formName) {
this.$refs[formName].validate((valid) => { this.$refs[formName].validate((valid) => {
......
...@@ -130,7 +130,7 @@ ...@@ -130,7 +130,7 @@
drag drag
:action="`${window.location.protocol}//${window.location.host}/api/v1/evm_store/upload`" :action="`${window.location.protocol}//${window.location.host}/api/v1/evm_store/upload`"
:on-remove="handleRemove" :on-remove="handleRemove"
:on-success="handleAppFilesUploadSuccess" :on-success="handleUploadSuccess"
multiple multiple
name="binfile" name="binfile"
> >
...@@ -189,7 +189,7 @@ ...@@ -189,7 +189,7 @@
</template> </template>
<script> <script>
import { getAppsList, deleteApp, addApp, updateApp, buildApp, addFramework } from "@/api/app-store"; import { getAppsList, deleteApp, addApp, updateApp, buildApp, addFramework } from "@/api/app-store";
import { mapTrim } from "@/utils/index"; import { mapTrim, checkURL } from "@/utils/index";
export default { export default {
name: "AppIndex", name: "AppIndex",
...@@ -299,12 +299,19 @@ export default { ...@@ -299,12 +299,19 @@ export default {
} }
); );
}, },
handleAppFilesUploadSuccess(res) { handleUploadSuccess(res) {
this.post.app_files.push(res.data) if (res.code == 200) {
if (!checkURL(res.data.filepath))
res.data.filepath = `${window.location.origin}/${res.data.filepath}`
this.post.app_files.push(res.data)
}
}, },
handleAvatarSuccess(res, file) { handleAvatarSuccess(res, file) {
if (res.code == 200) if (res.code == 200) {
if (!checkURL(res.data.filepath))
res.data.filepath = `${window.location.origin}/${res.data.filepath}`
this.post.app_icon = res.data this.post.app_icon = res.data
}
this.imageUrl = URL.createObjectURL(file.raw); this.imageUrl = URL.createObjectURL(file.raw);
}, },
beforeAvatarUpload() { beforeAvatarUpload() {
......
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