Skip to content

Commit e119bc5

Browse files
committed
feat: shared folder file listing
1 parent 1ce3068 commit e119bc5

File tree

4 files changed

+85
-22
lines changed

4 files changed

+85
-22
lines changed

frontend/public/themes/dark.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,10 @@ table th {
191191
}
192192
}
193193

194-
.share__box, .share__box__download {
195-
background: var(--surfaceSecondary) !important;
194+
.share__box, .share__box__header {
195+
background: var(--surfacePrimary) !important;
196196
color: var(--textPrimary);
197197
}
198-
.share__box__download {
198+
.share__box__header {
199199
border-bottom-color: var(--divider);
200200
}

frontend/src/css/_share.css

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,58 @@
1+
.share {
2+
display: flex;
3+
flex-wrap: wrap;
4+
justify-content: center;
5+
align-items: flex-start;
6+
}
7+
8+
@media (max-width: 736px) {
9+
.share {
10+
display: block;
11+
}
12+
}
13+
114
.share__box {
2-
text-align: center;
315
box-shadow: rgba(0, 0, 0, 0.06) 0px 1px 3px, rgba(0, 0, 0, 0.12) 0px 1px 2px;
416
background: #fff;
5-
display: block;
617
border-radius: 0.2em;
7-
width: 90%;
8-
max-width: 25em;
9-
margin: 6em auto;
18+
margin: 5px;
19+
overflow: hidden;
1020
}
1121

12-
.share__box__download {
22+
.share__box__header {
1323
width: 100%;
1424
padding: 1em;
1525
cursor: pointer;
1626
background: #ffffff;
17-
color: rgba(0, 0, 0, 0.5);
18-
border-bottom: 1px solid rgba(0, 0, 0, 0.05);
27+
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
1928
}
2029

21-
.share__box__info {
30+
.share__box__body {
2231
padding: 2em 3em;
2332
}
2433

2534
.share__box__title {
26-
margin-top: .2em;
35+
margin: 0 0 2em;
2736
overflow: hidden;
2837
text-overflow: ellipsis;
2938
}
39+
40+
.share__box__info {
41+
text-align: center;
42+
flex: 1 1 auto;
43+
}
44+
45+
.share__box__items {
46+
text-align: left;
47+
flex: 10 0 15em;
48+
}
49+
50+
.share__box__items #listing.list .item {
51+
cursor: auto;
52+
border-left: 0;
53+
border-right: 0;
54+
}
55+
56+
.share__box__items #listing.list .item .name {
57+
width: auto;
58+
}

frontend/src/views/Share.vue

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<template>
22
<div class="share" v-if="loaded">
3-
<a target="_blank" :href="link">
4-
<div class="share__box">
5-
<div class="share__box__download" v-if="file.isDir">{{ $t('download.downloadFolder') }}</div>
6-
<div class="share__box__download" v-else>{{ $t('download.downloadFile') }}</div>
7-
<div class="share__box__info">
3+
<div class="share__box share__box__info">
4+
<a target="_blank" :href="link">
5+
<div class="share__box__header" v-if="file.isDir">{{ $t('download.downloadFolder') }}</div>
6+
<div class="share__box__header" v-else>{{ $t('download.downloadFile') }}</div>
7+
<div class="share__box__body">
88
<svg v-if="file.isDir" fill="#40c4ff" height="150" viewBox="0 0 24 24" width="150" xmlns="http://www.w3.org/2000/svg">
99
<path d="M10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"/>
1010
<path d="M0 0h24v24H0z" fill="none"/>
@@ -16,8 +16,30 @@
1616
<h1 class="share__box__title">{{ file.name }}</h1>
1717
<qrcode-vue :value="fullLink" size="200" level="M"></qrcode-vue>
1818
</div>
19+
</a>
20+
</div>
21+
<div v-if="file.isDir" class="share__box share__box__items">
22+
<div class="share__box__header" v-if="file.isDir">{{ $t('files.files') }}</div>
23+
24+
<div id="listing" class="list">
25+
<div class="item" v-for="(item) in file.items.slice(0, this.showLimit)" :key="base64(item.name)">
26+
<div>
27+
<i v-if="item.isDir" class="material-icons">folder</i>
28+
<i v-else-if="item.type==='image'" class="material-icons">insert_photo</i>
29+
<i v-else class="material-icons">insert_drive_file</i>
30+
</div>
31+
32+
<div>
33+
<p class="name">{{ item.name }}</p>
34+
</div>
35+
</div>
36+
<div v-if="file.items.length > showLimit" class="item">
37+
<div>
38+
<p class="name"> + {{ file.items.length - showLimit }} </p>
39+
</div>
40+
</div>
1941
</div>
20-
</a>
42+
</div>
2143
</div>
2244
</template>
2345

@@ -34,7 +56,8 @@ export default {
3456
data: () => ({
3557
loaded: false,
3658
notFound: false,
37-
file: null
59+
file: null,
60+
showLimit: 500
3861
}),
3962
watch: {
4063
'$route': 'fetchData'
@@ -54,6 +77,9 @@ export default {
5477
},
5578
},
5679
methods: {
80+
base64: function (name) {
81+
return window.btoa(unescape(encodeURIComponent(name)))
82+
},
5783
fetchData: async function () {
5884
try {
5985
this.file = await api.getHash(this.hash)

http/public.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var withHashFile = func(fn handleFunc) handleFunc {
2828
Fs: d.user.Fs,
2929
Path: link.Path,
3030
Modify: d.user.Perm.Modify,
31-
Expand: false,
31+
Expand: true,
3232
Checker: d,
3333
})
3434
if err != nil {
@@ -54,7 +54,15 @@ func ifPathWithName(r *http.Request) string {
5454
}
5555

5656
var publicShareHandler = withHashFile(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {
57-
return renderJSON(w, r, d.raw)
57+
file := d.raw.(*files.FileInfo)
58+
59+
if file.IsDir {
60+
file.Listing.Sorting = files.Sorting{By: "name", Asc: false}
61+
file.Listing.ApplySort()
62+
return renderJSON(w, r, file)
63+
}
64+
65+
return renderJSON(w, r, file)
5866
})
5967

6068
var publicDlHandler = withHashFile(func(w http.ResponseWriter, r *http.Request, d *data) (int, error) {

0 commit comments

Comments
 (0)