-
Notifications
You must be signed in to change notification settings - Fork 305
/
bucketPage.vue
326 lines (292 loc) · 8.72 KB
/
bucketPage.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
<style lang="scss" scoped>
@import '../style/params';
.bucketpage {
background-color: var(--bg-bucketpage);
height: 100%;
display: flex;
flex-direction: column;
}
.dir-layout {
display: flex;
flex-direction: row;
align-items: center;
padding: 15px;
flex-shrink: 0;
.header-dir-view {
flex-grow: 1;
flex-shrink: 1;
overflow-x: auto;
margin-right: 10px;
.ivu-breadcrumb {
display: flex;
flex-direction: row;
color: var(--fontColor);
.bread-sub {
flex-shrink: 0;
.ivu-breadcrumb-item-separator {
color: var(--fontColor);
}
}
}
/*&:hover {
overflow-x: scroll;
}*/
}
.header-info-view {
display: flex;
flex-direction: row;
align-items: center;
flex-shrink: 0;
margin-right: 10px;
font-weight: 500;
font-size: 12px;
.count {
margin-right: 5px;
padding-left: 5px;
}
.size {
padding-left: 5px;
}
}
.header-button-view {
display: flex;
flex-direction: row;
flex-shrink: 0;
button {
font-size: 12px;
font-weight: 500;
}
.btn {
margin-right: 10px;
}
}
}
.file-list {
margin-top: 10px;
max-height: 300px;
overflow-y: scroll;
overflow-x: hidden;
word-break: break-all;
}
</style>
<style lang="scss">
@import '../style/params';
.bread-sub {
.ivu-breadcrumb-item-separator {
color: var(--fontColor);
}
}
</style>
<template>
<div class="bucketpage" v-if="bucket">
<Header :bucket="bucket"></Header>
<div class="dir-layout">
<div class="header-dir-view horizontal">
<Breadcrumb separator=">">
<div class="bread-sub" @click="changeFolderPath(-1)">
<BreadcrumbItem>
<Icon type="md-home" size="14"></Icon>
</BreadcrumbItem>
</div>
<template v-if="bucket.folderPath">
<div class="bread-sub" v-for="(item, index) in bucket.folderPath.split('/')" :key="item" @click="changeFolderPath(index)">
<BreadcrumbItem>{{ item }}</BreadcrumbItem>
</div>
</template>
</Breadcrumb>
</div>
<div class="header-info-view">
<span class="icon iconfont icon-wenjian"></span>
<span class="count">共{{ totalCount }}个 文件</span>
<span class="icon iconfont icon-fuwuqi"></span>
<span class="count">共{{ totalSize }} 存储量</span>
</div>
<div class="header-button-view">
<template v-if="bucket.selection.length > 0">
<Button class="btn" size="small" @click="cleanSelection()">取消</Button>
<Button class="btn" size="small" @click="allSelection()">全选</Button>
<Button class="btn" size="small" @click="callRefreshUrls()" icon="md-sync" v-feature:refreshCDN="bucket.key">刷新缓存({{ bucket.selection.length }})</Button>
<Button class="btn" size="small" @click="downloads()" icon="md-download">下载({{ bucket.selection.length }})</Button>
<Button v-if="!setup_hiddenDelBtn" class="btn" size="small" @click="askRemove()" icon="md-trash" type="error">删除({{ bucket.selection.length }})</Button>
</template>
<Button class="button-margin" style="margin-right: 10px" size="small" @click="showFilter" icon="md-funnel"></Button>
<Button-group size="small">
<Button :type="showType === 0 ? 'primary' : 'default'" @click="changeShowType(0)" icon="md-list"></Button>
<Button :type="showType === 1 ? 'primary' : 'default'" @click="changeShowType(1)" icon="md-folder"></Button>
</Button-group>
<Button-group size="small" style="margin-left: 10px" v-if="bucket.marker">
<Button @click="getResources({ keyword: bucket.folderPath })" icon="ios-arrow-forward"></Button>
</Button-group>
</div>
</div>
<!--<resource-table v-if="showType === 0" :bucket="bucket" ></resource-table>-->
<resource-list ref="resource-grid" :bucket="bucket" :type="showType" key="1"></resource-list>
<resource-filter ref="resource-filter" :bucket="bucket"></resource-filter>
<Modal v-model="modelDeleteAsk" title="确认删除文件?" class-name="vertical-center-modal" @on-ok="callRemove" @on-cancel="cleanSelection">
<div class="file-list">
<template>
<p v-for="file in bucket.selection" :key="file.key">{{ file.key }}</p>
</template>
</div>
</Modal>
</div>
</template>
<script>
import Header from '@/components/Header'
import ResourceList from '@/components/ResourceList.vue'
import ResourceFilter from '@/components/ResourceFilter'
import { mapGetters, mapActions } from 'vuex'
import * as types from '../vuex/mutation-types'
import { Constants, util, EventBus, mixins } from '../service/index'
import dayjs from 'dayjs'
export default {
name: 'bucketPage',
components: {
Header,
ResourceList,
ResourceFilter,
},
mixins: [mixins.base],
props: {
bucketInfo: {
type: Object,
default: {},
},
},
data() {
return {
bucket: null,
showType: -1, //0:列表 1:folder
folderPath: null,
modelDeleteAsk: false,
}
},
computed: {
...mapGetters({
buckets_info: types.app.buckets_info,
privatebucket: types.setup.privatebucket,
paging: types.setup.paging,
setup_deleteNoAsk: types.setup.deleteNoAsk,
setup_hiddenDelBtn: types.setup.hiddenDelBtn,
setup_https: types.setup.https,
setup_showType: types.setup.showType,
setup_deadline: types.setup.deadline,
customeDomains: types.setup.customedomain,
}),
totalSize() {
let totalSzie = 0
if (this.bucket.space) {
totalSzie = this.bucket.space
} else if (this.bucket && this.bucket.files) {
this.bucket.files.forEach(item => {
totalSzie += item.fsize
})
}
return util.formatFileSize(totalSzie)
},
totalCount() {
let totalCount = 0
if (this.bucket.count) {
totalCount = this.bucket.count
} else if (this.bucket && this.bucket.files) {
totalCount = this.bucket.files.length
}
return totalCount
},
},
watch: {
bucketInfo: function (val, oldVal) {
if (val && oldVal !== val) {
this.initBucket(val)
}
},
},
mounted() {
if (this.$route.query && this.$route.query.bucketInfo) {
this.initBucket(this.$route.query.bucketInfo)
} else {
console.log('mounted: error')
}
},
methods: {
...mapActions([types.app.a_update_buckets_info, types.setup.a_showType]),
/**
* 初始化空间信息
*/
initBucket(bucketInfo) {
if (this.$storage.cos) {
this.bucket = this.$storage.cos.generateBucket(bucketInfo)
this.bucket.bindPage(this)
this.showType = this.setup_showType
}
},
/**
* 获取指定前缀文件列表
*/
getResources(option) {
this.bucket.getResources(option)
},
/**
* 根据配置,是否弹出删除确认框
*/
askRemove() {
this.modelDeleteAsk = true
},
callRemove() {
EventBus.$emit(Constants.Event.resourceAction, this.bucket.selection, Constants.ActionType.remove)
this.bucket.selection = []
},
callRefreshUrls() {
EventBus.$emit(Constants.Event.resourceAction, this.bucket.selection, Constants.ActionType.refreshUrls)
this.bucket.selection = []
},
//取消选择
cleanSelection() {
this.bucket.selection = []
},
//全部选择
allSelection() {
this.$refs['resource-grid'].selection = []
this.bucket.selection = []
for (let i = 0; i < this.$refs['resource-grid'].files.length; i++) {
this.$refs['resource-grid'].selectFile(i)
}
},
downloads() {
EventBus.$emit(Constants.Event.resourceAction, this.bucket.selection, Constants.ActionType.download)
this.bucket.selection = []
},
/**
* list/grid
* @param type
*/
changeShowType(type) {
this.bucket.selection = []
this[types.setup.a_showType](type)
this.showType = type
},
changeFolderPath(index) {
if (index === -1) {
this.bucket.folderPath = ''
return
}
let arrays = this.bucket.folderPath.split('/')
this.bucket.folderPath = arrays.slice(0, index + 1).join('/')
},
showFilter() {
this.$refs['resource-filter'].toggle()
},
exportURL() {
//导出URL
let urls = []
this.bucket.files.forEach(item => {
urls.push(this.$refs['resource-grid'].getResourceUrl(item))
})
this.$electron.ipcRenderer.send(Constants.Listener.exportUrl, {
name: `${this.$storage.name}-${this.bucket.name}-${dayjs().format('YYYYMMDDHHmmss')}.txt`,
urls,
})
},
},
}
</script>