文件浏览功能
This commit is contained in:
@@ -11,20 +11,20 @@
|
|||||||
<span>文件浏览</span>
|
<span>文件浏览</span>
|
||||||
<div style="float: right;">
|
<div style="float: right;">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="currentPath"
|
v-model="fileBrowser.currentPath"
|
||||||
placeholder="当前路径"
|
placeholder="当前路径"
|
||||||
style="width: 300px; margin-right: 10px;"
|
style="width: 300px; margin-right: 10px;"
|
||||||
readonly>
|
readonly>
|
||||||
</el-input>
|
</el-input>
|
||||||
<el-button type="primary" size="small" @click="navigateUp">
|
<el-button type="primary" size="small" @click="fileBrowser.navigateUp">
|
||||||
<i class="el-icon-arrow-up"></i> 上级目录
|
<i class="el-icon-arrow-up"></i> 上级目录
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<el-table
|
<el-table
|
||||||
:data="fileList"
|
:data="fileBrowser.fileList"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
v-loading="loading">
|
v-loading="fileBrowser.loading">
|
||||||
<el-table-column
|
<el-table-column
|
||||||
prop="name"
|
prop="name"
|
||||||
label="名称"
|
label="名称"
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-link
|
<el-link
|
||||||
:type="scope.row.is_dir ? 'primary' : 'info'"
|
:type="scope.row.is_dir ? 'primary' : 'info'"
|
||||||
@click="scope.row.is_dir ? navigateTo(scope.row.name) : null">
|
@click="scope.row.is_dir ? fileBrowser.navigateTo(scope.row.name) : null">
|
||||||
<i :class="scope.row.is_dir ? 'el-icon-folder' : 'el-icon-document'"></i>
|
<i :class="scope.row.is_dir ? 'el-icon-folder' : 'el-icon-document'"></i>
|
||||||
[[ scope.row.name ]]
|
[[ scope.row.name ]]
|
||||||
</el-link>
|
</el-link>
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
label="大小"
|
label="大小"
|
||||||
width="120">
|
width="120">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
[[ scope.row.is_dir ? '-' : formatFileSize(scope.row.size) ]]
|
[[ fileBrowser.formatFileSize(scope.row.size) ]]
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
@@ -59,7 +59,7 @@
|
|||||||
label="修改时间"
|
label="修改时间"
|
||||||
width="180">
|
width="180">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
[[ formatDate(scope.row.modified) ]]
|
[[ fileBrowser.formatDate(scope.row.modified) ]]
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
@@ -70,7 +70,7 @@
|
|||||||
v-if="!scope.row.is_dir"
|
v-if="!scope.row.is_dir"
|
||||||
type="primary"
|
type="primary"
|
||||||
size="mini"
|
size="mini"
|
||||||
@click="downloadFile(scope.row.name)">
|
@click="fileBrowser.downloadFile(scope.row.name)">
|
||||||
下载
|
下载
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
@@ -84,20 +84,31 @@
|
|||||||
|
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<script>
|
<script>
|
||||||
new Vue({
|
// 扩展基础Vue实例
|
||||||
el: '#app',
|
Object.assign(baseApp, {
|
||||||
delimiters: ['[[', ']]'],
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
...baseApp.data(),
|
||||||
|
fileBrowser: {
|
||||||
currentPath: '',
|
currentPath: '',
|
||||||
fileList: [],
|
fileList: [],
|
||||||
loading: false
|
loading: false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.loadFiles('');
|
// 调用原始created方法
|
||||||
|
if (baseApp.created) {
|
||||||
|
baseApp.created.call(this);
|
||||||
|
}
|
||||||
|
// 设置当前视图为文件浏览
|
||||||
|
this.currentView = '15';
|
||||||
|
// 加载文件列表
|
||||||
|
this.fileBrowser.loadFiles('');
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
...baseApp.methods,
|
||||||
|
fileBrowser: {
|
||||||
formatFileSize(bytes) {
|
formatFileSize(bytes) {
|
||||||
if (bytes === 0) return '0 B';
|
if (bytes === 0) return '0 B';
|
||||||
const k = 1024;
|
const k = 1024;
|
||||||
@@ -149,6 +160,7 @@ new Vue({
|
|||||||
window.location.href = '/api/download_file?path=' + encodeURIComponent(filePath);
|
window.location.href = '/api/download_file?path=' + encodeURIComponent(filePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user