diff --git a/.gitignore b/.gitignore index a58be01..e1acb60 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,4 @@ nbdist/ !*/build/*.java !*/build/*.html !*/build/*.xml +/logs/ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/segchk/SegchkCarouseMgtController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/segchk/SegchkCarouseMgtController.java new file mode 100644 index 0000000..bafdc72 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/segchk/SegchkCarouseMgtController.java @@ -0,0 +1,103 @@ +package com.ruoyi.web.controller.segchk; + +import java.util.List; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.segchk.domain.SegchkCarouseMgt; +import com.ruoyi.segchk.service.ISegchkCarouseMgtService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * seg首页轮播图管理Controller + * + * @author yinzhiying + * @date 2021-08-22 + */ +@RestController +@RequestMapping("/system/segchk_carouse_mgt") +public class SegchkCarouseMgtController extends BaseController +{ + @Autowired + private ISegchkCarouseMgtService segchkCarouseMgtService; + + /** + * 查询seg首页轮播图管理列表 + */ + @PreAuthorize("@ss.hasPermi('system:segchk_carouse_mgt:list')") + @GetMapping("/list") + public TableDataInfo list(SegchkCarouseMgt segchkCarouseMgt) + { + startPage(); + List list = segchkCarouseMgtService.selectSegchkCarouseMgtList(segchkCarouseMgt); + return getDataTable(list); + } + + /** + * 导出seg首页轮播图管理列表 + */ + @PreAuthorize("@ss.hasPermi('system:segchk_carouse_mgt:export')") + @Log(title = "seg首页轮播图管理", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(SegchkCarouseMgt segchkCarouseMgt) + { + List list = segchkCarouseMgtService.selectSegchkCarouseMgtList(segchkCarouseMgt); + ExcelUtil util = new ExcelUtil(SegchkCarouseMgt.class); + return util.exportExcel(list, "seg首页轮播图管理数据"); + } + + /** + * 获取seg首页轮播图管理详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:segchk_carouse_mgt:query')") + @GetMapping(value = "/{carouseId}") + public AjaxResult getInfo(@PathVariable("carouseId") Long carouseId) + { + return AjaxResult.success(segchkCarouseMgtService.selectSegchkCarouseMgtByCarouseId(carouseId)); + } + + /** + * 新增seg首页轮播图管理 + */ + @PreAuthorize("@ss.hasPermi('system:segchk_carouse_mgt:add')") + @Log(title = "seg首页轮播图管理", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody SegchkCarouseMgt segchkCarouseMgt) + { + return toAjax(segchkCarouseMgtService.insertSegchkCarouseMgt(segchkCarouseMgt)); + } + + /** + * 修改seg首页轮播图管理 + */ + @PreAuthorize("@ss.hasPermi('system:segchk_carouse_mgt:edit')") + @Log(title = "seg首页轮播图管理", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody SegchkCarouseMgt segchkCarouseMgt) + { + return toAjax(segchkCarouseMgtService.updateSegchkCarouseMgt(segchkCarouseMgt)); + } + + /** + * 删除seg首页轮播图管理 + */ + @PreAuthorize("@ss.hasPermi('system:segchk_carouse_mgt:remove')") + @Log(title = "seg首页轮播图管理", businessType = BusinessType.DELETE) + @DeleteMapping("/{carouseIds}") + public AjaxResult remove(@PathVariable Long[] carouseIds) + { + return toAjax(segchkCarouseMgtService.deleteSegchkCarouseMgtByCarouseIds(carouseIds)); + } +} diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml index 1f098e4..dcd3b0c 100644 --- a/ruoyi-admin/src/main/resources/application-druid.yml +++ b/ruoyi-admin/src/main/resources/application-druid.yml @@ -6,9 +6,9 @@ spring: druid: # 主库数据源 master: - url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 - username: root - password: password + url: jdbc:mysql://10.1.192.113:13306/yzy_ruoyi_vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: yzyuser + password: yzy123456 # 从库数据源 slave: # 从数据源开关/默认关闭 diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 088a28e..4ef6230 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -18,7 +18,7 @@ ruoyi: # 开发环境配置 server: # 服务器的HTTP端口,默认为8080 - port: 8080 + port: 7070 servlet: # 应用的访问路径 context-path: / @@ -59,13 +59,13 @@ spring: # redis 配置 redis: # 地址 - host: localhost + host: 10.1.192.113 # 端口,默认为6379 - port: 6379 + port: 63795 # 数据库索引 - database: 0 + database: 2 # 密码 - password: + password: retinabd@2020 # 连接超时时间 timeout: 10s lettuce: diff --git a/ruoyi-admin/src/main/resources/logback.xml b/ruoyi-admin/src/main/resources/logback.xml index d69a572..ab4089b 100644 --- a/ruoyi-admin/src/main/resources/logback.xml +++ b/ruoyi-admin/src/main/resources/logback.xml @@ -1,7 +1,7 @@ - + diff --git a/ruoyi-system/src/main/java/com/ruoyi/segchk/domain/SegchkCarouseMgt.java b/ruoyi-system/src/main/java/com/ruoyi/segchk/domain/SegchkCarouseMgt.java new file mode 100644 index 0000000..0f440ed --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/segchk/domain/SegchkCarouseMgt.java @@ -0,0 +1,124 @@ +package com.ruoyi.segchk.domain; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * seg首页轮播图管理对象 segchk_carouse_mgt + * + * @author yinzhiying + * @date 2021-08-22 + */ +public class SegchkCarouseMgt extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 轮播图id */ + private Long carouseId; + + /** 运营商id,全局唯一 */ + @Excel(name = "运营商id,全局唯一") + private Long providerId; + + /** 商家id,全局唯一 */ + @Excel(name = "商家id,全局唯一") + private Long storeId; + + /** 商家轮播图1路径,默认用于首页推荐轮播图 */ + @Excel(name = "商家轮播图1路径,默认用于首页推荐轮播图") + private String storeCarousel; + + /** 管理状态,0有效,-1失效 */ + @Excel(name = "管理状态,0有效,-1失效") + private Integer mgtState; + + /** 排序id */ + @Excel(name = "排序id") + private Integer sortId; + + /** 修改时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "修改时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date modTime; + + public void setCarouseId(Long carouseId) + { + this.carouseId = carouseId; + } + + public Long getCarouseId() + { + return carouseId; + } + public void setProviderId(Long providerId) + { + this.providerId = providerId; + } + + public Long getProviderId() + { + return providerId; + } + public void setStoreId(Long storeId) + { + this.storeId = storeId; + } + + public Long getStoreId() + { + return storeId; + } + public void setStoreCarousel(String storeCarousel) + { + this.storeCarousel = storeCarousel; + } + + public String getStoreCarousel() + { + return storeCarousel; + } + public void setMgtState(Integer mgtState) + { + this.mgtState = mgtState; + } + + public Integer getMgtState() + { + return mgtState; + } + public void setSortId(Integer sortId) + { + this.sortId = sortId; + } + + public Integer getSortId() + { + return sortId; + } + public void setModTime(Date modTime) + { + this.modTime = modTime; + } + + public Date getModTime() + { + return modTime; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("carouseId", getCarouseId()) + .append("providerId", getProviderId()) + .append("storeId", getStoreId()) + .append("storeCarousel", getStoreCarousel()) + .append("mgtState", getMgtState()) + .append("sortId", getSortId()) + .append("modTime", getModTime()) + .toString(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/segchk/mapper/SegchkCarouseMgtMapper.java b/ruoyi-system/src/main/java/com/ruoyi/segchk/mapper/SegchkCarouseMgtMapper.java new file mode 100644 index 0000000..e3b16fa --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/segchk/mapper/SegchkCarouseMgtMapper.java @@ -0,0 +1,61 @@ +package com.ruoyi.segchk.mapper; + +import java.util.List; +import com.ruoyi.segchk.domain.SegchkCarouseMgt; + +/** + * seg首页轮播图管理Mapper接口 + * + * @author yinzhiying + * @date 2021-08-22 + */ +public interface SegchkCarouseMgtMapper +{ + /** + * 查询seg首页轮播图管理 + * + * @param carouseId seg首页轮播图管理主键 + * @return seg首页轮播图管理 + */ + public SegchkCarouseMgt selectSegchkCarouseMgtByCarouseId(Long carouseId); + + /** + * 查询seg首页轮播图管理列表 + * + * @param segchkCarouseMgt seg首页轮播图管理 + * @return seg首页轮播图管理集合 + */ + public List selectSegchkCarouseMgtList(SegchkCarouseMgt segchkCarouseMgt); + + /** + * 新增seg首页轮播图管理 + * + * @param segchkCarouseMgt seg首页轮播图管理 + * @return 结果 + */ + public int insertSegchkCarouseMgt(SegchkCarouseMgt segchkCarouseMgt); + + /** + * 修改seg首页轮播图管理 + * + * @param segchkCarouseMgt seg首页轮播图管理 + * @return 结果 + */ + public int updateSegchkCarouseMgt(SegchkCarouseMgt segchkCarouseMgt); + + /** + * 删除seg首页轮播图管理 + * + * @param carouseId seg首页轮播图管理主键 + * @return 结果 + */ + public int deleteSegchkCarouseMgtByCarouseId(Long carouseId); + + /** + * 批量删除seg首页轮播图管理 + * + * @param carouseIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteSegchkCarouseMgtByCarouseIds(Long[] carouseIds); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/segchk/service/ISegchkCarouseMgtService.java b/ruoyi-system/src/main/java/com/ruoyi/segchk/service/ISegchkCarouseMgtService.java new file mode 100644 index 0000000..22bf056 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/segchk/service/ISegchkCarouseMgtService.java @@ -0,0 +1,61 @@ +package com.ruoyi.segchk.service; + +import java.util.List; +import com.ruoyi.segchk.domain.SegchkCarouseMgt; + +/** + * seg首页轮播图管理Service接口 + * + * @author yinzhiying + * @date 2021-08-22 + */ +public interface ISegchkCarouseMgtService +{ + /** + * 查询seg首页轮播图管理 + * + * @param carouseId seg首页轮播图管理主键 + * @return seg首页轮播图管理 + */ + public SegchkCarouseMgt selectSegchkCarouseMgtByCarouseId(Long carouseId); + + /** + * 查询seg首页轮播图管理列表 + * + * @param segchkCarouseMgt seg首页轮播图管理 + * @return seg首页轮播图管理集合 + */ + public List selectSegchkCarouseMgtList(SegchkCarouseMgt segchkCarouseMgt); + + /** + * 新增seg首页轮播图管理 + * + * @param segchkCarouseMgt seg首页轮播图管理 + * @return 结果 + */ + public int insertSegchkCarouseMgt(SegchkCarouseMgt segchkCarouseMgt); + + /** + * 修改seg首页轮播图管理 + * + * @param segchkCarouseMgt seg首页轮播图管理 + * @return 结果 + */ + public int updateSegchkCarouseMgt(SegchkCarouseMgt segchkCarouseMgt); + + /** + * 批量删除seg首页轮播图管理 + * + * @param carouseIds 需要删除的seg首页轮播图管理主键集合 + * @return 结果 + */ + public int deleteSegchkCarouseMgtByCarouseIds(Long[] carouseIds); + + /** + * 删除seg首页轮播图管理信息 + * + * @param carouseId seg首页轮播图管理主键 + * @return 结果 + */ + public int deleteSegchkCarouseMgtByCarouseId(Long carouseId); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/segchk/service/impl/SegchkCarouseMgtServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/segchk/service/impl/SegchkCarouseMgtServiceImpl.java new file mode 100644 index 0000000..a889532 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/segchk/service/impl/SegchkCarouseMgtServiceImpl.java @@ -0,0 +1,93 @@ +package com.ruoyi.segchk.service.impl; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.segchk.mapper.SegchkCarouseMgtMapper; +import com.ruoyi.segchk.domain.SegchkCarouseMgt; +import com.ruoyi.segchk.service.ISegchkCarouseMgtService; + +/** + * seg首页轮播图管理Service业务层处理 + * + * @author yinzhiying + * @date 2021-08-22 + */ +@Service +public class SegchkCarouseMgtServiceImpl implements ISegchkCarouseMgtService +{ + @Autowired + private SegchkCarouseMgtMapper segchkCarouseMgtMapper; + + /** + * 查询seg首页轮播图管理 + * + * @param carouseId seg首页轮播图管理主键 + * @return seg首页轮播图管理 + */ + @Override + public SegchkCarouseMgt selectSegchkCarouseMgtByCarouseId(Long carouseId) + { + return segchkCarouseMgtMapper.selectSegchkCarouseMgtByCarouseId(carouseId); + } + + /** + * 查询seg首页轮播图管理列表 + * + * @param segchkCarouseMgt seg首页轮播图管理 + * @return seg首页轮播图管理 + */ + @Override + public List selectSegchkCarouseMgtList(SegchkCarouseMgt segchkCarouseMgt) + { + return segchkCarouseMgtMapper.selectSegchkCarouseMgtList(segchkCarouseMgt); + } + + /** + * 新增seg首页轮播图管理 + * + * @param segchkCarouseMgt seg首页轮播图管理 + * @return 结果 + */ + @Override + public int insertSegchkCarouseMgt(SegchkCarouseMgt segchkCarouseMgt) + { + return segchkCarouseMgtMapper.insertSegchkCarouseMgt(segchkCarouseMgt); + } + + /** + * 修改seg首页轮播图管理 + * + * @param segchkCarouseMgt seg首页轮播图管理 + * @return 结果 + */ + @Override + public int updateSegchkCarouseMgt(SegchkCarouseMgt segchkCarouseMgt) + { + return segchkCarouseMgtMapper.updateSegchkCarouseMgt(segchkCarouseMgt); + } + + /** + * 批量删除seg首页轮播图管理 + * + * @param carouseIds 需要删除的seg首页轮播图管理主键 + * @return 结果 + */ + @Override + public int deleteSegchkCarouseMgtByCarouseIds(Long[] carouseIds) + { + return segchkCarouseMgtMapper.deleteSegchkCarouseMgtByCarouseIds(carouseIds); + } + + /** + * 删除seg首页轮播图管理信息 + * + * @param carouseId seg首页轮播图管理主键 + * @return 结果 + */ + @Override + public int deleteSegchkCarouseMgtByCarouseId(Long carouseId) + { + return segchkCarouseMgtMapper.deleteSegchkCarouseMgtByCarouseId(carouseId); + } +} diff --git a/ruoyi-system/src/main/resources/mapper/segchk/SegchkCarouseMgtMapper.xml b/ruoyi-system/src/main/resources/mapper/segchk/SegchkCarouseMgtMapper.xml new file mode 100644 index 0000000..12af938 --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/segchk/SegchkCarouseMgtMapper.xml @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + select carouse_id, provider_id, store_id, store_carousel, mgt_state, sort_id, mod_time from segchk_carouse_mgt + + + + + + + + insert into segchk_carouse_mgt + + provider_id, + store_id, + store_carousel, + mgt_state, + sort_id, + mod_time, + + + #{providerId}, + #{storeId}, + #{storeCarousel}, + #{mgtState}, + #{sortId}, + #{modTime}, + + + + + update segchk_carouse_mgt + + provider_id = #{providerId}, + store_id = #{storeId}, + store_carousel = #{storeCarousel}, + mgt_state = #{mgtState}, + sort_id = #{sortId}, + mod_time = #{modTime}, + + where carouse_id = #{carouseId} + + + + delete from segchk_carouse_mgt where carouse_id = #{carouseId} + + + + delete from segchk_carouse_mgt where carouse_id in + + #{carouseId} + + + \ No newline at end of file diff --git a/ruoyi-ui/src/views/system/segchk_carouse_mgt/index.vue b/ruoyi-ui/src/views/system/segchk_carouse_mgt/index.vue new file mode 100644 index 0000000..b27974c --- /dev/null +++ b/ruoyi-ui/src/views/system/segchk_carouse_mgt/index.vue @@ -0,0 +1,351 @@ + + + diff --git a/ruoyi-ui/vue.config.js b/ruoyi-ui/vue.config.js index 7670746..4d4ff62 100644 --- a/ruoyi-ui/vue.config.js +++ b/ruoyi-ui/vue.config.js @@ -1,117 +1,117 @@ -'use strict' -const path = require('path') - -function resolve(dir) { - return path.join(__dirname, dir) -} - -const name = process.env.VUE_APP_TITLE || '若依管理系统' // 网页标题 - -const port = process.env.port || process.env.npm_config_port || 80 // 端口 - -// vue.config.js 配置说明 -//官方vue.config.js 参考文档 https://cli.vuejs.org/zh/config/#css-loaderoptions -// 这里只列一部分,具体配置参考文档 -module.exports = { - // 部署生产环境和开发环境下的URL。 - // 默认情况下,Vue CLI 会假设你的应用是被部署在一个域名的根路径上 - // 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.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 - }, - configureWebpack: { - name: name, - resolve: { - alias: { - '@': resolve('src') - } - } - }, - 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: './' //到根目录下 - } - } - ) - } -} +'use strict' +const path = require('path') + +function resolve(dir) { + return path.join(__dirname, dir) +} + +const name = process.env.VUE_APP_TITLE || '若依管理系统' // 网页标题 + +const port = process.env.port || process.env.npm_config_port || 8099 // 端口 + +// vue.config.js 配置说明 +//官方vue.config.js 参考文档 https://cli.vuejs.org/zh/config/#css-loaderoptions +// 这里只列一部分,具体配置参考文档 +module.exports = { + // 部署生产环境和开发环境下的URL。 + // 默认情况下,Vue CLI 会假设你的应用是被部署在一个域名的根路径上 + // 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.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:7070`, + changeOrigin: true, + pathRewrite: { + ['^' + process.env.VUE_APP_BASE_API]: '' + } + } + }, + disableHostCheck: true + }, + configureWebpack: { + name: name, + resolve: { + alias: { + '@': resolve('src') + } + } + }, + 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: './' //到根目录下 + } + } + ) + } +}