chore: improvments in rtl

This commit is contained in:
thewh1teagle 2022-10-21 19:01:34 +03:00
parent a25be32510
commit 791566b2a8
4 changed files with 15 additions and 12 deletions

View File

@ -100,6 +100,8 @@ const removeEmpty = (obj) =>
{}
);
export const rtlLanguages = ["he", "ar"];
const i18n = new VueI18n({
locale: detectLocale(),
fallbackLocale: "en",

View File

@ -12,8 +12,8 @@ import ProfileSettings from "@/views/settings/Profile";
import Shares from "@/views/settings/Shares";
import Errors from "@/views/Errors";
import store from "@/store";
import { baseURL, name, rtlLanguages } from "@/utils/constants";
import i18n from "@/i18n";
import { baseURL, name } from "@/utils/constants";
import i18n, { rtlLanguages } from "@/i18n";
Vue.use(Router);
@ -161,12 +161,13 @@ router.beforeEach((to, from, next) => {
/*** RTL related settings per route ****/
const rtlSet = document.querySelector("body").classList.contains("rtl");
const shouldSetRtl = rtlLanguages.includes(i18n.locale);
// Add RTL
if (shouldSetRtl && rtlSet === false) {
switch (true) {
case shouldSetRtl && !rtlSet:
document.querySelector("body").classList.add("rtl");
//Remove RTL
} else if (rtlSet === true && shouldSetRtl === false) {
break;
case !shouldSetRtl && rtlSet:
document.querySelector("body").classList.remove("rtl");
break;
}
if (to.matched.some((record) => record.meta.requiresAuth)) {

View File

@ -15,7 +15,6 @@ const enableThumbs = window.FileBrowser.EnableThumbs;
const resizePreview = window.FileBrowser.ResizePreview;
const enableExec = window.FileBrowser.EnableExec;
const origin = window.location.origin;
const rtlLanguages = ["he", "ar"];
export {
name,
@ -34,5 +33,4 @@ export {
resizePreview,
enableExec,
origin,
rtlLanguages,
};

View File

@ -75,7 +75,7 @@
import { mapState, mapMutations } from "vuex";
import { users as api } from "@/api";
import Languages from "@/components/settings/Languages";
import i18n from "@/i18n";
import i18n, { rtlLanguages } from "@/i18n";
export default {
name: "settings",
@ -144,7 +144,9 @@ export default {
singleClick: this.singleClick,
dateFormat: this.dateFormat,
};
const shouldReload = data.locale != i18n.locale;
const shouldReload =
rtlLanguages.includes(data.locale) !==
rtlLanguages.includes(i18n.locale);
await api.update(data, [
"locale",
"hideDotfiles",