https://github.com/wangcongmao/WHDMSS-frontend
环境: node.js: v18.16.0 pnpm:9.14.4
配置后端接口 1、文档 https://jeesite.com/docs/install-deploy/ 若已部署,请忽略。
2、打开 .env.development 文件,修改后台接口:
VITE_PROXY = [["/js","https://vue.jeesite.com/js",true]]
VITE_PROXY = [["/js","http://127.0.0.1:8980/js",false]]
访问接口的根路径(例如:https://vue.jeesite.com)一般不需要填写
VITE_GLOB_API_URL =
VITE_GLOB_API_URL_PREFIX = /js
启动运行服务 1、安装依赖
npm run bootstrap 2、运行方式1:开发环境(会加载文件较多,便于调试,请耐心等待,请开启浏览器缓存)
npm run dev
部署完成后访问 1、浏览器访问:http://127.0.0.1:3100(opens new window)
2、默认最高管理员账号:system 密码:admin weihaiAdmin 密码:admin
部署到正式服务器 1、打开 .env.production 文件,修改参数:
VITE_PUBLIC_PATH = /
VITE_GLOB_API_URL =
VITE_GLOB_API_URL_PREFIX = /js
VITE_ROUTE_WEB_HISTORY = true 2、执行打包命令
npm run build 打包完成后,会在根目录生成 dist 文件夹,发布 nginx。
打包后支持动态配置:
打开 _app.config.js 文件,用于项目在打包后,需要动态修改配置的需求,如接口地址。不用重新进行打包,可在打包后修改 /dist/_app.config.js 内的变量,刷新即可更新代码内的局部变量。
// _app.config.js // 变量名命名规则 PRODUCTION__xxx_CONF xxx:为 .env 配置的 VITE_GLOB_APP_SHORT_NAME window.PRODUCTION__JEESITE__CONF = { VITE_GLOB_APP_TITLE: 'JeeSite快速开发平台', VITE_GLOB_APP_SHORT_NAME: 'jeesite', VITE_GLOB_API_URL: '/js', VITE_GLOB_API_URL_PREFIX: '', VITE_GLOB_UPLOAD_URL: '/upload', }; 系统默认开启了百度统计,可在 _app.config.js 中删除 var _hmt 后的代码,即关闭统计。
路由 history 模式:
路由如果采用 history 模式 (opens new window),您还需要辅助配置 nginx 如下:
nginx.conf 文件
server {
location / { root /jeesite-vue/dist; index index.html; try_files $uri $uri/ /index.html; }
#location /vue {
#}
location /js { proxy_pass http://127.0.0.1:8980/js; proxy_set_header Host $host:$server_port; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Port $server_port; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } }