提交 2cce373a authored 作者: 刘旭's avatar 刘旭

新增字段 租户标识 租户域名

上级 392e301d
<template> <template>
<div class="app-container"> <div class="app-container">
<el-row justify="start" style="margin-bottom: 20px;"> <el-row justify="start" style="margin-bottom: 20px">
<el-col :span="4"> <el-col :span="4">
<el-input v-model="searchValue" placeholder="请输入MAC地址"></el-input> <el-input v-model="searchValue" placeholder="请输入MAC地址"></el-input>
</el-col> </el-col>
<el-col :span="2" style="text-align: center;"> <el-col :span="2" style="text-align: center">
<el-button type="primary" @click="search">搜索</el-button> <el-button type="primary" @click="search">搜索</el-button>
</el-col> </el-col>
</el-row> </el-row>
<el-button type="primary" @click="addlicInfo" style="margin-bottom: 20px;">添加信息</el-button> <el-button type="primary" @click="addlicInfo" style="margin-bottom: 20px"
<el-table :data="licInfoTable.licInfoData" border style="width: 100%" row-key="id" >添加信息</el-button
v-loading="licInfoTable.loading"> >
<el-table
:data="licInfoTable.licInfoData"
border
style="width: 100%"
row-key="id"
v-loading="licInfoTable.loading"
>
<el-table-column type="expand"> <el-table-column type="expand">
<template #default="scope"> <template #default="scope">
<div v-if="scope.row.dockerServices.length === 0"> <div v-if="scope.row.dockerServices.length === 0">
<el-empty description="暂无镜像" :image-size="100"> <el-empty description="暂无镜像" :image-size="100">
<el-button type="primary" size="small" @click="addMirror(scope.row)">添加镜像</el-button> <el-button
type="primary"
size="small"
@click="addMirror(scope.row)"
>添加镜像</el-button
>
</el-empty> </el-empty>
</div> </div>
<div v-else style="padding: 20px 40px;"> <div v-else style="padding: 20px 40px">
<div style="display: flex; justify-content: space-between; margin-bottom: 20px;"> <div
<span style="font-size: 16px; font-weight: 700;">docker镜像</span> style="
<el-button type="primary" size="small" @click="addMirror(scope.row)">添加镜像</el-button> display: flex;
justify-content: space-between;
margin-bottom: 20px;
"
>
<span style="font-size: 16px; font-weight: 700">docker镜像</span>
<el-button
type="primary"
size="small"
@click="addMirror(scope.row)"
>添加镜像</el-button
>
</div> </div>
<el-table :data="scope.row.dockerServices" style="width: 100%"> <el-table :data="scope.row.dockerServices" style="width: 100%">
<el-table-column prop="name" label="镜像名" align="center" /> <el-table-column prop="name" label="镜像名" align="center" />
<el-table-column prop="contextPath" label="服务路径" align="center" /> <el-table-column
prop="contextPath"
label="服务路径"
align="center"
/>
<el-table-column prop="version" label="版本" align="center" /> <el-table-column prop="version" label="版本" align="center" />
<el-table-column label="操作" width="200" align="center"> <el-table-column label="操作" width="200" align="center">
<template #default="item"> <template #default="item">
<el-button size="small" type="danger" <el-button
@click="handleServiceDelete(scope.row, item.row.id)">删除 size="small"
type="danger"
@click="handleServiceDelete(scope.row, item.row.id)"
>删除
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
...@@ -44,47 +74,108 @@ ...@@ -44,47 +74,108 @@
<el-table-column prop="fileEffectiveTime" label="导入后有效时间" /> <el-table-column prop="fileEffectiveTime" label="导入后有效时间" />
<el-table-column prop="verificationInterval" label="验证间隔时间(s)" /> <el-table-column prop="verificationInterval" label="验证间隔时间(s)" />
<el-table-column prop="moduleVerification" label="模块验证" /> <el-table-column prop="moduleVerification" label="模块验证" />
<el-table-column prop="tenantId" label="租户标识" />
<el-table-column prop="domainName" label="租户域名" />
<el-table-column label="操作" width="200"> <el-table-column label="操作" width="200">
<template #default="scope"> <template #default="scope">
<el-button size="small" type="primary" @click="handleEdit(scope.row)">编辑</el-button> <el-button size="small" type="primary" @click="handleEdit(scope.row)"
<el-button size="small" type="danger" @click="handleDelete(scope.row.id)">删除 >编辑</el-button
>
<el-button
size="small"
type="danger"
@click="handleDelete(scope.row.id)"
>删除
</el-button> </el-button>
<el-button size="small" type="primary" @click="handleExport(scope.row)">导出</el-button> <el-button
size="small"
type="primary"
@click="handleExport(scope.row)"
>导出</el-button
>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<div style="margin-top: 20px"> <div style="margin-top: 20px">
<el-pagination v-model:currentPage="licInfoTable.pageNo" v-model:page-size="licInfoTable.pageSize" <el-pagination
:page-sizes="[10, 15, 20]" layout="->, total,sizes, prev, pager, next, jumper" v-model:currentPage="licInfoTable.pageNo"
:total="licInfoTable.total" @size-change="handleSizeChange" @current-change="handleCurrentChange" v-model:page-size="licInfoTable.pageSize"
hide-on-single-page /> :page-sizes="[10, 15, 20]"
layout="->, total,sizes, prev, pager, next, jumper"
:total="licInfoTable.total"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
hide-on-single-page
/>
</div> </div>
</div> </div>
<!-- 添加对话框 --> <!-- 添加对话框 -->
<el-dialog v-model="licInfoForm.dialogVisible" :title="licInfoForm.title" width="30%" :before-close="handleClose"> <el-dialog
<el-form ref="licInfoRef" :model="licInfoForm.formLicInfo" :rules="licInfoForm.rules" label-width="150px" v-model="licInfoForm.dialogVisible"
status-icon> :title="licInfoForm.title"
width="30%"
:before-close="handleClose"
>
<el-form
ref="licInfoRef"
:model="licInfoForm.formLicInfo"
:rules="licInfoForm.rules"
label-width="150px"
status-icon
>
<el-form-item label="Lic名称" prop="lqLicName"> <el-form-item label="Lic名称" prop="lqLicName">
<el-input v-model="licInfoForm.formLicInfo.lqLicName" placeholder="请输入Lic名称"></el-input> <el-input
v-model="licInfoForm.formLicInfo.lqLicName"
placeholder="请输入Lic名称"
></el-input>
</el-form-item> </el-form-item>
<el-form-item label="MAC地址" prop="macAddress"> <el-form-item label="MAC地址" prop="macAddress">
<el-input v-model="licInfoForm.formLicInfo.macAddress" placeholder="请输入MAC地址"></el-input> <el-input
v-model="licInfoForm.formLicInfo.macAddress"
placeholder="请输入MAC地址"
></el-input>
</el-form-item> </el-form-item>
<el-form-item label="导入文件有效时间" prop="effectiveTime"> <el-form-item label="导入文件有效时间" prop="effectiveTime">
<el-date-picker v-model="licInfoForm.formLicInfo.effectiveTime" type="datetime" placeholder="请输入有效时间" <el-date-picker
value-format="YYYY-MM-DD HH:mm:ss" /> v-model="licInfoForm.formLicInfo.effectiveTime"
type="datetime"
placeholder="请输入有效时间"
value-format="YYYY-MM-DD HH:mm:ss"
/>
</el-form-item> </el-form-item>
<el-form-item label="导入后有效时间" prop="fileEffectiveTime"> <el-form-item label="导入后有效时间" prop="fileEffectiveTime">
<el-date-picker v-model="licInfoForm.formLicInfo.fileEffectiveTime" type="datetime" <el-date-picker
placeholder="请输入有效时间" value-format="YYYY-MM-DD HH:mm:ss" /> v-model="licInfoForm.formLicInfo.fileEffectiveTime"
type="datetime"
placeholder="请输入有效时间"
value-format="YYYY-MM-DD HH:mm:ss"
/>
</el-form-item> </el-form-item>
<el-form-item label="验证间隔时间(s)" prop="verificationInterval"> <el-form-item label="验证间隔时间(s)" prop="verificationInterval">
<el-input v-model.number="licInfoForm.formLicInfo.verificationInterval" placeholder="请输入验证间隔时间"> <el-input
v-model.number="licInfoForm.formLicInfo.verificationInterval"
placeholder="请输入验证间隔时间"
>
</el-input> </el-input>
</el-form-item> </el-form-item>
<el-form-item label="模块验证"> <el-form-item label="模块验证">
<el-input v-model="licInfoForm.formLicInfo.moduleVerification" placeholder="请输入模块验证"></el-input> <el-input
v-model="licInfoForm.formLicInfo.moduleVerification"
placeholder="请输入模块验证"
></el-input>
</el-form-item>
<el-form-item label="租户标识">
<el-input
v-model="licInfoForm.formLicInfo.tenantId"
placeholder="请输入租户标识"
></el-input>
</el-form-item>
<el-form-item label="租户域名">
<el-input
v-model="licInfoForm.formLicInfo.domainName"
placeholder="请输入租户域名"
></el-input>
</el-form-item> </el-form-item>
</el-form> </el-form>
<template #footer> <template #footer>
...@@ -95,134 +186,160 @@ ...@@ -95,134 +186,160 @@
</template> </template>
</el-dialog> </el-dialog>
<mirror-form ref="mirrorFormRef" v-model:mirror-dialog="mirrorDialog" @mirror-data="getMirrorData" /> <mirror-form
ref="mirrorFormRef"
v-model:mirror-dialog="mirrorDialog"
@mirror-data="getMirrorData"
/>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive } from 'vue' import { ref, reactive } from "vue";
import { licInfoList, licInfoDelete, licInfoFileCreate, licInfoUpdate, licInfoCreate } from '@/services/api/licInformation/licInformation' import {
licInfoList,
licInfoDelete,
licInfoFileCreate,
licInfoUpdate,
licInfoCreate,
} from "@/services/api/licInformation/licInformation";
import { ElMessageBox, ElMessage } from "element-plus"; import { ElMessageBox, ElMessage } from "element-plus";
import mirrorForm from './components/mirrorForm.vue' import mirrorForm from "./components/mirrorForm.vue";
const licInfoTable = reactive({ const licInfoTable = reactive({
licInfoData: [], licInfoData: [],
total: 0, total: 0,
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
loading: true loading: true,
}) });
const licInfoRef = ref() const licInfoRef = ref();
const mirrorFormRef = ref() const mirrorFormRef = ref();
const searchValue = ref() const searchValue = ref();
const mirrorDialog = ref() const mirrorDialog = ref();
const licInfoForm = reactive<any>({ const licInfoForm = reactive<any>({
dialogVisible: false, dialogVisible: false,
title: '新增', title: "新增",
formLicInfo: { formLicInfo: {
dockerServices: [], dockerServices: [],
macAddress: '', macAddress: "",
effectiveTime: '', effectiveTime: "",
fileEffectiveTime: '', fileEffectiveTime: "",
verificationInterval: '', verificationInterval: "",
moduleVerification: '', moduleVerification: "",
lqLicName: '' lqLicName: "",
tenantId: "",
domainName: "",
}, },
rules: { rules: {
macAddress: [{ required: true, message: '', trigger: 'blur' }], macAddress: [{ required: true, message: "", trigger: "blur" }],
lqLicName: [{ required: true, message: '', trigger: 'blur' }], lqLicName: [{ required: true, message: "", trigger: "blur" }],
effectiveTime: [{ effectiveTime: [
type: 'date', {
type: "date",
required: true, required: true,
message: '', message: "",
trigger: 'change', trigger: "change",
}], },
fileEffectiveTime: [{ ],
type: 'date', fileEffectiveTime: [
{
type: "date",
required: true, required: true,
message: '', message: "",
trigger: 'change', trigger: "change",
}], },
verificationInterval: [{ required: true, message: '', trigger: 'blur' }, { type: 'number', message: '请输入数字' }], ],
} verificationInterval: [
}) { required: true, message: "", trigger: "blur" },
{ type: "number", message: "请输入数字" },
],
},
});
const search = () => { const search = () => {
initLicInfo(searchValue.value, licInfoTable.pageNo, licInfoTable.pageSize) initLicInfo(searchValue.value, licInfoTable.pageNo, licInfoTable.pageSize);
} };
const addlicInfo = () => { const addlicInfo = () => {
licInfoForm.title = '新增' licInfoForm.title = "新增";
licInfoForm.dialogVisible = true licInfoForm.dialogVisible = true;
} };
const mirrorRow = ref() as any const mirrorRow = ref() as any;
const handleEdit = (data: any) => { const handleEdit = (data: any) => {
licInfoForm.title = '编辑' licInfoForm.title = "编辑";
licInfoForm.formLicInfo = data licInfoForm.formLicInfo = data;
licInfoForm.dialogVisible = true licInfoForm.dialogVisible = true;
} };
// 新条数 // 新条数
const handleSizeChange = (val: number) => { const handleSizeChange = (val: number) => {
licInfoTable.pageSize = val; licInfoTable.pageSize = val;
initLicInfo(searchValue.value, licInfoTable.pageNo, licInfoTable.pageSize) initLicInfo(searchValue.value, licInfoTable.pageNo, licInfoTable.pageSize);
}; };
// 新页数 // 新页数
const handleCurrentChange = (val: number) => { const handleCurrentChange = (val: number) => {
licInfoTable.pageNo = val; licInfoTable.pageNo = val;
initLicInfo(searchValue.value, licInfoTable.pageNo, licInfoTable.pageSize) initLicInfo(searchValue.value, licInfoTable.pageNo, licInfoTable.pageSize);
}; };
const onConfirm = () => { const onConfirm = () => {
licInfoRef.value?.validate((valid: any, fields: any) => { licInfoRef.value?.validate((valid: any, fields: any) => {
if (valid) { if (valid) {
if (licInfoForm.title === '新增') { if (licInfoForm.title === "新增") {
licInfoCreate(licInfoForm.formLicInfo).then((res: any) => { licInfoCreate(licInfoForm.formLicInfo).then((res: any) => {
if (res.code === 200) { if (res.code === 200) {
initLicInfo(searchValue.value, licInfoTable.pageNo, licInfoTable.pageSize) initLicInfo(
licInfoRef.value?.resetFields() searchValue.value,
licInfoTable.pageNo,
licInfoTable.pageSize
);
licInfoRef.value?.resetFields();
ElMessage({ type: "success", message: "添加成功!" }); ElMessage({ type: "success", message: "添加成功!" });
licInfoForm.dialogVisible = false licInfoForm.dialogVisible = false;
} }
}) });
} else { } else {
licInfoUpdate(licInfoForm.formLicInfo).then((res: any) => { licInfoUpdate(licInfoForm.formLicInfo).then((res: any) => {
if (res.code === 200) { if (res.code === 200) {
initLicInfo(searchValue.value, licInfoTable.pageNo, licInfoTable.pageSize) initLicInfo(
licInfoRef.value?.resetFields() searchValue.value,
licInfoTable.pageNo,
licInfoTable.pageSize
);
licInfoRef.value?.resetFields();
ElMessage({ type: "success", message: "修改成功!" }); ElMessage({ type: "success", message: "修改成功!" });
licInfoForm.dialogVisible = false licInfoForm.dialogVisible = false;
} }
}) });
} }
} else { } else {
console.log("校验失败", fields); console.log("校验失败", fields);
} }
}) });
};
}
const addMirror = (row: any) => { const addMirror = (row: any) => {
mirrorDialog.value = true mirrorDialog.value = true;
mirrorFormRef.value.title = '新增镜像' mirrorFormRef.value.title = "新增镜像";
mirrorFormRef.value.initService() mirrorFormRef.value.initService();
mirrorRow.value = JSON.parse(JSON.stringify(row)) mirrorRow.value = JSON.parse(JSON.stringify(row));
} };
const getMirrorData = async (data: any) => { const getMirrorData = async (data: any) => {
mirrorRow.value.dockerServices.push(data) mirrorRow.value.dockerServices.push(data);
const res: any = await licInfoUpdate(mirrorRow.value) const res: any = await licInfoUpdate(mirrorRow.value);
if (res.code === 200) { if (res.code === 200) {
ElMessage.success('添加成功') ElMessage.success("添加成功");
initLicInfo(searchValue.value, licInfoTable.pageNo, licInfoTable.pageSize) initLicInfo(searchValue.value, licInfoTable.pageNo, licInfoTable.pageSize);
mirrorFormRef.value.handleClose() mirrorFormRef.value.handleClose();
} }
} };
// 删除 // 删除
const handleDelete = (id: number) => { const handleDelete = (id: number) => {
...@@ -248,7 +365,7 @@ const handleDelete = (id: number) => { ...@@ -248,7 +365,7 @@ const handleDelete = (id: number) => {
message: "取消删除!", message: "取消删除!",
}); });
}); });
} };
const handleServiceDelete = (row: any, id: number) => { const handleServiceDelete = (row: any, id: number) => {
ElMessageBox.confirm("请确认删除?", "删除", { ElMessageBox.confirm("请确认删除?", "删除", {
...@@ -260,15 +377,19 @@ const handleServiceDelete = (row: any, id: number) => { ...@@ -260,15 +377,19 @@ const handleServiceDelete = (row: any, id: number) => {
let index; let index;
row.dockerServices.map((item: any, i: number) => { row.dockerServices.map((item: any, i: number) => {
if (item.id === id) { if (item.id === id) {
index = i index = i;
} }
}) });
row.dockerServices.splice(index, 1) row.dockerServices.splice(index, 1);
const res: any = await licInfoUpdate(row) const res: any = await licInfoUpdate(row);
if (res.code === 200) { if (res.code === 200) {
ElMessage.success('添加成功') ElMessage.success("添加成功");
initLicInfo(searchValue.value, licInfoTable.pageNo, licInfoTable.pageSize) initLicInfo(
mirrorDialog.value = false searchValue.value,
licInfoTable.pageNo,
licInfoTable.pageSize
);
mirrorDialog.value = false;
} }
}) })
.catch(() => { .catch(() => {
...@@ -277,7 +398,7 @@ const handleServiceDelete = (row: any, id: number) => { ...@@ -277,7 +398,7 @@ const handleServiceDelete = (row: any, id: number) => {
message: "取消删除!", message: "取消删除!",
}); });
}); });
} };
// 导出 // 导出
const handleExport = (data: any) => { const handleExport = (data: any) => {
...@@ -289,20 +410,20 @@ const handleExport = (data: any) => { ...@@ -289,20 +410,20 @@ const handleExport = (data: any) => {
.then(() => { .then(() => {
licInfoFileCreate(data).then((res: any) => { licInfoFileCreate(data).then((res: any) => {
const content = res; const content = res;
const blob = new Blob([content]) const blob = new Blob([content]);
const downloadElement = document.createElement('a') const downloadElement = document.createElement("a");
// 创建下载的链接 // 创建下载的链接
const href = window.URL.createObjectURL(blob) const href = window.URL.createObjectURL(blob);
downloadElement.href = href downloadElement.href = href;
// 下载后文件名 // 下载后文件名
downloadElement.download = 'lic' + data.macAddress + '.lqlic'; downloadElement.download = "lic" + data.macAddress + ".lqlic";
document.body.appendChild(downloadElement) document.body.appendChild(downloadElement);
// 点击下载 // 点击下载
downloadElement.click() downloadElement.click();
// 下载完成移除元素 // 下载完成移除元素
document.body.removeChild(downloadElement) document.body.removeChild(downloadElement);
// 释放掉blob对象 // 释放掉blob对象
window.URL.revokeObjectURL(href) window.URL.revokeObjectURL(href);
}); });
}) })
.catch(() => { .catch(() => {
...@@ -310,35 +431,41 @@ const handleExport = (data: any) => { ...@@ -310,35 +431,41 @@ const handleExport = (data: any) => {
type: "info", type: "info",
message: "取消导出!", message: "取消导出!",
}); });
}) });
} };
const handleClose = () => { const handleClose = () => {
licInfoRef.value?.resetFields() licInfoRef.value?.resetFields();
licInfoForm.formLicInfo = { licInfoForm.formLicInfo = {
dockerServices: [], dockerServices: [],
macAddress: '', macAddress: "",
effectiveTime: '', effectiveTime: "",
fileEffectiveTime: '', fileEffectiveTime: "",
verificationInterval: '', verificationInterval: "",
moduleVerification: '', moduleVerification: "",
lqLicName: '' lqLicName: "",
} tenantId: "",
licInfoForm.dialogVisible = false domainName: "",
} };
licInfoForm.dialogVisible = false;
};
// 列表数据 macAddress?: string, pageNo?: number, pageSize?: number // 列表数据 macAddress?: string, pageNo?: number, pageSize?: number
const initLicInfo = (macAddress?: string, pageNo?: number, pageSize?: number) => { const initLicInfo = (
macAddress?: string,
pageNo?: number,
pageSize?: number
) => {
licInfoList(macAddress, pageNo, pageSize).then((res: any) => { licInfoList(macAddress, pageNo, pageSize).then((res: any) => {
if (res.code === 200) { if (res.code === 200) {
licInfoTable.licInfoData = res.data.records licInfoTable.licInfoData = res.data.records;
licInfoTable.total = res.data.total licInfoTable.total = res.data.total;
licInfoTable.loading = false licInfoTable.loading = false;
} }
}) });
} };
initLicInfo() initLicInfo();
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
......
import { defineConfig } from 'vite'; import { defineConfig } from "vite";
import vue from '@vitejs/plugin-vue'; import vue from "@vitejs/plugin-vue";
// vite 提供的操作env配置变量的方法loadEnv // vite 提供的操作env配置变量的方法loadEnv
import { loadEnv } from 'vite'; import { loadEnv } from "vite";
// nodejs写法,获取项目目录 // nodejs写法,获取项目目录
import path from 'path'; import path from "path";
//按需要加载 //按需要加载
// import AutoImport from 'unplugin-auto-import/vite' // import AutoImport from 'unplugin-auto-import/vite'
...@@ -11,26 +11,26 @@ import path from 'path'; ...@@ -11,26 +11,26 @@ import path from 'path';
// import { ElementPlusResolver } from 'unplugin-vue-components/resolvers' // import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
// import Icons from 'unplugin-icons/vite' // import Icons from 'unplugin-icons/vite'
// import IconsResolver from 'unplugin-icons/resolver' // import IconsResolver from 'unplugin-icons/resolver'
import Inspect from 'vite-plugin-inspect' import Inspect from "vite-plugin-inspect";
import { viteMockServe } from 'vite-plugin-mock' import { viteMockServe } from "vite-plugin-mock";
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons' import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
const pathSrc = path.resolve(__dirname, 'src') const pathSrc = path.resolve(__dirname, "src");
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default ({ command, mode }) => { export default ({ command, mode }) => {
const env = loadEnv(mode, process.cwd()) const env = loadEnv(mode, process.cwd());
return defineConfig({ return defineConfig({
plugins: [ plugins: [
vue(), vue(),
createSvgIconsPlugin({ createSvgIconsPlugin({
// 指定需要缓存的图标文件夹 // 指定需要缓存的图标文件夹
iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')], iconDirs: [path.resolve(process.cwd(), "src/assets/icons")],
// 指定symbolId格式 // 指定symbolId格式
symbolId: 'icon-[dir]-[name]' symbolId: "icon-[dir]-[name]",
}), }),
viteMockServe({ viteMockServe({
// default // default
mockPath: 'mock', mockPath: "mock",
}), }),
// AutoImport({ // AutoImport({
// // Auto import functions from Vue, e.g. ref, reactive, toRef... // // Auto import functions from Vue, e.g. ref, reactive, toRef...
...@@ -75,17 +75,18 @@ export default ({ command, mode }) => { ...@@ -75,17 +75,18 @@ export default ({ command, mode }) => {
], ],
// 服务器配置 // 服务器配置
server: { server: {
host: '0.0.0.0', host: "0.0.0.0",
port: Number(loadEnv(mode, process.cwd()).VITE_APP_PORT), port: Number(loadEnv(mode, process.cwd()).VITE_APP_PORT),
strictPort: false, // 端口被占用直接退出 strictPort: false, // 端口被占用直接退出
https: false, // 默认用http方式 https: false, // 默认用http方式
open: true,// 在开发服务器启动时自动在浏览器中打开应用程序 open: true, // 在开发服务器启动时自动在浏览器中打开应用程序
proxy: { // 代理配置 proxy: {
// 代理配置
// 字符串简写写法 // 字符串简写写法
// '/foo': '', // '/foo': '',
// 选项写法 // 选项写法
"/lic": { "/lic": {
target: 'http://192.168.0.8:8090' target: "http://192.168.1.27:8090",
// rewrite: (path) => path.replace(/^\/api/, '') // rewrite: (path) => path.replace(/^\/api/, '')
}, },
// 正则表达式写法 // 正则表达式写法
...@@ -96,13 +97,14 @@ export default ({ command, mode }) => { ...@@ -96,13 +97,14 @@ export default ({ command, mode }) => {
// }, // },
}, },
hmr: { hmr: {
overlay: true // 屏蔽服务器报错 overlay: true, // 屏蔽服务器报错
} },
}, },
resolve: { // 设置项目文件导入路径 resolve: {
// 设置项目文件导入路径
alias: { alias: {
'@': pathSrc "@": pathSrc,
} },
}, },
css: { css: {
// css预处理器 // css预处理器
...@@ -111,28 +113,33 @@ export default ({ command, mode }) => { ...@@ -111,28 +113,33 @@ export default ({ command, mode }) => {
// 给导入的路径最后加上 ; // 给导入的路径最后加上 ;
scss: { scss: {
charset: false,//防止样式出现警告,中文 charset: false, //防止样式出现警告,中文
additionalData: '@import "@/assets/styles/global.scss";' additionalData: '@import "@/assets/styles/global.scss";',
} },
}
}, },
build: { // 分块打包配置 },
build: {
// 分块打包配置
chunkSizeWarningLimit: 1500, // 分块打包,分解块,将大块分解成更小的块 chunkSizeWarningLimit: 1500, // 分块打包,分解块,将大块分解成更小的块
rollupOptions: { rollupOptions: {
output: { output: {
manualChunks(id) { manualChunks(id) {
if (id.includes('node_modules')) { if (id.includes("node_modules")) {
return id.toString().split('node_modules/')[1].split('/')[0].toString(); return id
} .toString()
} .split("node_modules/")[1]
.split("/")[0]
.toString();
} }
}, },
},
},
terserOptions: { terserOptions: {
compress: { compress: {
drop_console: true, // 生产环境移除console drop_console: true, // 生产环境移除console
drop_debugger: true // 生产环境移除debugger drop_debugger: true, // 生产环境移除debugger
} },
} },
} },
}) });
} };
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论