From 5ec53f7fd03a8dacfd9af43d9d706119fc1cc997 Mon Sep 17 00:00:00 2001 From: 13713575202 <1345916905@qq.com> Date: Wed, 14 May 2025 15:15:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=8F=E6=BB=A8=E6=8E=A5=E5=85=A5=E4=B8=BB?= =?UTF-8?q?=E5=BA=94=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 17 +++++++- .env.production | 15 +++++-- .env.test | 5 --- src/components/custom-scroll-title/index.vue | 12 +++--- src/main.js | 42 +++++++++----------- src/plugins/globalComponents.js | 8 ++++ src/plugins/micro.js | 26 ++++++++++++ src/plugins/splitpanes.js | 7 ++++ src/router/index.js | 28 ++++++++----- src/router/modules/demo.js | 8 ++-- src/router/modules/v2.js | 18 ++++----- src/views/home/index.vue | 3 +- vite.config.js | 17 +++++--- 13 files changed, 138 insertions(+), 68 deletions(-) delete mode 100644 .env.test create mode 100644 src/plugins/globalComponents.js create mode 100644 src/plugins/micro.js create mode 100644 src/plugins/splitpanes.js diff --git a/.env.development b/.env.development index de343f2..24c1868 100644 --- a/.env.development +++ b/.env.development @@ -1,6 +1,19 @@ # 开发环境 -VITE_PORT = 9000 -VITE_APP_NAME = 'digital-agriculture-screen' +# VITE_PORT = 9530 +# VITE_APP_NAME = 'new-digital-agriculture-screen' +# VITE_APP_TITLE = '政务云数字农业智慧大屏' +# VITE_APP_BASE_API = '/apis' +# VITE_APP_BASE_URL = 'http://192.168.18.99:8080' + + +# 开发环境 +VITE_PORT = 9530 +VITE_MODE = 'DEV' VITE_APP_TITLE = '政务云数字农业智慧大屏' +VITE_APP_MIAN = 'daimp-front-main' +VITE_APP_MIAN_URL = 'http://localhost:9000' +VITE_APP_NAME = 'new-digital-agriculture-screen' VITE_APP_BASE_API = '/apis' VITE_APP_BASE_URL = 'http://192.168.18.99:8080' +VITE_APP_UPLOAD_API = '/uploadApis' +VITE_APP_UPLOAD_URL = 'http://192.168.18.99:9300' diff --git a/.env.production b/.env.production index 1e8d1d8..956fefa 100644 --- a/.env.production +++ b/.env.production @@ -1,5 +1,14 @@ # 生产环境 -VITE_APP_NAME = 'digital-agriculture-screen' -VITE_APP_TITLE = '政务云数字农业智慧大屏' +# VITE_APP_NAME = 'new-digital-agriculture-screen' +# VITE_APP_TITLE = '政务云数字农业智慧大屏' +# VITE_APP_BASE_API = '/apis' +# VITE_APP_BASE_URL = '' + +VITE_APP_MIAN = 'daimp-front-main' +VITE_APP_MIAN_URL = 'http://47.109.205.240:88' +VITE_APP_NAME = 'new-digital-agriculture-screen' +# 接口 VITE_APP_BASE_API = '/apis' -VITE_APP_BASE_URL = '' \ No newline at end of file +VITE_APP_BASE_URL = '' +VITE_APP_UPLOAD_API = '/uploadApis' +VITE_APP_UPLOAD_URL = '' diff --git a/.env.test b/.env.test deleted file mode 100644 index 164baac..0000000 --- a/.env.test +++ /dev/null @@ -1,5 +0,0 @@ -# 测试环境 -VITE_APP_NAME = 'digital-agriculture-screen' -VITE_APP_TITLE = '政务云数字农业智慧大屏' -VITE_APP_BASE_API = '/apis' -VITE_APP_BASE_URL = '' \ No newline at end of file diff --git a/src/components/custom-scroll-title/index.vue b/src/components/custom-scroll-title/index.vue index 5714650..f222342 100644 --- a/src/components/custom-scroll-title/index.vue +++ b/src/components/custom-scroll-title/index.vue @@ -54,14 +54,14 @@ const props = defineProps({ type: Array, default() { return [ - { label: '首页', value: '/v2/home' }, - { label: '土地资源', value: '/v2/land' }, - { label: '投入品监管', value: '/v2/inputs' }, - { label: '产出品管理', value: '/v2/entities' }, + { label: '首页', value: '/new-digital-agriculture-screen/v2/home' }, + { label: '土地资源', value: '/new-digital-agriculture-screen/v2/land' }, + { label: '投入品监管', value: '/new-digital-agriculture-screen/v2/inputs' }, + { label: '产出品管理', value: '/new-digital-agriculture-screen/v2/entities' }, // { label: '智慧种植监测', value: 'plant' }, // { label: '智慧养殖监测', value: 'breed' }, - { label: '生产经营主体', value: '/v2/business' }, - { label: '农产品溯源', value: '/v2/trace' }, + { label: '生产经营主体', value: '/new-digital-agriculture-screen/v2/business' }, + { label: '农产品溯源', value: '/new-digital-agriculture-screen/v2/trace' }, // { label: '产业预警决策', value: 'early' }, ]; }, diff --git a/src/main.js b/src/main.js index ed8a57d..1a8f3af 100644 --- a/src/main.js +++ b/src/main.js @@ -1,34 +1,30 @@ +/** + * @Description: + * @Author: zenghua.wang + * @Date: 2024-01-24 17:14:41 + * @LastEditors: zenghua.wang + * @LastEditTime: 2024-03-22 10:11:34 + */ import 'virtual:svg-icons-register'; -import { createApp, nextTick } from 'vue'; +import { createApp } from 'vue'; import App from './App.vue'; import router from './router'; import pinia from './store'; import ElementPlus from 'element-plus'; import 'element-plus/dist/index.css'; -import 'animate.css'; +import Avue from '@smallwei/avue'; +import '@smallwei/avue/lib/index.css'; import './utils/permission'; import { registerDirective } from './directives'; +import { registerGlobalComponents } from './plugins/globalComponents'; import { registerElIcons } from './plugins/icon'; -import VueAMap, { initAMapApiLoader } from '@vuemap/vue-amap'; -import '@vuemap/vue-amap/dist/style.css'; - -// 初始化高德地图 API -initAMapApiLoader({ - key: 'c843a50db7157faf295c6fa37c48719f', - securityJsCode: 'f09302d3ed65110614bdb26e44717ddf', // 新版key需要配合安全密钥使用 - version: '2.0', - Loca: { - version: '2.0', - }, - AMapUI: { - plugins: ['misc/PathSimplifier'], - }, - plugins: ['AMap.MapType'], -}); +import { registerMicroApps } from './plugins/micro'; const app = createApp(App); -nextTick(() => { - registerElIcons(app); - registerDirective(app); -}); -app.use(pinia).use(router).use(ElementPlus).use(VueAMap).mount('#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); diff --git a/src/plugins/globalComponents.js b/src/plugins/globalComponents.js new file mode 100644 index 0000000..98f5bd1 --- /dev/null +++ b/src/plugins/globalComponents.js @@ -0,0 +1,8 @@ +import * as components from '../../../main/src/components'; + +// 全局注册组件 +export const registerGlobalComponents = (app) => { + Object.keys(components).forEach((key) => { + app.component(key, components[key]); + }); +}; diff --git a/src/plugins/micro.js b/src/plugins/micro.js new file mode 100644 index 0000000..13e7a8b --- /dev/null +++ b/src/plugins/micro.js @@ -0,0 +1,26 @@ +import { renderWithQiankun, qiankunWindow } from 'vite-plugin-qiankun/dist/helper'; + +export const registerMicroApps = async (app) => { + const initQiankun = () => { + renderWithQiankun({ + bootstrap() { + console.log('bootstrap'); + }, + mount(props) { + console.log('mount', props); + render(props); + }, + update(props) { + console.log('update', props); + }, + unmount(props) { + console.log('unmount', props); + }, + }); + }; + const render = async ({ container }) => { + await new Promise((resolve) => setTimeout(resolve, 1000)); + app.mount(container ? container.querySelector('#app') : '#app'); + }; + qiankunWindow.__POWERED_BY_QIANKUN__ ? initQiankun() : render({}); +}; diff --git a/src/plugins/splitpanes.js b/src/plugins/splitpanes.js new file mode 100644 index 0000000..dca3790 --- /dev/null +++ b/src/plugins/splitpanes.js @@ -0,0 +1,7 @@ +import { Splitpanes, Pane } from 'splitpanes'; +import 'splitpanes/dist/splitpanes.css'; + +export const registerSplitpanes = (app) => { + app.component('Splitpanes', Splitpanes); + app.component('Pane', Pane); +}; diff --git a/src/router/index.js b/src/router/index.js index ca4ceee..a256543 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -11,18 +11,26 @@ export const constantRoutes = [ // component: () => import('@/views/error/404.vue'), // hidden: true, // }, - // { - // path: '/403', - // name: '403', - // component: () => import('@/views/error/403.vue'), - // hidden: true, - // }, { - path: '/', + path: '/new-digital-agriculture-screen/403', + name: '403', + component: () => import('@/views/error/403.vue'), + hidden: true, + }, + { + path: '/new-digital-agriculture-screen', name: 'layout', component: Layout, - redirect: '/v2/land', + redirect: '/new-digital-agriculture-screen/v2/home', meta: { title: '首页', icon: 'House' }, + children: [ + { + path: '/new-digital-agriculture-screen/v2/home', + component: () => import('@/views/home/index.vue'), + name: 'home', + meta: { title: '首页', icon: '' }, + }, + ], }, // ...demoRouters, v2, @@ -38,9 +46,9 @@ export const constantRoutes = [ * @Title notFoundRouter(找不到路由) */ export const notFoundRouter = { - path: '/:pathMatch(.*)', + path: '/new-digital-agriculture-screen/:pathMatch(.*)', name: 'notFound', - redirect: '/404', + redirect: '/new-digital-agriculture-screen/404', }; const router = createRouter({ diff --git a/src/router/modules/demo.js b/src/router/modules/demo.js index 21efc26..a0de3eb 100644 --- a/src/router/modules/demo.js +++ b/src/router/modules/demo.js @@ -2,20 +2,20 @@ import Layout from '@/layouts/index.vue'; export default [ { - path: '/demo', + path: '/new-digital-agriculture-screen/demo', name: 'demo', component: Layout, - redirect: '/scrollBoard', + redirect: '/new-digital-agriculture-screen/scrollBoard', meta: { title: '案例', icon: 'document' }, children: [ { - path: '/demo/scrollBoard', + path: '/new-digital-agriculture-screen/demo/scrollBoard', name: 'scrollBoard', component: () => import('@/views/demo/scrollBoard.vue'), meta: { title: '轮播列表', icon: 'document' }, }, { - path: '/demo/rank', + path: '/new-digital-agriculture-screen/demo/rank', name: 'rank', component: () => import('@/views/demo/rank.vue'), meta: { title: '滚动排名列表', icon: 'document' }, diff --git a/src/router/modules/v2.js b/src/router/modules/v2.js index b2f9d12..c6cae90 100644 --- a/src/router/modules/v2.js +++ b/src/router/modules/v2.js @@ -1,32 +1,32 @@ import Layout from '@/layouts/index.vue'; export default { - path: '/v2', - name: 'v2', + path: '/new-digital-agriculture-screen', + name: 'layout', component: Layout, - redirect: '/v2/home', + redirect: '/new-digital-agriculture-screen/v2/home', meta: { title: '首页', icon: '' }, children: [ { - path: '/v2/home', + path: '/new-digital-agriculture-screen/v2/home', component: () => import('@/views/home/index.vue'), name: 'home', meta: { title: '首页', icon: '' }, }, { - path: '/v2/land', + path: '/new-digital-agriculture-screen/v2/land', component: () => import('@/views/land/index.vue'), name: 'land', meta: { title: '土地资源', icon: '' }, }, { - path: '/v2/inputs', + path: '/new-digital-agriculture-screen/v2/inputs', name: 'inputs', component: () => import('@/views/inputs/index.vue'), meta: { title: '投入品监管', icon: '' }, }, { - path: '/v2/entities', + path: '/new-digital-agriculture-screen/v2/entities', name: 'entities', component: () => import('@/views/entities/index.vue'), meta: { title: '产出品管理', icon: '' }, @@ -44,13 +44,13 @@ export default { // meta: { title: '', icon: '' }, // }, { - path: '/v2/business', + path: '/new-digital-agriculture-screen/v2/business', name: 'business', component: () => import('@/views/business/index.vue'), meta: { title: '生产经营主体', icon: '' }, }, { - path: 'trace', + path: '/new-digital-agriculture-screen/trace', name: 'trace', component: () => import('@/views/trace/index.vue'), meta: { title: '农产品溯源', icon: '' }, diff --git a/src/views/home/index.vue b/src/views/home/index.vue index 92d4e3b..221ea40 100644 --- a/src/views/home/index.vue +++ b/src/views/home/index.vue @@ -48,7 +48,7 @@ let homeList = reactive([ title: '数字大屏', name: 'dataV', linkType: 1, - url: '/v2/land', + url: '/new-digital-agriculture-screen/v2/land', img: 'images/vsualized/home3.png', style: 'right: 20%;bottom:320px;', imgstyle: 'width:100px;height:100px', @@ -70,6 +70,7 @@ const itemClick = (index) => { let val = homeList[index] || null; if (val && val.url != '') { if (val.linkType == 1) { + // router.push({ name: val.url }); router.push({ path: val.url }); } } diff --git a/vite.config.js b/vite.config.js index 6c45139..95a6eff 100644 --- a/vite.config.js +++ b/vite.config.js @@ -3,12 +3,12 @@ * @Author: zenghua.wang * @Date: 2022-09-18 21:24:29 * @LastEditors: zenghua.wang - * @LastEditTime: 2025-04-18 15:41:11 + * @LastEditTime: 2025-02-28 11:04:41 */ import { defineConfig, loadEnv } from 'vite'; import vue from '@vitejs/plugin-vue'; -// import qiankun from 'vite-plugin-qiankun'; +import qiankun from 'vite-plugin-qiankun'; import eslintPlugin from 'vite-plugin-eslint'; import vueSetupExtend from 'vite-plugin-vue-setup-extend'; import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'; @@ -23,9 +23,9 @@ 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 } = loadEnv(mode, process.cwd()); + 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 config = { - base: '/', + base: '/new-digital-agriculture-screen/', build: { target: 'ESNext', outDir: 'dist', @@ -36,6 +36,7 @@ export default defineConfig(({ command, mode }) => { port: VITE_PORT, open: true, https: false, + origin: 'http://localhost:9530', headers: { 'Access-Control-Allow-Origin': '*', }, @@ -45,11 +46,17 @@ export default defineConfig(({ command, mode }) => { changeOrigin: true, rewrite: (path) => path.replace(/^\/apis/, ''), }, + [VITE_APP_UPLOAD_API]: { + target: VITE_APP_UPLOAD_URL, + changeOrigin: true, + rewrite: (path) => path.replace(/^\/uploadApis/, ''), + }, }, }, resolve: { alias: { '@': resolve(__dirname, 'src'), + '#': resolve(__dirname, '../main/src'), }, extensions: ['.js', '.vue', '.json', '.ts'], }, @@ -71,7 +78,7 @@ export default defineConfig(({ command, mode }) => { }, plugins: [ vue(), - // qiankun(VITE_APP_NAME, { useDevMode }), + qiankun(VITE_APP_NAME, { useDevMode }), vueSetupExtend(), eslintPlugin({ include: ['src/**/*.ts', 'src/**/*.vue', 'src/*.ts', 'src/*.vue'],