Commit dc36a1e7 by Jaxon

Merge branch 'SAAS+V5.8.4' of http://192.168.3.233:8090/saas_plus/dj-car-life-sy…

…stem into feature/584/jaxon
2 parents 0c637ea9 54dd3312
...@@ -27,6 +27,7 @@ export default antfu({ ...@@ -27,6 +27,7 @@ export default antfu({
"array-bracket-spacing": ["error", "always"], "array-bracket-spacing": ["error", "always"],
}, },
rules: { rules: {
"unicorn/prefer-node-protocol":"off",
"curly": ["error", "all"], "curly": ["error", "all"],
"vue/no-deprecated-slot-attribute": "off", "vue/no-deprecated-slot-attribute": "off",
"vue/no-deprecated-v-on-native-modifier": "off", "vue/no-deprecated-v-on-native-modifier": "off",
......
...@@ -59,15 +59,19 @@ export default { ...@@ -59,15 +59,19 @@ export default {
eventType, eventType,
pagePath: route.path, pagePath: route.path,
}; };
if (!prePagePath) if (!prePagePath) {
prePagePath = this.getPrePagePath(this); prePagePath = this.getPrePagePath(this);
}
item.prePagePath = prePagePath || "/index"; item.prePagePath = prePagePath || "/index";
if (batchId) if (batchId) {
item.batchId = batchId; item.batchId = batchId;
if (eventCode) }
if (eventCode) {
item.eventCode = eventCode; item.eventCode = eventCode;
if (businessParam) }
if (businessParam) {
item.businessParam = JSON.stringify(businessParam); item.businessParam = JSON.stringify(businessParam);
}
if (!recordList) { if (!recordList) {
recordList = [item]; recordList = [item];
} else { } else {
...@@ -79,8 +83,9 @@ export default { ...@@ -79,8 +83,9 @@ export default {
console.log("---------------- 重新打开定时埋点 ----------------"); console.log("---------------- 重新打开定时埋点 ----------------");
this.sendTrack(); // 开启定时埋点 this.sendTrack(); // 开启定时埋点
} }
if (recordList.length > 9) if (recordList.length > 9) {
this.sendTrackData(); this.sendTrackData();
}
}, },
getRandomString(length = 30) { getRandomString(length = 30) {
const characters const characters
...@@ -94,8 +99,9 @@ export default { ...@@ -94,8 +99,9 @@ export default {
return result; return result;
}, },
onPageShow() { onPageShow() {
if (this.track_page_view_flag) if (this.track_page_view_flag) {
return; return;
}
if (!this.track_batchId) { if (!this.track_batchId) {
this.track_batchId = `DJ_${this.getRandomString()}_${Date.now()}`; this.track_batchId = `DJ_${this.getRandomString()}_${Date.now()}`;
} }
...@@ -127,8 +133,9 @@ export default { ...@@ -127,8 +133,9 @@ export default {
}, 10e3); }, 10e3);
} }
let trackParams = {}; let trackParams = {};
if (this.track_businessParam_key) if (this.track_businessParam_key) {
trackParams = this[this.track_businessParam_key] || {}; trackParams = this[this.track_businessParam_key] || {};
}
this.setReportTrackData( this.setReportTrackData(
2, 2,
this.track_event_code, this.track_event_code,
...@@ -166,8 +173,11 @@ export default { ...@@ -166,8 +173,11 @@ export default {
reportTrack({ reportTrack({
recordList: JSON.parse(recordList), recordList: JSON.parse(recordList),
}).then((res) => { }).then((res) => {
if (res) if (res) {
localStorage.removeItem("recordList"); localStorage.removeItem("recordList");
}
}).catch((e) => {
console.log("发送出错", e);
}); });
} else { } else {
clearInterval(window.TRACK_TIMER); clearInterval(window.TRACK_TIMER);
......
...@@ -1474,7 +1474,7 @@ export const routerName = { ...@@ -1474,7 +1474,7 @@ export const routerName = {
parentId: "912250101", parentId: "912250101",
label: "详情", label: "详情",
handle: "handleViewDetail", handle: "handleViewDetail",
} },
], ],
component: _import( component: _import(
"residentManage/supervisionManagement/mission/detail", "residentManage/supervisionManagement/mission/detail",
...@@ -1508,11 +1508,11 @@ export const routerName = { ...@@ -1508,11 +1508,11 @@ export const routerName = {
}, },
912300101: { 912300101: {
path: "/resident-manage/task-center/detail", path: "/resident-manage/task-center-detail",
name: "residentManageTaskCenterDetail", name: "residentManageTaskCenterDetail",
meta: { meta: {
title: "详情", title: "详情",
authId: "9123001", authId: "912300101",
parentId: "91230", parentId: "91230",
activePath: "/resident-manage/task-center", activePath: "/resident-manage/task-center",
}, },
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
:title="detailInfo.failReason"> :title="detailInfo.failReason">
原因:【{{ detailInfo.failReason ? (detailInfo.failReason.length > 40 ? (`${detailInfo.failReason.slice(0, 40)}...`) : detailInfo.failReason) : '-' }}】 原因:【{{ detailInfo.failReason ? (detailInfo.failReason.length > 40 ? (`${detailInfo.failReason.slice(0, 40)}...`) : detailInfo.failReason) : '-' }}】
</div> </div>
<div class="tipsBt"> <div v-if="detailInfo.payType == 0" class="tipsBt">
<el-button size="small" <el-button size="small"
type="primary" type="primary"
@click="dataPush"> @click="dataPush">
...@@ -39,8 +39,8 @@ ...@@ -39,8 +39,8 @@
</div> </div>
</div> </div>
<el-form class="edit-sub-block" <el-form class="edit-sub-block"
:inline="true" label-width="150px"
label-width="150px"> :inline="true">
<div class="itemDiv"> <div class="itemDiv">
<el-form-item class="halfItem" <el-form-item class="halfItem"
label="付款单时间:"> label="付款单时间:">
......
...@@ -6,13 +6,17 @@ import DescriptionImageList from "@/components/descriptions/components/imageList ...@@ -6,13 +6,17 @@ import DescriptionImageList from "@/components/descriptions/components/imageList
import { statusOptions } from "@/views/residentManage/taskCenter/constant"; import { statusOptions } from "@/views/residentManage/taskCenter/constant";
import "dayjs/locale/zh-cn"; import "dayjs/locale/zh-cn";
if (typeof dayjs === "undefined") {
console.error("[cover2Descriptions] dayjs 未加载,请检查 CDN 顺序");
}
dayjs.extend(isSameOrBefore); dayjs.extend(isSameOrBefore);
dayjs.extend(isSameOrAfter); dayjs.extend(isSameOrAfter);
dayjs.extend(customParseFormat); dayjs.extend(customParseFormat);
function parseDatetime(value) { function parseDatetime(value) {
if (!value) if (!value) {
return "-"; return "-";
}
const formats = [ const formats = [
"YYYY-MM-DDTHH:mm:ss", "YYYY-MM-DDTHH:mm:ss",
...@@ -124,8 +128,9 @@ function renderLink() { ...@@ -124,8 +128,9 @@ function renderLink() {
}, },
render: (h, { data, schemaItem, schema }) => { render: (h, { data, schemaItem, schema }) => {
const { fieldValue, linkAlias } = schemaItem.meta; const { fieldValue, linkAlias } = schemaItem.meta;
if (!fieldValue) if (!fieldValue) {
return h("span", "-"); return h("span", "-");
}
const linkProps = { const linkProps = {
class: "link-type", class: "link-type",
...@@ -195,8 +200,9 @@ function renderAttachment() { ...@@ -195,8 +200,9 @@ function renderAttachment() {
style: { marginLeft: "8px", lineHeight: 1 }, style: { marginLeft: "8px", lineHeight: 1 },
on: { on: {
click: (e) => { click: (e) => {
if (!fileUrl) if (!fileUrl) {
return; return;
}
e.preventDefault(); e.preventDefault();
window.open(fileUrl, "_blank"); window.open(fileUrl, "_blank");
}, },
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
{{ detail.title }} {{ detail.title }}
</span> </span>
</div> </div>
<div class="description-wrapper"> <div v-if="descriptionSchema.length" class="description-wrapper">
<Descriptions :data="detail" <Descriptions :data="detail"
:schema="descriptionSchema"> :schema="descriptionSchema">
</Descriptions> </Descriptions>
...@@ -53,8 +53,13 @@ export default { ...@@ -53,8 +53,13 @@ export default {
}, },
async mounted() { async mounted() {
this.pageLoading = true;
try {
const { query } = this.$route; const { query } = this.$route;
this.taskId = query.taskId; if (!query?.taskId) {
return;
}
this.taskId = query?.taskId;
await this.getData(query.taskId); await this.getData(query.taskId);
const schema = await getTaskCenterTaskDescriptionSchema(); const schema = await getTaskCenterTaskDescriptionSchema();
...@@ -82,12 +87,14 @@ export default { ...@@ -82,12 +87,14 @@ export default {
meta: item, meta: item,
...cover2Descriptions?.[toUpper(item.fieldType)]?.(), ...cover2Descriptions?.[toUpper(item.fieldType)]?.(),
}))); })));
console.log("descriptionSchema", schema);
this.descriptionSchema = schema; this.descriptionSchema = schema;
} else { } else {
// 如果是空的, 去除两条横线 // 如果是空的, 去除两条横线
this.descriptionSchema = schema.filter(item => !item.divider); this.descriptionSchema = schema.filter(item => !item.divider);
} }
} finally {
this.pageLoading = false;
}
}, },
methods: { methods: {
async getData(taskId) { async getData(taskId) {
......
...@@ -249,13 +249,16 @@ export default { ...@@ -249,13 +249,16 @@ export default {
}, },
// 查看 // 查看
async handleDetail({ taskId, bizTypeName, bizType }) { async handleDetail({ taskId, bizTypeName, bizType }) {
try {
this.setReportTrackData(0, "task_web_view_detail", { taskId, bizTypeName, bizType }); this.setReportTrackData(0, "task_web_view_detail", { taskId, bizTypeName, bizType });
} finally {
this.$router.push({ this.$router.push({
path: "/resident-manage/task-center/detail", name: "residentManageTaskCenterDetail",
query: { query: {
taskId, taskId,
}, },
}); });
}
}, },
handleChangeSort(command) { handleChangeSort(command) {
if (this.table.searchForm.orderBy === command) { if (this.table.searchForm.orderBy === command) {
......
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
<div v-if="item.infoData && item.infoData.length" class="form_div"> <div v-if="item.infoData && item.infoData.length" class="form_div">
<el-form :ref="item.childRef" <el-form :ref="item.childRef"
class="edit-sub-block" class="edit-sub-block"
:inline="true"
label-width="150px" label-width="150px"
:inline="true"
:model="detailInfo" :model="detailInfo"
:rules="rules"> :rules="rules">
<el-row :gutter="20"> <el-row :gutter="20">
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
detailInfo[item.key] && detailInfo[item.key].length detailInfo[item.key] && detailInfo[item.key].length
" "
class="photo-box"> class="photo-box">
<GlsxPreview :image-url-arr="getImgPreviewUrls(item)" <GlsxPreview limit="1"
limit="1" :image-url-arr="getImgPreviewUrls(item)"
:pic-options="{ ...picOptions, type: item.otherType }" :pic-options="{ ...picOptions, type: item.otherType }"
:video-img="true"> :video-img="true">
</GlsxPreview> </GlsxPreview>
...@@ -113,34 +113,34 @@ ...@@ -113,34 +113,34 @@
<template v-if="item.type == 'input'"> <template v-if="item.type == 'input'">
<el-input v-model="detailInfo[item.key]" <el-input v-model="detailInfo[item.key]"
class="edit-form-item" class="edit-form-item"
size="small"
:maxlength="item.maxLength || ''" :maxlength="item.maxLength || ''"
:placeholder="`请输入${item.label}`" :placeholder="`请输入${item.label}`">
size="small">
</el-input> </el-input>
</template> </template>
<template v-else-if="item.type == 'date'"> <template v-else-if="item.type == 'date'">
<el-date-picker v-model="detailInfo[item.key]" <el-date-picker v-model="detailInfo[item.key]"
class="edit-form-item" class="edit-form-item"
:picker-options="item.pickerOptions"
:placeholder="item.label"
size="small" size="small"
type="date"> type="date"
:picker-options="item.pickerOptions"
:placeholder="item.label">
</el-date-picker> </el-date-picker>
</template> </template>
<template v-else-if="item.type == 'textarea'"> <template v-else-if="item.type == 'textarea'">
<el-input v-model="detailInfo[item.key]" <el-input v-model="detailInfo[item.key]"
class="edit-form-item" class="edit-form-item"
:maxlength="item.maxLength"
placeholder="请输入" placeholder="请输入"
:rows="3" type="textarea"
type="textarea"> :maxlength="item.maxLength"
:rows="3">
</el-input> </el-input>
</template> </template>
<template v-else-if="item.type == 'select'"> <template v-else-if="item.type == 'select'">
<el-select v-model="detailInfo[item.key]" <el-select v-model="detailInfo[item.key]"
class="edit-form-item" class="edit-form-item"
:placeholder="`请选择${item.label}`" size="small"
size="small"> :placeholder="`请选择${item.label}`">
<el-option v-for="item in item.options" <el-option v-for="item in item.options"
:key="item.value" :key="item.value"
:label="item.label" :label="item.label"
...@@ -150,7 +150,7 @@ ...@@ -150,7 +150,7 @@
</template> </template>
</template> </template>
<template v-else> <template v-else>
<div class="flex"> <div class="flex" :style="getExpiryTextStyle(item, detailInfo)">
<div v-if="item.className && item.className(detailInfo)" <div v-if="item.className && item.className(detailInfo)"
class="dot" class="dot"
:style="{ :style="{
...@@ -187,8 +187,8 @@ ...@@ -187,8 +187,8 @@
<div class="detail-content"> <div class="detail-content">
<div v-if="item.subData && item.subData.length" class="form_div"> <div v-if="item.subData && item.subData.length" class="form_div">
<el-form class="edit-sub-block" <el-form class="edit-sub-block"
:inline="true" label-width="150px"
label-width="150px"> :inline="true">
<el-row :gutter="20"> <el-row :gutter="20">
<template v-for="(item, key) in item.subData"> <template v-for="(item, key) in item.subData">
<el-col :key="key" :span="item.col ? item.col : 12"> <el-col :key="key" :span="item.col ? item.col : 12">
...@@ -236,6 +236,7 @@ import { ...@@ -236,6 +236,7 @@ import {
} from "@/common/constants.js"; } from "@/common/constants.js";
import { deepClone } from "@/common/util"; import { deepClone } from "@/common/util";
import preview from "../../components/preview"; import preview from "../../components/preview";
import { getExpiryTextStyle } from "./vehicleInfoExpiry";
export default { export default {
components: { components: {
...@@ -308,10 +309,24 @@ export default { ...@@ -308,10 +309,24 @@ export default {
}, },
}, },
{ {
title: "交强险到期",
key: "compulsoryInsuranceExpiry",
formatter: (cellValue) => {
return cellValue.compulsoryInsuranceExpiry || "-";
},
},
{
title: "表显里程", title: "表显里程",
key: "mileageStr", key: "mileageStr",
}, },
{ {
title: "年审到期",
key: "annualInspectionExpiry",
formatter: (cellValue) => {
return cellValue.annualInspectionExpiry || "-";
},
},
{
title: "使用性质", title: "使用性质",
key: "carTypeName", key: "carTypeName",
formatter: (row) => { formatter: (row) => {
...@@ -325,6 +340,13 @@ export default { ...@@ -325,6 +340,13 @@ export default {
}, },
}, },
{ {
title: "商业险到期",
key: "commercialInsuranceExpiry",
formatter: (cellValue) => {
return cellValue.commercialInsuranceExpiry || "-";
},
},
{
title: "所有人性质", title: "所有人性质",
key: "ownerType", key: "ownerType",
formatter: (row) => { formatter: (row) => {
...@@ -494,9 +516,11 @@ export default { ...@@ -494,9 +516,11 @@ export default {
}; };
}, },
methods: { methods: {
getExpiryTextStyle,
getStatusItem(baseData, optKey, row, rowKey) { getStatusItem(baseData, optKey, row, rowKey) {
if (!baseData || !baseData[optKey] || !row) if (!baseData || !baseData[optKey] || !row) {
return null; return null;
}
return baseData[optKey].find( return baseData[optKey].find(
item => item.confId == row[rowKey], // 使用严格相等 item => item.confId == row[rowKey], // 使用严格相等
...@@ -504,24 +528,29 @@ export default { ...@@ -504,24 +528,29 @@ export default {
}, },
getFileTypeFromUrl(url) { getFileTypeFromUrl(url) {
if (!url) if (!url) {
return "file"; return "file";
}
const pathname = url.split("?")[0]; const pathname = url.split("?")[0];
const extension = pathname.split(".").pop()?.toLowerCase() || ""; const extension = pathname.split(".").pop()?.toLowerCase() || "";
const imageExtensions = ["jpg", "jpeg", "png", "gif", "bmp", "webp"]; const imageExtensions = ["jpg", "jpeg", "png", "gif", "bmp", "webp"];
if (imageExtensions.includes(extension)) if (imageExtensions.includes(extension)) {
return "image"; return "image";
}
// 阿里云 OSS 图片处理:x-oss-process=image/format,jpg 表示图片 // 阿里云 OSS 图片处理:x-oss-process=image/format,jpg 表示图片
if (/x-oss-process=image\/format,\w+/.test(url)) if (/x-oss-process=image\/format,\w+/.test(url)) {
return "image"; return "image";
}
return "file"; return "file";
}, },
getOssImageUrl(url) { getOssImageUrl(url) {
if (!url) if (!url) {
return url; return url;
}
// 已经带有 x-oss-process 参数时不重复拼接 // 已经带有 x-oss-process 参数时不重复拼接
if (url.includes("x-oss-process=")) if (url.includes("x-oss-process=")) {
return url; return url;
}
const param = "x-oss-process=image/format,jpg/quality,q_100"; const param = "x-oss-process=image/format,jpg/quality,q_100";
const sep = url.includes("?") ? "&" : "?"; const sep = url.includes("?") ? "&" : "?";
return `${url}${sep}${param}`; return `${url}${sep}${param}`;
...@@ -529,16 +558,19 @@ export default { ...@@ -529,16 +558,19 @@ export default {
// imgList 类型(如 carImageUrls、carVideoUrls)预览使用的 URL 列表 // imgList 类型(如 carImageUrls、carVideoUrls)预览使用的 URL 列表
getImgPreviewUrls(item) { getImgPreviewUrls(item) {
const urls = this.detailInfo && this.detailInfo[item.key]; const urls = this.detailInfo && this.detailInfo[item.key];
if (!urls || !Array.isArray(urls)) if (!urls || !Array.isArray(urls)) {
return []; return [];
}
// 视频不加图片处理参数 // 视频不加图片处理参数
if (item.otherType === "video") if (item.otherType === "video") {
return urls; return urls;
}
return urls.map(url => this.getOssImageUrl(url)); return urls.map(url => this.getOssImageUrl(url));
}, },
getFileNameFromUrlForDisplay(url) { getFileNameFromUrlForDisplay(url) {
if (!url) if (!url) {
return "未知文件"; return "未知文件";
}
try { try {
const fileName = url.split("/").pop().split("?")[0]; const fileName = url.split("/").pop().split("?")[0];
return fileName || "未知文件"; return fileName || "未知文件";
...@@ -547,8 +579,9 @@ export default { ...@@ -547,8 +579,9 @@ export default {
} }
}, },
getFileNameFromUrl(url) { getFileNameFromUrl(url) {
if (!url) if (!url) {
return ""; return "";
}
try { try {
const fileName = url.split("/").pop().split("?")[0]; const fileName = url.split("/").pop().split("?")[0];
return fileName || "未命名文件"; return fileName || "未命名文件";
...@@ -570,8 +603,9 @@ export default { ...@@ -570,8 +603,9 @@ export default {
} }
}, },
processFileLinks(fileString) { processFileLinks(fileString) {
if (!fileString) if (!fileString) {
return []; return [];
}
// 兼容数组;字符串时按"逗号+http"分割,避免 OSS query 中逗号误分割 // 兼容数组;字符串时按"逗号+http"分割,避免 OSS query 中逗号误分割
const links = Array.isArray(fileString) const links = Array.isArray(fileString)
? fileString ? fileString
...@@ -589,8 +623,9 @@ export default { ...@@ -589,8 +623,9 @@ export default {
}); });
}, },
processFileUrls(fileUrls) { processFileUrls(fileUrls) {
if (!fileUrls || !Array.isArray(fileUrls)) if (!fileUrls || !Array.isArray(fileUrls)) {
return []; return [];
}
return fileUrls.map((url) => { return fileUrls.map((url) => {
const fileType = this.getFileTypeFromUrl(url); const fileType = this.getFileTypeFromUrl(url);
...@@ -605,15 +640,17 @@ export default { ...@@ -605,15 +640,17 @@ export default {
getImageFiles(fileUrls) { getImageFiles(fileUrls) {
const processedFiles = this.processFileUrls(fileUrls); const processedFiles = this.processFileUrls(fileUrls);
if (!processedFiles || !Array.isArray(processedFiles)) if (!processedFiles || !Array.isArray(processedFiles)) {
return []; return [];
}
return processedFiles.filter(file => this.isImageType(file)); return processedFiles.filter(file => this.isImageType(file));
}, },
getNonImageFiles(fileUrls) { getNonImageFiles(fileUrls) {
const processedFiles = this.processFileUrls(fileUrls); const processedFiles = this.processFileUrls(fileUrls);
if (!processedFiles || !Array.isArray(processedFiles)) if (!processedFiles || !Array.isArray(processedFiles)) {
return []; return [];
}
return processedFiles.filter(file => !this.isImageType(file)); return processedFiles.filter(file => !this.isImageType(file));
}, },
......
const expiryKeys = [
"compulsoryInsuranceExpiry",
"annualInspectionExpiry",
"commercialInsuranceExpiry",
];
function getLocalDate(value) {
if (!value) {
return null;
}
if (value instanceof Date) {
return new Date(value.getFullYear(), value.getMonth(), value.getDate());
}
const matched = String(value).match(/^(\d{4})[-/](\d{1,2})[-/](\d{1,2})/);
if (matched) {
return new Date(
Number(matched[1]),
Number(matched[2]) - 1,
Number(matched[3]),
);
}
const date = new Date(value);
if (Number.isNaN(date.getTime())) {
return null;
}
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
}
export function getExpiryTextStyle(item, row) {
if (!item || !expiryKeys.includes(item.key) || !row) {
return {};
}
const expiryDate = getLocalDate(row[item.key]);
if (!expiryDate) {
return {};
}
const now = new Date();
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
const diffDays = Math.ceil((expiryDate.getTime() - today.getTime()) / 86400000);
if (diffDays < 0) {
return { color: "#EB4E4E" };
}
if (diffDays <= 30) {
return { color: "#FF8D1A" };
}
return {};
}
import { getExpiryTextStyle } from "./vehicleInfoExpiry";
describe("vehicleInfo expiry date colors", () => {
beforeEach(() => {
jest.useFakeTimers("modern");
jest.setSystemTime(new Date(2026, 6, 6));
});
afterEach(() => {
jest.useRealTimers();
});
it("marks expired expiry fields red", () => {
const style = getExpiryTextStyle(
{ key: "annualInspectionExpiry" },
{ annualInspectionExpiry: "2026-07-05" },
);
expect(style).toEqual({ color: "#EB4E4E" });
});
it("marks expiry fields within thirty days orange", () => {
const style = getExpiryTextStyle(
{ key: "commercialInsuranceExpiry" },
{ commercialInsuranceExpiry: "2026-08-05" },
);
expect(style).toEqual({ color: "#FF8D1A" });
});
it("keeps non-expiry fields and later dates default", () => {
expect(getExpiryTextStyle(
{ key: "licensePlate" },
{ licensePlate: "A12345" },
)).toEqual({});
expect(getExpiryTextStyle(
{ key: "compulsoryInsuranceExpiry" },
{ compulsoryInsuranceExpiry: "2026-08-06" },
)).toEqual({});
});
});
const VueFilenameInjector = require("./tools/vue-filename-injector");
const ThemeColorReplacer = require("webpack-theme-color-replacer");
const forElementUI = require("webpack-theme-color-replacer/forElementUI");
// const HardPlugin = require('hard-source-webpack-plugin') // 使用缓存,优化启动速度 // const HardPlugin = require('hard-source-webpack-plugin') // 使用缓存,优化启动速度
const SentryWebpackPlugin = require("@sentry/webpack-plugin"); const SentryWebpackPlugin = require("@sentry/webpack-plugin");
const ThemeColorReplacer = require("webpack-theme-color-replacer");
const forElementUI = require("webpack-theme-color-replacer/forElementUI");
const VueFilenameInjector = require("./tools/vue-filename-injector");
// const SpeedMeasurePlugin = require('speed-measure-webpack-plugin') // const SpeedMeasurePlugin = require('speed-measure-webpack-plugin')
const timeStamp = new Date().getTime(); const timeStamp = new Date().getTime();
const CopyDir = require("./plugins/copyDir");
// const AsyncRomveDir = require('./plugins/removeDir') // const AsyncRomveDir = require('./plugins/removeDir')
const os = require("os"); const os = require("os");
const CopyDir = require("./plugins/copyDir");
// const { defineConfig } = require('@vue/cli-service') // const { defineConfig } = require('@vue/cli-service')
/** /**
* 获取当前机器的ip地址 * 获取当前机器的ip地址
*/ */
function getIpAddress() { function getIpAddress() {
var ifaces = os.networkInterfaces(); let ifaces = os.networkInterfaces();
for (var dev in ifaces) { for (let dev in ifaces) {
const iface = ifaces[dev]; const iface = ifaces[dev];
for (let i = 0; i < iface.length; i++) { for (let i = 0; i < iface.length; i++) {
...@@ -28,7 +28,8 @@ function getIpAddress() { ...@@ -28,7 +28,8 @@ function getIpAddress() {
} }
// 拼接路径 // 拼接路径
const path = require("path"); const path = require("path");
const resolve = (dir) => path.join(__dirname, dir);
const resolve = dir => path.join(__dirname, dir);
// 增加环境变量 // 增加环境变量
process.env.VUE_APP_VERSION = require("./package.json").version; process.env.VUE_APP_VERSION = require("./package.json").version;
...@@ -43,8 +44,8 @@ const isDev = process.env.NODE_ENV !== "development"; ...@@ -43,8 +44,8 @@ const isDev = process.env.NODE_ENV !== "development";
*/ */
function isLowMemBuild() { function isLowMemBuild() {
if ( if (
process.env.VUE_LOW_MEM_BUILD === "1" || process.env.VUE_LOW_MEM_BUILD === "1"
process.env.VUE_LOW_MEM_BUILD === "true" || process.env.VUE_LOW_MEM_BUILD === "true"
) { ) {
return true; return true;
} }
...@@ -147,21 +148,21 @@ module.exports = { ...@@ -147,21 +148,21 @@ module.exports = {
config.externals = { config.externals = {
// vue: "Vue", // vue: "Vue",
"vue-router": "VueRouter", "vue-router": "VueRouter",
vuex: "Vuex", "vuex": "Vuex",
axios: "axios", "axios": "axios",
"js-cookie": "Cookies", "js-cookie": "Cookies",
nprogress: "NProgress", "nprogress": "NProgress",
echarts: "echarts", "echarts": "echarts",
"ua-parser-js": "UAParser", "ua-parser-js": "UAParser",
qs: "Qs", "qs": "Qs",
html2canvas: "html2canvas", "html2canvas": "html2canvas",
// "element-ui": "ELEMENT", // "element-ui": "ELEMENT",
dayjs: "dayjs", // "dayjs": "dayjs",
// "vue-qr": "vue-qr", // "vue-qr": "vue-qr",
xlsx: "XLSX", "xlsx": "XLSX",
// 与 CDN UMD 全局名一致(非 BScroll) // 与 CDN UMD 全局名一致(非 BScroll)
// "better-scroll": "BetterScroll", // "better-scroll": "BetterScroll",
BScroll: "better-scroll", "BScroll": "better-scroll",
// lodash: "_", // lodash: "_",
}; };
} }
...@@ -227,7 +228,7 @@ module.exports = { ...@@ -227,7 +228,7 @@ module.exports = {
configFile: path.resolve(__dirname, ".sentryclirc"), configFile: path.resolve(__dirname, ".sentryclirc"),
// 与部署路径一致,便于 Sentry 将 map 与线上资源对齐 // 与部署路径一致,便于 Sentry 将 map 与线上资源对齐
urlPrefix: `~${publicPath}`, urlPrefix: `~${publicPath}`,
}) }),
); );
} }
...@@ -283,12 +284,12 @@ module.exports = { ...@@ -283,12 +284,12 @@ module.exports = {
// optional. Resolve result css code as you wish. // optional. Resolve result css code as you wish.
return resultCss.replace( return resultCss.replace(
/process.env.VUE_APP_ELEMENT_COLOR/g, /process.env.VUE_APP_ELEMENT_COLOR/g,
process.env.VUE_APP_ELEMENT_COLOR process.env.VUE_APP_ELEMENT_COLOR,
); );
}, },
matchColors: [ matchColors: [
...forElementUI.getElementUISeries( ...forElementUI.getElementUISeries(
process.env.VUE_APP_ELEMENT_COLOR process.env.VUE_APP_ELEMENT_COLOR,
), // Element-ui主色系列 ), // Element-ui主色系列
], ],
externalCssFiles: [ externalCssFiles: [
...@@ -302,15 +303,15 @@ module.exports = { ...@@ -302,15 +303,15 @@ module.exports = {
.when( .when(
process.env.NODE_ENV === "development", process.env.NODE_ENV === "development",
// sourcemap不包含列信息 // sourcemap不包含列信息
(config) => config.devtool("cheap-source-map") config => config.devtool("cheap-source-map"),
) )
// TRAVIS 构建 vue-loader 添加 filename // TRAVIS 构建 vue-loader 添加 filename
.when( .when(
process.env.VUE_APP_BUILD_MODE === "TRAVIS" || process.env.VUE_APP_BUILD_MODE === "TRAVIS"
process.env.NODE_ENV === "development", || process.env.NODE_ENV === "development",
VueFilenameInjector(config, { VueFilenameInjector(config, {
propName: process.env.VUE_APP_SOURCE_VIEWER_PROP_NAME, propName: process.env.VUE_APP_SOURCE_VIEWER_PROP_NAME,
}) }),
); );
// svg // svg
const svgRule = config.module.rule("svg"); const svgRule = config.module.rule("svg");
...@@ -329,7 +330,8 @@ module.exports = { ...@@ -329,7 +330,8 @@ module.exports = {
const imagesRule = config.module.rule("images"); const imagesRule = config.module.rule("images");
imagesRule imagesRule
.test(/\.(png|jpe?g|gif|webp|svg)(\?.*)?$/) .test(/\.(png|jpe?g|gif|webp|svg)(\?.*)?$/)
.exclude.add(resolve("src/assets/svg-icons/icons")) .exclude
.add(resolve("src/assets/svg-icons/icons"))
.end(); .end();
// 重新设置 alias // 重新设置 alias
config.resolve.alias config.resolve.alias
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!