接口接入
This commit is contained in:
23
env.js
Normal file
23
env.js
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
// 环境枚举
|
||||||
|
const ENV = {
|
||||||
|
DEV: 'development',
|
||||||
|
PROD: 'production',
|
||||||
|
};
|
||||||
|
|
||||||
|
const currentEnv = import.meta.env?.MODE || process.env.NODE_ENV;
|
||||||
|
|
||||||
|
// 环境配置映射
|
||||||
|
const envConfig = {
|
||||||
|
[ENV.DEV]: {
|
||||||
|
baseURL: 'http://192.168.2.56:8081',//http://192.168.2.56:8081
|
||||||
|
WS_URL: 'ws://192.168.2.56:9002/ws/',
|
||||||
|
},
|
||||||
|
[ENV.PROD]: {
|
||||||
|
// baseURL: 'http://192.168.2.56:8081',
|
||||||
|
baseURL: 'https://serviceri.satabot.com',
|
||||||
|
WS_URL: 'wss://ri.satabot.com/ws/'
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// 导出当前环境的配置
|
||||||
|
export default envConfig[currentEnv] || envConfig[ENV.DEV];
|
||||||
10
package-lock.json
generated
10
package-lock.json
generated
@@ -17,6 +17,7 @@
|
|||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"dotenv": "^17.2.3",
|
"dotenv": "^17.2.3",
|
||||||
"express": "^4.21.2",
|
"express": "^4.21.2",
|
||||||
|
"js-cookie": "^3.0.5",
|
||||||
"lucide-react": "^0.546.0",
|
"lucide-react": "^0.546.0",
|
||||||
"motion": "^12.23.24",
|
"motion": "^12.23.24",
|
||||||
"qrcode": "^1.5.4",
|
"qrcode": "^1.5.4",
|
||||||
@@ -3532,6 +3533,15 @@
|
|||||||
"jiti": "lib/jiti-cli.mjs"
|
"jiti": "lib/jiti-cli.mjs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/js-cookie": {
|
||||||
|
"version": "3.0.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/js-cookie/-/js-cookie-3.0.5.tgz",
|
||||||
|
"integrity": "sha512-cEiJEAEoIbWfCZYKWhVwFuvPX1gETRYPw6LlaTKoxD3s2AkXzkCjnp6h0V77ozyqj0jakteJ4YqDJT830+lVGw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/js-tokens": {
|
"node_modules/js-tokens": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"dotenv": "^17.2.3",
|
"dotenv": "^17.2.3",
|
||||||
"express": "^4.21.2",
|
"express": "^4.21.2",
|
||||||
|
"js-cookie": "^3.0.5",
|
||||||
"lucide-react": "^0.546.0",
|
"lucide-react": "^0.546.0",
|
||||||
"motion": "^12.23.24",
|
"motion": "^12.23.24",
|
||||||
"qrcode": "^1.5.4",
|
"qrcode": "^1.5.4",
|
||||||
|
|||||||
342
src/api/api.ts
Normal file
342
src/api/api.ts
Normal file
@@ -0,0 +1,342 @@
|
|||||||
|
import api from './request';
|
||||||
|
|
||||||
|
|
||||||
|
export function getDeviceListApi(data){
|
||||||
|
return api({
|
||||||
|
url: `/iot/device/userDevice?tenantName=${data.tenantName}&deptId=${data.deptId}`,
|
||||||
|
method: 'get',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getUserList(params) {
|
||||||
|
return api({
|
||||||
|
url: '/system/user/list',
|
||||||
|
method: 'get',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 作业列表
|
||||||
|
export function getWorkList(data) {
|
||||||
|
return api({
|
||||||
|
url: `/iot/workRecord/selectByUserId?userId=${data.userId}`,
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// /iot/deviceTask/save 新建路线
|
||||||
|
export function saveDeviceTask(data) {
|
||||||
|
return api({
|
||||||
|
url: `/iot/deviceTask/save`,
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 获取任务列表
|
||||||
|
export function getDeviceTask(data) {
|
||||||
|
return api({
|
||||||
|
url: `/iot/deviceTask/getDevicePlan`,
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取任务分布/iot/deviceTask/devicePlanStatistics
|
||||||
|
|
||||||
|
export function getTaskDistribution(params) {
|
||||||
|
return api({
|
||||||
|
url: `/iot/deviceTask/devicePlanStatistics`,
|
||||||
|
method: 'get',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
//选择某一个数据https://serviceri.satabot.com/iot/workRecord/selectByWorkName?workName=${workName}&_t=${Date.now()}
|
||||||
|
export function getSingleWork(data) {
|
||||||
|
return api({
|
||||||
|
url: `/iot/workRecord/selectByWorkName?workName=${data.workName}`,
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 执行结果/iot/deviceTask/devicePlanTaskStatistics
|
||||||
|
export function getDevicePlanTaskStatistics(params) {
|
||||||
|
return api({
|
||||||
|
url: `/iot/deviceTask/devicePlanTaskStatistics`,
|
||||||
|
method: 'get',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取当前的设备运行路线/iot/deviceTask/concurrentDeviceRoute
|
||||||
|
export function getConcurrentDeviceRoute (params) {
|
||||||
|
return api({
|
||||||
|
url: `/iot/deviceTask/concurrentDeviceRoute`,
|
||||||
|
method: 'get',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 获取作业数据/iot/deviceTask/workStatistics
|
||||||
|
export function getWorkStatistics(params) {
|
||||||
|
return api({
|
||||||
|
url: `/iot/deviceTask/workStatistics`,
|
||||||
|
method: 'get',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 判断是否能控制
|
||||||
|
export function getControlRight(params) {
|
||||||
|
const dataStr = localStorage.getItem('userInfo');
|
||||||
|
let parse = JSON.parse(dataStr);
|
||||||
|
var token=parse?.token;
|
||||||
|
return api({
|
||||||
|
url: `/websocket/judgeConnection`,
|
||||||
|
method: 'get',
|
||||||
|
headers: {
|
||||||
|
Authorization: token // token 正常带上
|
||||||
|
},
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 登录
|
||||||
|
export function loginApi(data) {
|
||||||
|
return api({
|
||||||
|
url: '/login',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 可视化面板获取无人机信息
|
||||||
|
|
||||||
|
export function getPlaneDeviceList() {
|
||||||
|
return api({
|
||||||
|
url: '/iot/UAV/getProjectDeviceList',
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 获取所有航线
|
||||||
|
|
||||||
|
export function getsinglePlan(data) {
|
||||||
|
return api({
|
||||||
|
url: `/iot/UAV/getFlightTask?sn=${data.gateway_sn}`,
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取航线轨迹 iot/UAV/getFlightTaskTrack
|
||||||
|
|
||||||
|
export function getsinglePlanTrack(data) {
|
||||||
|
return api({
|
||||||
|
url: `/iot/UAV/getFlightTaskTrack?taskId=${data.uuid}`,
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
//上传航线
|
||||||
|
|
||||||
|
export function uploadWayLine(data) {
|
||||||
|
return api({
|
||||||
|
url: '/iot/UAV/uploadWayline',
|
||||||
|
method: 'post',
|
||||||
|
data: data, // 上传文件必须用 data,不能用 params
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'multipart/form-data' // 上传文件必加!
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
//创建航线任务
|
||||||
|
export function createWaylineTask(data) {
|
||||||
|
return api({
|
||||||
|
url: '/iot/UAV/createFlightTask',
|
||||||
|
method: 'post',
|
||||||
|
data: data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export function updateFlightTaskStatus(taskId, status) {
|
||||||
|
return api({
|
||||||
|
url: '/iot/UAV/updateFlightTaskStatus',
|
||||||
|
method: 'post',
|
||||||
|
params: { taskId, status }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getFlightTaskDetail(taskId) {
|
||||||
|
return api({
|
||||||
|
url: '/iot/UAV/getFlightTaskDetail',
|
||||||
|
method: 'get',
|
||||||
|
params: { taskId }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 航线列表
|
||||||
|
export function getWayLine() {
|
||||||
|
return api({
|
||||||
|
url: '/iot/UAV/getWayline',
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
//直播流
|
||||||
|
|
||||||
|
export function getLiveStream(data) {
|
||||||
|
return api({
|
||||||
|
url: '/iot/UAV/liveStream',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
///iot/UAV/flightTaskCommand
|
||||||
|
export function postFlightCommmand(data) {
|
||||||
|
return api({
|
||||||
|
url: '/iot/UAV/flightTaskCommand',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
//切换相机
|
||||||
|
|
||||||
|
export function changeCamera(data) {
|
||||||
|
return api({
|
||||||
|
url: '/iot/UAV/changeCamera',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
//直播心跳
|
||||||
|
|
||||||
|
export function postLiveHeartbeat(data) {
|
||||||
|
return api({
|
||||||
|
url: `/iot/UAV/liveHeartbeat?sn=${data.sn}&cameraIndex=${data.cameraIndex}`,
|
||||||
|
method: 'post',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
//热成像分析
|
||||||
|
|
||||||
|
export function getThermalDefault() {
|
||||||
|
return api({
|
||||||
|
url: `/api/thermal/defaults`,
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
//点击分析
|
||||||
|
|
||||||
|
export function getThermalAnalyzelt(data) {
|
||||||
|
return api({
|
||||||
|
url: `/api/thermal/analyze`,
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
//像素点信息/api/thermal/probe
|
||||||
|
|
||||||
|
export function getThermalProbe(data) {
|
||||||
|
return api({
|
||||||
|
url: `/api/thermal/probe`,
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取报告
|
||||||
|
export function getThermalReport(data) {
|
||||||
|
return api({
|
||||||
|
url: `/api/thermal/downloadReport`,
|
||||||
|
method: 'get',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
//下载报告
|
||||||
|
export function downloadReport(data) {
|
||||||
|
return api({
|
||||||
|
url: `/api/thermal/report`,
|
||||||
|
method: 'get',
|
||||||
|
params: data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取 用户设备任务列表
|
||||||
|
|
||||||
|
export function getUserWorkRecord(params) {
|
||||||
|
return api({
|
||||||
|
url: `/iot/workRecord/selectByUserId`,
|
||||||
|
method: 'get',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取 任务数据
|
||||||
|
export function getWorkData(params) {
|
||||||
|
return api({
|
||||||
|
url: `/iot/workRecord/selectByWorkName`,
|
||||||
|
method: 'get',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function getAlimage(params) {
|
||||||
|
return api({
|
||||||
|
url: `/api/thermal/image`,
|
||||||
|
method: 'get',
|
||||||
|
params,
|
||||||
|
//responseType: "blob", // 必须加这个
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 远程遥控 判断是否有权限/forward/device/remoteControl platform:web
|
||||||
|
export function getJurisdiction(data) {
|
||||||
|
return api({
|
||||||
|
url: '/forward/device/remoteControl',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//下载割草任务记录
|
||||||
|
//
|
||||||
|
export function downloadOperationReport() {
|
||||||
|
return api({
|
||||||
|
url: '/iot/device/generateOperationReport',
|
||||||
|
method: 'get',
|
||||||
|
responseType: 'arraybuffer' // 👈 只需要加这一行!
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
export function getDeviceIntradayData(params) {
|
||||||
|
return api({
|
||||||
|
url: '/iot/device/getDeviceIntradayData',
|
||||||
|
method: 'get',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//释放控制权限/forward/device/releaseControl
|
||||||
|
export function releaseControl(data) {
|
||||||
|
return api({
|
||||||
|
url: '/forward/device/releaseControl',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
22
src/api/login/index.ts
Normal file
22
src/api/login/index.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import request from '../request';
|
||||||
|
|
||||||
|
//username, password, code, uuid, sourceType
|
||||||
|
export function login(data) {
|
||||||
|
return request({
|
||||||
|
url: '/login',
|
||||||
|
headers: {
|
||||||
|
isToken: false,
|
||||||
|
},
|
||||||
|
method: 'post',
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 退出方法
|
||||||
|
export function logout() {
|
||||||
|
return request({
|
||||||
|
url: '/logout',
|
||||||
|
method: 'post',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
319
src/api/reportDownloader.ts
Normal file
319
src/api/reportDownloader.ts
Normal file
@@ -0,0 +1,319 @@
|
|||||||
|
// reportDownloader.ts
|
||||||
|
export interface ReportData {
|
||||||
|
title: string;
|
||||||
|
metrics: {
|
||||||
|
label: string;
|
||||||
|
value: string;
|
||||||
|
}[];
|
||||||
|
bestTime: {
|
||||||
|
label: string;
|
||||||
|
value: string;
|
||||||
|
desc: string;
|
||||||
|
};
|
||||||
|
taskList: {
|
||||||
|
area: string;
|
||||||
|
[key: string]: string; // 适配割草(植被高度)、清洗(灰损率)的不同字段
|
||||||
|
lossPower: string;
|
||||||
|
priority: string;
|
||||||
|
}[];
|
||||||
|
taskTableHeader: string[];
|
||||||
|
taskTableKeys: string[];
|
||||||
|
processSteps: string[];
|
||||||
|
processTitle: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成HTML报告并下载
|
||||||
|
* @param reportData 报告数据
|
||||||
|
* @param fileName 下载文件名
|
||||||
|
*/
|
||||||
|
export const downloadHTMLReport = (reportData: ReportData, fileName: string) => {
|
||||||
|
// HTML报告模板(深蓝色科技主题,专业可视化)
|
||||||
|
const htmlContent = `
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh-CN">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>${reportData.title}</title>
|
||||||
|
<style>
|
||||||
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||||
|
body {
|
||||||
|
font-family: 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
||||||
|
background: #050b18;
|
||||||
|
color: #e0e6ff;
|
||||||
|
padding: 30px;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
max-width: 1200px;
|
||||||
|
margin: 0 auto;
|
||||||
|
background: #0a1428;
|
||||||
|
border-radius: 20px;
|
||||||
|
padding: 30px;
|
||||||
|
box-shadow: 0 0 30px rgba(14, 82, 255, 0.2);
|
||||||
|
border: 1px solid #162955;
|
||||||
|
}
|
||||||
|
h2 {
|
||||||
|
font-size: 24px;
|
||||||
|
font-weight: 600;
|
||||||
|
margin-bottom: 30px;
|
||||||
|
color: #4d7cff;
|
||||||
|
text-shadow: 0 0 10px rgba(77, 124, 255, 0.5);
|
||||||
|
border-bottom: 1px solid #162955;
|
||||||
|
padding-bottom: 15px;
|
||||||
|
}
|
||||||
|
.metrics-row {
|
||||||
|
display: flex;
|
||||||
|
gap: 20px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
margin-bottom: 30px;
|
||||||
|
}
|
||||||
|
.metric-card {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 200px;
|
||||||
|
background: linear-gradient(135deg, #0f1c3f 0%, #162955 100%);
|
||||||
|
border: 1px solid #244289;
|
||||||
|
border-radius: 16px;
|
||||||
|
padding: 20px;
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
.metric-card::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 3px;
|
||||||
|
background: linear-gradient(90deg, #4d7cff, #00c6ff);
|
||||||
|
}
|
||||||
|
.metric-label {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #94a3b8;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
}
|
||||||
|
.metric-value {
|
||||||
|
font-size: 28px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #4d7cff;
|
||||||
|
text-shadow: 0 0 8px rgba(77, 124, 255, 0.4);
|
||||||
|
}
|
||||||
|
.best-time-card {
|
||||||
|
background: linear-gradient(135deg, #0f1c3f 0%, #162955 100%);
|
||||||
|
border: 1px solid #244289;
|
||||||
|
border-radius: 16px;
|
||||||
|
padding: 20px;
|
||||||
|
margin-bottom: 30px;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.best-time-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #4d7cff;
|
||||||
|
}
|
||||||
|
.best-time-value {
|
||||||
|
font-size: 16px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
color: #e0e6ff;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
.best-time-desc {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #94a3b8;
|
||||||
|
line-height: 1.4;
|
||||||
|
}
|
||||||
|
.task-table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
margin-bottom: 30px;
|
||||||
|
border-radius: 16px;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #0f1c3f;
|
||||||
|
border: 1px solid #244289;
|
||||||
|
}
|
||||||
|
.task-table th, .task-table td {
|
||||||
|
padding: 15px 12px;
|
||||||
|
text-align: left;
|
||||||
|
border-bottom: 1px solid #162955;
|
||||||
|
}
|
||||||
|
.task-table th {
|
||||||
|
background: #162955;
|
||||||
|
color: #4d7cff;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
}
|
||||||
|
.task-table td {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #e0e6ff;
|
||||||
|
}
|
||||||
|
.task-table tr:last-child td {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
.task-table tr:hover td {
|
||||||
|
background: rgba(77, 124, 255, 0.1);
|
||||||
|
}
|
||||||
|
.priority-high {
|
||||||
|
background: rgba(255, 77, 79, 0.2);
|
||||||
|
color: #ff4d4f;
|
||||||
|
padding: 4px 10px;
|
||||||
|
border-radius: 12px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 500;
|
||||||
|
border: 1px solid rgba(255, 77, 79, 0.3);
|
||||||
|
}
|
||||||
|
.priority-medium {
|
||||||
|
background: rgba(255, 171, 0, 0.2);
|
||||||
|
color: #ffab00;
|
||||||
|
padding: 4px 10px;
|
||||||
|
border-radius: 12px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 500;
|
||||||
|
border: 1px solid rgba(255, 171, 0, 0.3);
|
||||||
|
}
|
||||||
|
.priority-low {
|
||||||
|
background: rgba(0, 255, 127, 0.2);
|
||||||
|
color: #00ff7f;
|
||||||
|
padding: 4px 10px;
|
||||||
|
border-radius: 12px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 500;
|
||||||
|
border: 1px solid rgba(0, 255, 127, 0.3);
|
||||||
|
}
|
||||||
|
.timeline-section {
|
||||||
|
background: linear-gradient(135deg, #0f1c3f 0%, #162955 100%);
|
||||||
|
border: 1px solid #244289;
|
||||||
|
border-radius: 16px;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
.timeline-title {
|
||||||
|
font-weight: 600;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
color: #4d7cff;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
.timeline-item {
|
||||||
|
position: relative;
|
||||||
|
padding-left: 30px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #e0e6ff;
|
||||||
|
padding-bottom: 20px;
|
||||||
|
border-left: 2px solid #162955;
|
||||||
|
}
|
||||||
|
.timeline-item:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
padding-bottom: 0;
|
||||||
|
border-left: none;
|
||||||
|
}
|
||||||
|
.timeline-item::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
left: -9px;
|
||||||
|
top: 0;
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: #00ff7f;
|
||||||
|
border: 2px solid #0a1428;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
.timeline-item:nth-child(3)::before {
|
||||||
|
background: #3b82f6;
|
||||||
|
}
|
||||||
|
.timeline-item:last-child::before {
|
||||||
|
background: #94a3b8;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<h2>${reportData.title}</h2>
|
||||||
|
|
||||||
|
<!-- 核心指标 -->
|
||||||
|
<div class="metrics-row">
|
||||||
|
${reportData.metrics
|
||||||
|
.map(
|
||||||
|
(metric) => `
|
||||||
|
<div class="metric-card">
|
||||||
|
<div class="metric-label">${metric.label}</div>
|
||||||
|
<div class="metric-value">${metric.value}</div>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
)
|
||||||
|
.join('')}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 最佳作业窗口 -->
|
||||||
|
<div class="best-time-card">
|
||||||
|
<div class="best-time-header">
|
||||||
|
<span>${reportData.bestTime.label}</span>
|
||||||
|
<span>⏰</span>
|
||||||
|
</div>
|
||||||
|
<div class="best-time-value">${reportData.bestTime.value}</div>
|
||||||
|
<div class="best-time-desc">${reportData.bestTime.desc}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 任务列表 -->
|
||||||
|
<table class="task-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
${reportData.taskTableHeader
|
||||||
|
.map((header) => `<th>${header}</th>`)
|
||||||
|
.join('')}
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
${reportData.taskList
|
||||||
|
.map(
|
||||||
|
(task) => `
|
||||||
|
<tr>
|
||||||
|
${reportData.taskTableKeys.map((key) => {
|
||||||
|
if (key === 'priority') {
|
||||||
|
let className = '';
|
||||||
|
if (task[key] === '高') className = 'priority-high';
|
||||||
|
else if (task[key] === '中') className = 'priority-medium';
|
||||||
|
else className = 'priority-low';
|
||||||
|
return `<td><span class="${className}">${task[key]}</span></td>`;
|
||||||
|
}
|
||||||
|
return `<td>${task[key]}</td>`;
|
||||||
|
}).join('')}
|
||||||
|
</tr>
|
||||||
|
`
|
||||||
|
)
|
||||||
|
.join('')}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<!-- 算法执行流程 -->
|
||||||
|
<div class="timeline-section">
|
||||||
|
<div class="timeline-title">${reportData.processTitle}</div>
|
||||||
|
<div class="timeline">
|
||||||
|
${reportData.processSteps
|
||||||
|
.map((step) => `<div class="timeline-item">${step}</div>`)
|
||||||
|
.join('')}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
`;
|
||||||
|
|
||||||
|
// 创建Blob并下载
|
||||||
|
const blob = new Blob([htmlContent], { type: 'text/html; charset=utf-8' });
|
||||||
|
const url = URL.createObjectURL(blob);
|
||||||
|
const a = document.createElement('a');
|
||||||
|
a.href = url;
|
||||||
|
a.download = `${fileName}.html`;
|
||||||
|
document.body.appendChild(a);
|
||||||
|
a.click();
|
||||||
|
document.body.removeChild(a);
|
||||||
|
URL.revokeObjectURL(url);
|
||||||
|
};
|
||||||
@@ -1,17 +1,24 @@
|
|||||||
import axios, { AxiosInstance, AxiosResponse, AxiosError, InternalAxiosRequestConfig } from 'axios';
|
import axios, { AxiosError, AxiosResponse, InternalAxiosRequestConfig } from 'axios';
|
||||||
|
import envConfig from '../../env';
|
||||||
|
import Cookies from 'js-cookie';
|
||||||
import { message } from 'antd';
|
import { message } from 'antd';
|
||||||
|
|
||||||
// 创建 axios 实例
|
|
||||||
const http: AxiosInstance = axios.create({
|
const API_BASE_URL = envConfig.baseURL;
|
||||||
baseURL: '/api', // 根据实际后端 API 路径调整
|
|
||||||
timeout: 10000,
|
const api = axios.create({
|
||||||
|
baseURL: API_BASE_URL,
|
||||||
|
timeout: 20000,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
|
||||||
},
|
},
|
||||||
|
withCredentials: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 请求拦截器:自动添加token
|
||||||
// 请求拦截器
|
// 请求拦截器
|
||||||
http.interceptors.request.use(
|
api.interceptors.request.use(
|
||||||
(config: InternalAxiosRequestConfig) => {
|
(config: InternalAxiosRequestConfig) => {
|
||||||
// 从 localStorage 获取 token
|
// 从 localStorage 获取 token
|
||||||
const token = localStorage.getItem('token');
|
const token = localStorage.getItem('token');
|
||||||
@@ -27,7 +34,7 @@ http.interceptors.request.use(
|
|||||||
);
|
);
|
||||||
|
|
||||||
// 响应拦截器
|
// 响应拦截器
|
||||||
http.interceptors.response.use(
|
api.interceptors.response.use(
|
||||||
(response: AxiosResponse) => {
|
(response: AxiosResponse) => {
|
||||||
// 处理成功响应
|
// 处理成功响应
|
||||||
const { data } = response;
|
const { data } = response;
|
||||||
@@ -69,4 +76,4 @@ http.interceptors.response.use(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
export default http;
|
export default api;
|
||||||
Reference in New Issue
Block a user