Skip to content

Commit

Permalink
1、修复浏览器上传的问题,官方web api限制导致的只能获取100个文件
Browse files Browse the repository at this point in the history
2、修复上传替换文件的ico问题
3、修复站点初始化未安装web服务器的问题
  • Loading branch information
songchudong committed Jan 12, 2022
1 parent 27a825b commit cea2bb3
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 24 deletions.
8 changes: 7 additions & 1 deletion BTPanel/static/css/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -10543,7 +10543,8 @@ select[name="disk-io"] {
}

.bt_table .divtable {
overflow: auto;
overflow: auto;
clear: both;
}

.bt_table .text-overflow {
Expand Down Expand Up @@ -12179,6 +12180,11 @@ span.unit {
font-size: 14px;
word-wrap: break-word;
}
.warning_layer_head .layui-layer-ico{
width: 30px;
height: 30px;
}

.warning_layer_box .details {
display: flex;
align-items: center;
Expand Down
15 changes: 9 additions & 6 deletions BTPanel/static/js/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,18 +586,17 @@ var bt_file = {

//设置单页显示的数量,默认为100,设置local本地缓存
$('.filePage').on('change', '.showRow', function() {
var val = $(this).val();
console.log(val);
var val = $(this).val()
bt.set_storage('local','showRow',val);
that.reader_file_list({ showRow: val, p: 1, is_operating: false });
});

// 页码跳转
$('.filePage').on('click', 'div:nth-child(2) a', function(e) {
var num = $(this).attr('href').match(/p=([0-9]+)$/)[1];
that.reader_file_list({ path: that.path, p: num })
e.stopPropagation();
e.preventDefault();
var num = $(this).attr('href').match(/p=([0-9]+)$/)[1]
that.reader_file_list({ path: that.path, p: num})
e.stopPropagation()
e.preventDefault()
})

// 获取文件夹大小
Expand Down Expand Up @@ -1338,6 +1337,10 @@ var bt_file = {
$('.file_table_view').removeClass('.list_view,.icon_view').addClass(model == 'list' ? 'list_view' : 'icon_view');
$('.cut_view_model:nth-child(' + (model == 'list' ? '2' : '1') + ')').addClass('active').siblings().removeClass('active');
this.file_images_list = [];
if(typeof data.search){
var search_input = $('.search_path_views .file_search_input').val()
data['search'] = search_input
}
this.get_dir_list(data, function(res){
if (res.status === false && res.msg.indexOf('指定目录不存在!') > -1) {
return that.reader_file_list({ path: '/www' })
Expand Down
34 changes: 20 additions & 14 deletions BTPanel/static/js/upload-drog.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,8 @@ UploadFile.prototype = {
item.querySelector('.filesize').innerText = config.size;
item.querySelector('.fileStatus').innerHTML = this.is_upload_status(config.upload, config.upload === 1 ? '(耗时:' + this.diff_time(this.uploadTime.startTime, this.uploadTime.endTime) + ')' : config.errorMsg);
var dropUpLoadFile = this.queryEl('.dropUpLoadFile');
dropUpLoadFile.scrollTop += 45;
if(this.uploadList.length === 1) dropUpLoadFile.scrollTop = 0
if(this.uploadList.length > 1) dropUpLoadFile.scrollTop += 45.5
} else {
item.querySelector('.fileLoading').setAttribute('style', 'width:' + config.percent);
item.querySelector('.filesize').innerText = config.upload_size + '/' + config.size;
Expand Down Expand Up @@ -745,7 +746,6 @@ UploadFile.prototype = {
* @param {Object} e 文件对象
*/
file_upload_limit: function file_upload_limit (e, path) {
console.log(this.fileList);
var extName = e.name.split('.');
path = path || e.webkitRelativePath
var paths = path.split('/');
Expand All @@ -758,7 +758,8 @@ UploadFile.prototype = {
type: extName.length > 1 ? extName[extName.length - 1] : 'txt',
status: 0
});
this.fileTotalNumber++;
console.log(this.fileTotalNumber);
this.fileTotalNumber ++;
this.fileTotalSize += e.size;
if (this.fileTotalNumber >= this.limit.number) {
layer.msg('当前文件数量已超过文件上传上限' + this.limit.number + '个, 请压缩文件夹后重试!');
Expand All @@ -768,20 +769,20 @@ UploadFile.prototype = {
layer.msg('当前文件大小已超过文件上传' + bt.format_size(e.size) + '限制, 请使用SFTP/FTP等工具上传文件!');
return false;
}
return true;
},

test_index:0,

/**
* @description 文件夹文件内容递归
* @param {object} item 文件对象
*/
traverse_file_tree: function traverse_file_tree (item) {
var _this6 = this;

var path = item.fullPath || '';

if (item.isFile) {
// console.log(item,this.timeNumber);
// console.log(item,'-----')
item.file(function (e) {
_this6.file_upload_limit(e, path);
});
Expand All @@ -790,27 +791,32 @@ UploadFile.prototype = {
_this6.load.close();
if (_this6.isUpload) {
_this6.render_file_list(_this6.fileList);
} else {
} else {
var layers = _this6.layer;
_this6.init_data();
_this6.layers = layers;
}
}, 50);
}, 10);
} else if (item.isDirectory) {
var dirReader = item.createReader();
dirReader.readEntries(function (entries) {
[].forEach.call(entries, function (e) {
var fnReadEntries = function (entries) {
[].forEach.call(entries,function (e) {
if (!_this6.isUpload) return false;
_this6.traverse_file_tree(e);
});
});
if (entries.length > 0) {
dirReader.readEntries(fnReadEntries);
}
};
dirReader.readEntries(fnReadEntries)
setTimeout(function () {
if (_this6.fileList.length === 0) {
layer.msg('拖拽上传文件夹内容为空')
}
}, 500)
}
},



/**
Expand All @@ -825,16 +831,16 @@ UploadFile.prototype = {
if (ev.target.files) {
var items = ev.target.files;
[].forEach.call(items, function (item) {
console.log(item);
_this7.traverse_file_tree(item);
});
} else if (ev.dataTransfer.items) {
var items = ev.dataTransfer.items;
console.log(items);
[].forEach.call(items, function (ev) {
var getAsEntry = ev.webkitGetAsEntry || ev.getAsEntry;
var item = getAsEntry.call(ev);
var item = getAsEntry.call(ev)
if (item) {
if (!_this7.isUpload){
console.log(_this7);
return false
}
_this7.traverse_file_tree(item);
Expand Down
10 changes: 7 additions & 3 deletions BTPanel/templates/default/site.html
Original file line number Diff line number Diff line change
Expand Up @@ -304,14 +304,18 @@
<script type="text/javascript">
bt.set_cookie('sites_path', "{{session['config']['sites_path']}}");
bt.set_cookie('serverType', "{{session['webserver']}}");
console.log("{{session['webserver']}}")
var isSetup = "{{data['isSetup']}}" === 'True' ? true : false
</script>
<script type="text/javascript" src="{{g.cdn_url}}/laydate/laydate.js?version={{g['version']}}"></script>
<script type="text/javascript" src="{{g.cdn_url}}/js/site.js?version={{g['version']}}&repair={{data['js_random']}}"></script>
<script type="text/javascript" src="{{g.cdn_url}}/editor/ace.js?version={{g['version']}}&repair={{data['js_random']}}"></script>
<!-- <script type="text/javascript" src="{{g.cdn_url}}/js/bootstrap-select.min.js?version={{g['version']}}&repair={{data['js_random']}}"></script> -->
<script type="text/javascript">
if (isSetup) site.plugin_firewall()
{% if not data['isSetup'] %}
layer.msg('test', { time: 0, icon: 2 });
layer.msg('{{data["lan"]["JS1"]}}<a href="/soft" style="color:#20a53a; float: right;">{{data["lan"]["JS2"]}}</a>', { icon: 7, shade: [0.3, '#000'], time: 0 });
$(".layui-layer-shade").css("margin-left", "180px");
{% else %}
if (isSetup) site.plugin_firewall()
{% endif %}
</script>
{% endblock %}

0 comments on commit cea2bb3

Please sign in to comment.