Skip to content

Commit

Permalink
修改路由和字典
Browse files Browse the repository at this point in the history
  • Loading branch information
little3201 committed Dec 25, 2023
1 parent 5b7a23b commit ac4491d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/mock/system/dictionaries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const pagation: Pagation<Dictionary> = {
}
const datas: Array<Dictionary> = [];

for (let i = 0; i < 30090; i++) {
for (let i = 0; i < 390; i++) {
datas.push({
id: Random.increment(),
dictionaryName: Random.cword(),
Expand Down
13 changes: 3 additions & 10 deletions src/router/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { createRouter, createWebHistory, RouteLocationNormalized } from 'vue-router';
import { createRouter, createWebHistory, RouteLocationNormalized, NavigationGuardNext } from 'vue-router';
import routes from './routes';
import ProgressBar from "@badrap/bar-of-progress";
import { getCookie } from '~/composables/cookies';

const progress = new ProgressBar();

Expand All @@ -11,15 +10,9 @@ const router = createRouter({
});

/* 路由之前 */
router.beforeEach(async (to: RouteLocationNormalized, _from: RouteLocationNormalized, next) => {
router.beforeEach(async (to: RouteLocationNormalized, from: RouteLocationNormalized, next: NavigationGuardNext) => {
progress.start()
const username = getCookie("username")
const isAuthenticated = username && username.length > 0;
if (to.meta.requiresAuth && !isAuthenticated) {
window.location.href = '/api/auth/'
} else {
next()
}
next()
})

router.afterEach(() => {
Expand Down
4 changes: 2 additions & 2 deletions src/router/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ const routes: Array<RouteRecordRaw> = [
{
path: '/signin',
name: 'SignIn',
component: () => import('/src/views/sign/SignIn.vue'),
component: () => import('~/views/sign/SignIn.vue'),
},
{
path: '/signup',
name: 'Signup',
component: () => import('/src/views/sign/SignUp.vue'),
component: () => import('~/views/sign/SignUp.vue'),
},
{ path: '/:pathMatch(.*)*', name: 'NotFound', component: NotFound }
];
Expand Down

0 comments on commit ac4491d

Please sign in to comment.