修改小程序
This commit is contained in:
4
government-admin/.env.development
Normal file
4
government-admin/.env.development
Normal file
@@ -0,0 +1,4 @@
|
||||
# 开发环境配置
|
||||
VITE_API_BASE_URL=http://localhost:5352/api
|
||||
VITE_APP_TITLE=政府管理系统
|
||||
VITE_APP_ENV=development
|
||||
4
government-admin/.env.production
Normal file
4
government-admin/.env.production
Normal file
@@ -0,0 +1,4 @@
|
||||
# 生产环境配置
|
||||
VITE_API_BASE_URL=https://ad.ningmuyun.com/api/government
|
||||
VITE_APP_TITLE=政府管理系统
|
||||
VITE_APP_ENV=production
|
||||
25
government-admin/package-lock.json
generated
25
government-admin/package-lock.json
generated
@@ -10,7 +10,6 @@
|
||||
"dependencies": {
|
||||
"@ant-design/icons-vue": "^6.1.0",
|
||||
"ant-design-vue": "^4.0.0",
|
||||
"axios": "^1.12.2",
|
||||
"dayjs": "^1.11.18",
|
||||
"echarts": "^5.4.2",
|
||||
"pinia": "^2.1.6",
|
||||
@@ -20,6 +19,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^4.2.3",
|
||||
"axios": "^1.12.2",
|
||||
"eslint": "^8.45.0",
|
||||
"eslint-plugin-vue": "^9.15.1",
|
||||
"sass": "^1.93.0",
|
||||
@@ -1238,12 +1238,14 @@
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmmirror.com/asynckit/-/asynckit-0.4.0.tgz",
|
||||
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/axios": {
|
||||
"version": "1.12.2",
|
||||
"resolved": "https://registry.npmmirror.com/axios/-/axios-1.12.2.tgz",
|
||||
"integrity": "sha512-vMJzPewAlRyOgxV2dU0Cuz2O8zzzx9VYtbJOaBgXFeLc4IV/Eg50n4LowmehOOR61S8ZMpc2K5Sa7g6A4jfkUw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.15.6",
|
||||
@@ -1294,6 +1296,7 @@
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmmirror.com/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
|
||||
"integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
@@ -1370,6 +1373,7 @@
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmmirror.com/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"delayed-stream": "~1.0.0"
|
||||
@@ -1471,6 +1475,7 @@
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmmirror.com/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
@@ -1519,6 +1524,7 @@
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/dunder-proto/-/dunder-proto-1.0.1.tgz",
|
||||
"integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind-apply-helpers": "^1.0.1",
|
||||
@@ -1555,6 +1561,7 @@
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/es-define-property/-/es-define-property-1.0.1.tgz",
|
||||
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
@@ -1564,6 +1571,7 @@
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmmirror.com/es-errors/-/es-errors-1.3.0.tgz",
|
||||
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
@@ -1573,6 +1581,7 @@
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmmirror.com/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
|
||||
"integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0"
|
||||
@@ -1585,6 +1594,7 @@
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz",
|
||||
"integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
@@ -1928,6 +1938,7 @@
|
||||
"version": "1.15.11",
|
||||
"resolved": "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.15.11.tgz",
|
||||
"integrity": "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
"type": "individual",
|
||||
@@ -1948,6 +1959,7 @@
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmmirror.com/form-data/-/form-data-4.0.4.tgz",
|
||||
"integrity": "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"asynckit": "^0.4.0",
|
||||
@@ -1986,6 +1998,7 @@
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmmirror.com/function-bind/-/function-bind-1.1.2.tgz",
|
||||
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
@@ -1995,6 +2008,7 @@
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmmirror.com/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
|
||||
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind-apply-helpers": "^1.0.2",
|
||||
@@ -2019,6 +2033,7 @@
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/get-proto/-/get-proto-1.0.1.tgz",
|
||||
"integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"dunder-proto": "^1.0.1",
|
||||
@@ -2083,6 +2098,7 @@
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmmirror.com/gopd/-/gopd-1.2.0.tgz",
|
||||
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
@@ -2112,6 +2128,7 @@
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/has-symbols/-/has-symbols-1.1.0.tgz",
|
||||
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
@@ -2124,6 +2141,7 @@
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmmirror.com/has-tostringtag/-/has-tostringtag-1.0.2.tgz",
|
||||
"integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"has-symbols": "^1.0.3"
|
||||
@@ -2139,6 +2157,7 @@
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmmirror.com/hasown/-/hasown-2.0.2.tgz",
|
||||
"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"function-bind": "^1.1.2"
|
||||
@@ -2394,6 +2413,7 @@
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
||||
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
@@ -2418,6 +2438,7 @@
|
||||
"version": "1.52.0",
|
||||
"resolved": "https://registry.npmmirror.com/mime-db/-/mime-db-1.52.0.tgz",
|
||||
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
@@ -2427,6 +2448,7 @@
|
||||
"version": "2.1.35",
|
||||
"resolved": "https://registry.npmmirror.com/mime-types/-/mime-types-2.1.35.tgz",
|
||||
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"mime-db": "1.52.0"
|
||||
@@ -2708,6 +2730,7 @@
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
||||
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/punycode": {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { message } from 'ant-design-vue'
|
||||
|
||||
// 创建axios实例
|
||||
const instance = axios.create({
|
||||
baseURL: 'http://localhost:5352/api',
|
||||
baseURL: import.meta.env.VITE_API_BASE_URL || 'http://localhost:5352/api',
|
||||
timeout: 10000,
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import axios from 'axios'
|
||||
|
||||
const API_BASE_URL = 'http://localhost:5352/api/approval-process'
|
||||
const API_BASE_URL = `${import.meta.env.VITE_API_BASE_URL || 'http://localhost:5352/api'}/approval-process`
|
||||
|
||||
// 创建axios实例
|
||||
const api = axios.create({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import axios from 'axios'
|
||||
|
||||
const API_BASE_URL = 'http://localhost:5352/api/cattle-academy'
|
||||
const API_BASE_URL = `${import.meta.env.VITE_API_BASE_URL || 'http://localhost:5352/api'}/cattle-academy`
|
||||
|
||||
// 创建axios实例
|
||||
const api = axios.create({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import axios from 'axios';
|
||||
import axios from 'axios'
|
||||
|
||||
const API_BASE_URL = 'http://localhost:5352/api/device-warning';
|
||||
const API_BASE_URL = `${import.meta.env.VITE_API_BASE_URL || 'http://localhost:5352/api'}/device-warning`;
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: API_BASE_URL,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import axios from 'axios'
|
||||
|
||||
const API_BASE_URL = 'http://localhost:5352/api/epidemic-activity'
|
||||
const API_BASE_URL = `${import.meta.env.VITE_API_BASE_URL || 'http://localhost:5352/api'}/epidemic-activity`
|
||||
|
||||
// 创建axios实例
|
||||
const api = axios.create({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import axios from 'axios'
|
||||
|
||||
const API_BASE_URL = 'http://localhost:5352/api/production-material-certification'
|
||||
const API_BASE_URL = `${import.meta.env.VITE_API_BASE_URL || 'http://localhost:5352/api'}/production-material-certification`
|
||||
|
||||
// 创建axios实例
|
||||
const api = axios.create({
|
||||
|
||||
135
government-admin/部署修复说明.md
Normal file
135
government-admin/部署修复说明.md
Normal file
@@ -0,0 +1,135 @@
|
||||
# 政府管理后台部署修复说明
|
||||
|
||||
## 问题描述
|
||||
|
||||
部署后前端仍然使用 `http://localhost:5352` 访问API,导致无法正常访问后端服务。
|
||||
|
||||
## 问题原因
|
||||
|
||||
前端代码中硬编码了本地开发环境的API地址,没有根据部署环境动态配置。
|
||||
|
||||
## 解决方案
|
||||
|
||||
### 1. 环境变量配置
|
||||
|
||||
已创建环境配置文件:
|
||||
|
||||
**开发环境** (`.env.development`):
|
||||
```env
|
||||
VITE_API_BASE_URL=http://localhost:5352/api
|
||||
VITE_APP_TITLE=政府管理系统
|
||||
VITE_APP_ENV=development
|
||||
```
|
||||
|
||||
**生产环境** (`.env.production`):
|
||||
```env
|
||||
VITE_API_BASE_URL=https://ad.ningmuyun.com/api/government
|
||||
VITE_APP_TITLE=政府管理系统
|
||||
VITE_APP_ENV=production
|
||||
```
|
||||
|
||||
### 2. API配置文件修改
|
||||
|
||||
已修改以下文件使用环境变量:
|
||||
|
||||
- `src/utils/api.js` - 主要API配置
|
||||
- `src/utils/productionMaterialCertificationApi.js` - 生产物料认证API
|
||||
- `src/utils/deviceWarningApi.js` - 设备预警API
|
||||
- `src/utils/cattleAcademyApi.js` - 牛只学院API
|
||||
- `src/utils/epidemicActivityApi.js` - 疫情活动API
|
||||
- `src/utils/approvalProcessApi.js` - 审批流程API
|
||||
|
||||
### 3. 部署步骤
|
||||
|
||||
#### 3.1 重新构建前端
|
||||
|
||||
```bash
|
||||
cd government-admin
|
||||
|
||||
# 安装依赖
|
||||
npm install
|
||||
|
||||
# 生产环境构建
|
||||
npm run build
|
||||
```
|
||||
|
||||
#### 3.2 部署到服务器
|
||||
|
||||
将构建后的 `dist` 目录上传到服务器的 `/var/www/html/government/` 目录。
|
||||
|
||||
#### 3.3 验证Nginx配置
|
||||
|
||||
确保服务器上的Nginx配置正确:
|
||||
|
||||
```nginx
|
||||
# 政府端前端静态文件
|
||||
location /government/ {
|
||||
alias /var/www/html/government/;
|
||||
try_files $uri $uri/ /government/index.html;
|
||||
index index.html;
|
||||
}
|
||||
|
||||
# 政府端API代理
|
||||
location ^~ /api/government/ {
|
||||
proxy_pass http://localhost:5352/api/government/;
|
||||
proxy_set_header Host $host;
|
||||
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;
|
||||
|
||||
# CORS配置
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS';
|
||||
add_header Access-Control-Allow-Headers 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization';
|
||||
|
||||
if ($request_method = 'OPTIONS') {
|
||||
return 204;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### 3.4 重启服务
|
||||
|
||||
```bash
|
||||
# 重新加载Nginx配置
|
||||
sudo nginx -t
|
||||
sudo nginx -s reload
|
||||
|
||||
# 确保government-backend服务运行
|
||||
pm2 restart government-backend
|
||||
```
|
||||
|
||||
### 4. 验证修复
|
||||
|
||||
访问以下地址验证修复结果:
|
||||
|
||||
- 前端页面: `https://ad.ningmuyun.com/government/`
|
||||
- API接口: `https://ad.ningmuyun.com/api/government/departments`
|
||||
|
||||
### 5. 注意事项
|
||||
|
||||
1. **环境变量**: 确保在生产环境构建时使用正确的环境变量
|
||||
2. **缓存清理**: 部署后清理浏览器缓存
|
||||
3. **HTTPS证书**: 确保SSL证书配置正确
|
||||
4. **防火墙**: 确保端口443和80开放
|
||||
5. **服务状态**: 确保government-backend服务正常运行
|
||||
|
||||
### 6. 故障排查
|
||||
|
||||
如果仍有问题,请检查:
|
||||
|
||||
1. **浏览器开发者工具**: 查看网络请求是否使用正确的URL
|
||||
2. **Nginx日志**: 检查 `/var/log/nginx/error.log`
|
||||
3. **后端日志**: 检查government-backend服务日志
|
||||
4. **端口监听**: 确认5352端口正常监听
|
||||
|
||||
```bash
|
||||
# 检查端口监听
|
||||
netstat -tlnp | grep 5352
|
||||
|
||||
# 检查服务状态
|
||||
pm2 status government-backend
|
||||
|
||||
# 测试API连通性
|
||||
curl -k https://ad.ningmuyun.com/api/government/departments
|
||||
```
|
||||
Reference in New Issue
Block a user