pull/109/head
midoks 3 years ago
parent 8039fc681e
commit 0b3c568232
  1. 31
      class/core/files_api.py
  2. 4
      route/static/app/files.js

@ -62,6 +62,13 @@ class files_api:
path = request.form.get('path', '')
return self.zip(sfile, dfile, stype, path)
def unzipApi(self):
sfile = request.form.get('sfile', '')
dfile = request.form.get('dfile', '')
stype = request.form.get('type', '')
path = request.form.get('path', '')
return self.unzip(sfile, dfile, stype, path)
# 移动文件或目录
def mvFileApi(self):
sfile = request.form.get('sfile', '')
@ -738,6 +745,30 @@ done
except:
return mw.returnJson(False, '文件压缩失败!')
def unzip(self, sfile, dfile, stype, path):
if sfile.find(',') == -1:
if not os.path.exists(path + '/' + sfile):
return mw.returnMsg(False, '指定文件不存在!')
try:
tmps = mw.getRunDir() + '/tmp/panelExec.log'
if stype == 'zip':
os.system("cd '" + path + "' && unzip -d '" + dfile +
"' '" + sfile + "' > " + tmps + " 2>&1")
else:
sfiles = ''
for sfile in sfile.split(','):
if not sfile:
continue
sfiles += " '" + sfile + "'"
os.system("cd '" + path + "' && tar -zxvf '" + sfiles +
"' -C " + dfile + "' " + " > " + tmps + " 2>&1")
self.setFileAccept(dfile)
mw.writeLog("文件管理", '文件解压成功!', (sfile, dfile))
return mw.returnJson(True, '文件解压成功!')
except:
return mw.returnJson(False, '文件解压失败!')
def delete(self, path):
if not os.path.exists(path):

@ -1182,7 +1182,7 @@ function unZip(fileName,type) {
coding = $("select[name='coding']").val();
layer.closeAll();
layer.msg(lan.files.unzip_the, {icon: 16,time: 0,shade: [0.3, '#000']});
$.post('/files?action=UnZip', 'sfile=' + sfile + '&dfile=' + dfile +'&type=' + type + '&coding=' + coding + '&password=' + password, function(rdata) {
$.post('/files/unzip', 'sfile=' + sfile + '&dfile=' + dfile +'&type=' + type + '&coding=' + coding + '&password=' + password, function(rdata) {
layer.closeAll();
layer.msg(rdata.msg, {icon: rdata.status ? 1 : 2});
getFiles(path);
@ -1212,7 +1212,7 @@ function unZip(fileName,type) {
+'</div>'
+'<div class="bt-form-submit-btn">'
+'<button type="button" class="btn btn-danger btn-sm btn-title" onclick="layer.closeAll()">'+lan.public.close+'</button>'
+'<button type="button" id="ReNameBtn" class="btn btn-success btn-sm btn-title" onclick="UnZip(\'' + fileName + '\',\''+type+'\')">'+lan.files.file_menu_unzip+'</button>'
+'<button type="button" id="ReNameBtn" class="btn btn-success btn-sm btn-title" onclick="unZip(\'' + fileName + '\',\''+type+'\')">'+lan.files.file_menu_unzip+'</button>'
+'</div>'
+'</div>'
});

Loading…
Cancel
Save