ruoyi-vue如何部署在根目录下的多级目录
1、找到vue.config.js
module.exports = { // 部署生产环境和开发环境下的URL。 // 默认情况下,Vue CLI 会假设你的应用是被部署在一个域名的根路径上 // 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。 publicPath: process.env.NODE_ENV === "production" ? "/" : "/micia/", // 在npm run build 或 yarn build 时 ,生成文件的目录名称(要和baseUrl的生产环境路径一致)(默认dist) outputDir: 'dist', // 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下) assetsDir: 'static',
2、找到router/index.js
1 2 3 4 5 6 | export default new Router({ base: 'micia' , mode: 'hash' , // 去掉url中的# scrollBehavior: () => ({ y: 0 }), routes: constantRoutes }) |
3、配置登出接口
修改/src/layout/componets/Navbar.vue文件里的logout()方法
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | methods: { toggleSideBar() { this .$store.dispatch( 'app/toggleSideBar' ) }, async logout() { this .$confirm( '确定注销并退出系统吗?' , '提示' , { confirmButtonText: '确定' , cancelButtonText: '取消' , type: 'warning' }).then(() => { this .$store.dispatch( 'LogOut' ).then(() => { // location.href = '/index'; location.href = '/admin' }) }). catch (() => {}); } } |
Nginx配置
一级域名一般部署的是公司官网website-dist,二级域名部署后台项目ruoyi-dist。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | server { listen 80; server_name localhost; charset utf-8; location / { root /root/website/website-dist; try_files $uri $uri/ /index.html; index index.html index.htm; } location /admin { alias /home/ruoyi/ruoyi-dist; try_files $uri $uri/ /index.html; index index.html index.htm; } location /prod-api/ { proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http: //127.0.0.1:9004/; } } |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!