| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- import { createApp } from "vue";
- import ElementPlus from "element-plus";
- import "element-plus/dist/index.css";
- import App from "./App.vue";
- import router from "./router";
- import store from "./store";
- import "./styles/index.css";
- import Uploader from "./components/Uploader.vue";
- import IdUploader from "./components/IdUploader.vue";
- import ShipInfo from "./components/ShipInfo.vue";
- import RemoteSearch from "./components/RemoteSearch.vue";
- import RemoteSelect from "./components/RemoteSelect.vue";
- import zhCn from "element-plus/dist/locale/zh-cn.mjs";
- import Layout from "./layout/Layout.vue";
- import { createPinia } from "pinia";
- const pinia = createPinia();
- const app = createApp(App);
- app.use(ElementPlus, {
- locale: zhCn,
- });
- app.use(pinia);
- app.component("Layout", Layout);
- app.component("ShipInfo", ShipInfo);
- app.component("Uploader", Uploader);
- app.component("IdUploader", IdUploader);
- app.component("RemoteSearch", RemoteSearch);
- app.component("RemoteSelect", RemoteSelect);
- import * as ElementPlusIconsVue from "@element-plus/icons-vue";
- for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
- app.component(key, component);
- }
- router.beforeEach(async (to, from, next) => {
- let id = localStorage.loginAccountId;
- if (id) {
- store.commit("changeLogin", true);
- if (0 === to.matched.length) {
- next("/index");
- } else if (to.path == "/login" || to.path == "/") {
- next("/index");
- } else {
- next();
- }
- } else {
- localStorage.removeItem("loginAccountId");
- localStorage.removeItem("loginName");
- localStorage.removeItem("loginPhone");
- localStorage.removeItem("shippingCompany");
- localStorage.removeItem("shippingId");
- store.commit("changeLogin", false);
- if (to.path == "/login") {
- next();
- } else {
- next("/login");
- }
- }
- });
- router.afterEach((to, from) => {
- let { title } = to.meta;
- document.title = "船务公司 - " + title;
- store.commit("setCurrentMenuItem", to.path);
- store.commit("changefirstTitle", title);
- });
- app.use(router).use(store).mount("#app");
|