mirror of
https://github.com/certd/certd.git
synced 2026-05-18 22:57:31 +08:00
ad360e81cb
perf: 优化antdv4 示例授权页面tree的样式 build: publish success chore: 1 chore: 1 chore: 1 fix: getFileName支持item参数 https://github.com/fast-crud/fast-crud/issues/385 fix: fs-form独立使用支持插槽 https://github.com/fast-crud/fast-crud/issues/389 fix: 修复三级以上路由页面无法缓存的问题 https://github.com/fast-crud/fast-crud/issues/394 perf: form.wrapper.buttons支持compute动态计算 feat: 表单支持变更关闭前提醒保存,form.wrapper支持beforeClose事件 fix: 修复图片裁剪按钮上下和左右相反的bug https://github.com/fast-crud/fast-crud/issues/402 perf: alioss getAuthorization接口支持后台返回key https://github.com/fast-crud/fast-crud/issues/405 perf: alioss getAuthorization接口支持后台返回key https://github.com/fast-crud/fast-crud/issues/405 perf: fs-dict-tree支持插槽 https://github.com/fast-crud/fast-crud/issues/407 perf: 单选、多选、select、tree-select、table-select 都提供selected-change事件,可以获取选中的dict选项 feat: table-select 支持查看模式 https://github.com/fast-crud/fast-crud/issues/413 perf: 优化fs-admin可以在手机上操作 chore: pnpm workspace问题优化 docs: 1 chore: antdv4 支持主题色选择 ...
75 lines
2.0 KiB
TypeScript
75 lines
2.0 KiB
TypeScript
import { createRouter, createWebHashHistory } from "vue-router";
|
|
// 进度条
|
|
import NProgress from "nprogress";
|
|
import "nprogress/nprogress.css";
|
|
import { usePageStore } from "../store/modules/page";
|
|
import { site } from "../utils/util.site";
|
|
import { routes } from "./resolve";
|
|
import { useResourceStore } from "../store/modules/resource";
|
|
import { useUserStore } from "../store/modules/user";
|
|
const router = createRouter({
|
|
history: createWebHashHistory(),
|
|
routes
|
|
});
|
|
|
|
/**
|
|
* 路由拦截
|
|
*/
|
|
router.beforeEach(async (to, from, next) => {
|
|
// 进度条
|
|
NProgress.start();
|
|
// 修复三级以上路由页面无法缓存的问题
|
|
if (to.matched && to.matched.length > 2) {
|
|
to.matched.splice(1, to.matched.length - 2);
|
|
}
|
|
// 验证当前路由所有的匹配中是否需要有登录验证的
|
|
if (
|
|
to.matched.some((r) => {
|
|
return r.meta?.auth || r.meta?.permission;
|
|
})
|
|
) {
|
|
const userStore = useUserStore();
|
|
// 这里暂时将cookie里是否存有token作为验证是否登录的条件
|
|
// 请根据自身业务需要修改
|
|
const token = userStore.getToken;
|
|
if (token) {
|
|
next();
|
|
} else {
|
|
// 没有登录的时候跳转到登录界面
|
|
// 携带上登陆成功之后需要跳转的页面完整路径
|
|
next({
|
|
name: "login",
|
|
query: {
|
|
redirect: to.fullPath
|
|
}
|
|
});
|
|
// https://github.com/d2-projects/d2-admin/issues/138
|
|
NProgress.done();
|
|
}
|
|
} else {
|
|
// 不需要身份校验 直接通过
|
|
next();
|
|
}
|
|
});
|
|
|
|
router.afterEach((to: any) => {
|
|
// 进度条
|
|
NProgress.done();
|
|
// 多页控制 打开新的页面
|
|
const pageStore = usePageStore();
|
|
// for (const item of to.matched) {
|
|
// pageStore.keepAlivePush(item.name);
|
|
// }
|
|
pageStore.open(to);
|
|
// 更改标题
|
|
site.title(to.meta.title);
|
|
|
|
//修改左侧边栏
|
|
const matched = to.matched;
|
|
if (matched.length > 0) {
|
|
const resourceStore = useResourceStore();
|
|
resourceStore.setAsideMenuByCurrentRoute(matched);
|
|
}
|
|
});
|
|
export default router;
|