一.去掉axios请求中的公共url配置选项,否则后续接口请求url都会加上这个url,导致接口异常
const service = axios.create({
// axios中请求配置有baseURL选项,表示请求URL公共部分
// baseURL: process.env.VUE_APP_BASE_API,
// 超时
timeout: 10000
})
不取消,就会加上生产环境前缀二
npm run build:+ 生产环境 进行打包
如果出现下列错误,在package.json的scripts中加上这俩行
"serve": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve", "build": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build",
node17版本问题
三 将生产的dist包复制到启动类所在模块的resources目录的static包下
四 修改 SysIndexController(admin模块 org.vds.ruoyi.web.controller.system包中)
主要修改controller注解返回页面,以及返回内容改成index页面
//@RestController
@Controller
public class SysIndexController
{
/** 系统基础配置 */
@Autowired
private TienChinConfig tienchinConfig;
/**
* 访问首页,提示语
*/
@RequestMapping(value = "/",method = RequestMethod.GET)
public String index()
{
//return StringUtils.format("欢迎使用{}后台管理框架,当前版本:v{},请通过前端地址访问。", ruoyiConfig.getName(), ruoyiConfig.getVersion());
return "index";
}
/**
* 访问首页,提示语
*/
@RequestMapping(value = "/index",method = RequestMethod.GET)
public String indexs()
{
return "index";
}
}
五 修改yaml中的mvc配置
# Spring配置 #配置静态资源路径
spring:
web:
resources:
static-locations: "classpath:/static/dist"
#配置mvc返回页面格式
mvc:
view:
suffix: .html
六 配置websecurityconfig过滤静态资源
七 加一个thymeleaf的依赖
大功告成