diff --git a/.env.development b/.env.development index 24c1868..f0e82d7 100644 --- a/.env.development +++ b/.env.development @@ -11,7 +11,7 @@ VITE_PORT = 9530 VITE_MODE = 'DEV' VITE_APP_TITLE = '政务云数字农业智慧大屏' VITE_APP_MIAN = 'daimp-front-main' -VITE_APP_MIAN_URL = 'http://localhost:9000' +VITE_APP_MIAN_URL = 'http://localhost:9530' VITE_APP_NAME = 'new-digital-agriculture-screen' VITE_APP_BASE_API = '/apis' VITE_APP_BASE_URL = 'http://192.168.18.99:8080' diff --git a/src/main.js b/src/main.js index 1a8f3af..2e4cefb 100644 --- a/src/main.js +++ b/src/main.js @@ -6,7 +6,7 @@ * @LastEditTime: 2024-03-22 10:11:34 */ import 'virtual:svg-icons-register'; -import { createApp } from 'vue'; +import { createApp, nextTick } from 'vue'; import App from './App.vue'; import router from './router'; import pinia from './store'; @@ -15,6 +15,7 @@ import 'element-plus/dist/index.css'; import Avue from '@smallwei/avue'; import '@smallwei/avue/lib/index.css'; import './utils/permission'; +import VueAMap, { initAMapApiLoader } from '@vuemap/vue-amap'; import { registerDirective } from './directives'; import { registerGlobalComponents } from './plugins/globalComponents'; import { registerElIcons } from './plugins/icon'; @@ -23,8 +24,11 @@ import { registerMicroApps } from './plugins/micro'; const app = createApp(App); // 注册 Vue3 Scroll Seamless 组件 // app.component('Vue3ScrollSeamless', vue3ScrollSeamless); -app.use(pinia).use(router).use(ElementPlus).use(Avue); -registerGlobalComponents(app); -registerElIcons(app); -registerDirective(app); -registerMicroApps(app); +// app.use(pinia).use(router).use(ElementPlus).use(Avue); +app.use(pinia).use(router).use(ElementPlus).use(Avue).use(VueAMap); +nextTick(() => { + registerGlobalComponents(app); + registerElIcons(app); + registerDirective(app); + registerMicroApps(app); +}); diff --git a/src/utils/permission.js b/src/utils/permission.js index c325e28..2ffc4d3 100644 --- a/src/utils/permission.js +++ b/src/utils/permission.js @@ -35,6 +35,11 @@ router.beforeEach(async (to, from, next) => { accessRoutes.forEach((item) => router.addRoute(item)); return next({ ...to, replace: true }); } else { + if (from.path.includes('/new') && to.path.includes('/platform')) { + window.location.reload(); + return; + } + next(); next(); } } catch (error) { diff --git a/vite.config.js b/vite.config.js index 95a6eff..0ae730b 100644 --- a/vite.config.js +++ b/vite.config.js @@ -23,7 +23,7 @@ import { resolve } from 'path'; const useDevMode = true; export default defineConfig(({ command, mode }) => { - const { VITE_PORT, VITE_APP_NAME, VITE_APP_BASE_API, VITE_APP_BASE_URL, VITE_APP_UPLOAD_API, VITE_APP_UPLOAD_URL } = loadEnv(mode, process.cwd()); + const { VITE_APP_MIAN_URL, VITE_PORT, VITE_APP_NAME, VITE_APP_BASE_API, VITE_APP_BASE_URL, VITE_APP_UPLOAD_API, VITE_APP_UPLOAD_URL } = loadEnv(mode, process.cwd()); const config = { base: '/new-digital-agriculture-screen/', build: { @@ -36,7 +36,7 @@ export default defineConfig(({ command, mode }) => { port: VITE_PORT, open: true, https: false, - origin: 'http://localhost:9530', + origin: VITE_APP_MIAN_URL, headers: { 'Access-Control-Allow-Origin': '*', },