diff --git a/src/router/index.js b/src/router/index.js
index 340fc410..ad3a202f 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -41,7 +41,9 @@ export default route(function (/* { store, ssrContext } */) {
if (from.name === to.name) return;
const app = useAppStore();
app.$patch({
- title: i18n.global.t(to.meta.title || 'home'),
+ title: i18n.global.t(
+ to.meta.title ? `titles.${to.meta.title}` : 'titles.Home'
+ ),
subtitle: null,
useRightDrawer: false,
rightDrawerOpen: true
diff --git a/src/stores/app.js b/src/stores/app.js
index ece6d4bb..8a856ad2 100644
--- a/src/stores/app.js
+++ b/src/stores/app.js
@@ -68,6 +68,7 @@ export const useAppStore = defineStore('hedera', {
},
async init() {
+ // this.router.push({ name: 'login' });
this.getBasketOrderId();
this.getLocaleDates();
},
@@ -150,6 +151,14 @@ export const useAppStore = defineStore('hedera', {
isMobile() {
const $q = useQuasar();
return $q?.screen?.width <= 768;
+ },
+ isTablet() {
+ const $q = useQuasar();
+ return $q?.screen?.width <= 1024;
+ },
+ isDesktop() {
+ const $q = useQuasar();
+ return $q?.screen?.width > 1024;
}
}
});
diff --git a/src/stores/user.js b/src/stores/user.js
index 4fc4c650..5c347005 100644
--- a/src/stores/user.js
+++ b/src/stores/user.js
@@ -37,6 +37,10 @@ export const useUserStore = defineStore('user', {
actions: {
async init() {
this.isGuest = localStorage.getItem('hederaGuest') || false;
+ const autoLoginStatus = await this.tryAutoLogin();
+ if (!autoLoginStatus) {
+ this.router.push({ name: 'login' });
+ }
await this.fetchUser();
await this.supplantInit();
this.updateSiteLocale();
@@ -48,6 +52,21 @@ export const useUserStore = defineStore('user', {
localStorage.getItem('vnToken');
},
+ async tryAutoLogin() {
+ const guest = localStorage.getItem('hederaGuest');
+
+ if (this.isGuest || guest) {
+ localStorage.setItem('hederaGuest', true);
+ return true;
+ }
+
+ if (!this.token) this.getToken();
+
+ if (this.token) return true;
+
+ return false;
+ },
+
async login(user, password, remember) {
const params = { user, password };
const res = await api.post('Accounts/login', params);