mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2026-08-06 19:07:25 +08:00
升级Vue3,iView替换ElementPlus
- 删除babel配置、更新依赖与入口初始化 - 全量替换UI组件、样式适配,新增迁移文档与标签/过滤器自动化替换脚本
This commit is contained in:
@@ -1,59 +1,50 @@
|
||||
import Vue from 'vue';
|
||||
import ViewUI from 'view-design';
|
||||
import Util from '../libs/util';
|
||||
import VueRouter from 'vue-router';
|
||||
import Cookies from 'js-cookie';
|
||||
import { routers } from './router';
|
||||
import { createRouter, createWebHistory } from "vue-router";
|
||||
import NProgress from "nprogress";
|
||||
import "nprogress/nprogress.css";
|
||||
import Util from "../libs/util";
|
||||
import Cookies from "js-cookie";
|
||||
import store from "@/store";
|
||||
import { routers } from "./router";
|
||||
|
||||
Vue.use(VueRouter);
|
||||
NProgress.configure({ showSpinner: false });
|
||||
|
||||
// 路由配置
|
||||
const RouterConfig = {
|
||||
mode: 'history',
|
||||
routes: routers
|
||||
};
|
||||
|
||||
/**
|
||||
* 解决重复点击菜单会控制台报错bug
|
||||
*/
|
||||
const routerPush = VueRouter.prototype.push
|
||||
VueRouter.prototype.push = function push(location) {
|
||||
return routerPush.call(this, location).catch(error => error)
|
||||
}
|
||||
|
||||
export const router = new VueRouter(RouterConfig);
|
||||
export const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes: routers,
|
||||
});
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
ViewUI.LoadingBar.start();
|
||||
NProgress.start();
|
||||
Util.title(to.meta.title);
|
||||
|
||||
next();
|
||||
|
||||
const name = to.name;
|
||||
const hasToken = Cookies.get("userInfoSeller");
|
||||
|
||||
if (!Cookies.get('userInfoSeller') && name !== 'login') {
|
||||
if (name === 'forgetPassword') {
|
||||
console.log(name)
|
||||
if (!hasToken && name !== "login") {
|
||||
if (name === "forgetPassword") {
|
||||
Util.toDefaultPage([...routers], name, router, next);
|
||||
} else {
|
||||
// 判断是否已经登录且前往的页面不是登录页
|
||||
next({
|
||||
name: 'login'
|
||||
});
|
||||
return;
|
||||
}
|
||||
} else if (Cookies.get('userInfoSeller') && name === 'login') {
|
||||
// 判断是否已经登录且前往的是登录页
|
||||
Util.title();
|
||||
next({
|
||||
name: 'home_index'
|
||||
});
|
||||
} else {
|
||||
Util.toDefaultPage([...routers], name, router, next);
|
||||
next({ name: "login" });
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasToken && name === "login") {
|
||||
Util.title();
|
||||
next({ name: "home_index" });
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasToken) {
|
||||
Util.toDefaultPage([...routers], name, router, next);
|
||||
return;
|
||||
}
|
||||
|
||||
next();
|
||||
});
|
||||
|
||||
router.afterEach((to) => {
|
||||
Util.openNewPage(router.app, to.name, to.params, to.query);
|
||||
ViewUI.LoadingBar.finish();
|
||||
Util.openNewPage({ $store: store }, to.name, to.params, to.query);
|
||||
NProgress.done();
|
||||
window.scrollTo(0, 0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user