feat: page title localization
This commit is contained in:
parent
c3bd1188aa
commit
8a43413f88
|
@ -13,9 +13,25 @@ import Shares from "@/views/settings/Shares";
|
||||||
import Errors from "@/views/Errors";
|
import Errors from "@/views/Errors";
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import { baseURL, name } from "@/utils/constants";
|
import { baseURL, name } from "@/utils/constants";
|
||||||
|
import i18n from "@/i18n";
|
||||||
|
|
||||||
Vue.use(Router);
|
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({
|
const router = new Router({
|
||||||
base: baseURL,
|
base: baseURL,
|
||||||
mode: "history",
|
mode: "history",
|
||||||
|
@ -29,7 +45,6 @@ const router = new Router({
|
||||||
return next({ path: "/files" });
|
return next({ path: "/files" });
|
||||||
}
|
}
|
||||||
|
|
||||||
document.title = "Login - " + name;
|
|
||||||
next();
|
next();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -140,7 +155,8 @@ const router = new Router({
|
||||||
});
|
});
|
||||||
|
|
||||||
router.beforeEach((to, from, next) => {
|
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 (to.matched.some((record) => record.meta.requiresAuth)) {
|
||||||
if (!store.getters.isLogged) {
|
if (!store.getters.isLogged) {
|
||||||
|
|
|
@ -28,7 +28,6 @@ import Breadcrumbs from "@/components/Breadcrumbs";
|
||||||
import Errors from "@/views/Errors";
|
import Errors from "@/views/Errors";
|
||||||
import Preview from "@/views/files/Preview";
|
import Preview from "@/views/files/Preview";
|
||||||
import Listing from "@/views/files/Listing";
|
import Listing from "@/views/files/Listing";
|
||||||
import { name } from "@/utils/constants";
|
|
||||||
|
|
||||||
function clean(path) {
|
function clean(path) {
|
||||||
return path.endsWith("/") ? path.slice(0, -1) : path;
|
return path.endsWith("/") ? path.slice(0, -1) : path;
|
||||||
|
@ -52,7 +51,6 @@ export default {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(["req", "reload", "loading", "show"]),
|
...mapState(["req", "reload", "loading", "show"]),
|
||||||
name: () => name,
|
|
||||||
currentView() {
|
currentView() {
|
||||||
if (this.req.type == undefined) {
|
if (this.req.type == undefined) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -118,7 +116,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$store.commit("updateRequest", res);
|
this.$store.commit("updateRequest", res);
|
||||||
document.title = `${res.name} - ${this.$route.name} - ${this.name}`;
|
document.title = `${res.name} - ${document.title}`;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.error = e;
|
this.error = e;
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -280,7 +280,7 @@ export default {
|
||||||
this.token = file.token || "";
|
this.token = file.token || "";
|
||||||
|
|
||||||
this.updateRequest(file);
|
this.updateRequest(file);
|
||||||
document.title = `${file.name} - ${this.$route.name}`;
|
document.title = `${file.name} - ${document.title}`;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.error = e;
|
this.error = e;
|
||||||
} finally {
|
} finally {
|
||||||
|
|
Loading…
Reference in New Issue