Compare commits

...

3 Commits

Author SHA1 Message Date
9d4581a2b5 可以正常访问后端api 2025-09-19 16:17:33 +08:00
3e13b4f7b0 更新swagger 2025-09-19 15:59:44 +08:00
7138838183 更新swagger 2025-09-19 15:55:40 +08:00
7 changed files with 42 additions and 26 deletions

View File

@@ -10,7 +10,7 @@
"host": "", "host": "",
"basePath": "", "basePath": "",
"paths": { "paths": {
"/devices": { "/api/v1/devices": {
"get": { "get": {
"description": "获取系统中所有设备的列表", "description": "获取系统中所有设备的列表",
"produces": [ "produces": [
@@ -62,7 +62,7 @@
} }
} }
}, },
"/devices/{id}": { "/api/v1/devices/{id}": {
"get": { "get": {
"description": "根据设备ID获取单个设备的详细信息", "description": "根据设备ID获取单个设备的详细信息",
"produces": [ "produces": [
@@ -157,7 +157,7 @@
} }
} }
}, },
"/plans": { "/api/v1/plans": {
"get": { "get": {
"description": "获取所有计划的列表", "description": "获取所有计划的列表",
"produces": [ "produces": [
@@ -209,7 +209,7 @@
} }
} }
}, },
"/plans/{id}": { "/api/v1/plans/{id}": {
"get": { "get": {
"description": "根据计划ID获取单个计划的详细信息。", "description": "根据计划ID获取单个计划的详细信息。",
"produces": [ "produces": [
@@ -304,7 +304,7 @@
} }
} }
}, },
"/plans/{id}/start": { "/api/v1/plans/{id}/start": {
"post": { "post": {
"description": "根据计划ID启动一个计划的执行。", "description": "根据计划ID启动一个计划的执行。",
"produces": [ "produces": [
@@ -333,7 +333,7 @@
} }
} }
}, },
"/plans/{id}/stop": { "/api/v1/plans/{id}/stop": {
"post": { "post": {
"description": "根据计划ID停止一个正在执行的计划。", "description": "根据计划ID停止一个正在执行的计划。",
"produces": [ "produces": [
@@ -362,7 +362,7 @@
} }
} }
}, },
"/users": { "/api/v1/users": {
"post": { "post": {
"description": "根据用户名和密码创建一个新的系统用户。", "description": "根据用户名和密码创建一个新的系统用户。",
"consumes": [ "consumes": [
@@ -396,7 +396,7 @@
} }
} }
}, },
"/users/login": { "/api/v1/users/login": {
"post": { "post": {
"description": "用户使用用户名和密码登录,成功后返回 JWT 令牌。", "description": "用户使用用户名和密码登录,成功后返回 JWT 令牌。",
"consumes": [ "consumes": [
@@ -650,6 +650,10 @@
"type": "string", "type": "string",
"example": "根据温度自动调节风扇和加热器" "example": "根据温度自动调节风扇和加热器"
}, },
"execute_num": {
"type": "integer",
"example": 10
},
"execution_type": { "execution_type": {
"allOf": [ "allOf": [
{ {
@@ -863,6 +867,10 @@
"type": "string", "type": "string",
"example": "更新后的描述" "example": "更新后的描述"
}, },
"execute_num": {
"type": "integer",
"example": 10
},
"execution_type": { "execution_type": {
"allOf": [ "allOf": [
{ {

View File

@@ -9,7 +9,7 @@ export class DeviceApi {
* @returns {Promise} 设备列表 * @returns {Promise} 设备列表
*/ */
static list() { static list() {
return http.get('/devices'); return http.get('/api/v1/devices');
} }
/** /**
@@ -18,7 +18,7 @@ export class DeviceApi {
* @returns {Promise} 创建结果 * @returns {Promise} 创建结果
*/ */
static create(deviceData) { static create(deviceData) {
return http.post('/devices', deviceData); return http.post('/api/v1/devices', deviceData);
} }
/** /**
@@ -27,7 +27,7 @@ export class DeviceApi {
* @returns {Promise} 设备详情 * @returns {Promise} 设备详情
*/ */
static get(id) { static get(id) {
return http.get(`/devices/${id}`); return http.get(`/api/v1/devices/${id}`);
} }
/** /**
@@ -37,7 +37,7 @@ export class DeviceApi {
* @returns {Promise} 更新结果 * @returns {Promise} 更新结果
*/ */
static update(id, deviceData) { static update(id, deviceData) {
return http.put(`/devices/${id}`, deviceData); return http.put(`/api/v1/devices/${id}`, deviceData);
} }
/** /**
@@ -46,7 +46,7 @@ export class DeviceApi {
* @returns {Promise} 删除结果 * @returns {Promise} 删除结果
*/ */
static delete(id) { static delete(id) {
return http.delete(`/devices/${id}`); return http.delete(`/api/v1/devices/${id}`);
} }
} }

View File

@@ -9,7 +9,7 @@ export class PlanApi {
* @returns {Promise} 计划列表 * @returns {Promise} 计划列表
*/ */
static list() { static list() {
return http.get('/plans'); return http.get('/api/v1/plans');
} }
/** /**
@@ -18,7 +18,7 @@ export class PlanApi {
* @returns {Promise} 创建结果 * @returns {Promise} 创建结果
*/ */
static create(planData) { static create(planData) {
return http.post('/plans', planData); return http.post('/api/v1/plans', planData);
} }
/** /**
@@ -27,7 +27,7 @@ export class PlanApi {
* @returns {Promise} 计划详情 * @returns {Promise} 计划详情
*/ */
static get(id) { static get(id) {
return http.get(`/plans/${id}`); return http.get(`/api/v1/plans/${id}`);
} }
/** /**
@@ -37,7 +37,7 @@ export class PlanApi {
* @returns {Promise} 更新结果 * @returns {Promise} 更新结果
*/ */
static update(id, planData) { static update(id, planData) {
return http.put(`/plans/${id}`, planData); return http.put(`/api/v1/plans/${id}`, planData);
} }
/** /**
@@ -46,7 +46,7 @@ export class PlanApi {
* @returns {Promise} 删除结果 * @returns {Promise} 删除结果
*/ */
static delete(id) { static delete(id) {
return http.delete(`/plans/${id}`); return http.delete(`/api/v1/plans/${id}`);
} }
/** /**
@@ -55,7 +55,7 @@ export class PlanApi {
* @returns {Promise} 启动结果 * @returns {Promise} 启动结果
*/ */
static start(id) { static start(id) {
return http.post(`/plans/${id}/start`); return http.post(`/api/v1/plans/${id}/start`);
} }
/** /**
@@ -64,7 +64,7 @@ export class PlanApi {
* @returns {Promise} 停止结果 * @returns {Promise} 停止结果
*/ */
static stop(id) { static stop(id) {
return http.post(`/plans/${id}/stop`); return http.post(`/api/v1/plans/${id}/stop`);
} }
} }

View File

@@ -10,7 +10,7 @@ export class UserApi {
* @returns {Promise} 创建结果 * @returns {Promise} 创建结果
*/ */
static create(userData) { static create(userData) {
return http.post('/users', userData); return http.post('/api/v1/users', userData);
} }
/** /**
@@ -19,7 +19,7 @@ export class UserApi {
* @returns {Promise} 登录结果 * @returns {Promise} 登录结果
*/ */
static login(credentials) { static login(credentials) {
return http.post('/users/login', credentials); return http.post('/api/v1/users/login', credentials);
} }
} }

View File

@@ -1,11 +1,11 @@
// API配置文件 // API配置文件
const API_CONFIG = { const API_CONFIG = {
// 后端服务基础URL // 后端服务基础URL
BASE_URL: 'http://localhost:8086', BASE_URL: '',
// API端点 // API端点
ENDPOINTS: { ENDPOINTS: {
DEVICES: '/devices' DEVICES: '/v1/devices'
}, },
// 请求超时时间(毫秒) // 请求超时时间(毫秒)

View File

@@ -1,7 +1,8 @@
import axios from 'axios'; import axios from 'axios';
import API_CONFIG from '../config/api.js'; import API_CONFIG from '../config/api.js';
// 创建axios实例 // 创建axios实例,自动将请求发送到 BASE_URL + 相对路径
// 例如http.get('/api/pigs') 会请求 BASE_URL + '/api/pigs'
const http = axios.create({ const http = axios.create({
baseURL: API_CONFIG.BASE_URL, baseURL: API_CONFIG.BASE_URL,
timeout: API_CONFIG.TIMEOUT, timeout: API_CONFIG.TIMEOUT,

View File

@@ -46,7 +46,14 @@ module.exports = (env, argv) => {
hot: true, hot: true,
open: true, open: true,
historyApiFallback: true, historyApiFallback: true,
port: 8080 port: 8080,
proxy: {
'/api': {
target: 'http://localhost:8086',
changeOrigin: true,
secure: false
}
}
}, },
resolve: { resolve: {
alias: { alias: {