move sort logic to backend, update deleted user name logic
This commit is contained in:
parent
3bd90ae2e3
commit
3d2bb9170d
@ -56,13 +56,13 @@ export default {
|
|||||||
},
|
},
|
||||||
async created () {
|
async created () {
|
||||||
try {
|
try {
|
||||||
this.links = await api.list()
|
let links = await api.list()
|
||||||
if (this.user.perm.admin) {
|
if (this.user.perm.admin) {
|
||||||
let userMap = new Map()
|
let userMap = new Map()
|
||||||
for (let user of await users.getAll()) userMap.set(user.id, user.username)
|
for (let user of await users.getAll()) userMap.set(user.id, user.username)
|
||||||
for (let link of this.links) link.username = userMap.has(link.userID) ? userMap.get(link.userID) : link.userID
|
for (let link of links) link.username = userMap.has(link.userID) ? userMap.get(link.userID) : ''
|
||||||
}
|
}
|
||||||
this.sort()
|
this.links = links
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.$showError(e)
|
this.$showError(e)
|
||||||
}
|
}
|
||||||
@ -88,14 +88,6 @@ export default {
|
|||||||
},
|
},
|
||||||
buildLink (hash) {
|
buildLink (hash) {
|
||||||
return `${window.location.origin}${baseURL}/share/${hash}`
|
return `${window.location.origin}${baseURL}/share/${hash}`
|
||||||
},
|
|
||||||
sort () {
|
|
||||||
this.links = this.links.sort((a, b) => {
|
|
||||||
if (a.userID !== b.userID) return a.userID - b.userID
|
|
||||||
if (a.expire === 0) return -1
|
|
||||||
if (b.expire === 0) return 1
|
|
||||||
return new Date(a.expire) - new Date(b.expire)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
"path"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -37,6 +38,13 @@ var shareListHandler = withPermShare(func(w http.ResponseWriter, r *http.Request
|
|||||||
return http.StatusInternalServerError, err
|
return http.StatusInternalServerError, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sort.Slice(s, func(i, j int) bool {
|
||||||
|
if s[i].UserID != s[j].UserID {
|
||||||
|
return s[i].UserID < s[j].UserID
|
||||||
|
}
|
||||||
|
return s[i].Expire < s[j].Expire
|
||||||
|
})
|
||||||
|
|
||||||
return renderJSON(w, r, s)
|
return renderJSON(w, r, s)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user