fix:sug-gas

This commit is contained in:
wangzenghua 2025-02-27 01:24:25 +00:00
parent f1721d8b71
commit f1e6740b0d
20 changed files with 645 additions and 146 deletions

View File

@ -2,6 +2,7 @@
VITE_PORT = 9528
VITE_MODE = 'DEV'
VITE_APP_MIAN = 'daimp-front-main'
VITE_APP_MIAN_URL = 'http://localhost:9000'
VITE_APP_NAME = 'sub-government-affairs-service'
VITE_APP_BASE_API = '/apis'
VITE_APP_BASE_URL = 'http://192.168.18.99:8080'

View File

@ -1,6 +1,7 @@
# 生产环境
VITE_MODE = 'PRO'
VITE_APP_MIAN = 'daimp-front-main'
VITE_APP_MIAN_URL = 'http://192.168.18.99:88'
VITE_APP_NAME = 'sub-government-affairs-service'
# 接口
VITE_APP_BASE_API = '/apis'

View File

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

View File

@ -6,8 +6,7 @@
"scripts": {
"dev": "vite --mode development",
"build": "vite build --mode production",
"build:dev": "vite build --mode dev",
"build:qa": "vite build --mode qa",
"test": "vite build --mode test",
"preview": "vite preview",
"format": "prettier --write 'src/**/*.{vue,ts,tsx,js,jsx,css,less,scss,json,md}'",
"eslint": "npx eslint --init",

View File

@ -1,43 +0,0 @@
import request from '@/utils/axios';
/**
* @Title: 登录
*/
export function Login(params, token) {
return request('/store/login', {
method: 'POST',
data: null,
params: params,
headers: {
'fairies-auth-token': token,
},
});
}
/**
* @Title: 登出
*/
export function LogOut() {
return request('/store/logout', {
method: 'POST',
});
}
/**
* @Title: 验证码
*/
export function GetCaptcha() {
return request('/store/login-captcha', {
method: 'GET',
responseType: 'arraybuffer',
});
}
/**
* @Title: 获取菜单
*/
export function GetMenus() {
return request('/store/self/menu', {
method: 'GET',
});
}

View File

@ -0,0 +1,61 @@
import request from '@/utils/axios';
/**
* @Title: 列表
*/
export function GetEntityList(params = {}) {
return request('/land-resource/annualManage/page', {
method: 'GET',
params,
});
}
/**
* @Title: 新增
*/
export function AddEntity(data = {}) {
return request('/land-resource/annualManage/save', {
method: 'POST',
data,
});
}
/**
* @Title: 修改
*/
export function UpdateEntity(data = {}) {
return request('/land-resource/annualManage/edit', {
method: 'PUT',
data,
});
}
/**
* @Title: 审核
*/
export function AuditEntity(data = {}) {
return request('/land-resource/annualManage/exam', {
method: 'PUT',
data,
});
}
/**
* @Title: 删除
*/
export function DeleteEntity(params = {}) {
return request(`/land-resource/annualManage/delete/${params.id}`, {
method: 'DELETE',
});
}
/**
* @Title: 导出
*/
export function ExportEntity(params = {}) {
return request('/land-resource/annualManage/export', {
method: 'GET',
params,
responseType: 'blob',
});
}

View File

@ -0,0 +1,54 @@
<template>
<el-dialog
v-model="state.visible"
draggable
title="溯源码"
width="40%"
:close-on-click-modal="false"
:close-on-press-escape="false"
@close="onClose"
>
<div class="code-panel">
<div class="code-panel-picture">
<el-image style="width: 200px; height: 200px" :src="row.orCodeUrl" fit="cover" lazy />
</div>
<el-button type="primary" @click="downloadFile(row.orCodeUrl, `${row.productName}-溯源码.png`, 'image')"> 下载溯源码</el-button>
</div>
</el-dialog>
</template>
<script setup name="code-dialog">
import { reactive } from 'vue';
import { downloadFile } from '@/utils';
const props = defineProps({
row: {
type: Object,
default: () => {},
},
});
const emit = defineEmits(['on-close']);
const state = reactive({
visible: false,
});
const onClose = () => {
state.visible = false;
};
defineExpose({
show: () => {
state.visible = true;
},
hide: () => {
onClose();
},
});
</script>
<style lang="scss" scoped>
.code {
&-panel {
padding-bottom: 40px;
text-align: center;
}
}
</style>

View File

@ -3,7 +3,7 @@
* @Author: zenghua.wang
* @Date: 2023-06-20 14:29:45
* @LastEditors: zenghua.wang
* @LastEditTime: 2025-02-14 11:39:56
* @LastEditTime: 2025-02-18 09:48:18
-->
<template>
<el-dropdown class="layout-avatar">
@ -33,7 +33,7 @@ import { useUserStore } from '@/store/modules/user';
import { useTagsViewStore } from '@/store/modules/tagsView';
import { usePermissionStore } from '@/store/modules/permission';
import { getAssetsFile } from '@/utils';
import { LogOut } from '@/apis/login';
import { Logout } from '#/apis/login';
const router = useRouter();
const UserStore = useUserStore();
@ -49,7 +49,7 @@ const logOut = async () => {
cancelButtonText: '取消',
type: 'warning',
}).then(async () => {
LogOut().then((res) => {
Logout().then((res) => {
if (res.code === 200) {
UserStore.logout();
TagsViewStore.clearVisitedView();

View File

@ -7,22 +7,55 @@
*/
import 'virtual:svg-icons-register';
import { createApp } from 'vue';
import { renderWithQiankun, qiankunWindow } from 'vite-plugin-qiankun/dist/helper';
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 Avue from '@smallwei/avue';
import '@smallwei/avue/lib/index.css';
import './utils/permission';
// import Avue from '@smallwei/avue';
// import '@smallwei/avue/lib/index.css';
import { registerDirective } from './directives';
import { registerGlobalComponents } from './plugins/globalComponents';
import { registerElIcons } from './plugins/icon';
import { registerMicroApps } from './plugins/micro';
// import { registerMicroApps } from './plugins/micro';
import './utils/permission';
const app = createApp(App);
app.use(pinia).use(router).use(ElementPlus).use(Avue);
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));
// if (!container) {
// console.error('挂载容器不存在');
// return;
// }
app = createApp(App);
app.use(pinia).use(router).use(ElementPlus);
registerGlobalComponents(app);
registerElIcons(app);
registerDirective(app);
registerMicroApps(app);
app.mount(container.querySelector('#sub-app') || '#sub-app');
};
qiankunWindow.__POWERED_BY_QIANKUN__ ? initQiankun() : render({});
};
registerMicroApps();

View File

@ -24,7 +24,7 @@ export const registerMicroApps = (app) => {
console.error('挂载容器不存在');
return;
}
app.mount(container.querySelector('#app') || '#app');
app.mount(container.querySelector('#sub-app') || '#sub-app');
};
qiankunWindow.__POWERED_BY_QIANKUN__ ? initQiankun() : render({});
};

View File

@ -3,7 +3,7 @@
* @Author: zenghua.wang
* @Date: 2023-06-20 11:48:41
* @LastEditors: zenghua.wang
* @LastEditTime: 2025-02-17 11:47:53
* @LastEditTime: 2025-02-18 11:22:07
*/
import { createRouter, createWebHistory } from 'vue-router';
import { qiankunWindow } from 'vite-plugin-qiankun/dist/helper';
@ -27,6 +27,16 @@ export const constantRoutes = [
component: () => import('@/views/error/403.vue'),
hidden: true,
},
// {
// path: '/login',
// name: 'login',
// component: () => import('@/views/error/404.vue'),
// hidden: true,
// meta: {
// title: '登录',
// icon: 'Login',
// },
// },
{
path: '/',
name: 'layout',
@ -42,7 +52,7 @@ export const constantRoutes = [
},
],
},
// ...resourceRouter,
...resourceRouter,
...plantingAndBreedingRouter,
];
@ -50,9 +60,9 @@ export const constantRoutes = [
* @Title notFoundRouter(找不到路由)
*/
export const notFoundRouter = {
// path: '/:pathMatch(.*)',
// name: 'notFound',
// redirect: '/404',
path: '/:pathMatch(.*)',
name: 'notFound',
redirect: '/404',
};
const router = createRouter({

View File

@ -15,12 +15,12 @@ export default [
name: 'grid',
meta: { title: '网格化管理', icon: 'Document' },
},
{
path: '/grid2',
component: () => import('@/views/resource/grid/index.vue'),
name: 'grid2',
meta: { title: '网格化管理2', icon: 'Document' },
},
// {
// path: '/annual-plan',
// component: () => import('@/views/resource/plan/index.vue'),
// name: 'annual-plan',
// meta: { title: '年度计划', icon: 'Document' },
// },
],
},
];

View File

@ -3,7 +3,7 @@ import { GenKey } from '@/config';
import { isEmpty, encode, decode } from '@/utils';
export const useUserStore = defineStore({
id: GenKey('user_store'),
id: GenKey('userStore'),
state: () => ({
token: null,
userInfo: {},
@ -52,14 +52,14 @@ export const useUserStore = defineStore({
this.currentOrg = null;
this.orgList = [];
this.menus = [];
localStorage.removeItem(GenKey('user_store'));
localStorage.removeItem(GenKey('userStore'));
},
clear() {
localStorage.removeItem(GenKey('user_store'));
localStorage.removeItem(GenKey('userStore'));
},
},
persist: {
key: GenKey('user_store'),
key: GenKey('userStore'),
storage: window.localStorage,
},
});

View File

@ -3,7 +3,7 @@
* @Author: zenghua.wang
* @Date: 2022-02-23 21:12:37
* @LastEditors: zenghua.wang
* @LastEditTime: 2025-02-13 14:47:02
* @LastEditTime: 2025-02-18 09:47:41
*/
import axios from 'axios';
import { ElNotification } from 'element-plus';

View File

@ -5,6 +5,7 @@
* @LastEditors: zenghua.wang
* @LastEditTime: 2024-02-26 13:54:43
*/
import { qiankunWindow } from 'vite-plugin-qiankun/dist/helper';
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';
import router from '@/router';
@ -13,8 +14,8 @@ import { usePermissionStore } from '@/store/modules/permission';
NProgress.configure({ showSpinner: false });
const whiteList = ['/login', '/auth-redirect']; // 设置白名单
const { VITE_APP_MIAN_URL } = import.meta.env;
const whiteList = [];
router.beforeEach(async (to, from, next) => {
NProgress.start();
if (typeof to.meta.title === 'string') {
@ -26,28 +27,30 @@ router.beforeEach(async (to, from, next) => {
console.log('sub', hasToken);
if (hasToken) {
if (to.path === '/login') {
// 如果已登录,请重定向到主页
next({ path: '/' });
} else {
try {
const PermissionStore = usePermissionStore();
// 路由添加进去了没有及时更新 需要重新进去一次拦截
if (!PermissionStore.routes.length) {
// 获取权限列表进行接口访问 因为这里页面要切换权限
const accessRoutes = await PermissionStore.generateRoutes(userStore.roles);
accessRoutes.forEach((item) => router.addRoute(item)); // 动态添加访问路由表
next({ ...to, replace: true }); // 这里相当于push到一个页面 不在进入路由拦截
accessRoutes.forEach((item) => router.addRoute(item));
next({ ...to, replace: true });
} else {
next(); // 如果不传参数就会重新执行路由拦截,重新进到这里
next();
}
} catch (error) {
next(`/login?redirect=${to.path}`);
}
}
} else {
NProgress.done();
if (whiteList.indexOf(to.path) !== -1) {
next();
} else {
if (qiankunWindow.__POWERED_BY_QIANKUN__) {
window.location.href = VITE_APP_MIAN_URL;
return;
}
next(`/login?redirect=${to.path}`);
}
}

View File

@ -129,13 +129,13 @@ const state = reactive({
},
{
label: '省',
prop: 'province',
prop: 'provinceCode',
hide: true,
display: false,
},
{
label: '市',
prop: 'city',
prop: 'cityCode',
hide: true,
display: false,
},
@ -165,11 +165,6 @@ const state = reactive({
rows: 4,
overHidden: true,
width: 200,
rules: {
required: true,
message: '请输入',
trigger: 'blur',
},
},
{
label: '创建时间',
@ -272,9 +267,10 @@ const rowView = (row) => {
const setCity = (row) => {
if (!isEmpty(row.cities)) {
row.province = row?.cities[0] ?? null;
row.city = row?.cities[1] ?? null;
row.county = row?.cities[2] ?? null;
row.provinceCode = row?.cities[0] ?? null;
row.cityCode = row?.cities[1] ?? null;
row.gridAreaCode = row?.cities[2] ?? null;
row.townCode = row?.cities[3] ?? null;
row.village = row?.cities[3] ?? null;
}
};
@ -300,7 +296,7 @@ const rowSave = (row, done, loading) => {
//
const rowEdit = (row) => {
row.cities = compact([row.province, row.city, row.county ?? '', row.village ?? '']);
row.cities = compact([row.provinceCode, row.cityCode, row.gridAreaCode ?? '', row.townCode ?? '', row.village ?? '']);
crudRef.value.rowEdit(row);
};
const rowUpdate = (row, index, done, loading) => {

View File

@ -0,0 +1,383 @@
<template>
<div class="custom-page">
<avue-crud
ref="crudRef"
v-model="state.form"
v-model:search="state.query"
v-model:page="state.pageData"
:table-loading="state.loading"
:data="state.data"
:option="state.options"
@refresh-change="refreshChange"
@search-reset="searchChange"
@search-change="searchChange"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@row-save="rowSave"
@row-update="rowUpdate"
@row-del="rowDel"
>
<template #menu-left>
<el-button type="success" icon="download" @click="onExport">导出</el-button>
</template>
<template #menu="scope">
<custom-table-operate :actions="state.options.actions" :data="scope" />
</template>
</avue-crud>
</div>
</template>
<script setup>
import { reactive, ref } from 'vue';
import { useApp } from '@/hooks';
import { CRUD_OPTIONS } from '@/config';
import { isEmpty, downloadFile } from '@/utils';
import { useUserStore } from '@/store/modules/user';
import { compact } from 'lodash';
import { GetEntityList, AddEntity, AuditEntity, UpdateEntity, DeleteEntity, ExportEntity } from '@/apis/plan';
const { VITE_APP_BASE_API } = import.meta.env;
const app = useApp();
const UserStore = useUserStore();
const crudRef = ref(null);
const state = reactive({
loading: false,
query: {
current: 1,
size: 10,
},
form: {},
selection: [],
options: {
...CRUD_OPTIONS,
addBtnText: '添加计划',
column: [
{
label: '计划编号',
prop: 'id',
search: true,
addDisplay: false,
editDisplay: false,
viewDisplay: true,
width: 200,
},
{
label: '计划名称',
prop: 'planName',
search: true,
width: 200,
rules: {
required: true,
message: '请输入',
trigger: 'blur',
},
},
{
label: '种植面积(亩)',
prop: 'plantingArea',
rules: {
required: true,
message: '请输入',
trigger: 'blur',
},
formatter: (row) => {
return row?.plantingArea ? row.plantingArea + '亩' : '';
},
},
{
label: '种植月份',
prop: 'plantingMonths',
type: 'select',
dicData: [
{ label: '1月', value: '1月' },
{ label: '2月', value: '2月' },
{ label: '3月', value: '3月' },
{ label: '4月', value: '4月' },
{ label: '5月', value: '5月' },
{ label: '6月', value: '6月' },
{ label: '7月', value: '7月' },
{ label: '8月', value: '8月' },
{ label: '9月', value: '9月' },
{ label: '10月', value: '10月' },
{ label: '11月', value: '11月' },
{ label: '12月', value: '12月' },
],
rules: {
required: true,
message: '请输入',
trigger: 'blur',
},
},
{
label: '生长周期',
prop: 'growthCycle',
labelTip: '如10周-12周',
rules: {
required: true,
message: '请输入',
trigger: 'blur',
},
},
{
label: '计划进度',
prop: 'planProgress',
addDisplay: false,
editDisplay: false,
viewDisplay: true,
rules: {
required: true,
message: '请输入',
trigger: 'blur',
},
},
{
label: '状态',
prop: 'planStatus',
type: 'select',
addDisplay: false,
editDisplay: false,
viewDisplay: true,
dicData: [
{
label: '待提交',
value: 1,
},
{
label: '已提交',
value: 2,
},
{
label: '审核通过',
value: 3,
},
{
label: '审核拒绝',
value: 4,
},
],
rules: {
required: true,
message: '请输入',
trigger: 'blur',
},
},
{
label: '备注',
prop: 'note',
type: 'textarea',
span: 24,
rows: 4,
overHidden: true,
width: 200,
},
],
actions: [
{
name: '查看',
icon: 'view',
event: ({ row }) => rowView(row),
},
{
name: '编辑',
icon: 'edit',
event: ({ row }) => rowEdit(row),
},
{
type: 'danger',
name: '删除',
icon: 'delete',
event: ({ row }) => rowDel(row),
},
{
name: '审核通过',
type: 'success',
icon: 'check',
event: ({ row }) => rowCheck(row, 4),
},
{
name: '审核拒绝',
type: 'danger',
icon: 'close',
event: ({ row }) => rowCheck(row, 3),
},
],
},
pageData: {
total: 0,
currentPage: 1,
pageSize: 10,
},
data: [],
minWeek: null,
maxWeek: null,
currentRow: {},
});
//
const loadData = () => {
state.loading = true;
GetEntityList(state.query)
.then((res) => {
if (res.code === 200) {
const { current, size, total, records } = res.data;
state.data = records;
state.pageData = {
currentPage: current || 1,
pageSize: size || 10,
total: total,
};
}
})
.catch((err) => {
app.$message.error(err.msg);
state.data = [];
})
.finally(() => {
state.loading = false;
});
};
loadData();
//
const currentChange = (current) => {
state.query.current = current;
loadData();
};
//
const sizeChange = (size) => {
state.query.size = size;
loadData();
};
//
const searchChange = (params, done) => {
if (done) done();
state.query = params;
state.query.current = 1;
loadData();
};
//
const refreshChange = () => {
loadData();
app.$message.success('刷新成功');
};
//
const selectionChange = (rows) => {
state.selection = rows;
};
//
const rowView = (row) => {
// state.currentRow = row;
crudRef.value.rowView(row);
};
//
const rowSave = (row, done, loading) => {
AddEntity(row)
.then((res) => {
if (res.code === 200) {
app.$message.success('添加成功!');
done();
loadData();
}
})
.catch((err) => {
app.$message.error(err.msg);
})
.finally(() => {
loading();
});
};
//
const rowEdit = (row) => {
crudRef.value.rowEdit(row);
};
const rowUpdate = (row, index, done, loading) => {
UpdateEntity(row)
.then((res) => {
if (res.code === 200) {
app.$message.success('更新成功!');
done();
loadData();
}
})
.catch((err) => {
app.$message.error(err.msg);
})
.finally(() => {
loading();
});
};
//
const rowDel = (row, index, done) => {
if (isEmpty(row)) return;
app
.$confirm(`删除后信息将不可查看,确认要删除吗?`, '确定删除', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
DeleteEntity({ id: row.id })
.then((res) => {
if (res.code === 200) {
app.$message.success('删除成功!');
done();
loadData();
}
})
.catch((err) => {
app.$message.error(err.msg);
});
})
.catch(() => {});
};
//
const rowCheck = (row, status) => {
const data = { id: row.id, planStatus: status };
AuditEntity(data)
.then((res) => {
if (res.code === 200) {
app.$message.success('操作成功!');
}
})
.catch((err) => {
app.$message.error(err.msg);
})
.finally(() => {
loadData();
});
};
//
const onExport = () => {
if (isEmpty(state.data)) {
app.$message.error('当前暂时没有可供导出的数据!');
return;
}
state.loading = true;
const fileName = '年度计划明细表';
ExportEntity(state.query)
.then((res) => {
if (res.status === 200) {
downloadFile(res.data, `${fileName}.xlsx`, 'blob');
app.$message.success('导出成功!');
}
})
.catch((err) => {
app.$message.error('导出失败!');
})
.finally(() => {
state.loading = false;
});
};
</script>

View File

@ -24,6 +24,10 @@
<el-button type="success" icon="download" @click="onExport">导出</el-button>
</template>
<template #id="{ row }">
<el-image style="width: 50px; height: 50px; cursor: pointer" :src="row.orCodeUrl" fit="cover" lazy @click="onViewCode(row)" />
</template>
<template #productUrl-form="{ column }">
<el-upload class="custom-form__uploader" action="#" :show-file-list="false" accept="image/*" :limit="1" :http-request="rowUploadPicture">
<img v-if="state.form.base64" :src="state.form.base64" class="custom-form__uploader__img" />
@ -47,6 +51,8 @@
@on-confirm="onUploadExcel"
/>
<code-dialog ref="codeRef" :row="state.currentRow" />
<custom-quality-add ref="qualityAddRef" :row="state.currentRow" />
</div>
</template>
@ -68,6 +74,7 @@ const UserStore = useUserStore();
const crudRef = ref(null);
const importExcelRef = ref(null);
const qualityAddRef = ref(null);
const codeRef = ref(null);
const state = reactive({
loading: false,
query: {
@ -87,7 +94,6 @@ const state = reactive({
addDisplay: false,
editDisplay: false,
viewDisplay: true,
width: 200,
},
{
label: '采收批次',
@ -273,7 +279,7 @@ const state = reactive({
label: '原产地详细地址',
prop: 'originAddressDetail',
hide: true,
// span: 24,
viewDisplay: false,
},
// {
// label: '',
@ -607,4 +613,9 @@ const onExport = () => {
state.loading = false;
});
};
const onViewCode = (row) => {
state.currentRow = row;
codeRef?.value && codeRef.value.show();
};
</script>

View File

@ -22,6 +22,10 @@
<el-button type="danger" icon="delete" @click="onDel(state.selection)">批量删除</el-button>
</template>
<template #harvestId="{ row }">
<el-image style="width: 50px; height: 50px; cursor: pointer" :src="row.orCodeUrl" fit="cover" lazy @click="onViewCode(row)" />
</template>
<template #qualityReportUrl="{ row }">
<el-button
v-if="row.qualityReportUrl"
@ -45,6 +49,8 @@
<custom-table-operate :actions="state.options.actions" :data="scope" />
</template>
</avue-crud>
<code-dialog ref="codeRef" :row="state.currentRow" />
</div>
</template>
<script setup>
@ -57,6 +63,7 @@ import { GetEntityList, AddEntity, UpdateEntity, DeleteEntity } from '@/apis/qua
const app = useApp();
const crudRef = ref(null);
const codeRef = ref(null);
const state = reactive({
loading: false,
query: {
@ -74,7 +81,6 @@ const state = reactive({
prop: 'harvestId',
search: true,
disabled: true,
width: 200,
},
{
label: '采收批次',
@ -249,6 +255,7 @@ const state = reactive({
pageSize: 10,
},
data: [],
currentRow: {},
});
//
@ -405,4 +412,9 @@ const onDel = (rows = []) => {
const rowDel = (row, index, done) => {
onDel([row]);
};
const onViewCode = (row) => {
state.currentRow = row;
codeRef?.value && codeRef.value.show();
};
</script>

View File

@ -3,7 +3,7 @@
* @Author: zenghua.wang
* @Date: 2022-09-18 21:24:29
* @LastEditors: zenghua.wang
* @LastEditTime: 2025-02-17 10:58:12
* @LastEditTime: 2025-02-27 09:16:00
*/
import { defineConfig, loadEnv } from 'vite';
@ -23,46 +23,37 @@ 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,
VITE_APP_SYSTEM_API,
VITE_APP_SYSTEM_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: '/sub-government-affairs-service/',
build: {
target: 'ESNext',
outDir: 'dist',
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]',
// },
// },
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: {
host: '0.0.0.0',
@ -83,11 +74,6 @@ export default defineConfig(({ command, mode }) => {
changeOrigin: true,
rewrite: (path) => path.replace(/^\/uploadApis/, ''),
},
[VITE_APP_SYSTEM_API]: {
target: VITE_APP_SYSTEM_URL,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/systemApis/, ''),
},
},
},
resolve: {
@ -142,13 +128,5 @@ export default defineConfig(({ command, mode }) => {
}),
],
};
if (mode === 'production') {
config.build.terserOptions = {
compress: {
drop_console: true,
drop_debugger: true,
},
};
}
return config;
});