Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
L
Lic
Project
Project
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
Graph
比较
统计图
议题
0
议题
0
列表
看板
标记
Milestones
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
刘旭
Lic
Commits
2cce373a
提交
2cce373a
authored
12月 08, 2023
作者:
刘旭
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
新增字段 租户标识 租户域名
上级
392e301d
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
305 行增加
和
172 行删除
+305
-172
licInformation.vue
src/views/business/licInformation.vue
+262
-135
vite.config.ts
vite.config.ts
+43
-37
没有找到文件。
src/views/business/licInformation.vue
浏览文件 @
2cce373a
<
template
>
<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-input
v-model=
"searchValue"
placeholder=
"请输入MAC地址"
></el-input>
</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-col>
</el-row>
<el-button
type=
"primary"
@
click=
"addlicInfo"
style=
"margin-bottom: 20px;"
>
添加信息
</el-button>
<el-table
:data=
"licInfoTable.licInfoData"
border
style=
"width: 100%"
row-key=
"id"
v-loading=
"licInfoTable.loading"
>
<el-button
type=
"primary"
@
click=
"addlicInfo"
style=
"margin-bottom: 20px"
>
添加信息
</el-button
>
<el-table
:data=
"licInfoTable.licInfoData"
border
style=
"width: 100%"
row-key=
"id"
v-loading=
"licInfoTable.loading"
>
<el-table-column
type=
"expand"
>
<template
#
default=
"scope"
>
<div
v-if=
"scope.row.dockerServices.length === 0"
>
<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>
</div>
<div
v-else
style=
"padding: 20px 40px;"
>
<div
style=
"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
v-else
style=
"padding: 20px 40px"
>
<div
style=
"
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>
<el-table
:data=
"scope.row.dockerServices"
style=
"width: 100%"
>
<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
label=
"操作"
width=
"200"
align=
"center"
>
<template
#
default=
"item"
>
<el-button
size=
"small"
type=
"danger"
@
click=
"handleServiceDelete(scope.row, item.row.id)"
>
删除
<el-button
size=
"small"
type=
"danger"
@
click=
"handleServiceDelete(scope.row, item.row.id)"
>
删除
</el-button>
</
template
>
</el-table-column>
...
...
@@ -44,47 +74,108 @@
<el-table-column
prop=
"fileEffectiveTime"
label=
"导入后有效时间"
/>
<el-table-column
prop=
"verificationInterval"
label=
"验证间隔时间(s)"
/>
<el-table-column
prop=
"moduleVerification"
label=
"模块验证"
/>
<el-table-column
prop=
"tenantId"
label=
"租户标识"
/>
<el-table-column
prop=
"domainName"
label=
"租户域名"
/>
<el-table-column
label=
"操作"
width=
"200"
>
<
template
#
default=
"scope"
>
<el-button
size=
"small"
type=
"primary"
@
click=
"handleEdit(scope.row)"
>
编辑
</el-button>
<el-button
size=
"small"
type=
"danger"
@
click=
"handleDelete(scope.row.id)"
>
删除
<el-button
size=
"small"
type=
"primary"
@
click=
"handleEdit(scope.row)"
>
编辑
</el-button
>
<el-button
size=
"small"
type=
"danger"
@
click=
"handleDelete(scope.row.id)"
>
删除
</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
>
</el-table-column>
</el-table>
<div
style=
"margin-top: 20px"
>
<el-pagination
v-model:currentPage=
"licInfoTable.pageNo"
v-model:page-size=
"licInfoTable.pageSize"
: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
/>
<el-pagination
v-model:currentPage=
"licInfoTable.pageNo"
v-model:page-size=
"licInfoTable.pageSize"
: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>
<!-- 添加对话框 -->
<el-dialog
v-model=
"licInfoForm.dialogVisible"
:title=
"licInfoForm.title"
width=
"30%"
:before-close=
"handleClose"
>
<el-form
ref=
"licInfoRef"
:model=
"licInfoForm.formLicInfo"
:rules=
"licInfoForm.rules"
label-width=
"150px"
status-icon
>
<el-dialog
v-model=
"licInfoForm.dialogVisible"
: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-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
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
label=
"导入文件有效时间"
prop=
"effectiveTime"
>
<el-date-picker
v-model=
"licInfoForm.formLicInfo.effectiveTime"
type=
"datetime"
placeholder=
"请输入有效时间"
value-format=
"YYYY-MM-DD HH:mm:ss"
/>
<el-date-picker
v-model=
"licInfoForm.formLicInfo.effectiveTime"
type=
"datetime"
placeholder=
"请输入有效时间"
value-format=
"YYYY-MM-DD HH:mm:ss"
/>
</el-form-item>
<el-form-item
label=
"导入后有效时间"
prop=
"fileEffectiveTime"
>
<el-date-picker
v-model=
"licInfoForm.formLicInfo.fileEffectiveTime"
type=
"datetime"
placeholder=
"请输入有效时间"
value-format=
"YYYY-MM-DD HH:mm:ss"
/>
<el-date-picker
v-model=
"licInfoForm.formLicInfo.fileEffectiveTime"
type=
"datetime"
placeholder=
"请输入有效时间"
value-format=
"YYYY-MM-DD HH:mm:ss"
/>
</el-form-item>
<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-form-item>
<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>
<
template
#
footer
>
...
...
@@ -95,134 +186,160 @@
</
template
>
</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>
<
script
setup
lang=
"ts"
>
import
{
ref
,
reactive
}
from
'vue'
import
{
licInfoList
,
licInfoDelete
,
licInfoFileCreate
,
licInfoUpdate
,
licInfoCreate
}
from
'@/services/api/licInformation/licInformation'
import
{
ref
,
reactive
}
from
"vue"
;
import
{
licInfoList
,
licInfoDelete
,
licInfoFileCreate
,
licInfoUpdate
,
licInfoCreate
,
}
from
"@/services/api/licInformation/licInformation"
;
import
{
ElMessageBox
,
ElMessage
}
from
"element-plus"
;
import
mirrorForm
from
'./components/mirrorForm.vue'
import
mirrorForm
from
"./components/mirrorForm.vue"
;
const
licInfoTable
=
reactive
({
licInfoData
:
[],
total
:
0
,
pageNo
:
1
,
pageSize
:
10
,
loading
:
true
})
loading
:
true
,
})
;
const
licInfoRef
=
ref
()
const
mirrorFormRef
=
ref
()
const
licInfoRef
=
ref
()
;
const
mirrorFormRef
=
ref
()
;
const
searchValue
=
ref
()
const
mirrorDialog
=
ref
()
const
searchValue
=
ref
()
;
const
mirrorDialog
=
ref
()
;
const
licInfoForm
=
reactive
<
any
>
({
dialogVisible
:
false
,
title
:
'新增'
,
title
:
"新增"
,
formLicInfo
:
{
dockerServices
:
[],
macAddress
:
''
,
effectiveTime
:
''
,
fileEffectiveTime
:
''
,
verificationInterval
:
''
,
moduleVerification
:
''
,
lqLicName
:
''
macAddress
:
""
,
effectiveTime
:
""
,
fileEffectiveTime
:
""
,
verificationInterval
:
""
,
moduleVerification
:
""
,
lqLicName
:
""
,
tenantId
:
""
,
domainName
:
""
,
},
rules
:
{
macAddress
:
[{
required
:
true
,
message
:
''
,
trigger
:
'blur'
}],
lqLicName
:
[{
required
:
true
,
message
:
''
,
trigger
:
'blur'
}],
effectiveTime
:
[{
type
:
'date'
,
macAddress
:
[{
required
:
true
,
message
:
""
,
trigger
:
"blur"
}],
lqLicName
:
[{
required
:
true
,
message
:
""
,
trigger
:
"blur"
}],
effectiveTime
:
[
{
type
:
"date"
,
required
:
true
,
message
:
''
,
trigger
:
'change'
,
}],
fileEffectiveTime
:
[{
type
:
'date'
,
message
:
""
,
trigger
:
"change"
,
},
],
fileEffectiveTime
:
[
{
type
:
"date"
,
required
:
true
,
message
:
''
,
trigger
:
'change'
,
}],
verificationInterval
:
[{
required
:
true
,
message
:
''
,
trigger
:
'blur'
},
{
type
:
'number'
,
message
:
'请输入数字'
}],
}
})
message
:
""
,
trigger
:
"change"
,
},
],
verificationInterval
:
[
{
required
:
true
,
message
:
""
,
trigger
:
"blur"
},
{
type
:
"number"
,
message
:
"请输入数字"
},
],
},
});
const
search
=
()
=>
{
initLicInfo
(
searchValue
.
value
,
licInfoTable
.
pageNo
,
licInfoTable
.
pageSize
)
}
initLicInfo
(
searchValue
.
value
,
licInfoTable
.
pageNo
,
licInfoTable
.
pageSize
);
}
;
const
addlicInfo
=
()
=>
{
licInfoForm
.
title
=
'新增'
licInfoForm
.
dialogVisible
=
true
}
licInfoForm
.
title
=
"新增"
;
licInfoForm
.
dialogVisible
=
true
;
}
;
const
mirrorRow
=
ref
()
as
any
const
mirrorRow
=
ref
()
as
any
;
const
handleEdit
=
(
data
:
any
)
=>
{
licInfoForm
.
title
=
'编辑'
licInfoForm
.
formLicInfo
=
data
licInfoForm
.
dialogVisible
=
true
}
licInfoForm
.
title
=
"编辑"
;
licInfoForm
.
formLicInfo
=
data
;
licInfoForm
.
dialogVisible
=
true
;
}
;
// 新条数
const
handleSizeChange
=
(
val
:
number
)
=>
{
licInfoTable
.
pageSize
=
val
;
initLicInfo
(
searchValue
.
value
,
licInfoTable
.
pageNo
,
licInfoTable
.
pageSize
)
initLicInfo
(
searchValue
.
value
,
licInfoTable
.
pageNo
,
licInfoTable
.
pageSize
);
};
// 新页数
const
handleCurrentChange
=
(
val
:
number
)
=>
{
licInfoTable
.
pageNo
=
val
;
initLicInfo
(
searchValue
.
value
,
licInfoTable
.
pageNo
,
licInfoTable
.
pageSize
)
initLicInfo
(
searchValue
.
value
,
licInfoTable
.
pageNo
,
licInfoTable
.
pageSize
);
};
const
onConfirm
=
()
=>
{
licInfoRef
.
value
?.
validate
((
valid
:
any
,
fields
:
any
)
=>
{
if
(
valid
)
{
if
(
licInfoForm
.
title
===
'新增'
)
{
if
(
licInfoForm
.
title
===
"新增"
)
{
licInfoCreate
(
licInfoForm
.
formLicInfo
).
then
((
res
:
any
)
=>
{
if
(
res
.
code
===
200
)
{
initLicInfo
(
searchValue
.
value
,
licInfoTable
.
pageNo
,
licInfoTable
.
pageSize
)
licInfoRef
.
value
?.
resetFields
()
initLicInfo
(
searchValue
.
value
,
licInfoTable
.
pageNo
,
licInfoTable
.
pageSize
);
licInfoRef
.
value
?.
resetFields
();
ElMessage
({
type
:
"success"
,
message
:
"添加成功!"
});
licInfoForm
.
dialogVisible
=
false
licInfoForm
.
dialogVisible
=
false
;
}
})
});
}
else
{
licInfoUpdate
(
licInfoForm
.
formLicInfo
).
then
((
res
:
any
)
=>
{
if
(
res
.
code
===
200
)
{
initLicInfo
(
searchValue
.
value
,
licInfoTable
.
pageNo
,
licInfoTable
.
pageSize
)
licInfoRef
.
value
?.
resetFields
()
initLicInfo
(
searchValue
.
value
,
licInfoTable
.
pageNo
,
licInfoTable
.
pageSize
);
licInfoRef
.
value
?.
resetFields
();
ElMessage
({
type
:
"success"
,
message
:
"修改成功!"
});
licInfoForm
.
dialogVisible
=
false
licInfoForm
.
dialogVisible
=
false
;
}
})
});
}
}
else
{
console
.
log
(
"校验失败"
,
fields
);
}
})
}
});
};
const
addMirror
=
(
row
:
any
)
=>
{
mirrorDialog
.
value
=
true
mirrorFormRef
.
value
.
title
=
'新增镜像'
mirrorFormRef
.
value
.
initService
()
mirrorRow
.
value
=
JSON
.
parse
(
JSON
.
stringify
(
row
))
}
mirrorDialog
.
value
=
true
;
mirrorFormRef
.
value
.
title
=
"新增镜像"
;
mirrorFormRef
.
value
.
initService
();
mirrorRow
.
value
=
JSON
.
parse
(
JSON
.
stringify
(
row
));
}
;
const
getMirrorData
=
async
(
data
:
any
)
=>
{
mirrorRow
.
value
.
dockerServices
.
push
(
data
)
const
res
:
any
=
await
licInfoUpdate
(
mirrorRow
.
value
)
mirrorRow
.
value
.
dockerServices
.
push
(
data
);
const
res
:
any
=
await
licInfoUpdate
(
mirrorRow
.
value
);
if
(
res
.
code
===
200
)
{
ElMessage
.
success
(
'添加成功'
)
initLicInfo
(
searchValue
.
value
,
licInfoTable
.
pageNo
,
licInfoTable
.
pageSize
)
mirrorFormRef
.
value
.
handleClose
()
ElMessage
.
success
(
"添加成功"
);
initLicInfo
(
searchValue
.
value
,
licInfoTable
.
pageNo
,
licInfoTable
.
pageSize
);
mirrorFormRef
.
value
.
handleClose
();
}
}
}
;
// 删除
const
handleDelete
=
(
id
:
number
)
=>
{
...
...
@@ -248,7 +365,7 @@ const handleDelete = (id: number) => {
message
:
"取消删除!"
,
});
});
}
}
;
const
handleServiceDelete
=
(
row
:
any
,
id
:
number
)
=>
{
ElMessageBox
.
confirm
(
"请确认删除?"
,
"删除"
,
{
...
...
@@ -260,15 +377,19 @@ const handleServiceDelete = (row: any, id: number) => {
let
index
;
row
.
dockerServices
.
map
((
item
:
any
,
i
:
number
)
=>
{
if
(
item
.
id
===
id
)
{
index
=
i
index
=
i
;
}
})
row
.
dockerServices
.
splice
(
index
,
1
)
const
res
:
any
=
await
licInfoUpdate
(
row
)
});
row
.
dockerServices
.
splice
(
index
,
1
);
const
res
:
any
=
await
licInfoUpdate
(
row
);
if
(
res
.
code
===
200
)
{
ElMessage
.
success
(
'添加成功'
)
initLicInfo
(
searchValue
.
value
,
licInfoTable
.
pageNo
,
licInfoTable
.
pageSize
)
mirrorDialog
.
value
=
false
ElMessage
.
success
(
"添加成功"
);
initLicInfo
(
searchValue
.
value
,
licInfoTable
.
pageNo
,
licInfoTable
.
pageSize
);
mirrorDialog
.
value
=
false
;
}
})
.
catch
(()
=>
{
...
...
@@ -277,7 +398,7 @@ const handleServiceDelete = (row: any, id: number) => {
message
:
"取消删除!"
,
});
});
}
}
;
// 导出
const
handleExport
=
(
data
:
any
)
=>
{
...
...
@@ -289,20 +410,20 @@ const handleExport = (data: any) => {
.
then
(()
=>
{
licInfoFileCreate
(
data
).
then
((
res
:
any
)
=>
{
const
content
=
res
;
const
blob
=
new
Blob
([
content
])
const
downloadElement
=
document
.
createElement
(
'a'
)
const
blob
=
new
Blob
([
content
]);
const
downloadElement
=
document
.
createElement
(
"a"
);
// 创建下载的链接
const
href
=
window
.
URL
.
createObjectURL
(
blob
)
downloadElement
.
href
=
href
const
href
=
window
.
URL
.
createObjectURL
(
blob
);
downloadElement
.
href
=
href
;
// 下载后文件名
downloadElement
.
download
=
'lic'
+
data
.
macAddress
+
'.lqlic'
;
document
.
body
.
appendChild
(
downloadElement
)
downloadElement
.
download
=
"lic"
+
data
.
macAddress
+
".lqlic"
;
document
.
body
.
appendChild
(
downloadElement
);
// 点击下载
downloadElement
.
click
()
downloadElement
.
click
();
// 下载完成移除元素
document
.
body
.
removeChild
(
downloadElement
)
document
.
body
.
removeChild
(
downloadElement
);
// 释放掉blob对象
window
.
URL
.
revokeObjectURL
(
href
)
window
.
URL
.
revokeObjectURL
(
href
);
});
})
.
catch
(()
=>
{
...
...
@@ -310,35 +431,41 @@ const handleExport = (data: any) => {
type
:
"info"
,
message
:
"取消导出!"
,
});
})
}
});
}
;
const
handleClose
=
()
=>
{
licInfoRef
.
value
?.
resetFields
()
licInfoRef
.
value
?.
resetFields
();
licInfoForm
.
formLicInfo
=
{
dockerServices
:
[],
macAddress
:
''
,
effectiveTime
:
''
,
fileEffectiveTime
:
''
,
verificationInterval
:
''
,
moduleVerification
:
''
,
lqLicName
:
''
}
licInfoForm
.
dialogVisible
=
false
}
macAddress
:
""
,
effectiveTime
:
""
,
fileEffectiveTime
:
""
,
verificationInterval
:
""
,
moduleVerification
:
""
,
lqLicName
:
""
,
tenantId
:
""
,
domainName
:
""
,
};
licInfoForm
.
dialogVisible
=
false
;
};
// 列表数据 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
)
=>
{
if
(
res
.
code
===
200
)
{
licInfoTable
.
licInfoData
=
res
.
data
.
records
licInfoTable
.
total
=
res
.
data
.
total
licInfoTable
.
loading
=
false
licInfoTable
.
licInfoData
=
res
.
data
.
records
;
licInfoTable
.
total
=
res
.
data
.
total
;
licInfoTable
.
loading
=
false
;
}
})
}
});
}
;
initLicInfo
()
initLicInfo
()
;
</
script
>
<
style
lang=
"scss"
scoped
>
...
...
vite.config.ts
浏览文件 @
2cce373a
import
{
defineConfig
}
from
'vite'
;
import
vue
from
'@vitejs/plugin-vue'
;
import
{
defineConfig
}
from
"vite"
;
import
vue
from
"@vitejs/plugin-vue"
;
// vite 提供的操作env配置变量的方法loadEnv
import
{
loadEnv
}
from
'vite'
;
import
{
loadEnv
}
from
"vite"
;
// nodejs写法,获取项目目录
import
path
from
'path'
;
import
path
from
"path"
;
//按需要加载
// import AutoImport from 'unplugin-auto-import/vite'
...
...
@@ -11,26 +11,26 @@ import path from 'path';
// import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
// import Icons from 'unplugin-icons/vite'
// import IconsResolver from 'unplugin-icons/resolver'
import
Inspect
from
'vite-plugin-inspect'
import
{
viteMockServe
}
from
'vite-plugin-mock'
import
{
createSvgIconsPlugin
}
from
'vite-plugin-svg-icons'
const
pathSrc
=
path
.
resolve
(
__dirname
,
'src'
)
import
Inspect
from
"vite-plugin-inspect"
;
import
{
viteMockServe
}
from
"vite-plugin-mock"
;
import
{
createSvgIconsPlugin
}
from
"vite-plugin-svg-icons"
;
const
pathSrc
=
path
.
resolve
(
__dirname
,
"src"
);
// https://vitejs.dev/config/
export
default
({
command
,
mode
})
=>
{
const
env
=
loadEnv
(
mode
,
process
.
cwd
())
const
env
=
loadEnv
(
mode
,
process
.
cwd
());
return
defineConfig
({
plugins
:
[
vue
(),
createSvgIconsPlugin
({
// 指定需要缓存的图标文件夹
iconDirs
:
[
path
.
resolve
(
process
.
cwd
(),
'src/assets/icons'
)],
iconDirs
:
[
path
.
resolve
(
process
.
cwd
(),
"src/assets/icons"
)],
// 指定symbolId格式
symbolId
:
'icon-[dir]-[name]'
symbolId
:
"icon-[dir]-[name]"
,
}),
viteMockServe
({
// default
mockPath
:
'mock'
,
mockPath
:
"mock"
,
}),
// AutoImport({
// // Auto import functions from Vue, e.g. ref, reactive, toRef...
...
...
@@ -75,17 +75,18 @@ export default ({ command, mode }) => {
],
// 服务器配置
server
:
{
host
:
'0.0.0.0'
,
host
:
"0.0.0.0"
,
port
:
Number
(
loadEnv
(
mode
,
process
.
cwd
()).
VITE_APP_PORT
),
strictPort
:
false
,
// 端口被占用直接退出
https
:
false
,
// 默认用http方式
open
:
true
,
// 在开发服务器启动时自动在浏览器中打开应用程序
proxy
:
{
// 代理配置
open
:
true
,
// 在开发服务器启动时自动在浏览器中打开应用程序
proxy
:
{
// 代理配置
// 字符串简写写法
// '/foo': '',
// 选项写法
"/lic"
:
{
target
:
'http://192.168.0.8:8090'
target
:
"http://192.168.1.27:8090"
,
// rewrite: (path) => path.replace(/^\/api/, '')
},
// 正则表达式写法
...
...
@@ -96,13 +97,14 @@ export default ({ command, mode }) => {
// },
},
hmr
:
{
overlay
:
true
// 屏蔽服务器报错
}
overlay
:
true
,
// 屏蔽服务器报错
},
},
resolve
:
{
// 设置项目文件导入路径
resolve
:
{
// 设置项目文件导入路径
alias
:
{
'@'
:
pathSrc
}
"@"
:
pathSrc
,
},
},
css
:
{
// css预处理器
...
...
@@ -111,28 +113,33 @@ export default ({ command, mode }) => {
// 给导入的路径最后加上 ;
scss
:
{
charset
:
false
,
//防止样式出现警告,中文
additionalData
:
'@import "@/assets/styles/global.scss";'
}
}
charset
:
false
,
//防止样式出现警告,中文
additionalData
:
'@import "@/assets/styles/global.scss";'
,
},
},
build
:
{
// 分块打包配置
},
build
:
{
// 分块打包配置
chunkSizeWarningLimit
:
1500
,
// 分块打包,分解块,将大块分解成更小的块
rollupOptions
:
{
output
:
{
manualChunks
(
id
)
{
if
(
id
.
includes
(
'node_modules'
))
{
return
id
.
toString
().
split
(
'node_modules/'
)[
1
].
split
(
'/'
)[
0
].
toString
();
}
}
if
(
id
.
includes
(
"node_modules"
))
{
return
id
.
toString
()
.
split
(
"node_modules/"
)[
1
]
.
split
(
"/"
)[
0
]
.
toString
();
}
},
},
},
terserOptions
:
{
compress
:
{
drop_console
:
true
,
// 生产环境移除console
drop_debugger
:
true
// 生产环境移除debugger
}
}
}
})
}
\ No newline at end of file
drop_debugger
:
true
,
// 生产环境移除debugger
},
},
},
});
};
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论