You've already forked filebrowser
mirror of
https://github.com/filebrowser/filebrowser.git
synced 2025-11-26 14:25:26 +08:00
chore: refactor url creation
This commit is contained in:
@@ -103,7 +103,7 @@
|
||||
</a>
|
||||
<a
|
||||
target="_blank"
|
||||
:href="downloadUrl + '&inline=true'"
|
||||
:href="raw"
|
||||
class="button button--flat"
|
||||
v-if="!req.isDir"
|
||||
>
|
||||
@@ -145,7 +145,7 @@
|
||||
<script>
|
||||
import { mapState } from "vuex";
|
||||
import { files as api } from "@/api";
|
||||
import { baseURL, resizePreview } from "@/utils/constants";
|
||||
import { resizePreview } from "@/utils/constants";
|
||||
import url from "@/utils/url";
|
||||
import throttle from "lodash.throttle";
|
||||
import HeaderBar from "@/components/header/HeaderBar";
|
||||
@@ -186,23 +186,14 @@ export default {
|
||||
return this.nextLink !== "";
|
||||
},
|
||||
downloadUrl() {
|
||||
return `${baseURL}/api/raw${url.encodePath(this.req.path)}?auth=${
|
||||
this.jwt
|
||||
}`;
|
||||
},
|
||||
previewUrl() {
|
||||
// reload the image when the file is replaced
|
||||
const key = Date.parse(this.req.modified);
|
||||
|
||||
if (this.req.type === "image" && !this.fullSize) {
|
||||
return `${baseURL}/api/preview/big${url.encodePath(
|
||||
this.req.path
|
||||
)}?k=${key}`;
|
||||
}
|
||||
return `${baseURL}/api/raw${url.encodePath(this.req.path)}?k=${key}`;
|
||||
return api.getDownloadURL(this.req);
|
||||
},
|
||||
raw() {
|
||||
return `${this.previewUrl}&inline=true`;
|
||||
if (this.req.type === "image" && !this.fullSize) {
|
||||
return api.getPreviewURL(this.req, "big");
|
||||
}
|
||||
|
||||
return api.getDownloadURL(this.req, true);
|
||||
},
|
||||
showMore() {
|
||||
return this.$store.state.show === "more";
|
||||
@@ -276,9 +267,7 @@ export default {
|
||||
}
|
||||
|
||||
if (this.req.subtitles) {
|
||||
this.subtitles = this.req.subtitles.map(
|
||||
(sub) => `${baseURL}/api/raw${sub}?inline=true`
|
||||
);
|
||||
this.subtitles = api.getSubtitlesURL(this.req);
|
||||
}
|
||||
|
||||
let dirs = this.$route.fullPath.split("/");
|
||||
@@ -320,15 +309,14 @@ export default {
|
||||
return;
|
||||
}
|
||||
},
|
||||
prefetchUrl: function (item) {
|
||||
const key = Date.parse(item.modified);
|
||||
if (item.type === "image" && !this.fullSize) {
|
||||
return `${baseURL}/api/preview/big${item.path}?k=${key}&inline=true`;
|
||||
} else if (item.type === "image") {
|
||||
return `${baseURL}/api/raw${item.path}?k=${key}&inline=true`;
|
||||
} else {
|
||||
prefetchUrl(item) {
|
||||
if (item.type !== "image") {
|
||||
return "";
|
||||
}
|
||||
|
||||
return this.fullSize
|
||||
? api.getDownloadURL(item, true)
|
||||
: api.getPreviewURL(item, "big");
|
||||
},
|
||||
openMore() {
|
||||
this.$store.commit("showHover", "more");
|
||||
@@ -358,7 +346,7 @@ export default {
|
||||
this.$router.push({ path: uri });
|
||||
},
|
||||
download() {
|
||||
api.download(null, this.$route.path);
|
||||
window.open(this.downloadUrl);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user