From dff2eae8c85da686ebe7ebc9782d160a53504081 Mon Sep 17 00:00:00 2001 From: administrator <2316696377@qq.com> Date: Thu, 21 May 2020 19:21:13 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A9=E9=A1=B9=E7=9B=AE=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E8=B5=B7=E6=9D=A5=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 88 ++-- pom.xml | 478 +++++++++--------- ruoyi-api/ruoyi-api-system/pom.xml | 59 ++- .../src/main/resources/application.yml | 12 + ruoyi-auth/pom.xml | 131 ++--- ruoyi-auth/src/main/resources/application.yml | 8 + .../RyResourceServerConfigurerAdapter.java | 127 +++-- ruoyi-modules/ruoyi-job/pom.xml | 179 +++---- .../com/ruoyi/job/RuoYiJobApplication.java | 75 +-- .../src/main/resources/application.yml | 13 + ruoyi-ui/vue.config.js | 260 +++++----- 11 files changed, 744 insertions(+), 686 deletions(-) create mode 100644 ruoyi-api/ruoyi-api-system/src/main/resources/application.yml create mode 100644 ruoyi-auth/src/main/resources/application.yml create mode 100644 ruoyi-modules/ruoyi-job/src/main/resources/application.yml diff --git a/.gitignore b/.gitignore index 4916f7a2..d994f235 100644 --- a/.gitignore +++ b/.gitignore @@ -1,43 +1,45 @@ -###################################################################### -# Build Tools - -.gradle -/build/ -!gradle/wrapper/gradle-wrapper.jar - -target/ -!.mvn/wrapper/maven-wrapper.jar - -###################################################################### -# IDE - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr - -### NetBeans ### -nbproject/private/ -build/* -nbbuild/ -dist/ -nbdist/ -.nb-gradle/ - -###################################################################### -# Others -*.log -*.xml.versionsBackup - -!*/build/*.java -!*/build/*.html -!*/build/*.xml \ No newline at end of file +###################################################################### +# Build Tools + +.gradle +/build/ +!gradle/wrapper/gradle-wrapper.jar + +target/ +!.mvn/wrapper/maven-wrapper.jar + +###################################################################### +# IDE + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +nbproject/private/ +build/* +nbbuild/ +dist/ +nbdist/ +.nb-gradle/ + +###################################################################### +# Others +*.log +*.xml.versionsBackup + +!*/build/*.java +!*/build/*.html +!*/build/*.xml +/**/src/main/resources/.triggerFile +/**/**/src/main/resources/.triggerFile \ No newline at end of file diff --git a/pom.xml b/pom.xml index 392cd0c5..b895b401 100644 --- a/pom.xml +++ b/pom.xml @@ -1,237 +1,243 @@ - - - 4.0.0 - - com.ruoyi - ruoyi - 1.0.0 - - ruoyi - http://www.ruoyi.vip - 若依微服务系统 - - - 1.0.0 - UTF-8 - UTF-8 - 1.8 - 2.2.6.RELEASE - Hoxton.SR4 - 2.2.3 - 2.1.2 - 2.9.2 - 1.5.24 - 2.3.2 - 1.2.12 - 2.5 - 1.3.3 - 1.7 - 1.2.68 - 3.17 - 2.6.2 - 1.19 - - - - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - - com.alibaba.cloud - spring-cloud-alibaba-dependencies - 2.1.0.RELEASE - pom - import - - - - - org.springframework.boot - spring-boot-dependencies - ${spring-boot.version} - pom - import - - - - - de.codecentric - spring-boot-admin-starter-client - ${spring-boot-admin.version} - - - - - org.mybatis.spring.boot - mybatis-spring-boot-starter - ${spring-boot.mybatis} - - - - - io.swagger - swagger-models - ${swagger.core.version} - - - io.swagger - swagger-annotations - ${swagger.core.version} - - - - - com.github.penggle - kaptcha - ${kaptcha.version} - - - - - com.github.pagehelper - pagehelper-spring-boot-starter - ${pagehelper.boot.version} - - - - - commons-io - commons-io - ${commons.io.version} - - - - - org.apache.poi - poi-ooxml - ${poi.version} - - - - - commons-fileupload - commons-fileupload - ${commons.fileupload.version} - - - - - org.apache.velocity - velocity - ${velocity.version} - - - - - com.alibaba - fastjson - ${fastjson.version} - - - - - org.apache.commons - commons-pool2 - ${common-pool.version} - - - - - eu.bitwalker - UserAgentUtils - ${bitwalker.version} - - - - - com.ruoyi - ruoyi-common-core - ${ruoyi.version} - - - - - com.ruoyi - ruoyi-common-swagger - ${ruoyi.version} - - - - - com.ruoyi - ruoyi-common-security - ${ruoyi.version} - - - - - com.ruoyi - ruoyi-common-datascope - ${ruoyi.version} - - - - - com.ruoyi - ruoyi-common-log - ${ruoyi.version} - - - - - com.ruoyi - ruoyi-common-redis - ${ruoyi.version} - - - - - com.ruoyi - ruoyi-api-system - ${ruoyi.version} - - - - - - - ruoyi-auth - ruoyi-gateway - ruoyi-visual - ruoyi-modules - ruoyi-api - ruoyi-common - - pom - - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - ${java.version} - ${java.version} - ${project.build.sourceEncoding} - - - - - + + + 4.0.0 + + com.ruoyi + ruoyi + 1.0.0 + + ruoyi + http://www.ruoyi.vip + 若依微服务系统 + + + 1.0.0 + UTF-8 + UTF-8 + 1.8 + 2.2.6.RELEASE + Hoxton.SR4 + 2.2.3 + 2.1.2 + 2.9.2 + 1.5.24 + 2.3.2 + 1.2.12 + 2.5 + 1.3.3 + 1.7 + 1.2.68 + 3.17 + 2.6.2 + 1.19 + + + + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + + com.alibaba.cloud + spring-cloud-alibaba-dependencies + 2.1.0.RELEASE + pom + import + + + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + + + + + de.codecentric + spring-boot-admin-starter-client + ${spring-boot-admin.version} + + + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + ${spring-boot.mybatis} + + + + + io.swagger + swagger-models + ${swagger.core.version} + + + io.swagger + swagger-annotations + ${swagger.core.version} + + + + + com.github.penggle + kaptcha + ${kaptcha.version} + + + + + com.github.pagehelper + pagehelper-spring-boot-starter + ${pagehelper.boot.version} + + + + + commons-io + commons-io + ${commons.io.version} + + + + + org.apache.poi + poi-ooxml + ${poi.version} + + + + + commons-fileupload + commons-fileupload + ${commons.fileupload.version} + + + + + org.apache.velocity + velocity + ${velocity.version} + + + + + com.alibaba + fastjson + ${fastjson.version} + + + + + org.apache.commons + commons-pool2 + ${common-pool.version} + + + + + eu.bitwalker + UserAgentUtils + ${bitwalker.version} + + + + + com.ruoyi + ruoyi-common-core + ${ruoyi.version} + + + + + com.ruoyi + ruoyi-common-swagger + ${ruoyi.version} + + + + + com.ruoyi + ruoyi-common-security + ${ruoyi.version} + + + + + com.ruoyi + ruoyi-common-datascope + ${ruoyi.version} + + + + + com.ruoyi + ruoyi-common-log + ${ruoyi.version} + + + + + com.ruoyi + ruoyi-common-redis + ${ruoyi.version} + + + + + com.ruoyi + ruoyi-api-system + ${ruoyi.version} + + + + com.alibaba + druid-spring-boot-starter + 1.1.14 + + + + + + + ruoyi-auth + ruoyi-gateway + ruoyi-visual + ruoyi-modules + ruoyi-api + ruoyi-common + + pom + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + ${java.version} + ${java.version} + ${project.build.sourceEncoding} + + + + + \ No newline at end of file diff --git a/ruoyi-api/ruoyi-api-system/pom.xml b/ruoyi-api/ruoyi-api-system/pom.xml index 50333181..cbc04788 100644 --- a/ruoyi-api/ruoyi-api-system/pom.xml +++ b/ruoyi-api/ruoyi-api-system/pom.xml @@ -1,28 +1,33 @@ - - - - com.ruoyi - ruoyi-api - 1.0.0 - - 4.0.0 - - ruoyi-api-system - - - ruoyi-api-system系统接口模块 - - - - - - - com.ruoyi - ruoyi-common-core - - - - + + + + com.ruoyi + ruoyi-api + 1.0.0 + + 4.0.0 + + ruoyi-api-system + + + ruoyi-api-system系统接口模块 + + + + + + + com.ruoyi + ruoyi-common-core + + + + com.alibaba + druid-spring-boot-starter + + + + \ No newline at end of file diff --git a/ruoyi-api/ruoyi-api-system/src/main/resources/application.yml b/ruoyi-api/ruoyi-api-system/src/main/resources/application.yml new file mode 100644 index 00000000..ebbee5ff --- /dev/null +++ b/ruoyi-api/ruoyi-api-system/src/main/resources/application.yml @@ -0,0 +1,12 @@ +server: + port: 80 +spring: + datasource: + type: com.alibaba.druid.pool.DruidDataSource + druid: + username: root + password: root + url: jdbc:mysql://localhost:3306/ry-cloud?serverTimezone=Asia/Shanghai + driver-class-name: com.mysql.cj.jdbc.Driver + application: + name: ruoyi-system \ No newline at end of file diff --git a/ruoyi-auth/pom.xml b/ruoyi-auth/pom.xml index 26d58a6d..c872a373 100644 --- a/ruoyi-auth/pom.xml +++ b/ruoyi-auth/pom.xml @@ -1,63 +1,68 @@ - - - com.ruoyi - ruoyi - 1.0.0 - - 4.0.0 - - ruoyi-auth - - - ruoyi-auth认证授权中心 - - - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - - org.springframework.cloud - spring-cloud-starter-netflix-hystrix - - - - - org.springframework.boot - spring-boot-starter-web - - - - - mysql - mysql-connector-java - - - - - com.ruoyi - ruoyi-common-security - - - - - com.ruoyi - ruoyi-common-redis - - - - - + + + com.ruoyi + ruoyi + 1.0.0 + + 4.0.0 + + ruoyi-auth + + + ruoyi-auth认证授权中心 + + + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + + org.springframework.cloud + spring-cloud-starter-netflix-hystrix + + + + + org.springframework.boot + spring-boot-starter-web + + + + + mysql + mysql-connector-java + + + + + com.ruoyi + ruoyi-common-security + + + + + com.ruoyi + ruoyi-common-redis + + + + com.alibaba + druid-spring-boot-starter + + + + + diff --git a/ruoyi-auth/src/main/resources/application.yml b/ruoyi-auth/src/main/resources/application.yml new file mode 100644 index 00000000..68245e6b --- /dev/null +++ b/ruoyi-auth/src/main/resources/application.yml @@ -0,0 +1,8 @@ +spring: + datasource: + type: com.alibaba.druid.pool.DruidDataSource + druid: + username: root + password: root + url: jdbc:mysql://localhost:3306/ry-cloud?serverTimezone=Asia/Shanghai + driver-class-name: com.mysql.cj.jdbc.Driver \ No newline at end of file diff --git a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/component/RyResourceServerConfigurerAdapter.java b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/component/RyResourceServerConfigurerAdapter.java index 7e230230..a4cd2b48 100644 --- a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/component/RyResourceServerConfigurerAdapter.java +++ b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/component/RyResourceServerConfigurerAdapter.java @@ -1,64 +1,63 @@ -package com.ruoyi.common.security.component; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; -import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter; -import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer; -import org.springframework.security.oauth2.provider.token.DefaultAccessTokenConverter; -import org.springframework.security.oauth2.provider.token.RemoteTokenServices; -import org.springframework.security.oauth2.provider.token.UserAuthenticationConverter; -import org.springframework.security.web.access.AccessDeniedHandler; -import org.springframework.web.client.RestTemplate; -import com.ruoyi.common.security.component.properties.PermitAllUrlProperties; - -public class RyResourceServerConfigurerAdapter extends ResourceServerConfigurerAdapter -{ - @Autowired - protected ResourceAuthExceptionEntryPoint resourceAuthExceptionEntryPoint; - - @Autowired - protected RemoteTokenServices remoteTokenServices; - - @Autowired - private AccessDeniedHandler accessDeniedHandler; - - @Autowired - private PermitAllUrlProperties permitAllUrl; - - @Autowired - private RestTemplate lbRestTemplate; - - /** - * 默认的配置,对外暴露 - * - * @param httpSecurity - * @throws Exception - */ - @Override - public void configure(HttpSecurity httpSecurity) throws Exception - { - //允许使用iframe 嵌套,避免swagger-ui 不被加载的问题 - httpSecurity.headers().frameOptions().disable(); - ExpressionUrlAuthorizationConfigurer - .ExpressionInterceptUrlRegistry registry = httpSecurity - .authorizeRequests(); - permitAllUrl.getUrls() - .forEach(url -> registry.antMatchers(url).permitAll()); - registry.anyRequest().authenticated() - .and().csrf().disable(); - } - - @Override - public void configure(ResourceServerSecurityConfigurer resources) - { - DefaultAccessTokenConverter accessTokenConverter = new DefaultAccessTokenConverter(); - UserAuthenticationConverter userTokenConverter = new RyUserAuthenticationConverter(); - accessTokenConverter.setUserTokenConverter(userTokenConverter); - - remoteTokenServices.setRestTemplate(lbRestTemplate); - remoteTokenServices.setAccessTokenConverter(accessTokenConverter); - resources.authenticationEntryPoint(resourceAuthExceptionEntryPoint).accessDeniedHandler(accessDeniedHandler) - .tokenServices(remoteTokenServices); - } -} +package com.ruoyi.common.security.component; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; +import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter; +import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer; +import org.springframework.security.oauth2.provider.token.DefaultAccessTokenConverter; +import org.springframework.security.oauth2.provider.token.RemoteTokenServices; +import org.springframework.security.oauth2.provider.token.UserAuthenticationConverter; +import org.springframework.security.web.access.AccessDeniedHandler; +import org.springframework.web.client.RestTemplate; +import com.ruoyi.common.security.component.properties.PermitAllUrlProperties; + +public class RyResourceServerConfigurerAdapter extends ResourceServerConfigurerAdapter +{ + @Autowired + protected ResourceAuthExceptionEntryPoint resourceAuthExceptionEntryPoint; + + protected RemoteTokenServices remoteTokenServices = new RemoteTokenServices(); + + @Autowired + private AccessDeniedHandler accessDeniedHandler; + + @Autowired + private PermitAllUrlProperties permitAllUrl; + + @Autowired + private RestTemplate lbRestTemplate; + + /** + * 默认的配置,对外暴露 + * + * @param httpSecurity + * @throws Exception + */ + @Override + public void configure(HttpSecurity httpSecurity) throws Exception + { + //允许使用iframe 嵌套,避免swagger-ui 不被加载的问题 + httpSecurity.headers().frameOptions().disable(); + ExpressionUrlAuthorizationConfigurer + .ExpressionInterceptUrlRegistry registry = httpSecurity + .authorizeRequests(); + permitAllUrl.getUrls() + .forEach(url -> registry.antMatchers(url).permitAll()); + registry.anyRequest().authenticated() + .and().csrf().disable(); + } + + @Override + public void configure(ResourceServerSecurityConfigurer resources) + { + DefaultAccessTokenConverter accessTokenConverter = new DefaultAccessTokenConverter(); + UserAuthenticationConverter userTokenConverter = new RyUserAuthenticationConverter(); + accessTokenConverter.setUserTokenConverter(userTokenConverter); + + remoteTokenServices.setRestTemplate(lbRestTemplate); + remoteTokenServices.setAccessTokenConverter(accessTokenConverter); + resources.authenticationEntryPoint(resourceAuthExceptionEntryPoint).accessDeniedHandler(accessDeniedHandler) + .tokenServices(remoteTokenServices); + } +} diff --git a/ruoyi-modules/ruoyi-job/pom.xml b/ruoyi-modules/ruoyi-job/pom.xml index b6395293..3e706716 100644 --- a/ruoyi-modules/ruoyi-job/pom.xml +++ b/ruoyi-modules/ruoyi-job/pom.xml @@ -1,88 +1,93 @@ - - - - com.ruoyi - ruoyi-modules - 1.0.0 - - 4.0.0 - - ruoyi-modules-job - - - ruoyi-modules-job定时任务 - - - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - - org.springframework.cloud - spring-cloud-starter-netflix-hystrix - - - - - org.springframework.boot - spring-boot-starter-web - - - - - io.springfox - springfox-swagger-ui - ${swagger.fox.version} - - - - - org.quartz-scheduler - quartz - - - com.mchange - c3p0 - - - - - - - mysql - mysql-connector-java - - - - - com.ruoyi - ruoyi-common-security - - - - - com.ruoyi - ruoyi-common-log - - - - - com.ruoyi - ruoyi-common-swagger - - - + + + + com.ruoyi + ruoyi-modules + 1.0.0 + + 4.0.0 + + ruoyi-modules-job + + + ruoyi-modules-job定时任务 + + + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + + org.springframework.cloud + spring-cloud-starter-netflix-hystrix + + + + + org.springframework.boot + spring-boot-starter-web + + + + + io.springfox + springfox-swagger-ui + ${swagger.fox.version} + + + + + org.quartz-scheduler + quartz + + + com.mchange + c3p0 + + + + + + + mysql + mysql-connector-java + + + + + com.ruoyi + ruoyi-common-security + + + + + com.ruoyi + ruoyi-common-log + + + + + com.ruoyi + ruoyi-common-swagger + + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + + + \ No newline at end of file diff --git a/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/RuoYiJobApplication.java b/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/RuoYiJobApplication.java index 073ff282..34ab2aa5 100644 --- a/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/RuoYiJobApplication.java +++ b/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/RuoYiJobApplication.java @@ -1,36 +1,39 @@ -package com.ruoyi.job; - -import org.springframework.boot.SpringApplication; -import org.springframework.cloud.client.SpringCloudApplication; -import com.ruoyi.common.security.annotation.EnableCustomConfig; -import com.ruoyi.common.security.annotation.EnableRyFeignClients; -import com.ruoyi.common.security.annotation.EnableRyResourceServer; -import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2; - -/** - * 定时任务 - * - * @author ruoyi - */ -@EnableCustomConfig -@EnableCustomSwagger2 -@EnableRyFeignClients -@EnableRyResourceServer -@SpringCloudApplication -public class RuoYiJobApplication -{ - public static void main(String[] args) - { - SpringApplication.run(RuoYiJobApplication.class, args); - System.out.println("(♥◠‿◠)ノ゙ 定时任务模块启动成功 ლ(´ڡ`ლ)゙ \n" + - " .-------. ____ __ \n" + - " | _ _ \\ \\ \\ / / \n" + - " | ( ' ) | \\ _. / ' \n" + - " |(_ o _) / _( )_ .' \n" + - " | (_,_).' __ ___(_ o _)' \n" + - " | |\\ \\ | || |(_,_)' \n" + - " | | \\ `' /| `-' / \n" + - " | | \\ / \\ / \n" + - " ''-' `'-' `-..-' "); - } -} +package com.ruoyi.job; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.cloud.client.SpringCloudApplication; +import com.ruoyi.common.security.annotation.EnableCustomConfig; +import com.ruoyi.common.security.annotation.EnableRyFeignClients; +import com.ruoyi.common.security.annotation.EnableRyResourceServer; +import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; + +/** + * 定时任务 + * + * @author ruoyi + */ +@EnableCustomConfig +@EnableCustomSwagger2 +@EnableRyFeignClients +@EnableRyResourceServer +@SpringCloudApplication +@EnableDiscoveryClient +public class RuoYiJobApplication +{ + public static void main(String[] args) + { + SpringApplication.run(RuoYiJobApplication.class, args); + System.out.println("(♥◠‿◠)ノ゙ 定时任务模块启动成功 ლ(´ڡ`ლ)゙ \n" + + " .-------. ____ __ \n" + + " | _ _ \\ \\ \\ / / \n" + + " | ( ' ) | \\ _. / ' \n" + + " |(_ o _) / _( )_ .' \n" + + " | (_,_).' __ ___(_ o _)' \n" + + " | |\\ \\ | || |(_,_)' \n" + + " | | \\ `' /| `-' / \n" + + " | | \\ / \\ / \n" + + " ''-' `'-' `-..-' "); + } +} diff --git a/ruoyi-modules/ruoyi-job/src/main/resources/application.yml b/ruoyi-modules/ruoyi-job/src/main/resources/application.yml new file mode 100644 index 00000000..e15c629c --- /dev/null +++ b/ruoyi-modules/ruoyi-job/src/main/resources/application.yml @@ -0,0 +1,13 @@ +spring: + datasource: + type: com.alibaba.druid.pool.DruidDataSource + druid: + username: root + password: root + url: jdbc:mysql://localhost:3306/ry-cloud?serverTimezone=Asia/Shanghai + driver-class-name: com.mysql.cj.jdbc.Driver + application: + name: ruoyi-job +mybatis: + mapper-locations: classpath*:/**/*Mapper.xml + type-aliases-package: com.ruoyi.job.domain \ No newline at end of file diff --git a/ruoyi-ui/vue.config.js b/ruoyi-ui/vue.config.js index 5dce8d69..c4c3f576 100644 --- a/ruoyi-ui/vue.config.js +++ b/ruoyi-ui/vue.config.js @@ -1,130 +1,130 @@ -'use strict' -const path = require('path') -const defaultSettings = require('./src/settings.js') - -function resolve(dir) { - return path.join(__dirname, dir) -} - -const name = defaultSettings.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, - 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() - - // set preserveWhitespace - config.module - .rule('vue') - .use('vue-loader') - .loader('vue-loader') - .tap(options => { - options.compilerOptions.preserveWhitespace = true - return options - }) - .end() - - config - // https://webpack.js.org/configuration/devtool/#development - .when(process.env.NODE_ENV === 'development', - config => config.devtool('cheap-source-map') - ) - - 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') - } - ) - } -} +'use strict' +const path = require('path') +const defaultSettings = require('./src/settings.js') + +function resolve(dir) { + return path.join(__dirname, dir) +} + +const name = defaultSettings.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, + 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() + + // set preserveWhitespace + config.module + .rule('vue') + .use('vue-loader') + .loader('vue-loader') + .tap(options => { + options.compilerOptions.preserveWhitespace = true + return options + }) + .end() + + config + // https://webpack.js.org/configuration/devtool/#development + .when(process.env.NODE_ENV === 'development', + config => config.devtool('cheap-source-map') + ) + + 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') + } + ) + } +}