Patch for URL

This commit is contained in:
Brandon 2025-05-20 23:17:55 -04:00
parent b594083bb1
commit 5b0f171915
6 changed files with 52 additions and 18 deletions

View File

@ -17,6 +17,7 @@
"path": "^0.12.7", "path": "^0.12.7",
"url": "^0.11.4", "url": "^0.11.4",
"vue": "^3.5.13", "vue": "^3.5.13",
"vue-router": "^4.5.1",
"vuetify": "^3.8.0-beta.0" "vuetify": "^3.8.0-beta.0"
}, },
"devDependencies": { "devDependencies": {

View File

@ -1,11 +1,7 @@
<template> <template>
<v-app> <v-app>
<v-main> <v-main>
<download-list /> <router-view />
</v-main> </v-main>
</v-app> </v-app>
</template> </template>
<script setup lang="ts">
import DownloadList from './components/DownloadList.vue'
</script>

View File

@ -47,12 +47,17 @@
<span <span
v-if="item.isDir" v-if="item.isDir"
class="blue--text text--darken-2" class="blue--text text--darken-2"
@click="enterFolder(item.path)"
style="cursor: pointer" style="cursor: pointer"
> >
<v-icon small class="me-2">mdi-folder-outline</v-icon> <v-icon small class="me-2">mdi-folder-outline</v-icon>
{{ item.name }} <a
:href="`${API_BASE_URL}/${item.path}`"
class="blue--text text--darken-2"
style="text-decoration: none"
>
{{ item.name }}
</a>
</span> </span>
<span v-else> <span v-else>
<v-icon small class="me-2">mdi-file-outline</v-icon> <v-icon small class="me-2">mdi-file-outline</v-icon>
@ -86,8 +91,6 @@
<script lang="ts"> <script lang="ts">
import { defineComponent, ref, nextTick } from "vue"; import { defineComponent, ref, nextTick } from "vue";
const API_BASE_URL = import.meta.env.VITE_API_BASE_URL;
interface FolderItem { interface FolderItem {
name: string; name: string;
path: string; path: string;
@ -128,7 +131,8 @@ export default defineComponent({
{ title: "Size", key: "size", width: "120px" }, { title: "Size", key: "size", width: "120px" },
{ title: "Last Modified", key: "lastModified", width: "200px" }, { title: "Last Modified", key: "lastModified", width: "200px" },
], ],
DOWNLOAD_BASE_URL: import.meta.env.VITE_DOWNLOAD_BASE_URL DOWNLOAD_BASE_URL: import.meta.env.VITE_DOWNLOAD_BASE_URL,
API_BASE_URL: import.meta.env.VITE_API_BASE_URL,
}; };
}, },
computed: { computed: {
@ -169,12 +173,17 @@ export default defineComponent({
methods: { methods: {
async fetchList(reset = false) { async fetchList(reset = false) {
if (this.loading) return; if (this.loading) return;
this.loading = true; this.loading = true;
const url = new URL(`${API_BASE_URL}/api/list`); const url = new URL(`${this.API_BASE_URL}/api/list`);
console.log(this.currentPath);
url.searchParams.set("prefix", this.currentPath); url.searchParams.set("prefix", this.currentPath);
url.searchParams.set("limit", "50"); url.searchParams.set("limit", "50");
if (this.search) url.searchParams.set("search", this.search); if (this.search) url.searchParams.set("search", this.search);
if (this.nextToken && !reset) { if (this.nextToken && !reset) {
url.searchParams.set("token", this.nextToken); url.searchParams.set("token", this.nextToken);
} }
@ -200,14 +209,9 @@ export default defineComponent({
this.nextToken = null; this.nextToken = null;
this.fetchList(true); this.fetchList(true);
}, },
enterFolder(path: string) {
this.currentPath = path;
this.nextToken = null;
this.fetchList(true);
},
goToBreadcrumb(path: string) { goToBreadcrumb(path: string) {
this.currentPath = path; this.currentPath = path;
this.nextToken = null; this.$router.push("/" + path);
this.fetchList(true); this.fetchList(true);
}, },
extractFolderName(path: string): string { extractFolderName(path: string): string {
@ -220,6 +224,19 @@ export default defineComponent({
return size + " B"; return size + " B";
}, },
}, },
created() {
// Remove leading slash if it exists
this.currentPath = this.$route?.path.replace(/^\/+/, "") || "";
// Check if the path ends in `.bz2` (case-sensitive)
if (this.currentPath.endsWith(".bz2")) {
window.open(`${this.DOWNLOAD_BASE_URL}${this.currentPath}`, '_blank', 'popup');
this.currentPath = "";
}
// Only add trailing slash if there's something left
this.currentPath = this.currentPath ? this.currentPath.replace(/\/?$/, "/") : "";
},
mounted() { mounted() {
this.fetchList(true); this.fetchList(true);
}, },

View File

@ -1,9 +1,12 @@
import { createApp } from 'vue' import { createApp } from 'vue'
import App from './App.vue' import App from './App.vue'
import { vuetify } from './plugins/vuetify' import { vuetify } from './plugins/vuetify'
import router from './router'
import '@mdi/font/css/materialdesignicons.css' import '@mdi/font/css/materialdesignicons.css'
import './main.css'; import './main.css';
const app = createApp(App) const app = createApp(App)
app.use(vuetify) app.use(vuetify)
app.use(router)
app.mount('#app') app.mount('#app')

17
src/router/index.ts Normal file
View File

@ -0,0 +1,17 @@
import { createRouter, createWebHistory } from 'vue-router'
import DownloadList from '../components/DownloadList.vue'
const routes = [
{
path: '/:catchAll(.*)*', // catches anything
name: 'DownloadList',
component: DownloadList,
},
]
const router = createRouter({
history: createWebHistory(),
routes,
})
export default router

View File

@ -1 +1 @@
{"root":["./src/app.vue","./src/main.ts","./src/vite-env.d.ts","./src/components/downloadlist.vue","./src/plugins/vuetify.ts"],"version":"5.8.3"} {"root":["./src/app.vue","./src/main.ts","./src/vite-env.d.ts","./src/components/downloadlist.vue","./src/plugins/vuetify.ts","./src/router/index.ts"],"version":"5.8.3"}