diff --git a/frontend/src/router/index.js b/frontend/src/router/index.js index 27e2e711..6af06f33 100644 --- a/frontend/src/router/index.js +++ b/frontend/src/router/index.js @@ -13,9 +13,25 @@ import Shares from "@/views/settings/Shares"; import Errors from "@/views/Errors"; import store from "@/store"; import { baseURL, name } from "@/utils/constants"; +import i18n from "@/i18n"; Vue.use(Router); +const titles = { + Login: "sidebar.login", + Share: "buttons.share", + Files: "files.files", + Settings: "sidebar.settings", + ProfileSettings: "settings.profileSettings", + Shares: "settings.shareManagement", + GlobalSettings: "settings.globalSettings", + Users: "settings.users", + User: "settings.user", + Forbidden: "errors.forbidden", + NotFound: "errors.notFound", + InternalServerError: "errors.internal", +}; + const router = new Router({ base: baseURL, mode: "history", @@ -29,7 +45,6 @@ const router = new Router({ return next({ path: "/files" }); } - document.title = "Login - " + name; next(); }, }, @@ -63,7 +78,7 @@ const router = new Router({ children: [ { path: "/settings/profile", - name: "Profile Settings", + name: "ProfileSettings", component: ProfileSettings, }, { @@ -73,7 +88,7 @@ const router = new Router({ }, { path: "/settings/global", - name: "Global Settings", + name: "GlobalSettings", component: GlobalSettings, meta: { requiresAdmin: true, @@ -108,7 +123,7 @@ const router = new Router({ }, { path: "/404", - name: "Not Found", + name: "NotFound", component: Errors, props: { errorCode: 404, @@ -117,7 +132,7 @@ const router = new Router({ }, { path: "/500", - name: "Internal Server Error", + name: "InternalServerError", component: Errors, props: { errorCode: 500, @@ -140,7 +155,8 @@ const router = new Router({ }); router.beforeEach((to, from, next) => { - document.title = to.name + " - " + name; + const title = i18n.t(titles[to.name]); + document.title = title + " - " + name; if (to.matched.some((record) => record.meta.requiresAuth)) { if (!store.getters.isLogged) { diff --git a/frontend/src/views/Files.vue b/frontend/src/views/Files.vue index bc9e24ce..9a20f39c 100644 --- a/frontend/src/views/Files.vue +++ b/frontend/src/views/Files.vue @@ -28,7 +28,6 @@ import Breadcrumbs from "@/components/Breadcrumbs"; import Errors from "@/views/Errors"; import Preview from "@/views/files/Preview"; import Listing from "@/views/files/Listing"; -import { name } from "@/utils/constants"; function clean(path) { return path.endsWith("/") ? path.slice(0, -1) : path; @@ -52,7 +51,6 @@ export default { }, computed: { ...mapState(["req", "reload", "loading", "show"]), - name: () => name, currentView() { if (this.req.type == undefined) { return null; @@ -118,7 +116,7 @@ export default { } this.$store.commit("updateRequest", res); - document.title = `${res.name} - ${this.$route.name} - ${this.name}`; + document.title = `${res.name} - ${document.title}`; } catch (e) { this.error = e; } finally { diff --git a/frontend/src/views/Share.vue b/frontend/src/views/Share.vue index 36490f1f..5e9feb2d 100644 --- a/frontend/src/views/Share.vue +++ b/frontend/src/views/Share.vue @@ -280,7 +280,7 @@ export default { this.token = file.token || ""; this.updateRequest(file); - document.title = `${file.name} - ${this.$route.name}`; + document.title = `${file.name} - ${document.title}`; } catch (e) { this.error = e; } finally {