reference.md 2.7 KB

pref-web 参考手册

devServer 代理完整列表(vue.config.js)

"/api"           → VUE_APP_APIPROXY
"/healthApi"     → VUE_APP_HEALTH_APIPROXY
"/WZLapi"        → VUE_APP_WZLAPIPROXY
"/ETLapi"        → VUE_APP_ETLAPIPROXY
"/tiles"         → VUE_APP_MAP
"/AnalysisMulti" → VUE_APP_AnalysisMultiAPIPROXY
"/transDataWeb"  → VUE_APP_WZLAPIPROXY
"/sAlgorithm"    → VUE_APP_sAlgorithmAPIPROXY
"/databaseApi"   → VUE_APP_databaseApiAPIPROXY
"/downLoadChart" → VUE_APP_downLoadChartAPIPROXY

pathRewrite 均去掉前缀后转发到 target。

healthRequest 模板

// src/utils/healthRequest.js
const HEALTH_BASE = process.env.NODE_ENV === "development"
  ? "/healthApi"
  : window?._BASE_CONFIG?.HEALTH_API || "/healthApi";

const service = axios.create({ baseURL: HEALTH_BASE, withCredentials: true });

// 拦截器:token 从 sessionStorage.vuex.auth.userInfo.token
// 404/HTML 错误:Message 提示 + reject,不 router.push
// src/api/healthAnalyse.js
export function getHealthOverview(params) {
  return healthRequest({
    url: "/energy-manage-analyse-service/healthscores/getHealthOverview",
    method: "post",
    params, // query 参数,POST 也需显式 params
  });
}

HealthHeader 默认风场逻辑

getDefaultTreeNode(treeData) {
  const root = treeData?.[0];
  return root?.children?.[0] || null;
}
// 加载树后:companyCode = defaultNode.codeNumber → emit change
// 勿用 selecttree type="1"(会选中根节点而非第一个子节点)

healthDashboardMapper 映射关系

UI 字段 API 来源
totalScore healthscoresWindVO.overallScore
scoreDistribution / scoreSummary excellentCount, goodCount, fairCount, poorCount
subsystemData structureScore, systemScore, componentScore
healthyRankList healthOverviewListVOList 按 overallScore 降序 Top5
riskRankList 同上升序 Top5
unitCards 列表项 → HealthUnitCard(含 engineId, fieldId)

下载 swagger 文档

curl "http://<host>:16880/energy-manage-analyse-service/v2/api-docs?group=2.X%E7%89%88%E6%9C%AC" \
  -o swagger.json

生产环境注意

  • public/config/config.js_BASE_CONFIG.API = "/api";健康服务需运维配置 /healthApi 反向代理
  • 勿在未授权时改 public/runtime-config.js、nginx、PM2

Rules vs Specs vs Skill

文件 作用 加载方式
.cursor/rules/*.mdc 每次对话自动注入的硬约束 alwaysApply
docs/AI_SPECS.md 人类/AI 详细说明 按需阅读
.cursor/skills/pref-web-dev/ 开发工作流与踩坑 匹配 description 或 @ 引用