修改
This commit is contained in:
parent
99a5c541c5
commit
8cf0b195cb
@ -1,12 +1,12 @@
|
||||
# 页面标题
|
||||
VUE_APP_TITLE = 全医通护理站管理平台
|
||||
VUE_APP_TITLE = 泉医通护理站管理平台
|
||||
|
||||
# 开发环境配置
|
||||
ENV = 'development'
|
||||
|
||||
# 全医通护理站管理平台/开发环境
|
||||
# 泉医通护理站管理平台/开发环境
|
||||
# VUE_APP_BASE_API = '/dev-api'
|
||||
VUE_APP_BASE_API = 'http://192.168.16.49:8080'
|
||||
VUE_APP_BASE_API = 'http://192.168.16.30:8080'
|
||||
|
||||
# 路由懒加载
|
||||
VUE_CLI_BABEL_TRANSPILE_MODULES = true
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
# 页面标题
|
||||
VUE_APP_TITLE = 全医通护理站管理平台
|
||||
VUE_APP_TITLE = 泉医通护理站管理平台
|
||||
|
||||
# 生产环境配置
|
||||
ENV = 'production'
|
||||
|
||||
# 全医通护理站管理平台/生产环境
|
||||
# 泉医通护理站管理平台/生产环境
|
||||
VUE_APP_BASE_API = '/prod-api'
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
# 页面标题
|
||||
VUE_APP_TITLE = 全医通护理站管理平台
|
||||
VUE_APP_TITLE = 泉医通护理站管理平台
|
||||
|
||||
NODE_ENV = production
|
||||
|
||||
# 测试环境配置
|
||||
ENV = 'staging'
|
||||
|
||||
# 全医通护理站管理平台/测试环境
|
||||
# 泉医通护理站管理平台/测试环境
|
||||
VUE_APP_BASE_API = '/stage-api'
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
var baseurl = "http://192.168.16.49:8080";
|
||||
var baseurl = "http://192.168.16.30:8080";
|
||||
|
||||
export default baseurl
|
||||
export default baseurl
|
||||
44
src/api/system/goodsCategory.js
Normal file
44
src/api/system/goodsCategory.js
Normal file
@ -0,0 +1,44 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询商品分类信息列表
|
||||
export function listGoodsCategory(query) {
|
||||
return request({
|
||||
url: '/system/goodsCategory/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询商品分类信息详细
|
||||
export function getGoodsCategory(id) {
|
||||
return request({
|
||||
url: '/system/goodsCategory/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增商品分类信息
|
||||
export function addGoodsCategory(data) {
|
||||
return request({
|
||||
url: '/system/goodsCategory/add',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改商品分类信息
|
||||
export function updateGoodsCategory(data) {
|
||||
return request({
|
||||
url: '/system/goodsCategory/edit',
|
||||
method: 'POST',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除商品分类信息
|
||||
export function delGoodsCategory(id) {
|
||||
return request({
|
||||
url: '/system/goodsCategory/' + id,
|
||||
method: 'POST'
|
||||
})
|
||||
}
|
||||
389
src/views/system/goodsCategory/index.vue
Normal file
389
src/views/system/goodsCategory/index.vue
Normal file
@ -0,0 +1,389 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form
|
||||
:model="queryParams"
|
||||
ref="queryForm"
|
||||
size="small"
|
||||
:inline="true"
|
||||
v-show="showSearch"
|
||||
label-width="100px"
|
||||
>
|
||||
<el-form-item label="商品分类名称" prop="goodsCategoryName">
|
||||
<el-input
|
||||
v-model="queryParams.goodsCategoryName"
|
||||
placeholder="请输入商品分类名称"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品分类编码" prop="goodsCategoryCode">
|
||||
<el-input
|
||||
v-model="queryParams.goodsCategoryCode"
|
||||
placeholder="请输入商品分类编码"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="显示顺序" prop="sort">
|
||||
<el-input
|
||||
v-model="queryParams.sort"
|
||||
placeholder="请输入显示顺序"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button
|
||||
type="primary"
|
||||
icon="el-icon-search"
|
||||
size="mini"
|
||||
@click="handleQuery"
|
||||
>搜索</el-button
|
||||
>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
|
||||
>重置</el-button
|
||||
>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['system:goodsCategory:add']"
|
||||
>新增</el-button
|
||||
>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="el-icon-edit"
|
||||
size="mini"
|
||||
:disabled="single"
|
||||
@click="handleUpdate"
|
||||
v-hasPermi="['system:goodsCategory:edit']"
|
||||
>修改</el-button
|
||||
>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="el-icon-delete"
|
||||
size="mini"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-hasPermi="['system:goodsCategory:remove']"
|
||||
>删除</el-button
|
||||
>
|
||||
</el-col>
|
||||
<!-- <el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="el-icon-download"
|
||||
size="mini"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['system:goodsCategory:export']"
|
||||
>导出</el-button
|
||||
>
|
||||
</el-col> -->
|
||||
<right-toolbar
|
||||
:showSearch.sync="showSearch"
|
||||
@queryTable="getList"
|
||||
></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="goodsCategoryList"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column
|
||||
label="商品分类名称"
|
||||
align="center"
|
||||
prop="goodsCategoryName"
|
||||
/>
|
||||
<el-table-column
|
||||
label="商品分类编码"
|
||||
align="center"
|
||||
prop="goodsCategoryCode"
|
||||
/>
|
||||
<!-- <el-table-column label="商品分类图片地址" align="center" prop="goodsCategoryPicture" /> -->
|
||||
<el-table-column label="分类概述" align="center" prop="categoryRemark" />
|
||||
<el-table-column label="显示顺序" align="center" prop="sort" />
|
||||
<el-table-column
|
||||
label="操作"
|
||||
align="center"
|
||||
class-name="small-padding fixed-width"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['system:goodsCategory:edit']"
|
||||
>修改</el-button
|
||||
>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['system:goodsCategory:remove']"
|
||||
>删除</el-button
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改商品分类信息对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
|
||||
<el-form-item label="商品分类名称" prop="goodsCategoryName">
|
||||
<el-input
|
||||
v-model="form.goodsCategoryName"
|
||||
placeholder="请输入商品分类名称"
|
||||
maxlength="50"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品分类编码" prop="goodsCategoryCode">
|
||||
<el-input
|
||||
v-model="form.goodsCategoryCode"
|
||||
placeholder="请输入商品分类编码"
|
||||
maxlength="20"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="商品分类图片" prop="goodsCategoryPicture">
|
||||
<stationAcatar
|
||||
@imgUrl="imgUrl"
|
||||
:img="form.goodsCategoryPicture"
|
||||
:type="'goodsCategoryPicture'"
|
||||
/>
|
||||
<!-- <img :src="form.goodsCategoryPicture" alt="" /> -->
|
||||
</el-form-item>
|
||||
<el-form-item label="分类概述" prop="categoryRemark">
|
||||
<el-input
|
||||
v-model="form.categoryRemark"
|
||||
placeholder="请输入分类概述"
|
||||
maxlength="300"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="显示顺序" prop="sort">
|
||||
<el-input
|
||||
v-model="form.sort"
|
||||
type="number"
|
||||
oninput="if(value.length>9){value=value.slice(0,9)}"
|
||||
placeholder="请输入显示顺序"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
listGoodsCategory,
|
||||
getGoodsCategory,
|
||||
delGoodsCategory,
|
||||
addGoodsCategory,
|
||||
updateGoodsCategory,
|
||||
} from "@/api/system/goodsCategory";
|
||||
import stationAcatar from "../stationAvatar/index.vue";
|
||||
import baseurl from "@/api/baseurl";
|
||||
export default {
|
||||
name: "GoodsCategory",
|
||||
components: { stationAcatar },
|
||||
data() {
|
||||
return {
|
||||
baseurl: "",
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 商品分类信息表格数据
|
||||
goodsCategoryList: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
goodsCategoryName: null,
|
||||
goodsCategoryCode: null,
|
||||
goodsCategoryPicture: null,
|
||||
categoryRemark: null,
|
||||
sort: null,
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
goodsCategoryName: [
|
||||
{ required: true, message: "商品分类名称不能为空", trigger: "blur" },
|
||||
],
|
||||
goodsCategoryCode: [
|
||||
{ required: true, message: "商品分类编码不能为空", trigger: "blur" },
|
||||
],
|
||||
goodsCategoryPicture: [
|
||||
{ required: true, message: "商品分类图片不能为空", trigger: "blur" },
|
||||
],
|
||||
categoryRemark: [
|
||||
{ required: true, message: "分类概述不能为空", trigger: "blur" },
|
||||
],
|
||||
sort: [
|
||||
{ required: true, message: "显示顺序不能为空", trigger: "blur" },
|
||||
],
|
||||
},
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.baseurl = baseurl;
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询商品分类信息列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listGoodsCategory(this.queryParams).then((response) => {
|
||||
this.goodsCategoryList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
id: null,
|
||||
goodsCategoryName: null,
|
||||
goodsCategoryCode: null,
|
||||
goodsCategoryPicture: null,
|
||||
categoryRemark: null,
|
||||
sort: null,
|
||||
createBy: null,
|
||||
createTime: null,
|
||||
updateBy: null,
|
||||
updateTime: null,
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map((item) => item.id);
|
||||
this.single = selection.length !== 1;
|
||||
this.multiple = !selection.length;
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.open = true;
|
||||
this.title = "添加商品分类信息";
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
const id = row.id || this.ids;
|
||||
getGoodsCategory(id).then((response) => {
|
||||
this.form = response.data;
|
||||
this.open = true;
|
||||
this.title = "修改商品分类信息";
|
||||
console.log(this.form);
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
console.log(this.form);
|
||||
|
||||
this.$refs["form"].validate((valid) => {
|
||||
if (valid) {
|
||||
if (this.form.id != null) {
|
||||
updateGoodsCategory(this.form).then((response) => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
} else {
|
||||
addGoodsCategory(this.form).then((response) => {
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const ids = row.id || this.ids;
|
||||
this.$modal
|
||||
.confirm('是否确认删除商品分类信息编号为"' + ids + '"的数据项?')
|
||||
.then(function () {
|
||||
return delGoodsCategory(ids);
|
||||
})
|
||||
.then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
})
|
||||
.catch(() => {});
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.download(
|
||||
"system/goodsCategory/export",
|
||||
{
|
||||
...this.queryParams,
|
||||
},
|
||||
`goodsCategory_${new Date().getTime()}.xlsx`
|
||||
);
|
||||
},
|
||||
imgUrl(imgUrl) {
|
||||
this.form.goodsCategoryPicture = imgUrl;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@ -128,7 +128,7 @@
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column
|
||||
<el-table-column
|
||||
label="所属护理站"
|
||||
align="center"
|
||||
prop="nurseStationName"
|
||||
@ -175,16 +175,8 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
label="创建时间"
|
||||
align="center"
|
||||
prop="createTime"
|
||||
/>
|
||||
<el-table-column
|
||||
label="创建人"
|
||||
align="center"
|
||||
prop="createBy"
|
||||
/>
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" />
|
||||
<el-table-column label="创建人" align="center" prop="createBy" />
|
||||
<el-table-column
|
||||
label="操作"
|
||||
align="center"
|
||||
@ -199,7 +191,7 @@
|
||||
v-hasPermi="['system:goodsInfo:edit']"
|
||||
>修改</el-button
|
||||
>
|
||||
<el-button
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@ -236,19 +228,20 @@
|
||||
ref="form"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
label-width="100px"
|
||||
label-width="120px"
|
||||
:inline="true"
|
||||
>
|
||||
<el-form-item label="商品名称" prop="goodsName">
|
||||
<el-input
|
||||
v-model="form.goodsName"
|
||||
placeholder="请输入商品名称"
|
||||
max="40"
|
||||
style="width: 210px; margin-left: 10px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="护理站名称" prop="nurseStationId">
|
||||
<el-select
|
||||
style="width: 210px; "
|
||||
style="width: 210px"
|
||||
v-model="form.nurseStationId"
|
||||
clearable
|
||||
placeholder="请选择护理站"
|
||||
@ -331,7 +324,8 @@
|
||||
<template slot-scope="scope">
|
||||
<el-input
|
||||
v-model="scope.row.goodsPrice"
|
||||
maxlength="40"
|
||||
type="number"
|
||||
oninput=" if(value.length>7){value=value.slice(0,7)}"
|
||||
></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@ -339,16 +333,17 @@
|
||||
<template slot-scope="scope">
|
||||
<el-input
|
||||
v-model="scope.row.goodsStock"
|
||||
maxlength="40"
|
||||
type="number"
|
||||
oninput="if(value.length>9){value=value.slice(0,9)}"
|
||||
></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="显示顺序" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-input
|
||||
type="number"
|
||||
v-model.number="scope.row.attributeDetailsSort"
|
||||
maxlength="40"
|
||||
v-model="scope.row.attributeDetailsSort"
|
||||
type="number"
|
||||
oninput=" if(value.length>9){value=value.slice(0,9)}"
|
||||
></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@ -800,6 +795,15 @@ export default {
|
||||
updateBy: null,
|
||||
updateTime: null,
|
||||
};
|
||||
this.goodDetailsLists = [
|
||||
{
|
||||
attributePitureUrl: "",
|
||||
goodsPrice: "",
|
||||
goodsStock: "",
|
||||
sort: "",
|
||||
ids: 9999999,
|
||||
},
|
||||
];
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
@ -823,7 +827,6 @@ export default {
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.title = "商品基本信息";
|
||||
console.log(this.ids);
|
||||
this.goodDetailsLists = [
|
||||
{
|
||||
attributePitureUrl: "",
|
||||
@ -841,7 +844,9 @@ export default {
|
||||
const id = row.goodsInfoId || this.ids;
|
||||
getGoodsInfo(id).then((response) => {
|
||||
this.form = response.data[0];
|
||||
this.goodDetailsLists = response.data[0].goodAttributeDetailsLists;
|
||||
if (response.data[0].goodAttributeDetailsLists) {
|
||||
this.goodDetailsLists = response.data[0].goodAttributeDetailsLists;
|
||||
}
|
||||
this.open = true;
|
||||
this.title = "修改商品基本信息";
|
||||
});
|
||||
@ -885,17 +890,13 @@ export default {
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
console.log('row :>> ', row);
|
||||
this.$confirm(
|
||||
'是否确认删除订单信息的数据项?',
|
||||
"提示",
|
||||
{
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
}
|
||||
)
|
||||
handleDelete(row) {
|
||||
console.log("row :>> ", row);
|
||||
this.$confirm("是否确认删除订单信息的数据项?", "提示", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
})
|
||||
.then(() => {
|
||||
delGoodsInfo(row.goodsInfoId).then((res) => {
|
||||
this.$message.success("删除成功");
|
||||
|
||||
@ -145,7 +145,7 @@
|
||||
>修改</el-button
|
||||
>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<!-- <el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
@ -156,7 +156,7 @@
|
||||
v-hasPermi="['system:station:remove']"
|
||||
>删除</el-button
|
||||
>
|
||||
</el-col>
|
||||
</el-col> -->
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="info"
|
||||
|
||||
235
vue.config.js
235
vue.config.js
@ -2,7 +2,7 @@
|
||||
const path = require('path')
|
||||
|
||||
function resolve(dir) {
|
||||
return path.join(__dirname, dir)
|
||||
return path.join(__dirname, dir)
|
||||
}
|
||||
|
||||
const CompressionPlugin = require('compression-webpack-plugin')
|
||||
@ -15,122 +15,121 @@ const port = process.env.port || process.env.npm_config_port || 80 // 端口
|
||||
//官方vue.config.js 参考文档 https://cli.vuejs.org/zh/config/#css-loaderoptions
|
||||
// 这里只列一部分,具体配置参考文档
|
||||
module.exports = {
|
||||
// 部署生产环境和开发环境下的URL。
|
||||
// 默认情况下,Vue CLI 会假设你的应用是被部署在一个域名的根路径上
|
||||
// 例如 https://www.xinyilu.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.xinyilu.vip/admin/,则设置 baseUrl 为 /admin/。
|
||||
publicPath: process.env.NODE_ENV === "production" ? "/" : "/",
|
||||
// 在npm run build 或 yarn build 时 ,生成文件的目录名称(要和baseUrl的生产环境路径一致)(默认dist)
|
||||
outputDir: 'dist',
|
||||
// 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下)
|
||||
assetsDir: 'static',
|
||||
// 是否开启eslint保存检测,有效值:ture | false | 'error'
|
||||
lintOnSave: process.env.NODE_ENV === 'development',
|
||||
// 如果你不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建。
|
||||
productionSourceMap: false,
|
||||
// webpack-dev-server 相关配置
|
||||
devServer: {
|
||||
host: '0.0.0.0',
|
||||
port: port,
|
||||
open: true,
|
||||
proxy: {
|
||||
// detail: https://cli.vuejs.org/config/#devserver-proxy
|
||||
[process.env.VUE_APP_BASE_API]: {
|
||||
target: `http://localhost:8080`,
|
||||
changeOrigin: true,
|
||||
pathRewrite: {
|
||||
['^' + process.env.VUE_APP_BASE_API]: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
disableHostCheck: true
|
||||
},
|
||||
css: {
|
||||
loaderOptions: {
|
||||
sass: {
|
||||
sassOptions: { outputStyle: "expanded" }
|
||||
}
|
||||
}
|
||||
},
|
||||
configureWebpack: {
|
||||
name: name,
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': resolve('src')
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
// http://doc.xinyilu.vip/xinyilu-vue/other/faq.html#使用gzip解压缩静态文件
|
||||
new CompressionPlugin({
|
||||
cache: false, // 不启用文件缓存
|
||||
test: /\.(js|css|html)?$/i, // 压缩文件格式
|
||||
filename: '[path].gz[query]', // 压缩后的文件名
|
||||
algorithm: 'gzip', // 使用gzip压缩
|
||||
minRatio: 0.8 // 压缩率小于1才会压缩
|
||||
})
|
||||
],
|
||||
},
|
||||
chainWebpack(config) {
|
||||
config.plugins.delete('preload') // TODO: need test
|
||||
config.plugins.delete('prefetch') // TODO: need test
|
||||
|
||||
// set svg-sprite-loader
|
||||
config.module
|
||||
.rule('svg')
|
||||
.exclude.add(resolve('src/assets/icons'))
|
||||
.end()
|
||||
config.module
|
||||
.rule('icons')
|
||||
.test(/\.svg$/)
|
||||
.include.add(resolve('src/assets/icons'))
|
||||
.end()
|
||||
.use('svg-sprite-loader')
|
||||
.loader('svg-sprite-loader')
|
||||
.options({
|
||||
symbolId: 'icon-[name]'
|
||||
})
|
||||
.end()
|
||||
|
||||
config
|
||||
.when(process.env.NODE_ENV !== 'development',
|
||||
config => {
|
||||
config
|
||||
.plugin('ScriptExtHtmlWebpackPlugin')
|
||||
.after('html')
|
||||
.use('script-ext-html-webpack-plugin', [{
|
||||
// `runtime` must same as runtimeChunk name. default is `runtime`
|
||||
inline: /runtime\..*\.js$/
|
||||
}])
|
||||
.end()
|
||||
config
|
||||
.optimization.splitChunks({
|
||||
chunks: 'all',
|
||||
cacheGroups: {
|
||||
libs: {
|
||||
name: 'chunk-libs',
|
||||
test: /[\\/]node_modules[\\/]/,
|
||||
priority: 10,
|
||||
chunks: 'initial' // only package third parties that are initially dependent
|
||||
},
|
||||
elementUI: {
|
||||
name: 'chunk-elementUI', // split elementUI into a single package
|
||||
priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
|
||||
test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm
|
||||
},
|
||||
commons: {
|
||||
name: 'chunk-commons',
|
||||
test: resolve('src/components'), // can customize your rules
|
||||
minChunks: 3, // minimum common number
|
||||
priority: 5,
|
||||
reuseExistingChunk: true
|
||||
// 部署生产环境和开发环境下的URL。
|
||||
// 默认情况下,Vue CLI 会假设你的应用是被部署在一个域名的根路径上
|
||||
// 例如 https://www.xinyilu.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.xinyilu.vip/admin/,则设置 baseUrl 为 /admin/。
|
||||
publicPath: process.env.NODE_ENV === "production" ? "/" : "/",
|
||||
// 在npm run build 或 yarn build 时 ,生成文件的目录名称(要和baseUrl的生产环境路径一致)(默认dist)
|
||||
outputDir: 'dist',
|
||||
// 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下)
|
||||
assetsDir: 'static',
|
||||
// 是否开启eslint保存检测,有效值:ture | false | 'error'
|
||||
lintOnSave: process.env.NODE_ENV === 'development',
|
||||
// 如果你不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建。
|
||||
productionSourceMap: false,
|
||||
// webpack-dev-server 相关配置
|
||||
devServer: {
|
||||
host: '0.0.0.0',
|
||||
port: port,
|
||||
open: true,
|
||||
proxy: {
|
||||
// detail: https://cli.vuejs.org/config/#devserver-proxy
|
||||
[process.env.VUE_APP_BASE_API]: {
|
||||
target: `http://localhost:8080`,
|
||||
changeOrigin: true,
|
||||
pathRewrite: {
|
||||
['^' + process.env.VUE_APP_BASE_API]: ''
|
||||
}
|
||||
}
|
||||
})
|
||||
config.optimization.runtimeChunk('single'),
|
||||
{
|
||||
from: path.resolve(__dirname, './public/robots.txt'), //防爬虫文件
|
||||
to: './' //到根目录下
|
||||
}
|
||||
}
|
||||
},
|
||||
disableHostCheck: true
|
||||
},
|
||||
css: {
|
||||
loaderOptions: {
|
||||
sass: {
|
||||
sassOptions: { outputStyle: "expanded" }
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
configureWebpack: {
|
||||
name: name,
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': resolve('src')
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
// http://doc.xinyilu.vip/xinyilu-vue/other/faq.html#使用gzip解压缩静态文件
|
||||
new CompressionPlugin({
|
||||
cache: false, // 不启用文件缓存
|
||||
test: /\.(js|css|html)?$/i, // 压缩文件格式
|
||||
filename: '[path].gz[query]', // 压缩后的文件名
|
||||
algorithm: 'gzip', // 使用gzip压缩
|
||||
minRatio: 0.8 // 压缩率小于1才会压缩
|
||||
})
|
||||
],
|
||||
},
|
||||
chainWebpack(config) {
|
||||
config.plugins.delete('preload') // TODO: need test
|
||||
config.plugins.delete('prefetch') // TODO: need test
|
||||
|
||||
// set svg-sprite-loader
|
||||
config.module
|
||||
.rule('svg')
|
||||
.exclude.add(resolve('src/assets/icons'))
|
||||
.end()
|
||||
config.module
|
||||
.rule('icons')
|
||||
.test(/\.svg$/)
|
||||
.include.add(resolve('src/assets/icons'))
|
||||
.end()
|
||||
.use('svg-sprite-loader')
|
||||
.loader('svg-sprite-loader')
|
||||
.options({
|
||||
symbolId: 'icon-[name]'
|
||||
})
|
||||
.end()
|
||||
|
||||
config
|
||||
.when(process.env.NODE_ENV !== 'development',
|
||||
config => {
|
||||
config
|
||||
.plugin('ScriptExtHtmlWebpackPlugin')
|
||||
.after('html')
|
||||
.use('script-ext-html-webpack-plugin', [{
|
||||
// `runtime` must same as runtimeChunk name. default is `runtime`
|
||||
inline: /runtime\..*\.js$/
|
||||
}])
|
||||
.end()
|
||||
config
|
||||
.optimization.splitChunks({
|
||||
chunks: 'all',
|
||||
cacheGroups: {
|
||||
libs: {
|
||||
name: 'chunk-libs',
|
||||
test: /[\\/]node_modules[\\/]/,
|
||||
priority: 10,
|
||||
chunks: 'initial' // only package third parties that are initially dependent
|
||||
},
|
||||
elementUI: {
|
||||
name: 'chunk-elementUI', // split elementUI into a single package
|
||||
priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
|
||||
test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm
|
||||
},
|
||||
commons: {
|
||||
name: 'chunk-commons',
|
||||
test: resolve('src/components'), // can customize your rules
|
||||
minChunks: 3, // minimum common number
|
||||
priority: 5,
|
||||
reuseExistingChunk: true
|
||||
}
|
||||
}
|
||||
})
|
||||
config.optimization.runtimeChunk('single'), {
|
||||
from: path.resolve(__dirname, './public/robots.txt'), //防爬虫文件
|
||||
to: './' //到根目录下
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user