mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-15 07:27:33 +08:00
code refactor
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { createRouter, createWebHashHistory } from 'vue-router';
|
||||
|
||||
import { TemplateType } from '@/core/template.ts';
|
||||
import userState from '@/lib/userstate.ts';
|
||||
import { isUserLogined, isUserUnlocked } from '@/lib/userstate.ts';
|
||||
|
||||
import MainLayout from '@/views/desktop/MainLayout.vue';
|
||||
import LoginPage from '@/views/desktop/LoginPage.vue';
|
||||
@@ -32,14 +32,14 @@ import ExchangeRatesPage from '@/views/desktop/ExchangeRatesPage.vue';
|
||||
import AboutPage from '@/views/desktop/AboutPage.vue';
|
||||
|
||||
function checkLogin() {
|
||||
if (!userState.isUserLogined()) {
|
||||
if (!isUserLogined()) {
|
||||
return {
|
||||
path: '/login',
|
||||
replace: true
|
||||
};
|
||||
}
|
||||
|
||||
if (!userState.isUserUnlocked()) {
|
||||
if (!isUserUnlocked()) {
|
||||
return {
|
||||
path: '/unlock',
|
||||
replace: true
|
||||
@@ -48,14 +48,14 @@ function checkLogin() {
|
||||
}
|
||||
|
||||
function checkLocked() {
|
||||
if (!userState.isUserLogined()) {
|
||||
if (!isUserLogined()) {
|
||||
return {
|
||||
path: '/login',
|
||||
replace: true
|
||||
};
|
||||
}
|
||||
|
||||
if (userState.isUserUnlocked()) {
|
||||
if (isUserUnlocked()) {
|
||||
return {
|
||||
path: '/',
|
||||
replace: true
|
||||
@@ -64,14 +64,14 @@ function checkLocked() {
|
||||
}
|
||||
|
||||
function checkNotLogin() {
|
||||
if (userState.isUserLogined() && !userState.isUserUnlocked()) {
|
||||
if (isUserLogined() && !isUserUnlocked()) {
|
||||
return {
|
||||
path: '/unlock',
|
||||
replace: true
|
||||
};
|
||||
}
|
||||
|
||||
if (userState.isUserLogined()) {
|
||||
if (isUserLogined()) {
|
||||
return {
|
||||
path: '/',
|
||||
replace: true
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import userState from '@/lib/userstate.ts';
|
||||
import { isUserLogined, isUserUnlocked } from '@/lib/userstate.ts';
|
||||
|
||||
import HomePage from '@/views/mobile/HomePage.vue';
|
||||
import LoginPage from '@/views/mobile/LoginPage.vue';
|
||||
@@ -49,7 +49,7 @@ function asyncResolve(component) {
|
||||
}
|
||||
|
||||
function checkLogin({ router, resolve, reject }) {
|
||||
if (!userState.isUserLogined()) {
|
||||
if (!isUserLogined()) {
|
||||
reject();
|
||||
router.navigate('/login', {
|
||||
clearPreviousHistory: true,
|
||||
@@ -58,7 +58,7 @@ function checkLogin({ router, resolve, reject }) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!userState.isUserUnlocked()) {
|
||||
if (!isUserUnlocked()) {
|
||||
reject();
|
||||
router.navigate('/unlock', {
|
||||
clearPreviousHistory: true,
|
||||
@@ -71,7 +71,7 @@ function checkLogin({ router, resolve, reject }) {
|
||||
}
|
||||
|
||||
function checkLocked({ router, resolve, reject }) {
|
||||
if (!userState.isUserLogined()) {
|
||||
if (!isUserLogined()) {
|
||||
reject();
|
||||
router.navigate('/login', {
|
||||
clearPreviousHistory: true,
|
||||
@@ -80,7 +80,7 @@ function checkLocked({ router, resolve, reject }) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (userState.isUserUnlocked()) {
|
||||
if (isUserUnlocked()) {
|
||||
reject();
|
||||
router.navigate('/', {
|
||||
clearPreviousHistory: true,
|
||||
@@ -93,7 +93,7 @@ function checkLocked({ router, resolve, reject }) {
|
||||
}
|
||||
|
||||
function checkNotLogin({ router, resolve, reject }) {
|
||||
if (userState.isUserLogined() && !userState.isUserUnlocked()) {
|
||||
if (isUserLogined() && !isUserUnlocked()) {
|
||||
reject();
|
||||
router.navigate('/unlock', {
|
||||
clearPreviousHistory: true,
|
||||
@@ -102,7 +102,7 @@ function checkNotLogin({ router, resolve, reject }) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (userState.isUserLogined()) {
|
||||
if (isUserLogined()) {
|
||||
reject();
|
||||
router.navigate('/', {
|
||||
clearPreviousHistory: true,
|
||||
|
||||
Reference in New Issue
Block a user