| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- import { createApp } from "vue";
- import ElementPlus from "element-plus";
- import "element-plus/dist/index.css";
- import zhCn from "element-plus/es/locale/lang/zh-cn";
- import App from "./App.vue";
- import router from "./router";
- import store from "./store";
- import md5 from "md5";
- import "./styles/index.css";
- import Uploader from "./components/Uploader.vue";
- import Certs from "./components/Certs.vue";
- // import RemoteSearch from "./components/RemoteSearch.vue";
- import RemoteSelect from "./components/RemoteSelect.vue";
- const app = createApp(App);
- app.component("RemoteSelect", RemoteSelect);
- // app.component("RemoteSearch", RemoteSearch);
- app.component("Certs", Certs);
- app.component("Uploader", Uploader);
- // let userId = localStorage.userId;
- // if (userId) {
- // store.dispatch("GetBasePermissionData", localStorage.loginAccountId);
- // store.dispatch("GetUserPermission", localStorage.loginAccountId);
- // }
- router.beforeEach(async (to, from, next) => {
- console.log(to, from);
- let { token } = to.query;
- localStorage.setItem("token", token);
- if (token && to.matched.length) {
- store.commit("changeLogin", true);
- next();
- // let rolePermission = localStorage.rolePermission?.split(",") || [];
- // if (store.state.menuData.length) {
- // let path = store.state?.menuData[0]?.items[0].path;
- // if (0 === to.matched.length) {
- // next("/index");
- // } else if (to.path == "/login") {
- // next("/index");
- // } else if (rolePermission?.indexOf(to.meta.code) == -1) {
- // if (to.path == "/index") {
- // next();
- // } else {
- // next("/index");
- // }
- // } else {
- // if (to.path == "/") {
- // next("/index");
- // } else {
- // next();
- // }
- // }
- // } else {
- // if (to.path == "/" || to.path == "/login") {
- // next("/index");
- // } else {
- // next();
- // }
- // }
- } else {
- store.commit("changeLogin", false);
- if (to.path == "/notFound") {
- next();
- } else {
- next("/notFound");
- }
- }
- });
- router.afterEach((to, from) => {
- let { title } = to.meta;
- document.title = title;
- store.commit("setCurrentMenuItem", to.path);
- store.commit("changefirstTitle", title);
- });
- app.directive("auth", {
- mounted(el, bind) {
- // let permissions = localStorage.rolePermission?.split(",") || [];
- // if (permissions.indexOf(bind.value) == -1) {
- // el.parentNode.removeChild(el);
- // }
- },
- });
- app
- .use(router)
- .use(ElementPlus, {
- locale: zhCn,
- })
- .use(store)
- .mount("#app");
|