diff --git a/src/api/humanResource/personnel/index.ts b/src/api/humanResource/personnel/index.ts
index a2b7464..adbc7c6 100644
--- a/src/api/humanResource/personnel/index.ts
+++ b/src/api/humanResource/personnel/index.ts
@@ -5,6 +5,7 @@ export function listApi(config : object) {
return http({
url: '/cxc_rlzy.zb/cxcRlzyZb/list',
method: 'GET',
+ timeout: 5000,
data: config
})
}
diff --git a/src/api/production/index.ts b/src/api/production/index.ts
index 5159a3d..2d07362 100644
--- a/src/api/production/index.ts
+++ b/src/api/production/index.ts
@@ -60,7 +60,7 @@ export function queryJldDataByJldID(params : object) { // 获取计量点五分
export function queryJldRbDataByJldID(params : object) { // 获取计量点日报数据
return http({
- url: 'http://10.75.166.6:9999/Gyk/jldls/cxcSssjLssjJldls/getLssjByJldId',
+ url: '/tbqr/cxcScdtRbTbqr/listJldZongHe',
method: 'GET',
data: params
})
diff --git a/src/components/dataTimeShow.vue b/src/components/dataTimeShow.vue
new file mode 100644
index 0000000..dfb4fad
--- /dev/null
+++ b/src/components/dataTimeShow.vue
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/pages-humanResource/personnel/standingbook.vue b/src/pages-humanResource/personnel/standingbook.vue
index 888f3e7..040b96b 100644
--- a/src/pages-humanResource/personnel/standingbook.vue
+++ b/src/pages-humanResource/personnel/standingbook.vue
@@ -1,6 +1,6 @@
-
+
@@ -16,11 +16,12 @@
-
+
-
+
diff --git a/src/pages-operate/caiwu/index.vue b/src/pages-operate/caiwu/index.vue
new file mode 100644
index 0000000..f6cb4df
--- /dev/null
+++ b/src/pages-operate/caiwu/index.vue
@@ -0,0 +1,22 @@
+
+ {
+ layout: 'default',
+ style: {
+ navigationStyle: 'custom',
+ navigationBarTitleText: '计划财务 ',
+ },
+ }
+
+
+
+
+ 财务管理
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/pages-operate/jingying/index.vue b/src/pages-operate/jingying/index.vue
new file mode 100644
index 0000000..4c886a1
--- /dev/null
+++ b/src/pages-operate/jingying/index.vue
@@ -0,0 +1,22 @@
+
+ {
+ layout: 'default',
+ style: {
+ navigationStyle: 'custom',
+ navigationBarTitleText: '经营考核 ',
+ },
+ }
+
+
+
+
+ 经营管理
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/pages-production/shishishuju/chart/lssjChart.vue b/src/pages-production/shishishuju/chart/lssjChart.vue
index 48a128f..bd002e6 100644
--- a/src/pages-production/shishishuju/chart/lssjChart.vue
+++ b/src/pages-production/shishishuju/chart/lssjChart.vue
@@ -12,15 +12,19 @@
+ {{startTime}}
-
+
+
+
- 前一天
- 后一天
+ 上一月
+ 本月
+ 后一月
查询数据
生成曲线
@@ -29,15 +33,15 @@
-
-
-
+
+
+
-
@@ -65,10 +69,10 @@
{
name: '日流量',
- field: 'jrl',
+ field: 'ljql',
min: '0',
- max: '50000',
- unit: 'm³'
+ max: '500000',
+ unit: '10^4m³'
}
])
@@ -82,19 +86,21 @@
const drawLineFlag = ref(false)
function handleQuery() {
-
- const jldid = props.jldData.id;
+ const dwmc = props.jldData.qu;
+ const zcmc = props.jldData.zhan;
+ const jldmc = props.jldData.jldname;
+ console.log(dwmc, zcmc, jldmc)
queryJldRbDataByJldID({
- jldId: jldid,
+ fenzu: 'a.scrq',
+ dwmc: dwmc,
+ zcmc: zcmc,
+ jldname: jldmc,
startTime: startTime.value,
endTime: endTime.value
}).then(res => {
- chartData.value = JSON.parse(res.result)
+ console.log(res)
+ chartData.value = res.result
- chartData.value.forEach(item => {
- item.createTime = formatDate(item.createTime, "YYYY-MM-DD HH:mm ss")
- })
- console.log(123, chartData.value)
})
@@ -105,58 +111,60 @@
}
// 前一天 - 以当前选择的起始日期为基准计算
function handleForward() {
- // 使用当前选择的开始时间作为基准,而不是系统当前时间
- lssjTimeRange.value = getDefaultTimeRange(-1);
+ const now = new Date(startTime.value);
+ now.setMonth(now.getMonth() - 1);
+
+ const year = now.getFullYear();
+ const month = now.getMonth();
+
+ const firstDay = new Date(year, month, 1);
+ const lastDay = new Date(year, month + 1, 0);
+
+ startTime.value = formatDate(firstDay, "YYYY-MM-DD");
+ endTime.value = formatDate(lastDay, "YYYY-MM-DD");
+
+ lssjTimeRange.value = [formatDate(firstDay, "YYYY-MM-DD"), formatDate(lastDay, "YYYY-MM-DD")];
+ getTime(); // 触发时间变更事件
+ }
+
+ // 本月
+ function handleThis() {
+
+ lssjTimeRange.value = getDefaultTimeRange()
+ getTime(); // 触发时间变更事件
}
// 后一天
function handleNext() {
- // 获取当前选择的开始时间
- const currentStart = new Date(startTime.value);
- // 获取今天8点的时间对象
- const today8AM = new Date();
- today8AM.setHours(8, 0, 0, 0);
+ const now = new Date(startTime.value);
+ now.setMonth(now.getMonth() + 1);
- // 允许切换到今天及之前的日期范围
- if (currentStart < today8AM || isSameDay(currentStart, today8AM)) {
- lssjTimeRange.value = getDefaultTimeRange(1);
- } else {
- // 可添加提示:已经是最新数据
- uni.showToast({
- title: '已是最新数据',
- icon: 'none',
- duration: 1500
- });
- }
+ const year = now.getFullYear();
+ const month = now.getMonth();
+
+ const firstDay = new Date(year, month, 1);
+ const lastDay = new Date(year, month + 1, 0);
+ startTime.value = formatDate(firstDay, "YYYY-MM-DD");
+ endTime.value = formatDate(lastDay, "YYYY-MM-DD");
+
+ lssjTimeRange.value = [formatDate(firstDay, "YYYY-MM-DD"), formatDate(lastDay, "YYYY-MM-DD")];
+ getTime(); // 触发时间变更事件
}
// 获取指定日期偏移的时间范围(每天8:00至次日7:59)
- const getDefaultTimeRange = (days) => {
- // 防止原日期对象被污染,使用当前选择的开始时间作为基准
- var baseDate;
- if (startTime.value && new Date(startTime.value).toString() !== 'Invalid Date') {
- baseDate = new Date(startTime.value);
- } else {
- // 如果选择的时间无效,则使用当前时间作为 fallback
- baseDate = new Date();
- }
+ const getDefaultTimeRange = () => {
+ const now = new Date();
+ const year = now.getFullYear();
+ const month = now.getMonth();
- // 计算目标日期(基础日期 + 偏移天数)
- const targetDate = new Date(baseDate);
- targetDate.setDate(baseDate.getDate() + days);
-
- // 构建开始时间:目标日期的8:00:00
- const start = new Date(targetDate);
- start.setHours(8, 0, 0, 0);
-
- // 构建结束时间:目标日期+1天的7:59:59
- const end = new Date(targetDate);
- end.setDate(targetDate.getDate() + 1);
- end.setHours(7, 59, 59, 0);
+ // 当月第一天
+ const start = new Date(year, month, 1);
+ // 当月最后一天
+ const end = new Date(year, month + 1, 0);
// 格式化时间字符串
- const formattedStart = formatDate(start, 'YYYY-MM-DD HH:mm:ss');
- const formattedEnd = formatDate(end, 'YYYY-MM-DD HH:mm:ss');
+ const formattedStart = formatDate(start, 'YYYY-MM-DD');
+ const formattedEnd = formatDate(end, 'YYYY-MM-DD');
// 更新响应式变量
startTime.value = formattedStart;
@@ -165,12 +173,7 @@
return [formattedStart, formattedEnd];
};
- // 辅助函数:判断两个日期是否是同一天
- const isSameDay = (date1, date2) => {
- return date1.getFullYear() === date2.getFullYear() &&
- date1.getMonth() === date2.getMonth() &&
- date1.getDate() === date2.getDate();
- };
+
onMounted(() => {
// 设置默认时间范围 需要延时等控件渲染好
@@ -188,8 +191,8 @@
// 时间选择变化
const getTime = (e) => {
if (e && e.length === 2) {
- startTime.value = formatDate(e[0], 'YYYY-MM-DD HH:mm:ss')
- endTime.value = formatDate(e[1], 'YYYY-MM-DD HH:mm:ss')
+ startTime.value = formatDate(e[0], 'YYYY-MM-DD')
+ endTime.value = formatDate(e[1], 'YYYY-MM-DD')
// updateChart()
}
}
diff --git a/src/pages-production/shishishuju/index.vue b/src/pages-production/shishishuju/index.vue
index 467da78..7e99fd4 100644
--- a/src/pages-production/shishishuju/index.vue
+++ b/src/pages-production/shishishuju/index.vue
@@ -1,7 +1,50 @@
+
+ {
+ layout: 'default',
+ style: {
+ navigationStyle: 'custom',
+ navigationBarTitleText: '实时数据 ',
+ },
+ }
+
-
+
+
+
+
+
+
+ 天然气实时数据汇总计算结果,用标签显示出各类天然气的实时数据,需要工业库后台进行计算
+
+ 查看详情
+
+
+
+
+ 各条管线的天然气实时数据汇总计算结果,用标签显示出各类天然气的实时数据,需要工业库后台进行计算
+
+ 查看详情
+
+
+
+
\ No newline at end of file
+ import dateTimeShow from '@/components/dataTimeShow.vue'
+
+ function gotoTrqSssj() {
+ uni.navigateTo({
+ url: '/pages-production/shishishuju/trqSssj'
+ })
+ }
+
+ function gotoGdSssj() {
+ uni.navigateTo({
+ url: '/pages-production/shishishuju/trqSssj'
+ })
+ }
+
+
+
\ No newline at end of file
diff --git a/src/pages-production/shishishuju/trqSssj.vue b/src/pages-production/shishishuju/trqSssj.vue
index bcc1c20..3b27660 100644
--- a/src/pages-production/shishishuju/trqSssj.vue
+++ b/src/pages-production/shishishuju/trqSssj.vue
@@ -3,14 +3,14 @@
layout: 'default',
style: {
navigationStyle: 'custom',
- navigationBarTitleText: '生产数据',
+ navigationBarTitleText: '天然气实时数据',
},
}
-
+
-
{
websocketheart()
+ // stationID.value = "1267633458481725442"
})
onUnmounted(() => {
diff --git a/src/pages.json b/src/pages.json
index c00cee5..42a9490 100644
--- a/src/pages.json
+++ b/src/pages.json
@@ -183,47 +183,6 @@
"navigationBarTitleText": "工作台",
"navigationStyle": "custom"
}
- },
- {
- "path": "pages/production/ribaoshuju/rbsjLsxq",
- "type": "page",
- "layout": "default",
- "style": {
- "navigationStyle": "custom",
- "navigationBarTitleText": "历史数据"
- }
- },
- {
- "path": "pages/production/ribaoshuju/trqRbsj",
- "type": "page"
- },
- {
- "path": "pages/production/ribaoshuju/yyRbsj",
- "type": "page"
- },
- {
- "path": "pages/production/shishishuju/aqbjSssj",
- "type": "page"
- },
- {
- "path": "pages/production/shishishuju/gycsSssj",
- "type": "page"
- },
- {
- "path": "pages/production/shishishuju/index",
- "type": "page"
- },
- {
- "path": "pages/production/shishishuju/nyxhSssj",
- "type": "page"
- },
- {
- "path": "pages/production/shishishuju/trqSssj",
- "type": "page"
- },
- {
- "path": "pages/production/shishishuju/ysjSssj",
- "type": "page"
}
],
"subPackages": [
@@ -384,6 +343,15 @@
{
"root": "pages-operate",
"pages": [
+ {
+ "path": "caiwu/index",
+ "type": "page",
+ "layout": "default",
+ "style": {
+ "navigationStyle": "custom",
+ "navigationBarTitleText": "计划财务 "
+ }
+ },
{
"path": "file/detail",
"type": "page",
@@ -402,6 +370,15 @@
"navigationBarTitleText": "公文/通知公告/法律法规/上级制度/厂级制度"
}
},
+ {
+ "path": "jingying/index",
+ "type": "page",
+ "layout": "default",
+ "style": {
+ "navigationStyle": "custom",
+ "navigationBarTitleText": "经营考核 "
+ }
+ },
{
"path": "sc/index",
"type": "page",
@@ -630,6 +607,80 @@
"type": "page"
}
]
+ },
+ {
+ "root": "pages-production",
+ "pages": [
+ {
+ "path": "ribaoshuju/rbsjLsxq",
+ "type": "page",
+ "layout": "default",
+ "style": {
+ "navigationStyle": "custom",
+ "navigationBarTitleText": "历史数据"
+ }
+ },
+ {
+ "path": "ribaoshuju/trqRbsj",
+ "type": "page"
+ },
+ {
+ "path": "ribaoshuju/yyRbsj",
+ "type": "page"
+ },
+ {
+ "path": "shishishuju/aqbjSssj",
+ "type": "page"
+ },
+ {
+ "path": "shishishuju/gycsSssj",
+ "type": "page"
+ },
+ {
+ "path": "shishishuju/index",
+ "type": "page",
+ "layout": "default",
+ "style": {
+ "navigationStyle": "custom",
+ "navigationBarTitleText": "实时数据 "
+ }
+ },
+ {
+ "path": "shishishuju/nyxhSssj",
+ "type": "page"
+ },
+ {
+ "path": "shishishuju/trqSssj",
+ "type": "page",
+ "layout": "default",
+ "style": {
+ "navigationStyle": "custom",
+ "navigationBarTitleText": "天然气实时数据"
+ }
+ },
+ {
+ "path": "shishishuju/ysjSssj",
+ "type": "page"
+ },
+ {
+ "path": "shishishuju/chart/lssjChart",
+ "type": "page",
+ "layout": "default",
+ "style": {
+ "navigationStyle": "custom",
+ "navigationBarTitleText": "历史数据图表"
+ }
+ },
+ {
+ "path": "shishishuju/chart/sssjChart",
+ "type": "page",
+ "layout": "default",
+ "style": {
+ "navigationStyle": "custom",
+ "navigationBarTitleText": "历史数据图表"
+ }
+ }
+ ]
}
]
}
\ No newline at end of file
diff --git a/src/pages/operation/index.vue b/src/pages/operation/index.vue
index a801521..1b956fb 100644
--- a/src/pages/operation/index.vue
+++ b/src/pages/operation/index.vue
@@ -9,8 +9,118 @@
-
- 功能正在开发中... 请耐心等待
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
\ No newline at end of file
+
+
+
+
+
\ No newline at end of file
diff --git a/src/pages/production/index.vue b/src/pages/production/index.vue
index 503b8f4..1019e73 100644
--- a/src/pages/production/index.vue
+++ b/src/pages/production/index.vue
@@ -49,8 +49,8 @@
//、、东风风光的
import trqData from '@/pages-production/ribaoshuju/trqRbsj';
import yyData from '@/pages-production/ribaoshuju/yyRbsj';
- import sssjData from '@/pages-production/shishishuju/trqSssj';
- const items = ref(['油气实时', '油气历史', '管线运行', '安防监控', '设备运行'])
+ import sssjData from '@/pages-production/shishishuju/index';
+ const items = ref(['实时数据', '日报数据', '安全管理', '工程技术', '仪控设备'])
const current = ref(0)
const res = wx.getSystemInfoSync();
const statusHeight = res.statusBarHeight; //状态栏高度
diff --git a/src/pages/production/ribaoshuju/rbsjLsxq.vue b/src/pages/production/ribaoshuju/rbsjLsxq.vue
deleted file mode 100644
index 8520956..0000000
--- a/src/pages/production/ribaoshuju/rbsjLsxq.vue
+++ /dev/null
@@ -1,274 +0,0 @@
-
- {
- layout: 'default',
- style: {
- navigationStyle: 'custom',
- navigationBarTitleText: '历史数据',
- },
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 最大值: {{ dataStats.max }}
- 最小值: {{ dataStats.min }}
- 平均值: {{ dataStats.average }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/pages/production/ribaoshuju/trqRbsj.vue b/src/pages/production/ribaoshuju/trqRbsj.vue
deleted file mode 100644
index 9861942..0000000
--- a/src/pages/production/ribaoshuju/trqRbsj.vue
+++ /dev/null
@@ -1,633 +0,0 @@
-
-
-
-
-
-
-
-
- {{ item.gas }}
-
- 气量
- {{ formatNumber(item.dailyVolume) || '-' }}
-
-
- 年累计
- {{ formatNumber(item.yearVolume) || '-' }}
-
-
-
-
-
-
- {{ item.yearPerCent }}%
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 历史
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/pages/production/ribaoshuju/yyRbsj.vue b/src/pages/production/ribaoshuju/yyRbsj.vue
deleted file mode 100644
index 94ed949..0000000
--- a/src/pages/production/ribaoshuju/yyRbsj.vue
+++ /dev/null
@@ -1,317 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
- 日油量
- {{ item.rcwy || '-' }}
-
-
- 月累计
- {{ item.yl || '-' }}
-
-
- 年累计
- {{ item.nl || '-' }}
-
-
-
-
-
-
- {{ item.yearPerCent }}%
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 历史
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/pages/production/shishishuju/aqbjSssj.vue b/src/pages/production/shishishuju/aqbjSssj.vue
deleted file mode 100644
index 02409e3..0000000
--- a/src/pages/production/shishishuju/aqbjSssj.vue
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/pages/production/shishishuju/gycsSssj.vue b/src/pages/production/shishishuju/gycsSssj.vue
deleted file mode 100644
index 02409e3..0000000
--- a/src/pages/production/shishishuju/gycsSssj.vue
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/pages/production/shishishuju/index.vue b/src/pages/production/shishishuju/index.vue
deleted file mode 100644
index 467da78..0000000
--- a/src/pages/production/shishishuju/index.vue
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/src/pages/production/shishishuju/nyxhSssj.vue b/src/pages/production/shishishuju/nyxhSssj.vue
deleted file mode 100644
index 02409e3..0000000
--- a/src/pages/production/shishishuju/nyxhSssj.vue
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/pages/production/shishishuju/trqSssj.vue b/src/pages/production/shishishuju/trqSssj.vue
deleted file mode 100644
index b97dc1f..0000000
--- a/src/pages/production/shishishuju/trqSssj.vue
+++ /dev/null
@@ -1,293 +0,0 @@
-
-
-
-
-
-
-
-
-
- {{ stationName }}--{{ item.jldname }}
-
- {{item.yxzt}}
-
-
-
-
-
-
-
- 压力(MPa)
- {{ formatNumber(item.yl) || '-' }}
-
-
-
- 差压(kPa)
- {{ formatNumber(item.yc) || '-' }}
-
-
-
- 温度(℃)
- {{ formatNumber(item.wd) || '-' }}
-
-
-
- 瞬时流量(m³/d)
- {{ formatNumber(item.ssll) || '-' }}
-
-
-
-
- 今日流量(m³)
- {{ formatNumber(item.jrl) || '-' }}
-
-
-
-
- 昨日流量(m³)
- {{ formatNumber(item.zrl) || '-' }}
-
-
-
-
- 昨日时间(min)
- {{ formatNumber(item.zrsj) || '-' }}
-
-
-
-
- 今日时间(min)
- {{ formatNumber(item.jrsj) || '-' }}
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/pages/production/shishishuju/ysjSssj.vue b/src/pages/production/shishishuju/ysjSssj.vue
deleted file mode 100644
index 02409e3..0000000
--- a/src/pages/production/shishishuju/ysjSssj.vue
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/types/uni-pages.d.ts b/src/types/uni-pages.d.ts
index 7cc9dd7..85d7163 100644
--- a/src/types/uni-pages.d.ts
+++ b/src/types/uni-pages.d.ts
@@ -19,15 +19,6 @@ interface NavigateToOptions {
"/pages/sljd/index" |
"/pages/user/people" |
"/pages/workHome/index" |
- "/pages/production/ribaoshuju/rbsjLsxq" |
- "/pages/production/ribaoshuju/trqRbsj" |
- "/pages/production/ribaoshuju/yyRbsj" |
- "/pages/production/shishishuju/aqbjSssj" |
- "/pages/production/shishishuju/gycsSssj" |
- "/pages/production/shishishuju/index" |
- "/pages/production/shishishuju/nyxhSssj" |
- "/pages/production/shishishuju/trqSssj" |
- "/pages/production/shishishuju/ysjSssj" |
"/pages-home/device-control/office/ALLleader" |
"/pages-home/device-control/office/index" |
"/pages-home/device-control/office/officehomedevice" |
@@ -44,8 +35,10 @@ interface NavigateToOptions {
"/pages-sub/online/online" |
"/pages-sub/online/onlineCard" |
"/pages-sub/online/onlineTable" |
+ "/pages-operate/caiwu/index" |
"/pages-operate/file/detail" |
"/pages-operate/file/index" |
+ "/pages-operate/jingying/index" |
"/pages-operate/sc/index" |
"/pages-humanResource/absence/add" |
"/pages-humanResource/absence/detail" |
@@ -78,7 +71,18 @@ interface NavigateToOptions {
"/pages-bpm/SuperiorSystem/index" |
"/pages-bpm/unconventional/index" |
"/pages-bpm/unconventional/stamp" |
- "/pages-bpm/zbkh/index";
+ "/pages-bpm/zbkh/index" |
+ "/pages-production/ribaoshuju/rbsjLsxq" |
+ "/pages-production/ribaoshuju/trqRbsj" |
+ "/pages-production/ribaoshuju/yyRbsj" |
+ "/pages-production/shishishuju/aqbjSssj" |
+ "/pages-production/shishishuju/gycsSssj" |
+ "/pages-production/shishishuju/index" |
+ "/pages-production/shishishuju/nyxhSssj" |
+ "/pages-production/shishishuju/trqSssj" |
+ "/pages-production/shishishuju/ysjSssj" |
+ "/pages-production/shishishuju/chart/lssjChart" |
+ "/pages-production/shishishuju/chart/sssjChart";
}
interface RedirectToOptions extends NavigateToOptions {}
diff --git a/vite.config.ts b/vite.config.ts
index 117c126..bb350b3 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -23,164 +23,165 @@ import { viteMockServe } from 'vite-plugin-mock'
// https://vitejs.dev/config/
export default ({ command, mode }) => {
- // console.log(mode === process.env.NODE_ENV) // true
+ // console.log(mode === process.env.NODE_ENV) // true
- // mode: 区分生产环境还是开发环境
- console.log('command, mode -> ', command, mode)
- // pnpm dev:h5 时得到 => serve development
- // pnpm build:h5 时得到 => build production
- // pnpm dev:mp-weixin 时得到 => build development (注意区别,command为build)
- // pnpm build:mp-weixin 时得到 => build production
- // pnpm dev:app 时得到 => build development (注意区别,command为build)
- // pnpm build:app 时得到 => build production
- // dev 和 build 命令可以分别使用 .env.development 和 .env.production 的环境变量
+ // mode: 区分生产环境还是开发环境
+ console.log('command, mode -> ', command, mode)
+ // pnpm dev:h5 时得到 => serve development
+ // pnpm build:h5 时得到 => build production
+ // pnpm dev:mp-weixin 时得到 => build development (注意区别,command为build)
+ // pnpm build:mp-weixin 时得到 => build production
+ // pnpm dev:app 时得到 => build development (注意区别,command为build)
+ // pnpm build:app 时得到 => build production
+ // dev 和 build 命令可以分别使用 .env.development 和 .env.production 的环境变量
- const { UNI_PLATFORM } = process.env
- console.log('UNI_PLATFORM -> ', UNI_PLATFORM) // 得到 mp-weixin, h5, app 等
+ const { UNI_PLATFORM } = process.env
+ console.log('UNI_PLATFORM -> ', UNI_PLATFORM) // 得到 mp-weixin, h5, app 等
- const env = loadEnv(mode, path.resolve(process.cwd(), 'env'))
- const {
- VITE_APP_PORT,
- VITE_SERVER_BASEURL,
- VITE_DELETE_CONSOLE,
- VITE_SHOW_SOURCEMAP,
- VITE_APP_PROXY,
- VITE_APP_PROXY_PREFIX,
- VITE_USE_MOCK,
- WEBAPP
- } = env
- console.log('环境变量 env -> ', env)
+ const env = loadEnv(mode, path.resolve(process.cwd(), 'env'))
+ const {
+ VITE_APP_PORT,
+ VITE_SERVER_BASEURL,
+ VITE_DELETE_CONSOLE,
+ VITE_SHOW_SOURCEMAP,
+ VITE_APP_PROXY,
+ VITE_APP_PROXY_PREFIX,
+ VITE_USE_MOCK,
+ WEBAPP
+ } = env
+ console.log('环境变量 env -> ', env)
- return defineConfig({
- envDir: './env', // 自定义env目录
+ return defineConfig({
+ envDir: './env', // 自定义env目录
- plugins: [
- UniPages({
- exclude: ['**/components/**/**.*'],
- routeBlockLang: 'json5', // 虽然设了默认值,但是vue文件还是要加上 lang="json5", 这样才能很好地格式化
- // homePage 通过 vue 文件的 route-block 的type="home"来设定
- // pages 目录为 src/pages,分包目录不能配置在pages目录下
- subPackages: [
- 'src/pages-home',
- 'src/pages-message',
- 'src/pages-user',
- 'src/pages-work',
- 'src/pages-sub',
- 'src/pages-operate',
- 'src/pages-humanResource',
- 'src/pages-integrated',
- 'src/pages-politics',
- 'src/pages-process',
- 'src/pages-bpm'
- ], // 是个数组,可以配置多个,但是不能为pages里面的目录
- dts: 'src/types/uni-pages.d.ts',
- }),
- UniLayouts(),
- UniPlatform(),
- UniManifest(),
- // UniXXX 需要在 Uni 之前引入
- Uni(),
- {
- // 临时解决 dcloudio 官方的 @dcloudio/uni-mp-compiler 出现的编译 BUG
- // 参考 github issue: https://github.com/dcloudio/uni-app/issues/4952
- // 自定义插件禁用 vite:vue 插件的 devToolsEnabled,强制编译 vue 模板时 inline 为 true
- name: 'fix-vite-plugin-vue',
- configResolved(config) {
- const plugin = config.plugins.find((p) => p.name === 'vite:vue')
- if (plugin && plugin.api && plugin.api.options) {
- plugin.api.options.devToolsEnabled = false
- }
- },
- },
- UnoCSS(),
- AutoImport({
- imports: ['vue', 'uni-app'],
- dts: 'src/types/auto-import.d.ts',
- dirs: ['src/hooks'], // 自动导入 hooks
- eslintrc: { enabled: true },
- vueTemplate: true, // default false
- }),
+ plugins: [
+ UniPages({
+ exclude: ['**/components/**/**.*'],
+ routeBlockLang: 'json5', // 虽然设了默认值,但是vue文件还是要加上 lang="json5", 这样才能很好地格式化
+ // homePage 通过 vue 文件的 route-block 的type="home"来设定
+ // pages 目录为 src/pages,分包目录不能配置在pages目录下
+ subPackages: [
+ 'src/pages-home',
+ 'src/pages-message',
+ 'src/pages-user',
+ 'src/pages-work',
+ 'src/pages-sub',
+ 'src/pages-operate',
+ 'src/pages-humanResource',
+ 'src/pages-integrated',
+ 'src/pages-politics',
+ 'src/pages-process',
+ 'src/pages-bpm',
+ 'src/pages-production'
+ ], // 是个数组,可以配置多个,但是不能为pages里面的目录
+ dts: 'src/types/uni-pages.d.ts',
+ }),
+ UniLayouts(),
+ UniPlatform(),
+ UniManifest(),
+ // UniXXX 需要在 Uni 之前引入
+ Uni(),
+ {
+ // 临时解决 dcloudio 官方的 @dcloudio/uni-mp-compiler 出现的编译 BUG
+ // 参考 github issue: https://github.com/dcloudio/uni-app/issues/4952
+ // 自定义插件禁用 vite:vue 插件的 devToolsEnabled,强制编译 vue 模板时 inline 为 true
+ name: 'fix-vite-plugin-vue',
+ configResolved(config) {
+ const plugin = config.plugins.find((p) => p.name === 'vite:vue')
+ if (plugin && plugin.api && plugin.api.options) {
+ plugin.api.options.devToolsEnabled = false
+ }
+ },
+ },
+ UnoCSS(),
+ AutoImport({
+ imports: ['vue', 'uni-app'],
+ dts: 'src/types/auto-import.d.ts',
+ dirs: ['src/hooks'], // 自动导入 hooks
+ eslintrc: { enabled: true },
+ vueTemplate: true, // default false
+ }),
- ViteRestart({
- // 通过这个插件,在修改vite.config.js文件则不需要重新运行也生效配置
- restart: ['vite.config.js'],
- }),
- // h5环境增加 BUILD_TIME 和 BUILD_BRANCH
- UNI_PLATFORM === 'h5' && {
- name: 'html-transform',
- transformIndexHtml(html) {
- return html.replace('%BUILD_TIME%', dayjs().format('YYYY-MM-DD HH:mm:ss'))
- },
- },
- // 打包分析插件,h5 + 生产环境才弹出
- UNI_PLATFORM === 'h5' &&
- mode === 'production' &&
- visualizer({
- filename: './node_modules/.cache/visualizer/stats.html',
- open: true,
- gzipSize: true,
- brotliSize: true,
- }),
- // 只有在 app 平台时才启用 copyNativeRes 插件
- UNI_PLATFORM === 'app' && copyNativeRes(),
- viteMockServe({
- // 指定 mock 文件目录
- mockPath: './mock',
- // 开发服务器才启用mock数据
- enable: mode === 'development' && JSON.parse(VITE_USE_MOCK),
- }),
- ],
- define: {
- __UNI_PLATFORM__: JSON.stringify(UNI_PLATFORM),
- __VITE_APP_PROXY__: JSON.stringify(VITE_APP_PROXY),
- },
- css: {
- postcss: {
- plugins: [
- // autoprefixer({
- // // 指定目标浏览器
- // overrideBrowserslist: ['> 1%', 'last 2 versions'],
- // }),
- ],
- },
- },
+ ViteRestart({
+ // 通过这个插件,在修改vite.config.js文件则不需要重新运行也生效配置
+ restart: ['vite.config.js'],
+ }),
+ // h5环境增加 BUILD_TIME 和 BUILD_BRANCH
+ UNI_PLATFORM === 'h5' && {
+ name: 'html-transform',
+ transformIndexHtml(html) {
+ return html.replace('%BUILD_TIME%', dayjs().format('YYYY-MM-DD HH:mm:ss'))
+ },
+ },
+ // 打包分析插件,h5 + 生产环境才弹出
+ UNI_PLATFORM === 'h5' &&
+ mode === 'production' &&
+ visualizer({
+ filename: './node_modules/.cache/visualizer/stats.html',
+ open: true,
+ gzipSize: true,
+ brotliSize: true,
+ }),
+ // 只有在 app 平台时才启用 copyNativeRes 插件
+ UNI_PLATFORM === 'app' && copyNativeRes(),
+ viteMockServe({
+ // 指定 mock 文件目录
+ mockPath: './mock',
+ // 开发服务器才启用mock数据
+ enable: mode === 'development' && JSON.parse(VITE_USE_MOCK),
+ }),
+ ],
+ define: {
+ __UNI_PLATFORM__: JSON.stringify(UNI_PLATFORM),
+ __VITE_APP_PROXY__: JSON.stringify(VITE_APP_PROXY),
+ },
+ css: {
+ postcss: {
+ plugins: [
+ // autoprefixer({
+ // // 指定目标浏览器
+ // overrideBrowserslist: ['> 1%', 'last 2 versions'],
+ // }),
+ ],
+ },
+ },
- resolve: {
- alias: {
- '@': path.join(process.cwd(), './src'),
- '@img': path.join(process.cwd(), './src/static/images'),
- },
- },
- server: {
- host: '0.0.0.0',
- headers: { //允许跨域by 闵
- 'Access-Control-Allow-Origin': '*'
- },
- hmr: true,
- port: Number.parseInt(VITE_APP_PORT, 10),
- // 仅 H5 端生效,其他端不生效(其他端走build,不走devServer)
- proxy: JSON.parse(VITE_APP_PROXY)
- ? {
- [VITE_APP_PROXY_PREFIX]: {
- target: VITE_SERVER_BASEURL,
- changeOrigin: true,
- rewrite: (path) => path.replace(new RegExp(`^${VITE_APP_PROXY_PREFIX}`), ''),
- },
- }
- : undefined,
- },
- build: {
- // 方便非h5端调试
- sourcemap: VITE_SHOW_SOURCEMAP === 'true', // 默认是false
- target: 'es6',
- // 开发环境不用压缩
- minify: mode === 'development' ? false : 'terser',
- terserOptions: {
- compress: {
- drop_console: VITE_DELETE_CONSOLE === 'true',
- drop_debugger: true,
- },
- },
- },
- })
-}
+ resolve: {
+ alias: {
+ '@': path.join(process.cwd(), './src'),
+ '@img': path.join(process.cwd(), './src/static/images'),
+ },
+ },
+ server: {
+ host: '0.0.0.0',
+ headers: { //允许跨域by 闵
+ 'Access-Control-Allow-Origin': '*'
+ },
+ hmr: true,
+ port: Number.parseInt(VITE_APP_PORT, 10),
+ // 仅 H5 端生效,其他端不生效(其他端走build,不走devServer)
+ proxy: JSON.parse(VITE_APP_PROXY)
+ ? {
+ [VITE_APP_PROXY_PREFIX]: {
+ target: VITE_SERVER_BASEURL,
+ changeOrigin: true,
+ rewrite: (path) => path.replace(new RegExp(`^${VITE_APP_PROXY_PREFIX}`), ''),
+ },
+ }
+ : undefined,
+ },
+ build: {
+ // 方便非h5端调试
+ sourcemap: VITE_SHOW_SOURCEMAP === 'true', // 默认是false
+ target: 'es6',
+ // 开发环境不用压缩
+ minify: mode === 'development' ? false : 'terser',
+ terserOptions: {
+ compress: {
+ drop_console: VITE_DELETE_CONSOLE === 'true',
+ drop_debugger: true,
+ },
+ },
+ },
+ })
+}
\ No newline at end of file