This commit is contained in:
lzc 2025-03-03 14:52:28 +08:00
commit 0e143dfc5b
19 changed files with 71 additions and 204 deletions

View File

@ -1,5 +1,4 @@
# 开发环境 # 开发环境
VITE_PORT = 9000
VITE_APP_NAME = 'daimp-front-main' VITE_APP_NAME = 'daimp-front-main'
VITE_APP_TITLE = '数字农业产业管理平台' VITE_APP_TITLE = '数字农业产业管理平台'
VITE_APP_SUB_OS = '//localhost:8090/sub-operation-service/' VITE_APP_SUB_OS = '//localhost:8090/sub-operation-service/'

View File

@ -18,9 +18,6 @@ actions.onGlobalStateChange((newState, prev) => {
} }
}); });
// 有key表示取globalState下的某个子级对象
// 无key表示取全部
actions.getGlobalState = (key) => { actions.getGlobalState = (key) => {
return key ? initialState[key] : initialState; return key ? initialState[key] : initialState;
}; };

View File

@ -25,7 +25,6 @@ export const usePermissionStore = defineStore({
actions: { actions: {
generateRoutes(roles) { generateRoutes(roles) {
return new Promise((resolve) => { return new Promise((resolve) => {
// 在这判断是否有权限,哪些角色拥有哪些权限
const UserStore = useUserStore(); const UserStore = useUserStore();
this.asyncRoutes = createAsyncRoutes(getTree(UserStore.getMenus())); this.asyncRoutes = createAsyncRoutes(getTree(UserStore.getMenus()));
let accessedRoutes; let accessedRoutes;

View File

@ -1,64 +1,12 @@
import { defineStore } from 'pinia'; import { defineStore } from 'pinia';
import { CONSTANTS } from '@/config';
export const useSettingStore = defineStore({ export const useSettingStore = defineStore({
id: 'settingStore', id: 'settingStore',
state: () => ({ state: () => ({
// menu 是否收缩
isCollapse: true,
//
withoutAnimation: false,
device: 'desktop',
// 刷新当前页
isReload: true, isReload: true,
// 主题设置
themeConfig: {
// 显示设置
showSetting: false,
// 菜单展示模式 默认 vertical horizontal / vertical /columns
mode: 'vertical',
// tagsView 是否展示 默认展示
showTag: true,
// 页脚
footer: true,
// 深色模式 切换暗黑模式
isDark: false,
// 显示侧边栏Logo
showLogo: true,
// 主题颜色
primary: CONSTANTS.PRIMARY,
// element组件大小
globalComSize: 'default',
// 是否只保持一个子菜单的展开
uniqueOpened: true,
// 固定header
fixedHeader: true,
// 灰色模式
gray: false,
// 色弱模式
weak: false,
},
}), }),
getters: {}, getters: {},
actions: { actions: {
// 设置主题
setThemeConfig({ key, val }) {
this.themeConfig[key] = val;
},
// 切换 Collapse
setCollapse(value) {
this.isCollapse = value;
this.withoutAnimation = false;
},
// 关闭侧边栏
closeSideBar({ withoutAnimation }) {
this.isCollapse = false;
this.withoutAnimation = withoutAnimation;
},
toggleDevice(device) {
this.device = device;
},
// 刷新
setReload() { setReload() {
this.isReload = false; this.isReload = false;
setTimeout(() => { setTimeout(() => {

View File

@ -34,9 +34,10 @@ router.beforeEach(async (to, from, next) => {
if (!PermissionStore.routes.length) { if (!PermissionStore.routes.length) {
const accessRoutes = await PermissionStore.generateRoutes(userStore.roles); const accessRoutes = await PermissionStore.generateRoutes(userStore.roles);
accessRoutes.forEach((item) => router.addRoute(item)); accessRoutes.forEach((item) => router.addRoute(item));
next({ ...to, replace: true }); return next({ ...to, replace: true });
} else { } else {
if (from.path.includes('/sub') && !to.path.includes('/sub')) { if (from.path.includes('/sub') && (!to.path.includes('/sub') || to.path.includes('/platform'))) {
NProgress.done();
window.location.reload(); window.location.reload();
return; return;
} }

View File

@ -36,22 +36,15 @@ import actions from '@/micro/actions';
import { getAssetsFile } from '@/utils'; import { getAssetsFile } from '@/utils';
const gotoPage = (row) => { const gotoPage = (row) => {
// const curentApp = microApps.find((item) => row.name === item.name);
// actions.setGlobalState({
// curentApp,
// });
// console.log('===', actions.getGlobalState('user'));
// if (row.name !== 'sub-government-affairs-service') return;
window.history.pushState({}, row.name, row.activeRule); window.history.pushState({}, row.name, row.activeRule);
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.platform { .platform {
width: 100%; width: 100%;
height: 100%; min-height: 100%;
background-image: url('@/assets/images/platform/bg.png'); background-image: url('@/assets/images/platform/bg.png');
background-size: cover; background-size: cover;
// background-position: center;
&-title { &-title {
width: 1200px; width: 1200px;

View File

@ -21,30 +21,6 @@ export default defineConfig(({ command, mode }) => {
target: 'ESNext', target: 'ESNext',
outDir: 'dist', outDir: 'dist',
minify: 'terser', minify: 'terser',
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
pure_funcs: ['console.log'],
},
output: {
comments: true,
},
},
reportCompressedSize: false,
chunkSizeWarningLimit: 2000,
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes('node_modules')) {
return id.toString().split('node_modules/')[1].split('/')[1].toString();
}
},
chunkFileNames: 'assets/js/[name]-[hash].js',
entryFileNames: 'assets/js/[name]-[hash].js',
assetFileNames: 'assets/[ext]/[name]-[hash].[ext]',
},
},
}, },
server: { server: {
host: '0.0.0.0', host: '0.0.0.0',
@ -119,5 +95,13 @@ export default defineConfig(({ command, mode }) => {
}), }),
], ],
}; };
if (mode === 'production') {
config.build.terserOptions = {
compress: {
drop_console: true,
drop_debugger: true,
},
};
}
return config; return config;
}); });

View File

@ -7,7 +7,7 @@
<title>政务服务</title> <title>政务服务</title>
</head> </head>
<body> <body>
<div id="sub-app"></div> <div id="app"></div>
<script type="module" src="/src/main.js"></script> <script type="module" src="/src/main.js"></script>
</body> </body>
</html> </html>

View File

@ -3,7 +3,7 @@
* @Author: zenghua.wang * @Author: zenghua.wang
* @Date: 2024-01-24 18:54:01 * @Date: 2024-01-24 18:54:01
* @LastEditors: zenghua.wang * @LastEditors: zenghua.wang
* @LastEditTime: 2024-01-26 22:57:34 * @LastEditTime: 2025-02-28 11:31:12
--> -->
<template> <template>
<el-config-provider :size="size" :locale="zhCn"> <el-config-provider :size="size" :locale="zhCn">

View File

@ -2,7 +2,7 @@ import { qiankunWindow } from 'vite-plugin-qiankun/dist/helper';
const { VITE_APP_MIAN, VITE_APP_NAME } = import.meta.env; const { VITE_APP_MIAN, VITE_APP_NAME } = import.meta.env;
export const GenKey = (key, prefix = VITE_APP_NAME) => { export const GenKey = (key, prefix = VITE_APP_NAME) => {
prefix = qiankunWindow.__POWERED_BY_QIANKUN__ ? VITE_APP_MIAN : VITE_APP_NAME; prefix = qiankunWindow.__POWERED_BY_QIANKUN__ ? VITE_APP_MIAN : VITE_APP_MIAN;
return prefix ? `${prefix}_` + key : key; return prefix ? `${prefix}_` + key : key;
}; };

View File

@ -7,7 +7,7 @@
*/ */
import 'virtual:svg-icons-register'; import 'virtual:svg-icons-register';
import { createApp } from 'vue'; import { createApp } from 'vue';
import { renderWithQiankun, qiankunWindow } from 'vite-plugin-qiankun/dist/helper'; import VueAMap, { initAMapApiLoader } from '@vuemap/vue-amap';
import App from './App.vue'; import App from './App.vue';
import router from './router'; import router from './router';
import pinia from './store'; import pinia from './store';
@ -15,11 +15,12 @@ import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css'; import 'element-plus/dist/index.css';
import Avue from '@smallwei/avue'; import Avue from '@smallwei/avue';
import '@smallwei/avue/lib/index.css'; import '@smallwei/avue/lib/index.css';
import './utils/permission';
import { registerDirective } from './directives'; import { registerDirective } from './directives';
import { registerGlobalComponents } from './plugins/globalComponents'; import { registerGlobalComponents } from './plugins/globalComponents';
import { registerElIcons } from './plugins/icon'; import { registerElIcons } from './plugins/icon';
import './utils/permission'; import { registerMicroApps } from './plugins/micro';
import VueAMap, { initAMapApiLoader } from '@vuemap/vue-amap';
initAMapApiLoader({ initAMapApiLoader({
key: 'c843a50db7157faf295c6fa37c48719f', key: 'c843a50db7157faf295c6fa37c48719f',
securityJsCode: 'f09302d3ed65110614bdb26e44717ddf', // 新版key需要配合安全密钥使用 securityJsCode: 'f09302d3ed65110614bdb26e44717ddf', // 新版key需要配合安全密钥使用
@ -27,37 +28,10 @@ initAMapApiLoader({
// version: '2.0.0' // version: '2.0.0'
//} // 如果需要使用loca组件库需要加载Loca //} // 如果需要使用loca组件库需要加载Loca
}); });
const registerMicroApps = () => {
let app = null;
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);
app = null;
},
});
};
const render = async ({ container }) => {
await new Promise((resolve) => setTimeout(resolve, 1000));
app = createApp(App);
app.use(pinia).use(router).use(ElementPlus).use(Avue).use(VueAMap);
registerGlobalComponents(app);
registerElIcons(app);
registerDirective(app);
registerMicroApps(app);
app.mount(container.querySelector('#sub-app') || '#sub-app');
};
qiankunWindow.__POWERED_BY_QIANKUN__ ? initQiankun() : render({});
};
registerMicroApps(); const app = createApp(App);
app.use(pinia).use(router).use(ElementPlus).use(Avue).use(VueAMap);
registerGlobalComponents(app);
registerElIcons(app);
registerDirective(app);
registerMicroApps(app);

View File

@ -1,6 +1,6 @@
import { renderWithQiankun, qiankunWindow } from 'vite-plugin-qiankun/dist/helper'; import { renderWithQiankun, qiankunWindow } from 'vite-plugin-qiankun/dist/helper';
export const registerMicroApps = (app) => { export const registerMicroApps = async (app) => {
const initQiankun = () => { const initQiankun = () => {
renderWithQiankun({ renderWithQiankun({
bootstrap() { bootstrap() {
@ -20,11 +20,7 @@ export const registerMicroApps = (app) => {
}; };
const render = async ({ container }) => { const render = async ({ container }) => {
await new Promise((resolve) => setTimeout(resolve, 1000)); await new Promise((resolve) => setTimeout(resolve, 1000));
if (!container) { app.mount(container ? container.querySelector('#app') : '#app');
console.error('挂载容器不存在');
return;
}
app.mount(container.querySelector('#sub-app') || '#sub-app');
}; };
qiankunWindow.__POWERED_BY_QIANKUN__ ? initQiankun() : render({}); qiankunWindow.__POWERED_BY_QIANKUN__ ? initQiankun() : render({});
}; };

View File

@ -3,10 +3,9 @@
* @Author: zenghua.wang * @Author: zenghua.wang
* @Date: 2023-06-20 11:48:41 * @Date: 2023-06-20 11:48:41
* @LastEditors: zenghua.wang * @LastEditors: zenghua.wang
* @LastEditTime: 2025-02-18 11:22:07 * @LastEditTime: 2025-02-28 13:50:00
*/ */
import { createRouter, createWebHistory } from 'vue-router'; import { createRouter, createWebHistory } from 'vue-router';
import { qiankunWindow } from 'vite-plugin-qiankun/dist/helper';
import Layout from '@/layouts/index.vue'; import Layout from '@/layouts/index.vue';
import resourceRouter from './modules/resource'; import resourceRouter from './modules/resource';
@ -15,40 +14,28 @@ import landsRoutes from './modules/lands';
import annualplanRoutes from './modules/annualplan'; import annualplanRoutes from './modules/annualplan';
import statisticsRoutes from './modules/statistics'; import statisticsRoutes from './modules/statistics';
const { VITE_APP_NAME } = import.meta.env;
export const constantRoutes = [ export const constantRoutes = [
{ {
path: '/404', path: '/sub-government-affairs-service/404',
name: '404', name: '404',
component: () => import('@/views/error/404.vue'), component: () => import('@/views/error/404.vue'),
hidden: true, hidden: true,
}, },
{ {
path: '/403', path: '/sub-government-affairs-service/403',
name: '403', name: '403',
component: () => import('@/views/error/403.vue'), component: () => import('@/views/error/403.vue'),
hidden: true, hidden: true,
}, },
// {
// path: '/login',
// name: 'login',
// component: () => import('@/views/error/404.vue'),
// hidden: true,
// meta: {
// title: '登录',
// icon: 'Login',
// },
// },
{ {
path: '/', path: '/sub-government-affairs-service',
name: 'layout', name: 'layout',
component: Layout, component: Layout,
redirect: '/home', redirect: '/sub-government-affairs-service/home',
meta: { title: '政务服务', icon: 'House' }, meta: { title: '政务服务', icon: 'House' },
children: [ children: [
{ {
path: '/home', path: '/sub-government-affairs-service/home',
component: () => import('@/views/home/index.vue'), component: () => import('@/views/home/index.vue'),
name: 'home', name: 'home',
meta: { title: '首页', icon: 'House' }, meta: { title: '首页', icon: 'House' },
@ -66,13 +53,13 @@ export const constantRoutes = [
* @Title notFoundRouter(找不到路由) * @Title notFoundRouter(找不到路由)
*/ */
export const notFoundRouter = { export const notFoundRouter = {
path: '/:pathMatch(.*)', path: '/sub-government-affairs-service/:pathMatch(.*)',
name: 'notFound', name: 'notFound',
redirect: '/404', redirect: '/sub-government-affairs-service/404',
}; };
const router = createRouter({ const router = createRouter({
history: createWebHistory(qiankunWindow.__POWERED_BY_QIANKUN__ ? `/${VITE_APP_NAME}/` : '/'), // history history: createWebHistory(),
routes: constantRoutes, routes: constantRoutes,
}); });

View File

@ -3,27 +3,27 @@ import Views from '@/layouts/Views.vue';
export default [ export default [
{ {
path: '/plantingAndBreeding', path: '/sub-government-affairs-service/plantingAndBreeding',
name: 'plantingAndBreeding', name: 'plantingAndBreeding',
component: Layout, component: Layout,
redirect: '/breeding', redirect: '/sub-government-affairs-service/breeding',
meta: { title: '种养殖管理', icon: 'Document' }, meta: { title: '种养殖管理', icon: 'Document' },
children: [ children: [
{ {
path: '/planting', path: '/sub-government-affairs-service/planting',
name: 'planting', name: 'planting',
component: Views, component: Views,
meta: { title: '种植档案', icon: 'Document' }, meta: { title: '种植档案', icon: 'Document' },
redirect: '/planting-base', redirect: '/sub-government-affairs-service/planting-base',
children: [ children: [
{ {
path: '/planting-base', path: '/sub-government-affairs-service/planting-base',
component: () => import('@/views/trace/planting/base/index.vue'), component: () => import('@/views/trace/planting/base/index.vue'),
name: 'planting-base', name: 'planting-base',
meta: { title: '基地档案', icon: 'Document' }, meta: { title: '基地档案', icon: 'Document' },
}, },
{ {
path: '/planting-seed', path: '/sub-government-affairs-service/planting-seed',
component: () => import('@/views/trace/planting/seed/index.vue'), component: () => import('@/views/trace/planting/seed/index.vue'),
name: 'planting-seed', name: 'planting-seed',
meta: { title: '种子档案', icon: 'Document' }, meta: { title: '种子档案', icon: 'Document' },
@ -31,20 +31,20 @@ export default [
], ],
}, },
{ {
path: '/breeding', path: '/sub-government-affairs-service/breeding',
name: 'breeding', name: 'breeding',
component: Views, component: Views,
meta: { title: '农事管理', icon: 'Document' }, meta: { title: '农事管理', icon: 'Document' },
redirect: '/breeding-coding', redirect: '/sub-government-affairs-service/breeding-coding',
children: [ children: [
{ {
path: '/breeding-coding', path: '/sub-government-affairs-service/breeding-coding',
component: () => import('@/views/trace/breeding/coding/index.vue'), component: () => import('@/views/trace/breeding/coding/index.vue'),
name: 'breeding-coding', name: 'breeding-coding',
meta: { title: '采收与赋码管理', icon: 'Document' }, meta: { title: '采收与赋码管理', icon: 'Document' },
}, },
{ {
path: '/breeding-quality', path: '/sub-government-affairs-service/breeding-quality',
component: () => import('@/views/trace/breeding/quality/index.vue'), component: () => import('@/views/trace/breeding/quality/index.vue'),
name: 'breeding-quality', name: 'breeding-quality',
meta: { title: '产品质检管理', icon: 'Document' }, meta: { title: '产品质检管理', icon: 'Document' },
@ -54,20 +54,20 @@ export default [
], ],
}, },
{ {
path: '/trace', path: '/sub-government-affairs-service/trace',
name: 'trace', name: 'trace',
component: Layout, component: Layout,
redirect: '/trace-search', redirect: '/sub-government-affairs-service/trace-search',
meta: { title: '溯源查询', icon: 'Document' }, meta: { title: '溯源查询', icon: 'Document' },
children: [ children: [
{ {
path: '/trace-search', path: '/sub-government-affairs-service/trace-search',
name: 'trace-search', name: 'trace-search',
component: () => import('@/views/trace/search/index.vue'), component: () => import('@/views/trace/search/index.vue'),
meta: { title: '溯源查询', icon: 'Document' }, meta: { title: '溯源查询', icon: 'Document' },
}, },
{ {
path: '/trace-info', path: '/sub-government-affairs-service/trace-info',
name: 'trace-info', name: 'trace-info',
component: () => import('@/views/trace/search/info.vue'), component: () => import('@/views/trace/search/info.vue'),
meta: { title: '溯源详情', icon: 'Document' }, meta: { title: '溯源详情', icon: 'Document' },

View File

@ -3,14 +3,14 @@ import Views from '@/layouts/Views.vue';
export default [ export default [
{ {
path: '/resource', path: '/sub-government-affairs-service/resource',
name: 'resource', name: 'resource',
component: Layout, component: Layout,
redirect: '/grid', redirect: '/sub-government-affairs-service/grid',
meta: { title: '土地资源管理', icon: 'icon-test' }, meta: { title: '土地资源管理', icon: 'icon-test' },
children: [ children: [
{ {
path: '/grid', path: '/sub-government-affairs-service/grid',
component: () => import('@/views/resource/grid/index.vue'), component: () => import('@/views/resource/grid/index.vue'),
name: 'grid', name: 'grid',
meta: { title: '网格化管理', icon: 'Document' }, meta: { title: '网格化管理', icon: 'Document' },

View File

@ -1,8 +1,9 @@
import { defineStore } from 'pinia'; import { defineStore } from 'pinia';
import { CONSTANTS } from '@/config'; import { CONSTANTS } from '@/config';
import { GenKey } from '@/config';
export const useSettingStore = defineStore({ export const useSettingStore = defineStore({
id: 'settingStore', id: GenKey('settingStore'),
state: () => ({ state: () => ({
// menu 是否收缩 // menu 是否收缩
isCollapse: true, isCollapse: true,

View File

@ -34,8 +34,12 @@ router.beforeEach(async (to, from, next) => {
if (!PermissionStore.routes.length) { if (!PermissionStore.routes.length) {
const accessRoutes = await PermissionStore.generateRoutes(userStore.roles); const accessRoutes = await PermissionStore.generateRoutes(userStore.roles);
accessRoutes.forEach((item) => router.addRoute(item)); accessRoutes.forEach((item) => router.addRoute(item));
next({ ...to, replace: true }); return next({ ...to, replace: true });
} else { } else {
if (from.path.includes('/sub') && to.path.includes('/platform')) {
window.location.reload();
return;
}
next(); next();
} }
} catch (error) { } catch (error) {

View File

@ -24,9 +24,9 @@
<el-button type="success" icon="download" @click="onExport">导出</el-button> <el-button type="success" icon="download" @click="onExport">导出</el-button>
</template> </template>
<template #id="{ row }"> <!-- <template #id="{ row }">
<el-image style="width: 50px; height: 50px; cursor: pointer" :src="row.orCodeUrl" fit="cover" lazy @click="onViewCode(row)" /> <el-image style="width: 50px; height: 50px; cursor: pointer" :src="row.orCodeUrl" fit="cover" lazy @click="onViewCode(row)" />
</template> </template> -->
<template #productUrl-form="{ column }"> <template #productUrl-form="{ column }">
<el-upload class="custom-form__uploader" action="#" :show-file-list="false" accept="image/*" :limit="1" :http-request="rowUploadPicture"> <el-upload class="custom-form__uploader" action="#" :show-file-list="false" accept="image/*" :limit="1" :http-request="rowUploadPicture">

View File

@ -3,7 +3,7 @@
* @Author: zenghua.wang * @Author: zenghua.wang
* @Date: 2022-09-18 21:24:29 * @Date: 2022-09-18 21:24:29
* @LastEditors: zenghua.wang * @LastEditors: zenghua.wang
* @LastEditTime: 2025-02-27 09:16:00 * @LastEditTime: 2025-02-28 11:04:41
*/ */
import { defineConfig, loadEnv } from 'vite'; import { defineConfig, loadEnv } from 'vite';
@ -30,30 +30,6 @@ export default defineConfig(({ command, mode }) => {
target: 'ESNext', target: 'ESNext',
outDir: 'dist', outDir: 'dist',
minify: 'terser', minify: 'terser',
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
pure_funcs: ['console.log'],
},
output: {
comments: true,
},
},
reportCompressedSize: false,
chunkSizeWarningLimit: 2000,
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes('node_modules')) {
return id.toString().split('node_modules/')[1].split('/')[1].toString();
}
},
chunkFileNames: 'assets/js/[name]-[hash].js',
entryFileNames: 'assets/js/[name]-[hash].js',
assetFileNames: 'assets/[ext]/[name]-[hash].[ext]',
},
},
}, },
server: { server: {
host: '0.0.0.0', host: '0.0.0.0',
@ -128,5 +104,13 @@ export default defineConfig(({ command, mode }) => {
}), }),
], ],
}; };
if (mode === 'production') {
config.build.terserOptions = {
compress: {
drop_console: true,
drop_debugger: true,
},
};
}
return config; return config;
}); });