Compare commits

..

42 Commits

Author SHA1 Message Date
libertyspy
8b3fe9b548 UPDATE: fk 2026-02-09 21:05:07 +08:00
libertyspy
db30244cd1 Initial commit 2026-02-09 21:03:57 +08:00
libertyspy
c9bc62fb8c Initial commit 2026-02-09 20:10:24 +08:00
libertyspy
9d54395c29 Initial commit 2026-02-09 20:05:56 +08:00
libertyspy
35fd1c8937 Initial commit 2026-02-09 19:53:17 +08:00
libertyspy
579d0f2bd8 Initial commit 2026-02-09 15:35:20 +08:00
libertyspy
7f8abf2ff2 Initial commit 2026-02-09 15:26:21 +08:00
libertyspy
f1bcd3812d Initial commit 2026-02-09 15:06:04 +08:00
libertyspy
d3fda27bb0 Initial commit 2026-02-09 15:04:34 +08:00
libertyspy
538a43f597 Merge remote-tracking branch 'origin/master' 2026-02-09 14:53:43 +08:00
libertyspy
fcab8585c5 UPDATE: fk 2026-02-09 14:53:05 +08:00
libertyspy
0ffc42ab69 UPDATE: fk 2026-02-09 14:52:56 +08:00
libertyspy
46bead08a0 UPDATE: fk 2026-02-09 14:52:46 +08:00
zouju
e07b11ef95 修改部分规则代码 2026-02-09 11:15:26 +08:00
libertyspy
a78781782e Initial commit 2026-02-08 22:32:50 +08:00
libertyspy
0b55384442 Initial commit 2026-02-08 22:31:13 +08:00
libertyspy
43837901f3 Initial commit 2026-02-08 22:30:08 +08:00
libertyspy
8898cd2e6f Initial commit 2026-02-08 22:28:52 +08:00
libertyspy
f34274ea35 Initial commit 2026-02-08 22:16:22 +08:00
libertyspy
5ffdb5e508 Initial commit 2026-02-08 22:09:28 +08:00
libertyspy
a5a3c93135 UPDATE: fk 2026-02-08 21:50:56 +08:00
libertyspy
af697e9304 UPDATE: fk 2026-02-08 21:50:33 +08:00
libertyspy
e7abfca9f7 Initial commit 2026-02-08 21:36:39 +08:00
libertyspy
1058d666a0 Initial commit 2026-02-08 20:57:07 +08:00
libertyspy
58d36a3d6d Initial commit 2026-02-08 20:41:49 +08:00
libertyspy
b544391b5c Initial commit 2026-02-08 20:27:40 +08:00
libertyspy
e12c3c0302 UPDATE: fk 2026-02-08 20:14:46 +08:00
libertyspy
d8c429d000 UPDATE: fk 2026-02-08 20:14:07 +08:00
libertyspy
7909ea8acb UPDATE: fk 2026-02-08 18:51:18 +08:00
libertyspy
444c31612d Merge remote-tracking branch 'origin/master' 2026-02-08 18:50:38 +08:00
libertyspy
a3e34424d8 UPDATE: fk 2026-02-08 18:48:21 +08:00
libertyspy
76065ed5c4 Initial commit 2026-02-08 18:43:42 +08:00
libertyspy
70de3c68a8 Initial commit 2026-02-08 18:41:38 +08:00
libertyspy
3bb9178399 Initial commit 2026-02-08 18:05:48 +08:00
libertyspy
82fcedfa97 Initial commit 2026-02-08 17:57:40 +08:00
libertyspy
294e5d687e Initial commit 2026-02-08 17:11:03 +08:00
libertyspy
a246c88341 Initial commit 2026-02-08 16:44:50 +08:00
libertyspy
c9d5c38b52 Initial commit 2026-02-08 16:01:21 +08:00
libertyspy
9ded6b757c Initial commit 2026-02-08 15:59:14 +08:00
libertyspy
015030d650 Initial commit 2026-02-08 15:38:50 +08:00
libertyspy
b67f493678 UPDATE: fk 2026-02-08 15:38:32 +08:00
e3be036bd3 fix(behaviour): 修复行为树实例节点保存方法返回值类型
- 将返回类型从 Integer 改为 Long 以匹配实际数据类型
- 调整新增逻辑中的返回值,直接返回节点实例ID而不是插入操作的结果
- 统一更新逻辑的返回值处理方式
- 移动服务层调用顺序以确保正确的业务逻辑执行
2026-02-08 11:23:57 +08:00
153 changed files with 3765 additions and 13286 deletions

2
.gitignore vendored
View File

@@ -8,6 +8,8 @@
target/ target/
!.mvn/wrapper/maven-wrapper.jar !.mvn/wrapper/maven-wrapper.jar
node_modules/
###################################################################### ######################################################################
# IDE # IDE

View File

@@ -1,8 +1,14 @@
package com.solution.web.controller.algo; package com.solution.web.controller.algo;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
@@ -32,11 +38,56 @@ import com.solution.common.core.page.TableDataInfo;
*/ */
@RestController @RestController
@Api("规则模块") @Api("规则模块")
@RequestMapping("/algo/algorithm") @RequestMapping("/api/algo/algorithm")
public class AlgorithmController extends BaseController { public class AlgorithmController extends BaseController {
@Autowired @Autowired
private IAlgorithmService algorithmService; private IAlgorithmService algorithmService;
/**
* 导出规则列表
*/
@ApiOperation("运行python程序")
@PostMapping("/run")
public Object run(@RequestBody Algorithm algorithm) {
List<Algorithm> list = algorithmService.selectAlgorithmList(algorithm);
ObjectMapper objectMapper = new ObjectMapper();
for (Algorithm al : list) {
String codePath = al.getCodePath();
try {
String jsonInput = objectMapper.writeValueAsString(al);
String pythonExe = "E:\\Apps\\anaconda3\\python.exe";
ProcessBuilder pb = new ProcessBuilder(pythonExe, codePath);
Process process = pb.start();
try (OutputStream os = process.getOutputStream()) {
os.write(jsonInput.getBytes(StandardCharsets.UTF_8));
os.flush();
}
String result;
// 修改你 Java 代码中的这一段
try (BufferedReader reader = new BufferedReader(
new InputStreamReader(process.getInputStream(), StandardCharsets.UTF_8))) {
result = reader.lines().collect(Collectors.joining("\n"));
}
int exitCode = process.waitFor();
if (exitCode != 0) {
return "Python执行失败错误码" + exitCode;
}
return objectMapper.readTree(result);
} catch (Exception e) {
e.printStackTrace();
return "执行异常: " + e.getMessage();
}
}
return "未找到算法";
}
/** /**
* 查询规则列表 * 查询规则列表
*/ */
@@ -56,7 +107,7 @@ public class AlgorithmController extends BaseController {
@PreAuthorize("@ss.hasPermi('algo:algorithm:export')") @PreAuthorize("@ss.hasPermi('algo:algorithm:export')")
@Log(title = "规则", businessType = BusinessType.EXPORT) @Log(title = "规则", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, Algorithm algorithm) { public void export(HttpServletResponse response, @RequestBody Algorithm algorithm) {
List<Algorithm> list = algorithmService.selectAlgorithmList(algorithm); List<Algorithm> list = algorithmService.selectAlgorithmList(algorithm);
ExcelUtil<Algorithm> util = new ExcelUtil<Algorithm>(Algorithm.class); ExcelUtil<Algorithm> util = new ExcelUtil<Algorithm>(Algorithm.class);
util.exportExcel(response, list, "规则数据"); util.exportExcel(response, list, "规则数据");

View File

@@ -3,6 +3,7 @@ package com.solution.web.controller.behaviour;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.solution.web.core.BehaviortreeProcessor;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
@@ -32,12 +33,15 @@ import com.solution.common.core.page.TableDataInfo;
*/ */
@Api("行为树管理") @Api("行为树管理")
@RestController @RestController
@RequestMapping("/system/behaviortree") @RequestMapping("/api/system/behaviortree")
public class BehaviortreeController extends BaseController public class BehaviortreeController extends BaseController
{ {
@Autowired @Autowired
private IBehaviortreeService behaviortreeService; private IBehaviortreeService behaviortreeService;
@Autowired
private BehaviortreeProcessor behaviortreeProcessor;
/** /**
* 查询行为树主列表 * 查询行为树主列表
*/ */
@@ -84,7 +88,7 @@ public class BehaviortreeController extends BaseController
@PostMapping @PostMapping
public AjaxResult add(@RequestBody Behaviortree behaviortree) public AjaxResult add(@RequestBody Behaviortree behaviortree)
{ {
return toAjax(behaviortreeService.insertBehaviortree(behaviortree)); return toAjax(behaviortreeProcessor.create(behaviortree));
} }
/** /**
@@ -96,7 +100,7 @@ public class BehaviortreeController extends BaseController
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody Behaviortree behaviortree) public AjaxResult edit(@RequestBody Behaviortree behaviortree)
{ {
return toAjax(behaviortreeService.updateBehaviortree(behaviortree)); return toAjax(behaviortreeProcessor.update(behaviortree));
} }
/** /**

View File

@@ -32,7 +32,7 @@ import com.solution.common.core.page.TableDataInfo;
*/ */
@Api("节点连接管理") @Api("节点连接管理")
@RestController @RestController
@RequestMapping("/system/nodeconnection") @RequestMapping("/api/system/nodeconnection")
public class NodeconnectionController extends BaseController public class NodeconnectionController extends BaseController
{ {
@Autowired @Autowired

View File

@@ -32,7 +32,7 @@ import com.solution.common.core.page.TableDataInfo;
*/ */
@Api("节点参数管理") @Api("节点参数管理")
@RestController @RestController
@RequestMapping("/system/nodeparameter") @RequestMapping("/api/system/nodeparameter")
public class NodeparameterController extends BaseController public class NodeparameterController extends BaseController
{ {
@Autowired @Autowired

View File

@@ -7,6 +7,11 @@ import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.solution.common.core.domain.R; import com.solution.common.core.domain.R;
import com.solution.system.domain.NodeTemplateEntity;
import com.solution.system.domain.Nodeparameter;
import com.solution.system.domain.Templateparameterdef;
import com.solution.system.service.INodeparameterService;
import com.solution.system.service.ITemplateparameterdefService;
import com.solution.web.controller.behaviour.vo.NodetemplateDTO; import com.solution.web.controller.behaviour.vo.NodetemplateDTO;
import com.solution.web.controller.behaviour.vo.NodetemplateVO; import com.solution.web.controller.behaviour.vo.NodetemplateVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@@ -14,6 +19,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.PutMapping;
@@ -39,11 +45,17 @@ import com.solution.common.core.page.TableDataInfo;
*/ */
@Api("节点模板管理") @Api("节点模板管理")
@RestController @RestController
@RequestMapping("/system/nodetemplate") @RequestMapping("/api/system/nodetemplate")
public class NodetemplateController extends BaseController { public class NodetemplateController extends BaseController {
@Autowired @Autowired
private INodetemplateService nodetemplateService; private INodetemplateService nodetemplateService;
@Autowired
private INodeparameterService nodeparameterService;
@Autowired
private ITemplateparameterdefService templateparameterdefService;
/** /**
* 查询节点模板列表 * 查询节点模板列表
*/ */
@@ -55,10 +67,29 @@ public class NodetemplateController extends BaseController {
return getDataTable(list); return getDataTable(list);
} }
@ApiOperation("节点模板列表")
@PreAuthorize("@ss.hasPermi('system:nodetemplate:all')")
@GetMapping("/all")
public R<List<NodeTemplateEntity>> all() {
Nodetemplate nodetemplate = new Nodetemplate();
List<Nodetemplate> list = nodetemplateService.selectNodetemplateList(nodetemplate);
if (CollectionUtils.isEmpty(list)) {
return R.ok(null);
}
List<NodeTemplateEntity> entities = new ArrayList<>();
for (Nodetemplate template : list) {
Templateparameterdef def = new Templateparameterdef();
def.setTemplateId(template.getId());
List<Templateparameterdef> parameters = templateparameterdefService.selectTemplateparameterdefList(def);
entities.add(new NodeTemplateEntity(template, parameters));
}
return R.ok(entities);
}
@ApiOperation("节点模板列表") @ApiOperation("节点模板列表")
@PreAuthorize("@ss.hasPermi('system:nodetemplate:list')") @PreAuthorize("@ss.hasPermi('system:nodetemplate:list')")
@GetMapping("/listAll") @GetMapping("/listAll")
public R<List<NodetemplateVO>> listAll() { public R<List<Nodetemplate>> listAll() {
Nodetemplate nodetemplate = new Nodetemplate(); Nodetemplate nodetemplate = new Nodetemplate();
List<Nodetemplate> list = nodetemplateService.selectNodetemplateList(nodetemplate); List<Nodetemplate> list = nodetemplateService.selectNodetemplateList(nodetemplate);
if (CollectionUtils.isEmpty(list)) { if (CollectionUtils.isEmpty(list)) {
@@ -72,18 +103,19 @@ public class NodetemplateController extends BaseController {
dto.setDescription(template.getDescription()); dto.setDescription(template.getDescription());
dto.setEnglishName(template.getEnglishName()); dto.setEnglishName(template.getEnglishName());
dto.setLogicHandler(template.getLogicHandler()); dto.setLogicHandler(template.getLogicHandler());
dto.setTemplateType(template.getTemplateType());
return dto; return dto;
}) })
.collect(Collectors.groupingBy(NodetemplateDTO::getTempleteType)); .collect(Collectors.groupingBy(NodetemplateDTO::getTemplateType));
List<NodetemplateVO> vos = new ArrayList<>(); List<NodetemplateVO> vos = new ArrayList<>();
groupedByTemplateType.forEach((key, value) -> { groupedByTemplateType.forEach((key, value) -> {
// 处理逻辑 // 处理逻辑
NodetemplateVO vo = new NodetemplateVO(); NodetemplateVO vo = new NodetemplateVO();
vo.setTempleteType(key); vo.setTemplateType(key);
vo.setDtoList(value); vo.setDtoList(value);
vos.add(vo); vos.add(vo);
}); });
return R.ok(vos); return R.ok(list);
} }
/** /**

View File

@@ -28,7 +28,7 @@ import com.solution.common.core.page.TableDataInfo;
* @date 2026-02-05 * @date 2026-02-05
*/ */
@RestController @RestController
@RequestMapping("/system/templateparameterdef") @RequestMapping("/api/system/templateparameterdef")
public class TemplateparameterdefController extends BaseController public class TemplateparameterdefController extends BaseController
{ {
@Autowired @Autowired

View File

@@ -48,7 +48,7 @@ import com.solution.common.core.page.TableDataInfo;
*/ */
@Api("行为树实例节点管理") @Api("行为树实例节点管理")
@RestController @RestController
@RequestMapping("/system/treenodeinstance") @RequestMapping("/api/system/treenodeinstance")
public class TreenodeinstanceController extends BaseController { public class TreenodeinstanceController extends BaseController {
@Autowired @Autowired
private ITreenodeinstanceService treenodeinstanceService; private ITreenodeinstanceService treenodeinstanceService;
@@ -141,14 +141,15 @@ public class TreenodeinstanceController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:treenodeinstance:add')") @PreAuthorize("@ss.hasPermi('system:treenodeinstance:add')")
@Log(title = "行为树实例节点", businessType = BusinessType.INSERT) @Log(title = "行为树实例节点", businessType = BusinessType.INSERT)
@PostMapping("/saveOrUpdate") @PostMapping("/saveOrUpdate")
public R<Integer> saveOrUpdate(@RequestBody Treenodeinstance treenodeinstance) { public R<Long> saveOrUpdate(@RequestBody Treenodeinstance treenodeinstance) {
if (null == treenodeinstance.getId()) { if (null == treenodeinstance.getId()) {
//新增 //新增
treenodeinstanceService.insertTreenodeinstance(treenodeinstance);
Templateparameterdef templateparameterdef = new Templateparameterdef(); Templateparameterdef templateparameterdef = new Templateparameterdef();
templateparameterdef.setTemplateId(treenodeinstance.getTemplateId()); templateparameterdef.setTemplateId(treenodeinstance.getTemplateId());
List<Templateparameterdef> templateparameterdefs = templateparameterdefService.selectTemplateparameterdefList(templateparameterdef); List<Templateparameterdef> templateparameterdefs = templateparameterdefService.selectTemplateparameterdefList(templateparameterdef);
if (CollectionUtils.isEmpty(templateparameterdefs)) { if (CollectionUtils.isEmpty(templateparameterdefs)) {
return R.ok(treenodeinstanceService.insertTreenodeinstance(treenodeinstance)); return R.ok(treenodeinstance.getId());
} }
templateparameterdefs.forEach(t -> { templateparameterdefs.forEach(t -> {
Nodeparameter nodeparameter = new Nodeparameter(); Nodeparameter nodeparameter = new Nodeparameter();
@@ -158,7 +159,8 @@ public class TreenodeinstanceController extends BaseController {
nodeparameterService.insertNodeparameter(nodeparameter); nodeparameterService.insertNodeparameter(nodeparameter);
}); });
} }
return R.ok(treenodeinstanceService.updateTreenodeinstance(treenodeinstance)); treenodeinstanceService.updateTreenodeinstance(treenodeinstance);
return R.ok(treenodeinstance.getId());
} }
/** /**

View File

@@ -23,7 +23,7 @@ public class NodetemplateDTO {
@ApiModelProperty("afsim 中转换的节点名") @ApiModelProperty("afsim 中转换的节点名")
private String englishName; private String englishName;
private String templeteType; private String templateType;
public Long getId() { public Long getId() {
return id; return id;
@@ -65,11 +65,11 @@ public class NodetemplateDTO {
this.englishName = englishName; this.englishName = englishName;
} }
public String getTempleteType() { public String getTemplateType() {
return templeteType; return templateType;
} }
public void setTempleteType(String templeteType) { public void setTemplateType(String templateType) {
this.templeteType = templeteType; this.templateType = templateType;
} }
} }

View File

@@ -9,17 +9,17 @@ import java.util.List;
public class NodetemplateVO { public class NodetemplateVO {
/** 模版类型节点模版或者条件判断例如“node”precondition“ */ /** 模版类型节点模版或者条件判断例如“node”precondition“ */
@ApiModelProperty("模版类型节点模版或者条件判断例如“node”precondition“") @ApiModelProperty("模版类型节点模版或者条件判断例如“node”precondition“")
private String templeteType; private String templateType;
@ApiModelProperty("节点模板数据") @ApiModelProperty("节点模板数据")
private List<NodetemplateDTO> dtoList; private List<NodetemplateDTO> dtoList;
public String getTempleteType() { public String getTemplateType() {
return templeteType; return templateType;
} }
public void setTempleteType(String templeteType) { public void setTemplateType(String templateType) {
this.templeteType = templeteType; this.templateType = templateType;
} }
public List<NodetemplateDTO> getDtoList() { public List<NodetemplateDTO> getDtoList() {

View File

@@ -0,0 +1,160 @@
package com.solution.web.core;
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2026 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.solution.system.domain.*;
import com.solution.system.service.IBehaviortreeService;
import com.solution.system.service.INodeconnectionService;
import com.solution.system.service.INodeparameterService;
import com.solution.system.service.ITreenodeinstanceService;
import com.solution.web.core.graph.Graph;
import com.solution.web.core.graph.GraphEdge;
import com.solution.web.core.graph.GraphNode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
@Component
public class BehaviortreeProcessor {
@Autowired
private IBehaviortreeService behaviortreeService;
@Autowired
private ITreenodeinstanceService treenodeinstanceService;
@Autowired
private INodeparameterService nodeparameterService;
@Autowired
private INodeconnectionService nodeconnectionService;
private ObjectMapper objectMapper = createObjectMapper();
public static ObjectMapper createObjectMapper() {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
return objectMapper;
}
public int create(Behaviortree behaviortree) {
int result = behaviortreeService.insertBehaviortree(behaviortree);
processGraph(behaviortree);
return result;
}
public int update(Behaviortree behaviortree) {
int result = behaviortreeService.updateBehaviortree(behaviortree);
// 删除节点实例
treenodeinstanceService.deleteByTreeId(behaviortree.getId());
// 删除参数
nodeparameterService.deleteByTreeId(behaviortree.getId());
// 删除连线
nodeconnectionService.deleteByTreeId(behaviortree.getId());
processGraph(behaviortree);
return result;
}
private void processGraph(Behaviortree behaviortree) {
Graph graph = null;
try {
graph = objectMapper.readValue(behaviortree.getXmlContent(), Graph.class);
} catch (Exception e) {
// skip
e.printStackTrace();
}
if (null == graph) {
return;
}
// 插入节点 treenodeinstance
Map<String, Treenodeinstance> instanceKeyMap = new HashMap<>();
Map<String, Long> nodeKeyIndexMap = new HashMap<>();
if (graph.hasNodes()) {
Long index = 0L;
for (GraphNode node : graph.getNodes()) {
Treenodeinstance instance = createNodeInstance(behaviortree, node);
treenodeinstanceService.insertTreenodeinstance(instance);
instanceKeyMap.put(node.getKey(), instance);
if (node.hasParameters()) {
// 插入parameter nodeparameter
for (Templateparameterdef parameter : node.getParameters()) {
Nodeparameter nodeparameter = createNodeParameter(behaviortree, parameter, instance);
nodeparameterService.insertNodeparameter(nodeparameter);
}
}
nodeKeyIndexMap.put(node.getKey(), index);
index++;
}
}
// 插入连线 nodeconnection
if (graph.hasEdges()) {
for (GraphEdge edge : graph.getEdges()) {
Nodeconnection connection = createConnection(behaviortree, edge, instanceKeyMap, nodeKeyIndexMap);
nodeconnectionService.insertNodeconnection(connection);
}
}
}
private Nodeconnection createConnection(Behaviortree behaviortree, GraphEdge edge,
Map<String, Treenodeinstance> instanceKeyMap,
Map<String, Long> nodeKeyIndexMap) {
Nodeconnection connection = new Nodeconnection();
connection.setTreeId(behaviortree.getId());
if (null != instanceKeyMap.get(edge.getSource().getCell())) {
Treenodeinstance parent = instanceKeyMap.get(edge.getSource().getCell());
connection.setParentNodeId(parent.getId());
}
if (null != instanceKeyMap.get(edge.getTarget().getCell())) {
Treenodeinstance children = instanceKeyMap.get(edge.getTarget().getCell());
connection.setChildNodeId(children.getId());
}
if (null != nodeKeyIndexMap.get(edge.getSource().getCell())) {
connection.setOrderIndex(nodeKeyIndexMap.get(edge.getSource().getCell()));
}
return connection;
}
private Nodeparameter createNodeParameter(Behaviortree behaviortree, Templateparameterdef parameter,
Treenodeinstance instance) {
Nodeparameter nodeparameter = new Nodeparameter();
nodeparameter.setTreeId(behaviortree.getId());
nodeparameter.setNodeInstanceId(instance.getId());
nodeparameter.setParamDefId(parameter.getId());
nodeparameter.setValue(parameter.getDefaultValue());
return nodeparameter;
}
private Treenodeinstance createNodeInstance(Behaviortree behaviortree, GraphNode node) {
Treenodeinstance instance = new Treenodeinstance();
instance.setTreeId(behaviortree.getId());
instance.setTemplateId((long) node.getTemplate());
instance.setInstanceName(node.getName());
instance.setIsRoot((long) (node.isRoot() ? 1 : 0));
if ("precondition".equalsIgnoreCase(node.getTemplateType())) {
instance.setPreconditionTempleteId((long) node.getTemplate());
}
return instance;
}
}

View File

@@ -0,0 +1,52 @@
package com.solution.web.core.graph;
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2026 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
import java.io.Serializable;
import java.util.List;
public class Graph implements Serializable {
private List<GraphNode> nodes;
private List<GraphEdge> edges;
public boolean hasNodes() {
return nodes != null && !nodes.isEmpty();
}
public boolean hasEdges() {
return edges != null && !edges.isEmpty();
}
@Override
public String toString() {
return "Graph{" +
"nodes=" + nodes +
", edges=" + edges +
'}';
}
public List<GraphNode> getNodes() {
return nodes;
}
public void setNodes(List<GraphNode> nodes) {
this.nodes = nodes;
}
public List<GraphEdge> getEdges() {
return edges;
}
public void setEdges(List<GraphEdge> edges) {
this.edges = edges;
}
}

View File

@@ -0,0 +1,85 @@
package com.solution.web.core.graph;
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2026 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
import org.springframework.util.StringUtils;
import java.io.Serializable;
public class GraphEdge implements Serializable {
private String key;
private Line source;
private Line target;
public boolean hasSource() {
return source != null && StringUtils.hasText(source.cell);
}
public boolean hasTarget() {
return target != null && StringUtils.hasText(target.cell);
}
public static class Line implements Serializable {
private String cell;
@Override
public String toString() {
return "Line{" +
"cell='" + cell + '\'' +
'}';
}
public String getCell() {
return cell;
}
public void setCell(String cell) {
this.cell = cell;
}
}
@Override
public String toString() {
return "GraphEdge{" +
"key='" + key + '\'' +
", source='" + source + '\'' +
", target='" + target + '\'' +
'}';
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public Line getSource() {
return source;
}
public void setSource(Line source) {
this.source = source;
}
public Line getTarget() {
return target;
}
public void setTarget(Line target) {
this.target = target;
}
}

View File

@@ -0,0 +1,142 @@
package com.solution.web.core.graph;
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2026 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
import com.solution.system.domain.Templateparameterdef;
import java.io.Serializable;
import java.util.List;
public class GraphNode implements Serializable {
private int id;
private int template;
private String templateType;
private String type;
private String key;
private String name;
private String description;
private String category;
private List<Templateparameterdef> parameters;
private List<GraphVariable> variables;
public boolean hasParameters() {
return parameters != null && !parameters.isEmpty();
}
public boolean hasVariables() {
return variables != null && !variables.isEmpty();
}
public boolean isRoot() {
return "root".equalsIgnoreCase(this.category);
}
@Override
public String toString() {
return "GraphNode{" +
"id=" + id +
", key='" + key + '\'' +
", name='" + name + '\'' +
", description='" + description + '\'' +
", parameters=" + parameters +
", variables=" + variables +
'}';
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getTemplateType() {
return templateType;
}
public void setTemplateType(String templateType) {
this.templateType = templateType;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getTemplate() {
return template;
}
public void setTemplate(int template) {
this.template = template;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public List<Templateparameterdef> getParameters() {
return parameters;
}
public void setParameters(List<Templateparameterdef> parameters) {
this.parameters = parameters;
}
public List<GraphVariable> getVariables() {
return variables;
}
public void setVariables(List<GraphVariable> variables) {
this.variables = variables;
}
}

View File

@@ -0,0 +1,65 @@
package com.solution.web.core.graph;
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2026 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
import java.io.Serializable;
public class GraphVariable implements Serializable {
private String key;
private String value;
private String defaults;
private String unit;
@Override
public String toString() {
return "GraphVariable{" +
"key='" + key + '\'' +
", value='" + value + '\'' +
", defaults='" + defaults + '\'' +
", unit='" + unit + '\'' +
'}';
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getDefaults() {
return defaults;
}
public void setDefaults(String defaults) {
this.defaults = defaults;
}
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
}

View File

@@ -0,0 +1,89 @@
package com.solution.algo;
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2026 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.CollectionType;
import com.solution.algo.domain.AlgorithmConfig;
import org.apache.ibatis.type.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
@Component
@MappedTypes(List.class)
@MappedJdbcTypes({
JdbcType.VARCHAR,
JdbcType.BLOB
})
public class AlgorithmConfigTypeHandler extends BaseTypeHandler<List<AlgorithmConfig>>
implements TypeHandler<List<AlgorithmConfig>> {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final ObjectMapper objectMapper = new ObjectMapper();
private final CollectionType collectionType = objectMapper.getTypeFactory()
.constructCollectionType(List.class, AlgorithmConfig.class);
@Override
public void setNonNullParameter(PreparedStatement ps, int i, List<AlgorithmConfig> parameter, JdbcType jdbcType)
throws SQLException {
ps.setString(i, serialize(parameter));
}
public String serialize(List<AlgorithmConfig> indicatorConfig) {
if (null != indicatorConfig) {
try {
return objectMapper.writeValueAsString(indicatorConfig);
} catch (Exception e) {
logger.error("Can not serialize", e);
}
}
return null;
}
public List<AlgorithmConfig> deserialize(String config) throws SQLException {
if (StringUtils.hasText(config)) {
try {
return objectMapper.readValue(config, collectionType);
} catch (Exception e) {
logger.error("Can not deserialize", e);
}
}
return new ArrayList<>();
}
@Override
public List<AlgorithmConfig> getNullableResult(ResultSet rs, String columnName) throws SQLException {
String jsonValue = rs.getString(columnName);
return deserialize(jsonValue);
}
@Override
public List<AlgorithmConfig> getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
String jsonValue = rs.getString(columnIndex);
return deserialize(jsonValue);
}
@Override
public List<AlgorithmConfig> getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
String jsonValue = cs.getString(columnIndex);
return deserialize(jsonValue);
}
}

View File

@@ -34,6 +34,13 @@ public class Algorithm
@Excel(name = "算法描述") @Excel(name = "算法描述")
private String description; private String description;
/** 算法配置 */
@Excel(name = "算法配置")
private String algoConfig;
/** 算法配置 */
private List<AlgorithmConfig> algoConfigList;
/** 算法参数定义信息 */ /** 算法参数定义信息 */
private List<AlgorithmParam> algorithmParamList; private List<AlgorithmParam> algorithmParamList;
@@ -87,6 +94,16 @@ public class Algorithm
return description; return description;
} }
public void setAlgoConfig(String algoConfig)
{
this.algoConfig = algoConfig;
}
public String getAlgoConfig()
{
return algoConfig;
}
public List<AlgorithmParam> getAlgorithmParamList() public List<AlgorithmParam> getAlgorithmParamList()
{ {
return algorithmParamList; return algorithmParamList;
@@ -97,6 +114,14 @@ public class Algorithm
this.algorithmParamList = algorithmParamList; this.algorithmParamList = algorithmParamList;
} }
public List<AlgorithmConfig> getAlgoConfigList() {
return algoConfigList;
}
public void setAlgoConfigList(List<AlgorithmConfig> algoConfigList) {
this.algoConfigList = algoConfigList;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@@ -105,6 +130,7 @@ public class Algorithm
.append("type", getType()) .append("type", getType())
.append("codePath", getCodePath()) .append("codePath", getCodePath())
.append("description", getDescription()) .append("description", getDescription())
.append("algoConfig", getAlgoConfig())
.append("algorithmParamList", getAlgorithmParamList()) .append("algorithmParamList", getAlgorithmParamList())
.toString(); .toString();
} }

View File

@@ -0,0 +1,35 @@
package com.solution.algo.domain;
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2026 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
import java.io.Serializable;
public class AlgorithmConfig implements Serializable {
private String name;
private String operation;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getOperation() {
return operation;
}
public void setOperation(String operation) {
this.operation = operation;
}
}

View File

@@ -10,6 +10,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="type" column="type" /> <result property="type" column="type" />
<result property="codePath" column="code_path" /> <result property="codePath" column="code_path" />
<result property="description" column="description" /> <result property="description" column="description" />
<result property="algoConfig" column="algo_config" />
<result property="algoConfigList" column="algo_config_list" typeHandler="com.solution.algo.AlgorithmConfigTypeHandler" />
</resultMap> </resultMap>
<resultMap id="AlgorithmAlgorithmParamResult" type="Algorithm" extends="AlgorithmResult"> <resultMap id="AlgorithmAlgorithmParamResult" type="Algorithm" extends="AlgorithmResult">
@@ -25,7 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectAlgorithmVo"> <sql id="selectAlgorithmVo">
select id, name, type, code_path, description from algorithm select id, name, type, code_path, description, algo_config, algo_config_list from algorithm
</sql> </sql>
<select id="selectAlgorithmList" parameterType="Algorithm" resultMap="AlgorithmAlgorithmParamResult"> <select id="selectAlgorithmList" parameterType="Algorithm" resultMap="AlgorithmAlgorithmParamResult">
@@ -35,11 +37,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="type != null and type != ''"> and type = #{type}</if> <if test="type != null and type != ''"> and type = #{type}</if>
<if test="codePath != null and codePath != ''"> and code_path = #{codePath}</if> <if test="codePath != null and codePath != ''"> and code_path = #{codePath}</if>
<if test="description != null and description != ''"> and description = #{description}</if> <if test="description != null and description != ''"> and description = #{description}</if>
<if test="algoConfig != null and algoConfig != ''"> and algo_config = #{algoConfig}</if>
</where> </where>
</select> </select>
<select id="selectAlgorithmById" parameterType="Long" resultMap="AlgorithmAlgorithmParamResult"> <select id="selectAlgorithmById" parameterType="Long" resultMap="AlgorithmAlgorithmParamResult">
select id, name, type, code_path, description select id, name, type, code_path, description, algo_config
from algorithm from algorithm
where id = #{id} where id = #{id}
</select> </select>
@@ -57,12 +60,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="type != null and type != ''">type,</if> <if test="type != null and type != ''">type,</if>
<if test="codePath != null">code_path,</if> <if test="codePath != null">code_path,</if>
<if test="description != null">description,</if> <if test="description != null">description,</if>
<if test="algoConfig != null">algo_config,</if>
<if test="algoConfigList != null">algo_config_list,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">#{name},</if> <if test="name != null and name != ''">#{name},</if>
<if test="type != null and type != ''">#{type},</if> <if test="type != null and type != ''">#{type},</if>
<if test="codePath != null">#{codePath},</if> <if test="codePath != null">#{codePath},</if>
<if test="description != null">#{description},</if> <if test="description != null">#{description},</if>
<if test="algoConfig != null">#{algoConfig},</if>
<if test="algoConfigList != null">#{algoConfigList,typeHandler=com.solution.algo.AlgorithmConfigTypeHandler},</if>
</trim> </trim>
</insert> </insert>
@@ -73,6 +80,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="type != null and type != ''">type = #{type},</if> <if test="type != null and type != ''">type = #{type},</if>
<if test="codePath != null">code_path = #{codePath},</if> <if test="codePath != null">code_path = #{codePath},</if>
<if test="description != null">description = #{description},</if> <if test="description != null">description = #{description},</if>
<if test="algoConfig != null">algo_config = #{algoConfig},</if>
<if test="algoConfigList != null">algo_config_list = #{algoConfigList,typeHandler=com.solution.algo.AlgorithmConfigTypeHandler},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>

View File

@@ -0,0 +1,43 @@
package com.solution.system.domain;
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2026 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
import java.util.ArrayList;
import java.util.List;
public class NodeTemplateEntity extends Nodetemplate {
private List<Templateparameterdef> parameters = new ArrayList<>();
public NodeTemplateEntity() {
}
public NodeTemplateEntity(List<Templateparameterdef> parameters) {
this.parameters = parameters;
}
public NodeTemplateEntity(NodeTemplateEntity entity) {
super(entity);
this.parameters = entity.getParameters();
}
public NodeTemplateEntity(Nodetemplate entity, List<Templateparameterdef> parameters) {
super(entity);
this.parameters = parameters;
}
public List<Templateparameterdef> getParameters() {
return parameters;
}
public void setParameters(List<Templateparameterdef> parameters) {
this.parameters = parameters;
}
}

View File

@@ -18,6 +18,8 @@ public class Nodeconnection extends BaseEntity
/** 连接ID (主键) */ /** 连接ID (主键) */
private Long id; private Long id;
private Long treeId;
/** 父节点 (外键: TreeInstanceNode.id) */ /** 父节点 (外键: TreeInstanceNode.id) */
@Excel(name = "父节点 (外键: TreeInstanceNode.id)") @Excel(name = "父节点 (外键: TreeInstanceNode.id)")
private Long parentNodeId; private Long parentNodeId;
@@ -40,6 +42,14 @@ public class Nodeconnection extends BaseEntity
return id; return id;
} }
public Long getTreeId() {
return treeId;
}
public void setTreeId(Long treeId) {
this.treeId = treeId;
}
public void setParentNodeId(Long parentNodeId) public void setParentNodeId(Long parentNodeId)
{ {
this.parentNodeId = parentNodeId; this.parentNodeId = parentNodeId;

View File

@@ -18,6 +18,8 @@ public class Nodeparameter extends BaseEntity
/** 节点参数ID (主键) */ /** 节点参数ID (主键) */
private Long id; private Long id;
private Long treeId;
/** 关联到哪个节点实例 (外键: TreeInstanceNode.id) */ /** 关联到哪个节点实例 (外键: TreeInstanceNode.id) */
@Excel(name = "关联到哪个节点实例 (外键: TreeInstanceNode.id)") @Excel(name = "关联到哪个节点实例 (外键: TreeInstanceNode.id)")
private Long nodeInstanceId; private Long nodeInstanceId;
@@ -40,6 +42,14 @@ public class Nodeparameter extends BaseEntity
return id; return id;
} }
public Long getTreeId() {
return treeId;
}
public void setTreeId(Long treeId) {
this.treeId = treeId;
}
public void setNodeInstanceId(Long nodeInstanceId) public void setNodeInstanceId(Long nodeInstanceId)
{ {
this.nodeInstanceId = nodeInstanceId; this.nodeInstanceId = nodeInstanceId;

View File

@@ -40,7 +40,20 @@ public class Nodetemplate extends BaseEntity
/** 模版类型节点模版或者条件判断例如“node”precondition“ */ /** 模版类型节点模版或者条件判断例如“node”precondition“ */
@Excel(name = "模版类型节点模版或者条件判断例如“node”precondition“") @Excel(name = "模版类型节点模版或者条件判断例如“node”precondition“")
private String templeteType; private String templateType;
public Nodetemplate() {
}
public Nodetemplate(Nodetemplate template) {
this.id = template.id;
this.type = template.type;
this.name = template.name;
this.logicHandler = template.logicHandler;
this.description = template.description;
this.englishName = template.englishName;
this.templateType = template.templateType;
}
public void setId(Long id) public void setId(Long id)
{ {
@@ -102,14 +115,14 @@ public class Nodetemplate extends BaseEntity
return englishName; return englishName;
} }
public void setTempleteType(String templeteType) public void setTemplateType(String templateType)
{ {
this.templeteType = templeteType; this.templateType = templateType;
} }
public String getTempleteType() public String getTemplateType()
{ {
return templeteType; return templateType;
} }
@Override @Override
@@ -121,7 +134,7 @@ public class Nodetemplate extends BaseEntity
.append("logicHandler", getLogicHandler()) .append("logicHandler", getLogicHandler())
.append("description", getDescription()) .append("description", getDescription())
.append("englishName", getEnglishName()) .append("englishName", getEnglishName())
.append("templeteType", getTempleteType()) .append("templateType", getTemplateType())
.toString(); .toString();
} }
} }

View File

@@ -2,6 +2,7 @@ package com.solution.system.mapper;
import java.util.List; import java.util.List;
import com.solution.system.domain.Nodeconnection; import com.solution.system.domain.Nodeconnection;
import org.apache.ibatis.annotations.Param;
/** /**
* 节点连接Mapper接口 * 节点连接Mapper接口
@@ -11,6 +12,8 @@ import com.solution.system.domain.Nodeconnection;
*/ */
public interface NodeconnectionMapper public interface NodeconnectionMapper
{ {
void deleteByTreeId(@Param("treeId") Long treeId);
/** /**
* 查询节点连接 * 查询节点连接
* *

View File

@@ -2,6 +2,7 @@ package com.solution.system.mapper;
import java.util.List; import java.util.List;
import com.solution.system.domain.Nodeparameter; import com.solution.system.domain.Nodeparameter;
import org.apache.ibatis.annotations.Param;
/** /**
* 节点参数Mapper接口 * 节点参数Mapper接口
@@ -11,6 +12,8 @@ import com.solution.system.domain.Nodeparameter;
*/ */
public interface NodeparameterMapper public interface NodeparameterMapper
{ {
void deleteByTreeId(@Param("treeId") Long treeId);
/** /**
* 查询节点参数 * 查询节点参数
* *

View File

@@ -2,6 +2,7 @@ package com.solution.system.mapper;
import java.util.List; import java.util.List;
import com.solution.system.domain.Treenodeinstance; import com.solution.system.domain.Treenodeinstance;
import org.apache.ibatis.annotations.Param;
/** /**
* 行为树实例节点Mapper接口 * 行为树实例节点Mapper接口
@@ -11,6 +12,8 @@ import com.solution.system.domain.Treenodeinstance;
*/ */
public interface TreenodeinstanceMapper public interface TreenodeinstanceMapper
{ {
void deleteByTreeId(@Param(value = "treeId") Long treeId);
/** /**
* 查询行为树实例节点 * 查询行为树实例节点
* *

View File

@@ -2,6 +2,7 @@ package com.solution.system.service;
import java.util.List; import java.util.List;
import com.solution.system.domain.Nodeconnection; import com.solution.system.domain.Nodeconnection;
import org.apache.ibatis.annotations.Param;
/** /**
* 节点连接Service接口 * 节点连接Service接口
@@ -11,6 +12,9 @@ import com.solution.system.domain.Nodeconnection;
*/ */
public interface INodeconnectionService public interface INodeconnectionService
{ {
void deleteByTreeId(@Param("treeId") Long treeId);
/** /**
* 查询节点连接 * 查询节点连接
* *

View File

@@ -11,6 +11,9 @@ import com.solution.system.domain.Nodeparameter;
*/ */
public interface INodeparameterService public interface INodeparameterService
{ {
void deleteByTreeId(Long treeId);
/** /**
* 查询节点参数 * 查询节点参数
* *

View File

@@ -11,6 +11,9 @@ import com.solution.system.domain.Treenodeinstance;
*/ */
public interface ITreenodeinstanceService public interface ITreenodeinstanceService
{ {
void deleteByTreeId(Long treeId);
/** /**
* 查询行为树实例节点 * 查询行为树实例节点
* *

View File

@@ -19,6 +19,11 @@ public class NodeconnectionServiceImpl implements INodeconnectionService
@Autowired @Autowired
private NodeconnectionMapper nodeconnectionMapper; private NodeconnectionMapper nodeconnectionMapper;
@Override
public void deleteByTreeId(Long treeId) {
nodeconnectionMapper.deleteByTreeId(treeId);
}
/** /**
* 查询节点连接 * 查询节点连接
* *

View File

@@ -19,6 +19,11 @@ public class NodeparameterServiceImpl implements INodeparameterService
@Autowired @Autowired
private NodeparameterMapper nodeparameterMapper; private NodeparameterMapper nodeparameterMapper;
@Override
public void deleteByTreeId(Long treeId) {
nodeparameterMapper.deleteByTreeId(treeId);
}
/** /**
* 查询节点参数 * 查询节点参数
* *

View File

@@ -19,6 +19,11 @@ public class TreenodeinstanceServiceImpl implements ITreenodeinstanceService
@Autowired @Autowired
private TreenodeinstanceMapper treenodeinstanceMapper; private TreenodeinstanceMapper treenodeinstanceMapper;
@Override
public void deleteByTreeId(Long treeId) {
treenodeinstanceMapper.deleteByTreeId(treeId);
}
/** /**
* 查询行为树实例节点 * 查询行为树实例节点
* *

View File

@@ -6,18 +6,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="Nodeconnection" id="NodeconnectionResult"> <resultMap type="Nodeconnection" id="NodeconnectionResult">
<result property="id" column="id" /> <result property="id" column="id" />
<result property="treeId" column="tree_id" />
<result property="parentNodeId" column="parent_node_id" /> <result property="parentNodeId" column="parent_node_id" />
<result property="childNodeId" column="child_node_id" /> <result property="childNodeId" column="child_node_id" />
<result property="orderIndex" column="order_index" /> <result property="orderIndex" column="order_index" />
</resultMap> </resultMap>
<delete id="deleteByTreeId">
delete from nodeconnection where tree_id=#{treeId}
</delete>
<sql id="selectNodeconnectionVo"> <sql id="selectNodeconnectionVo">
select id, parent_node_id, child_node_id, order_index from nodeconnection select id, tree_id, parent_node_id, child_node_id, order_index from nodeconnection
</sql> </sql>
<select id="selectNodeconnectionList" parameterType="Nodeconnection" resultMap="NodeconnectionResult"> <select id="selectNodeconnectionList" parameterType="Nodeconnection" resultMap="NodeconnectionResult">
<include refid="selectNodeconnectionVo"/> <include refid="selectNodeconnectionVo"/>
<where> <where>
<if test="treeId != null "> and tree_id = #{treeId}</if>
<if test="parentNodeId != null "> and parent_node_id = #{parentNodeId}</if> <if test="parentNodeId != null "> and parent_node_id = #{parentNodeId}</if>
<if test="childNodeId != null "> and child_node_id = #{childNodeId}</if> <if test="childNodeId != null "> and child_node_id = #{childNodeId}</if>
<if test="orderIndex != null "> and order_index = #{orderIndex}</if> <if test="orderIndex != null "> and order_index = #{orderIndex}</if>
@@ -32,11 +38,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertNodeconnection" parameterType="Nodeconnection" useGeneratedKeys="true" keyProperty="id"> <insert id="insertNodeconnection" parameterType="Nodeconnection" useGeneratedKeys="true" keyProperty="id">
insert into nodeconnection insert into nodeconnection
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="treeId != null">tree_id,</if>
<if test="parentNodeId != null">parent_node_id,</if> <if test="parentNodeId != null">parent_node_id,</if>
<if test="childNodeId != null">child_node_id,</if> <if test="childNodeId != null">child_node_id,</if>
<if test="orderIndex != null">order_index,</if> <if test="orderIndex != null">order_index,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="treeId != null">#{treeId},</if>
<if test="parentNodeId != null">#{parentNodeId},</if> <if test="parentNodeId != null">#{parentNodeId},</if>
<if test="childNodeId != null">#{childNodeId},</if> <if test="childNodeId != null">#{childNodeId},</if>
<if test="orderIndex != null">#{orderIndex},</if> <if test="orderIndex != null">#{orderIndex},</if>
@@ -46,6 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateNodeconnection" parameterType="Nodeconnection"> <update id="updateNodeconnection" parameterType="Nodeconnection">
update nodeconnection update nodeconnection
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="treeId != null">tree_id = #{treeId},</if>
<if test="parentNodeId != null">parent_node_id = #{parentNodeId},</if> <if test="parentNodeId != null">parent_node_id = #{parentNodeId},</if>
<if test="childNodeId != null">child_node_id = #{childNodeId},</if> <if test="childNodeId != null">child_node_id = #{childNodeId},</if>
<if test="orderIndex != null">order_index = #{orderIndex},</if> <if test="orderIndex != null">order_index = #{orderIndex},</if>

View File

@@ -6,13 +6,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="Nodeparameter" id="NodeparameterResult"> <resultMap type="Nodeparameter" id="NodeparameterResult">
<result property="id" column="id" /> <result property="id" column="id" />
<result property="treeId" column="tree_id" />
<result property="nodeInstanceId" column="node_instance_id" /> <result property="nodeInstanceId" column="node_instance_id" />
<result property="paramDefId" column="param_def_id" /> <result property="paramDefId" column="param_def_id" />
<result property="value" column="value" /> <result property="value" column="value" />
</resultMap> </resultMap>
<delete id="deleteByTreeId">
delete from nodeparameter where tree_id=#{treeId}
</delete>
<sql id="selectNodeparameterVo"> <sql id="selectNodeparameterVo">
select id, node_instance_id, param_def_id, value from nodeparameter select id, treeId, node_instance_id, param_def_id, value from nodeparameter
</sql> </sql>
<select id="selectNodeparameterList" parameterType="Nodeparameter" resultMap="NodeparameterResult"> <select id="selectNodeparameterList" parameterType="Nodeparameter" resultMap="NodeparameterResult">
@@ -32,11 +37,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertNodeparameter" parameterType="Nodeparameter" useGeneratedKeys="true" keyProperty="id"> <insert id="insertNodeparameter" parameterType="Nodeparameter" useGeneratedKeys="true" keyProperty="id">
insert into nodeparameter insert into nodeparameter
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="treeId != null">tree_id,</if>
<if test="nodeInstanceId != null">node_instance_id,</if> <if test="nodeInstanceId != null">node_instance_id,</if>
<if test="paramDefId != null">param_def_id,</if> <if test="paramDefId != null">param_def_id,</if>
<if test="value != null">value,</if> <if test="value != null">value,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="treeId != null">#{treeId},</if>
<if test="nodeInstanceId != null">#{nodeInstanceId},</if> <if test="nodeInstanceId != null">#{nodeInstanceId},</if>
<if test="paramDefId != null">#{paramDefId},</if> <if test="paramDefId != null">#{paramDefId},</if>
<if test="value != null">#{value},</if> <if test="value != null">#{value},</if>
@@ -46,6 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateNodeparameter" parameterType="Nodeparameter"> <update id="updateNodeparameter" parameterType="Nodeparameter">
update nodeparameter update nodeparameter
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="treeId != null">tree_id = #{treeId},</if>
<if test="nodeInstanceId != null">node_instance_id = #{nodeInstanceId},</if> <if test="nodeInstanceId != null">node_instance_id = #{nodeInstanceId},</if>
<if test="paramDefId != null">param_def_id = #{paramDefId},</if> <if test="paramDefId != null">param_def_id = #{paramDefId},</if>
<if test="value != null">value = #{value},</if> <if test="value != null">value = #{value},</if>

View File

@@ -11,7 +11,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="logicHandler" column="logic_handler" /> <result property="logicHandler" column="logic_handler" />
<result property="description" column="description" /> <result property="description" column="description" />
<result property="englishName" column="english_name" /> <result property="englishName" column="english_name" />
<result property="templeteType" column="templete_type" /> <result property="templateType" column="templete_type" />
</resultMap> </resultMap>
<sql id="selectNodetemplateVo"> <sql id="selectNodetemplateVo">
@@ -26,7 +26,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="logicHandler != null and logicHandler != ''"> and logic_handler = #{logicHandler}</if> <if test="logicHandler != null and logicHandler != ''"> and logic_handler = #{logicHandler}</if>
<if test="description != null and description != ''"> and description = #{description}</if> <if test="description != null and description != ''"> and description = #{description}</if>
<if test="englishName != null and englishName != ''"> and english_name like concat('%', #{englishName}, '%')</if> <if test="englishName != null and englishName != ''"> and english_name like concat('%', #{englishName}, '%')</if>
<if test="templeteType != null and templeteType != ''"> and templete_type = #{templeteType}</if> <if test="templateType != null and templateType != ''"> and templete_type = #{templateType}</if>
</where> </where>
</select> </select>
@@ -43,7 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="logicHandler != null">logic_handler,</if> <if test="logicHandler != null">logic_handler,</if>
<if test="description != null">description,</if> <if test="description != null">description,</if>
<if test="englishName != null">english_name,</if> <if test="englishName != null">english_name,</if>
<if test="templeteType != null and templeteType != ''">templete_type,</if> <if test="templateType != null and templateType != ''">templete_type,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="type != null and type != ''">#{type},</if> <if test="type != null and type != ''">#{type},</if>
@@ -51,7 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="logicHandler != null">#{logicHandler},</if> <if test="logicHandler != null">#{logicHandler},</if>
<if test="description != null">#{description},</if> <if test="description != null">#{description},</if>
<if test="englishName != null">#{englishName},</if> <if test="englishName != null">#{englishName},</if>
<if test="templeteType != null and templeteType != ''">#{templeteType},</if> <if test="templateType != null and templateType != ''">#{templateType},</if>
</trim> </trim>
</insert> </insert>
@@ -63,7 +63,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="logicHandler != null">logic_handler = #{logicHandler},</if> <if test="logicHandler != null">logic_handler = #{logicHandler},</if>
<if test="description != null">description = #{description},</if> <if test="description != null">description = #{description},</if>
<if test="englishName != null">english_name = #{englishName},</if> <if test="englishName != null">english_name = #{englishName},</if>
<if test="templeteType != null and templeteType != ''">templete_type = #{templeteType},</if> <if test="templateType != null and templateType != ''">templete_type = #{templateType},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>

View File

@@ -15,6 +15,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="desciption" column="desciption" /> <result property="desciption" column="desciption" />
</resultMap> </resultMap>
<delete id="deleteByTreeId">
delete from treenodeinstance where tree_id=#{treeId}
</delete>
<sql id="selectTreenodeinstanceVo"> <sql id="selectTreenodeinstanceVo">
select id, tree_id, template_id, instance_name, is_root, precondition_templete_id, uuid,desciption from treenodeinstance select id, tree_id, template_id, instance_name, is_root, precondition_templete_id, uuid,desciption from treenodeinstance
</sql> </sql>

View File

@@ -4,7 +4,7 @@
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> <link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>博弈竞赛环境</title> <title>决策管理</title>
</head> </head>
<body> <body>
<div id="app" class="w-full h-full"></div> <div id="app" class="w-full h-full"></div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 MiB

After

Width:  |  Height:  |  Size: 418 KiB

View File

@@ -8,7 +8,7 @@
*/ */
export default { export default {
dashboardUrl: '/app/ai/project/management', dashboardUrl: '/app/decision/designer',
// 训练任务监控URL // 训练任务监控URL
taskMonitorUrl: 'http://192.168.1.100:8080', taskMonitorUrl: 'http://192.168.1.100:8080',
// 集群监控URL // 集群监控URL

View File

@@ -7,9 +7,39 @@
* that was distributed with this source code. * that was distributed with this source code.
*/ */
import { type RouteRecordRaw } from 'vue-router'; import { type RouteRecordRaw, type RouteRecordRedirect } from 'vue-router';
import { routers } from '@/views/ai/router';
export const routes: RouteRecordRaw[] = [ export const routes: RouteRecordRaw[] = [
...routers, {
name: 'index',
path: '/',
redirect: '/app/decision/designer',
meta: {
hidden: true,
},
} as RouteRecordRedirect,
{
name: 'signin',
path: '/signin',
meta: {
title: '登录',
},
component: () => import('@/views/signin.vue'),
},
{
name: 'decision-designer',
path: '/app/decision/designer',
meta: {
title: '决策树',
},
component: () => import('@/views/decision/designer.vue'),
},
{
name: 'decision-algorithm-management',
path: '/app/decision/algorithm/management',
meta: {
title: '指挥决策规则库管理',
},
component: () => import('@/views/decision/algorithm/management.vue'),
},
] ]

File diff suppressed because it is too large Load Diff

View File

@@ -34,3 +34,9 @@ export interface PageableResponse<T = any> extends BasicResponse {
[key: string]: unknown; [key: string]: unknown;
} }
export interface ApiPaginationQuery {
page: number;
limit: number;
keyword: NullableString;
}

View File

@@ -7,7 +7,16 @@
* that was distributed with this source code. * that was distributed with this source code.
*/ */
import type { NullableString } from '@/types';
export const generateKey = (type: string | null = ''): string => { export const generateKey = (type: string | null = ''): string => {
return `${type ? (type + '_') : ''}${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}` return `${type ? (type + '_') : ''}${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`
.replace('-', '_').toLowerCase(); .replace('-', '_').toLowerCase();
}; };
export const substring = (s: NullableString, n: number = 10, p: string = '...') => {
if (s) {
return s.length > n ? (s.substring(0, n) + p) : s;
}
return s;
};

View File

@@ -1,22 +0,0 @@
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2025 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
import request from '@/utils/request';
import type { DeductionTestResponse, FinderBrowserResult } from './types';
import type { NullableString } from '@/types';
export const findFinderBrowser = (path: NullableString): Promise<FinderBrowserResult> => {
return request.post<FinderBrowserResult>('/finder/browser', {
path: path,
});
};
export const startDeduction = (): Promise<DeductionTestResponse> => {
return request.postJson<DeductionTestResponse>('/deductionTest/startDeduction', {});
};

View File

@@ -1,36 +0,0 @@
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2025 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
import request from '@/utils/request';
import type { DeductionPodResult, ModelDeduction, ModelDeductionDataResponse, ModelDeductionDetailsResponse, ModelDeductionPodStatusResponse } from './types';
import type { BasicResponse } from '@/types';
export const findDeductionPodResult = (query: Record<any, any> = { pageSize: 1000 }): Promise<DeductionPodResult> => {
return request.get<DeductionPodResult>('/deductionPodInfo/listAll', query);
};
export const createModelDeduction = (deduction: Partial<ModelDeduction>): Promise<BasicResponse> => {
return request.postJson<BasicResponse>('/deductionPodInfo/add', deduction);
};
export const deleteModelDeduction = (id: number): Promise<BasicResponse> => {
return request.delete<BasicResponse>(`/deductionPodInfo/${id}`);
};
export const findOneModelDeductionDetails = (id: number): Promise<ModelDeductionDetailsResponse> => {
return request.get<ModelDeductionDetailsResponse>(`/deductionPodInfo/${id}`);
}
export const findChartsDataById = (id: number): Promise<ModelDeductionDataResponse> => {
return request.get<ModelDeductionDataResponse>(`/deductionPodData/listByPodId/${id}`);
};
export const runDeductionPodAfsimControl = (data: any): Promise<ModelDeductionPodStatusResponse> => {
return request.postJson<ModelDeductionPodStatusResponse>(`/deductionPodInfo/afsimControl`, data);
};

View File

@@ -1,117 +0,0 @@
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2026 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
import { xAxisConfig } from './config';
import * as echarts from 'echarts';
import type { ChartOption } from './types';
export const createAreaChartOption = (options: ChartOption) => {
let blueName = options.blueName ?? '蓝方';
let redName = options.redName ?? '红方';
return {
title: {
text: options.title,
textStyle: {
color: '#eee',
fontSize: 16,
},
},
tooltip: {
trigger: 'axis',
textStyle: {
color: '#999',
},
},
grid: {
left: '1%',
right: '5%',
bottom: '15%',
containLabel: true,
},
legend: {
data: [blueName, redName],
textStyle: {
color: '#ddd',
fontSize: 14,
},
},
xAxis: {
type: 'category',
data: options.xAxisData,
boundaryGap: [0.1, 0.1],
...xAxisConfig,
},
yAxis: {
type: 'value',
boundaryGap: [0, 0.1],
...xAxisConfig,
},
series: [
{
name: blueName,
data: options.blueData,
type: 'line',
areaStyle: {
opacity: 0.8,
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: '#0f86d7',
},
{
offset: 1,
color: '#0f1e48cc',
},
]),
},
itemStyle: {
color: '#409EFF', // 轮数1整体颜色
},
label: {
show: false, // 开启数值显示
position: 'top', // 数值显示在柱子顶部可选top/inside/outside/bottom等
textStyle: {
color: '#eee', // 数值文字颜色
fontSize: 12, // 数值文字大小
},
},
},
{
name: redName,
data: options.redData,
type: 'line',
areaStyle: {
opacity: 0.8,
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: '#dc5959',
},
{
offset: 1,
color: '#bc1f1f',
},
]),
},
itemStyle: {
color: '#bc1f1f', // 轮数2整体颜色
},
label: {
show: false, // 开启数值显示
position: 'top', // 数值显示在柱子顶部可选top/inside/outside/bottom等
textStyle: {
color: '#eee', // 数值文字颜色
fontSize: 12, // 数值文字大小
},
},
},
],
};
};

View File

@@ -1,96 +0,0 @@
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2026 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
import { getVerticalGradient, xAxisConfig } from './config';
import type { ChartOption } from './types';
export const createBarChartOption = (options: ChartOption) => {
let blueName = options.blueName ?? '蓝方';
let redName = options.redName ?? '红方';
return {
title: {
text: options.title,
textStyle: {
color: '#eee',
fontSize: 16
}
},
tooltip: {
trigger: 'axis',
textStyle: {
color: '#999'
}
},
grid: {
left: '1%',
right: '5%',
bottom: '15%',
containLabel: true
},
legend: {
data: [blueName, redName],
textStyle: {
color: '#ddd',
fontSize: 14
}
},
xAxis: {
type: 'category',
data: options.xAxisData,
boundaryGap: [0.1, 0.1],
...xAxisConfig
},
yAxis: {
type: 'value',
boundaryGap: [0.1, 0.5],
...xAxisConfig
},
series: [
{
name: blueName,
data: options.blueData,
type: 'bar',
barWidth: '20%',
barGap: '10%',
barCategoryGap: '30%',
itemStyle: {
color: getVerticalGradient('#409EFF', '#87CEFA')
},
label: {
show: false, // 开启数值显示
position: 'top', // 数值显示在柱子顶部可选top/inside/outside/bottom等
textStyle: {
color: '#eee', // 数值文字颜色
fontSize: 12 // 数值文字大小
}
}
},
{
name: redName,
data: options.redData,
type: 'bar',
barWidth: '20%',
barGap: '10%',
barCategoryGap: '30%',
itemStyle: {
color: getVerticalGradient('#bc1f1f', '#e67e7e')
},
label: {
show: false, // 开启数值显示
position: 'top', // 数值显示在柱子顶部可选top/inside/outside/bottom等
textStyle: {
color: '#eee', // 数值文字颜色
fontSize: 12 // 数值文字大小
}
}
}
]
};
};

View File

@@ -1,77 +0,0 @@
<template>
<div class="ks-model-chart-item" ref="chartContainer"></div>
</template>
<script lang="ts">
import { defineComponent, nextTick, type PropType, ref, watch } from 'vue';
import * as echarts from 'echarts';
import type { ModelDeductionData } from '../types';
import { createLineChartOption } from './line-options';
export default defineComponent({
props: {
datas: {
type: Array as PropType<ModelDeductionData[]>,
default: [],
},
redName: {
type: String as PropType<String>,
default: '红方',
},
blueName: {
type: String as PropType<String>,
default: '蓝方',
}
},
setup(props) {
const chartContainer = ref<HTMLElement | null>(null);
let chartInstance: echarts.ECharts | null = null;
const initChart = (option: any) => {
if (!chartContainer.value) return;
if (chartInstance) {
chartInstance.dispose();
}
chartInstance = echarts.init(chartContainer.value);
chartInstance.setOption(option);
// 自适应窗口大小(可选,提升体验)
window.addEventListener('resize', () => {
chartInstance?.resize();
});
};
const load = (d: ModelDeductionData[]) => {
const xAxisData: string[] = [];
const blueData: any[] = [];
const redData: any[] = [];
if (d) {
d.forEach(item => {
xAxisData.push(`轮数${item.currentEpisode}`);
blueData.push(item.episodeReturnsBlue);
redData.push(item.episodeReturnsRed);
});
}
const options = createLineChartOption({
title: '环境总奖励对比',
blueName: props.blueName as string,
redName: props.redName as string,
xAxisData: xAxisData,
blueData: blueData,
redData: redData,
xAxisDataVisible: true,
labelVisible: false,
});
nextTick(() => initChart(options));
};
watch(() => props.datas, (n: ModelDeductionData[]) => load(n), { deep: true, immediate: true });
return {
chartContainer
};
}
});
</script>

View File

@@ -1,97 +0,0 @@
<template>
<div class="ks-model-chart-item" ref="chartContainer"></div>
</template>
<script lang="ts">
import { defineComponent, nextTick, type PropType, ref, watch } from 'vue';
import * as echarts from 'echarts';
import type { ModelDeductionData } from '../types';
import { createScatterChartOption } from './scatter-options';
export default defineComponent({
props: {
datas: {
type: Array as PropType<ModelDeductionData[]>,
default: [],
},
redName: {
type: String as PropType<String>,
default: '红方',
},
blueName: {
type: String as PropType<String>,
default: '蓝方',
},
},
setup(props) {
const chartContainer = ref<HTMLElement | null>(null);
let chartInstance: echarts.ECharts | null = null;
const initChart = (option: any) => {
if (!chartContainer.value) return;
if (chartInstance) {
chartInstance.dispose();
}
chartInstance = echarts.init(chartContainer.value);
chartInstance.setOption(option);
// 自适应窗口大小(可选,提升体验)
window.addEventListener('resize', () => {
chartInstance?.resize();
});
};
const defaultValues = {
hide_missile: 0,
angle: 0,
height: 0,
speed: 0,
}
const parseJson = (v: any)=> {
let values = {...defaultValues}
try{
values = JSON.parse(v as string);
} catch (e: any) {
console.error('error',e);
}
return {
...defaultValues,
...values
}
}
const load = (d: ModelDeductionData[]) => {
const xAxisData: string[] = [];
const blueData: any[] = [];
const redData: any[] = [];
if (d) {
d.forEach(item => {
let blueValues = parseJson(item.returnComponentsBlue);
let redValues = parseJson(item.returnComponentsRed);
xAxisData.push(`轮数${item.currentEpisode}`);
blueData.push(blueValues.hide_missile);
redData.push(redValues.hide_missile);
});
}
const options = createScatterChartOption({
title: '躲避奖励',
xAxisData,
blueData,
redData,
blueName: props.blueName as string,
redName: props.redName as string,
});
nextTick(() => initChart(options));
};
watch(() => props.datas, (n: ModelDeductionData[]) => load(n), { deep: true, immediate: true });
return {
chartContainer
};
}
});
</script>

View File

@@ -1,94 +0,0 @@
<template>
<div class="ks-model-chart-item" ref="chartContainer"></div>
</template>
<script lang="ts">
import { defineComponent, nextTick, type PropType, ref, watch } from 'vue';
import * as echarts from 'echarts';
import type { ModelDeductionData } from '../types';
import { createScatterChartOption } from './scatter-options';
export default defineComponent({
props: {
datas: {
type: Array as PropType<ModelDeductionData[]>,
default: [],
},
redName: {
type: String as PropType<String>,
default: '红方',
},
blueName: {
type: String as PropType<String>,
default: '蓝方',
},
},
setup(props) {
const chartContainer = ref<HTMLElement | null>(null);
let chartInstance: echarts.ECharts | null = null;
const initChart = (option: any) => {
if (!chartContainer.value) return;
if (chartInstance) {
chartInstance.dispose();
}
chartInstance = echarts.init(chartContainer.value);
chartInstance.setOption(option);
// 自适应窗口大小(可选,提升体验)
window.addEventListener('resize', () => {
chartInstance?.resize();
});
};
const defaultValues = {
hide_missile: 0,
angle: 0,
height: 0,
speed: 0,
}
const parseJson = (v: any)=> {
let values = {...defaultValues}
try{
values = JSON.parse(v as string);
} catch (e: any) {
console.error('error',e);
}
return {
...defaultValues,
...values
}
}
const load = (d: ModelDeductionData[]) => {
const xAxisData: string[] = [];
const blueData: any[] = [];
const redData: any[] = [];
if (d) {
d.forEach(item => {
let blueValues = parseJson(item.returnComponentsBlue);
let redValues = parseJson(item.returnComponentsRed);
xAxisData.push(`轮数${item.currentEpisode}`);
blueData.push(blueValues.angle);
redData.push(redValues.angle);
});
}
const options = createScatterChartOption({
title: '角度奖励', xAxisData, blueData, redData,
blueName: props.blueName as string,
redName: props.redName as string,
});
nextTick(() => initChart(options));
};
watch(() => props.datas, (n: ModelDeductionData[]) => load(n), { deep: true, immediate: true });
return {
chartContainer
};
}
});
</script>

View File

@@ -1,94 +0,0 @@
<template>
<div class="ks-model-chart-item" ref="chartContainer"></div>
</template>
<script lang="ts">
import { defineComponent, nextTick, type PropType, ref, watch } from 'vue';
import * as echarts from 'echarts';
import type { ModelDeductionData } from '../types';
import { createScatterChartOption } from './scatter-options';
export default defineComponent({
props: {
datas: {
type: Array as PropType<ModelDeductionData[]>,
default: [],
},
redName: {
type: String as PropType<String>,
default: '红方',
},
blueName: {
type: String as PropType<String>,
default: '蓝方',
},
},
setup(props) {
const chartContainer = ref<HTMLElement | null>(null);
let chartInstance: echarts.ECharts | null = null;
const initChart = (option: any) => {
if (!chartContainer.value) return;
if (chartInstance) {
chartInstance.dispose();
}
chartInstance = echarts.init(chartContainer.value);
chartInstance.setOption(option);
// 自适应窗口大小(可选,提升体验)
window.addEventListener('resize', () => {
chartInstance?.resize();
});
};
const defaultValues = {
hide_missile: 0,
angle: 0,
height: 0,
speed: 0,
}
const parseJson = (v: any)=> {
let values = {...defaultValues}
try{
values = JSON.parse(v as string);
} catch (e: any) {
console.error('error',e);
}
return {
...defaultValues,
...values
}
}
const load = (d: ModelDeductionData[]) => {
const xAxisData: string[] = [];
const blueData: any[] = [];
const redData: any[] = [];
if (d) {
d.forEach(item => {
let blueValues = parseJson(item.returnComponentsBlue);
let redValues = parseJson(item.returnComponentsRed);
xAxisData.push(`轮数${item.currentEpisode}`);
blueData.push(blueValues.height);
redData.push(redValues.height);
});
}
const options = createScatterChartOption({
title: '高度奖励', xAxisData, blueData, redData,
blueName: props.blueName as string,
redName: props.redName as string,
});
nextTick(() => initChart(options));
};
watch(() => props.datas, (n: ModelDeductionData[]) => load(n), { deep: true, immediate: true });
return {
chartContainer
};
}
});
</script>

View File

@@ -1,94 +0,0 @@
<template>
<div class="ks-model-chart-item" ref="chartContainer"></div>
</template>
<script lang="ts">
import { defineComponent, nextTick, type PropType, ref, watch } from 'vue';
import * as echarts from 'echarts';
import type { ModelDeductionData } from '../types';
import { createScatterChartOption } from './scatter-options';
export default defineComponent({
props: {
datas: {
type: Array as PropType<ModelDeductionData[]>,
default: [],
},
redName: {
type: String as PropType<String>,
default: '红方',
},
blueName: {
type: String as PropType<String>,
default: '蓝方',
},
},
setup(props) {
const chartContainer = ref<HTMLElement | null>(null);
let chartInstance: echarts.ECharts | null = null;
const initChart = (option: any) => {
if (!chartContainer.value) return;
if (chartInstance) {
chartInstance.dispose();
}
chartInstance = echarts.init(chartContainer.value);
chartInstance.setOption(option);
// 自适应窗口大小(可选,提升体验)
window.addEventListener('resize', () => {
chartInstance?.resize();
});
};
const defaultValues = {
hide_missile: 0,
angle: 0,
height: 0,
speed: 0,
}
const parseJson = (v: any)=> {
let values = {...defaultValues}
try{
values = JSON.parse(v as string);
} catch (e: any) {
console.error('error',e);
}
return {
...defaultValues,
...values
}
}
const load = (d: ModelDeductionData[]) => {
const xAxisData: string[] = [];
const blueData: any[] = [];
const redData: any[] = [];
if (d) {
d.forEach(item => {
let blueValues = parseJson(item.returnComponentsBlue);
let redValues = parseJson(item.returnComponentsRed);
xAxisData.push(`轮数${item.currentEpisode}`);
blueData.push(blueValues.speed);
redData.push(redValues.speed);
});
}
const options = createScatterChartOption({
title: '速度奖励', xAxisData, blueData, redData,
blueName: props.blueName as string,
redName: props.redName as string,
});
nextTick(() => initChart(options));
};
watch(() => props.datas, (n: ModelDeductionData[]) => load(n), { deep: true, immediate: true });
return {
chartContainer
};
}
});
</script>

View File

@@ -1,72 +0,0 @@
<template>
<div class="ks-model-chart-item" ref="chartContainer"></div>
</template>
<script lang="ts">
import { defineComponent, nextTick, type PropType, ref, watch } from 'vue';
import * as echarts from 'echarts';
import type { ModelDeductionData } from '../types';
import { createScatterChartOption } from './scatter-options';
export default defineComponent({
props: {
datas: {
type: Array as PropType<ModelDeductionData[]>,
default: [],
},
redName: {
type: String as PropType<String>,
default: '红方',
},
blueName: {
type: String as PropType<String>,
default: '蓝方',
},
},
setup(props) {
const chartContainer = ref<HTMLElement | null>(null);
let chartInstance: echarts.ECharts | null = null;
const initChart = (option: any) => {
if (!chartContainer.value) return;
if (chartInstance) {
chartInstance.dispose();
}
chartInstance = echarts.init(chartContainer.value);
chartInstance.setOption(option);
// 自适应窗口大小(可选,提升体验)
window.addEventListener('resize', () => {
chartInstance?.resize();
});
};
const load = (d: ModelDeductionData[]) => {
const xAxisData: string[] = [];
const blueData: any[] = [];
const redData: any[] = [];
if (d) {
d.forEach(item => {
xAxisData.push(`轮数${item.currentEpisode}`);
blueData.push(item.returnComponentsBlue);
redData.push(item.returnComponentsRed);
});
}
const options = createScatterChartOption({
title: '分项奖励对比', xAxisData, blueData, redData,
blueName: props.blueName as string,
redName: props.redName as string,
});
nextTick(() => initChart(options));
};
watch(() => props.datas, (n: ModelDeductionData[]) => load(n), { deep: true, immediate: true });
return {
chartContainer
};
}
});
</script>

View File

@@ -1,72 +0,0 @@
<template>
<div class="ks-model-chart-item" ref="chartContainer"></div>
</template>
<script lang="ts">
import { defineComponent, nextTick, type PropType, ref, watch } from 'vue';
import * as echarts from 'echarts';
import type { ModelDeductionData } from '../types';
import { createBarChartOption } from './bar-options';
export default defineComponent({
props: {
datas: {
type: Array as PropType<ModelDeductionData[]>,
default: [],
},
redName: {
type: String as PropType<String>,
default: '红方',
},
blueName: {
type: String as PropType<String>,
default: '蓝方',
},
},
setup(props) {
const chartContainer = ref<HTMLElement | null>(null);
let chartInstance: echarts.ECharts | null = null;
const initChart = (option: any) => {
if (!chartContainer.value) return;
if (chartInstance) {
chartInstance.dispose();
}
chartInstance = echarts.init(chartContainer.value);
chartInstance.setOption(option);
// 自适应窗口大小(可选,提升体验)
window.addEventListener('resize', () => {
chartInstance?.resize();
});
};
const load = (d: ModelDeductionData[]) => {
const xAxisData: string[] = [];
const blueData: any[] = [];
const redData: any[] = [];
if (d) {
d.forEach(item => {
xAxisData.push(`轮数${item.currentEpisode}`);
blueData.push(item.returnDelnatyBlue);
redData.push(item.returnDelnatyRed);
});
}
const options = createBarChartOption({
title: '决策错误对比', xAxisData, blueData, redData,
blueName: props.blueName as string,
redName: props.redName as string,
});
nextTick(() => initChart(options));
};
watch(() => props.datas, (n: ModelDeductionData[]) => load(n), { deep: true, immediate: true });
return {
chartContainer
};
}
});
</script>

View File

@@ -1,73 +0,0 @@
<template>
<div class="ks-model-chart-item" ref="chartContainer"></div>
</template>
<script lang="ts">
import { defineComponent, nextTick, type PropType, ref, watch } from 'vue';
import * as echarts from 'echarts';
import type { ModelDeductionData } from '../types';
import { createScatterChartOption } from './scatter-options';
export default defineComponent({
props: {
datas: {
type: Array as PropType<ModelDeductionData[]>,
default: [],
},
redName: {
type: String as PropType<String>,
default: '红方',
},
blueName: {
type: String as PropType<String>,
default: '蓝方',
},
},
setup(props) {
const chartContainer = ref<HTMLElement | null>(null);
let chartInstance: echarts.ECharts | null = null;
const initChart = (option: any) => {
if (!chartContainer.value) return;
if (chartInstance) {
chartInstance.dispose();
}
chartInstance = echarts.init(chartContainer.value);
chartInstance.setOption(option);
// 自适应窗口大小(可选,提升体验)
window.addEventListener('resize', () => {
chartInstance?.resize();
});
};
const load = (d: ModelDeductionData[]) => {
const xAxisData: string[] = [];
const blueData: any[] = [];
const redData: any[] = [];
if (d) {
d.forEach(item => {
xAxisData.push(`轮数${item.currentEpisode}`);
blueData.push(item.episodeLengthsBlue ?? 0);
redData.push(item.episodeLengthsRed ?? 0);
});
}
console.error('chart4',d, blueData, redData)
const options = createScatterChartOption({
title: '最长生存步数', xAxisData, blueData, redData,
blueName: props.blueName as string,
redName: props.redName as string,
});
nextTick(() => initChart(options));
};
watch(() => props.datas, (n: ModelDeductionData[]) => load(n), { deep: true, immediate: true });
return {
chartContainer
};
}
});
</script>

View File

@@ -1,72 +0,0 @@
<template>
<div class="ks-model-chart-item" ref="chartContainer"></div>
</template>
<script lang="ts">
import { defineComponent, nextTick, type PropType, ref, watch } from 'vue';
import * as echarts from 'echarts';
import type { ModelDeductionData } from '../types';
import { createScatterChartOption } from './scatter-options';
export default defineComponent({
props: {
datas: {
type: Array as PropType<ModelDeductionData[]>,
default: [],
},
redName: {
type: String as PropType<String>,
default: '红方',
},
blueName: {
type: String as PropType<String>,
default: '蓝方',
},
},
setup(props) {
const chartContainer = ref<HTMLElement | null>(null);
let chartInstance: echarts.ECharts | null = null;
const initChart = (option: any) => {
if (!chartContainer.value) return;
if (chartInstance) {
chartInstance.dispose();
}
chartInstance = echarts.init(chartContainer.value);
chartInstance.setOption(option);
// 自适应窗口大小(可选,提升体验)
window.addEventListener('resize', () => {
chartInstance?.resize();
});
};
const load = (d: ModelDeductionData[]) => {
const xAxisData: string[] = [];
const blueData: any[] = [];
const redData: any[] = [];
if (d) {
d.forEach(item => {
xAxisData.push(`轮数${item.currentEpisode}`);
blueData.push(item.fireConsumeBlue);
redData.push(item.fireConsumeRed);
});
}
const options = createScatterChartOption({
title: '击杀单位耗弹量', xAxisData, blueData, redData,
blueName: props.blueName as string,
redName: props.redName as string,
});
nextTick(() => initChart(options));
};
watch(() => props.datas, (n: ModelDeductionData[]) => load(n), { deep: true, immediate: true });
return {
chartContainer
};
}
});
</script>

View File

@@ -1,74 +0,0 @@
<template>
<div class="ks-model-chart-item-chart" ref="chartContainer" style="height: 480px;"></div>
</template>
<script lang="ts">
import { defineComponent, nextTick, type PropType, ref, watch } from 'vue';
import * as echarts from 'echarts';
import { createLineChartOption } from './line-options';
import type {ChartLineData} from './types'
export default defineComponent({
props: {
datas: {
type: Object as PropType<ChartLineData>,
},
redName: {
type: String as PropType<String>,
default: '红方',
},
blueName: {
type: String as PropType<String>,
default: '蓝方',
}
},
setup(props) {
const chartContainer = ref<HTMLElement | null>(null);
let chartInstance: echarts.ECharts | null = null;
const initChart = (option: any) => {
if (!chartContainer.value) return;
if (chartInstance) {
chartInstance.dispose();
}
chartInstance = echarts.init(chartContainer.value);
chartInstance.setOption(option);
// 自适应窗口大小(可选,提升体验)
window.addEventListener('resize', () => {
chartInstance?.resize();
});
};
const load = (d: ChartLineData) => {
if(d){
const options = createLineChartOption({
title: '飞行状态稳定性',
blueName: props.blueName as string,
redName: props.redName as string,
xAxisData: d.xAxisData,
blueData: d.blueData,
redData: d.redData,
xAxisDataVisible: true,
labelVisible: false,
});
nextTick(() => initChart(options));
} else {
if (chartInstance) {
chartInstance.dispose();
}
}
};
watch(() => props.datas, (n: ChartLineData | undefined) => n && load(n), { deep: true, immediate: true });
return {
chartContainer
};
}
});
</script>

View File

@@ -1,84 +0,0 @@
<template>
<div class="ks-model-chart-item" ref="chartContainer">
<a-carousel
arrows
:dots="false"
:slides-to-show="1"
:slides-to-scroll="1"
arrow="always"
:autoplay="false"
class="chart-carousel"
>
<template #prevArrow>
<div class="custom-slick-arrow prev-arrow" style="z-index: 1">
<left-circle-outlined />
</div>
</template>
<template #nextArrow>
<div class="custom-slick-arrow next-arrow">
<right-circle-outlined />
</div>
</template>
<div class="slick-slide-item" v-for="d in realDatas">
<div style="height: 500px">
<Charts006Impl :datas="d" :blueName="blueName" :redName="redName" />
</div>
</div>
</a-carousel>
</div>
</template>
<script lang="ts">
import { defineComponent, type PropType, ref, watch } from 'vue';
import type { ModelDeductionData } from '../types';
import type {ChartLineData} from './types';
import {downSampleData} from './utils'
import { LeftCircleOutlined, RightCircleOutlined } from '@ant-design/icons-vue';
import Charts006Impl from './charts-006-impl.vue'
export default defineComponent({
components: { RightCircleOutlined, LeftCircleOutlined ,Charts006Impl},
props: {
datas: {
type: Array as PropType<ModelDeductionData[]>,
default: [],
},
redName: {
type: String as PropType<String>,
default: '红方',
},
blueName: {
type: String as PropType<String>,
default: '蓝方',
},
},
setup(props) {
const realDatas = ref<ChartLineData[]>([])
const load = (d: ModelDeductionData[]) => {
realDatas.value = [];
let dv:ChartLineData[] = [];
if (d) {
d.forEach(item => {
dv.push({
name: `轮数${item.currentEpisode}`,
xAxisData: [`轮数${item.currentEpisode}`],
blueData: downSampleData(item.normalizedBlueTrajectory || []),
redData: downSampleData(item.normalizedRedTrajectory || []),
options: {},
deduction: item,
})
});
}
realDatas.value = dv;
};
watch(() => props.datas, (n: ModelDeductionData[]) => load(n), { deep: true, immediate: true });
return {
realDatas
};
}
});
</script>

View File

@@ -1,77 +0,0 @@
<template>
<div class="ks-model-chart-item" ref="chartContainer"></div>
</template>
<script lang="ts">
import { defineComponent, nextTick, type PropType, ref, watch } from 'vue';
import * as echarts from 'echarts';
import type { ModelDeductionData } from '../types';
import { createLineChartOption } from './line-options';
export default defineComponent({
props: {
datas: {
type: Array as PropType<ModelDeductionData[]>,
default: [],
},
redName: {
type: String as PropType<String>,
default: '红方',
},
blueName: {
type: String as PropType<String>,
default: '蓝方',
},
},
setup(props) {
const chartContainer = ref<HTMLElement | null>(null);
let chartInstance: echarts.ECharts | null = null;
const initChart = (option: any) => {
if (!chartContainer.value) return;
if (chartInstance) {
chartInstance.dispose();
}
chartInstance = echarts.init(chartContainer.value);
chartInstance.setOption(option);
// 自适应窗口大小(可选,提升体验)
window.addEventListener('resize', () => {
chartInstance?.resize();
});
};
const load = (d: ModelDeductionData[]) => {
const xAxisData: string[] = [];
const blueData: any[] = [];
const redData: any[] = [];
if (d) {
d.forEach(item => {
xAxisData.push(`轮数${item.currentEpisode}`);
blueData.push(item.firstFireTimeBlue);
redData.push(item.firstFireTimeRed);
});
}
const options = createLineChartOption({
title: '最早锁定发射时间',
blueName: props.blueName as string,
redName: props.redName as string,
xAxisData: xAxisData,
blueData: blueData,
redData: redData,
xAxisDataVisible: true,
labelVisible: false,
});
nextTick(() => initChart(options));
};
watch(() => props.datas, (n: ModelDeductionData[]) => load(n), { deep: true, immediate: true });
return {
chartContainer
};
}
});
</script>

View File

@@ -1,72 +0,0 @@
<template>
<div class="ks-model-chart-item" ref="chartContainer"></div>
</template>
<script lang="ts">
import { defineComponent, nextTick, type PropType, ref, watch } from 'vue';
import * as echarts from 'echarts';
import type { ModelDeductionData } from '../types';
import { createAreaChartOption } from './area-options';
export default defineComponent({
props: {
datas: {
type: Array as PropType<ModelDeductionData[]>,
default: [],
},
redName: {
type: String as PropType<String>,
default: '红方',
},
blueName: {
type: String as PropType<String>,
default: '蓝方',
},
},
setup(props) {
const chartContainer = ref<HTMLElement | null>(null);
let chartInstance: echarts.ECharts | null = null;
const initChart = (option: any) => {
if (!chartContainer.value) return;
if (chartInstance) {
chartInstance.dispose();
}
chartInstance = echarts.init(chartContainer.value);
chartInstance.setOption(option);
// 自适应窗口大小(可选,提升体验)
window.addEventListener('resize', () => {
chartInstance?.resize();
});
};
const load = (d: ModelDeductionData[]) => {
const xAxisData: string[] = [];
const blueData: any[] = [];
const redData: any[] = [];
if (d) {
d.forEach(item => {
xAxisData.push(`轮数${item.currentEpisode}`);
blueData.push(item.attackTimeBlue);
redData.push(item.attackTimeRed);
});
}
const options = createAreaChartOption({
title: '总攻击持续时间', xAxisData, blueData, redData,
blueName: props.blueName as string,
redName: props.redName as string,
});
nextTick(() => initChart(options));
};
watch(() => props.datas, (n: ModelDeductionData[]) => load(n), { deep: true, immediate: true });
return {
chartContainer
};
}
});
</script>

View File

@@ -1,74 +0,0 @@
<template>
<div class="ks-model-chart-item-chart" ref="chartContainer" style="height: 480px;"></div>
</template>
<script lang="ts">
import { defineComponent, nextTick, type PropType, ref, watch } from 'vue';
import * as echarts from 'echarts';
import { createLineChartOption } from './line-options';
import type {ChartLineData} from './types'
export default defineComponent({
props: {
datas: {
type: Object as PropType<ChartLineData>,
},
redName: {
type: String as PropType<String>,
default: '红方',
},
blueName: {
type: String as PropType<String>,
default: '蓝方',
},
},
setup(props) {
const chartContainer = ref<HTMLElement | null>(null);
let chartInstance: echarts.ECharts | null = null;
const initChart = (option: any) => {
if (!chartContainer.value) return;
if (chartInstance) {
chartInstance.dispose();
}
chartInstance = echarts.init(chartContainer.value);
chartInstance.setOption(option);
// 自适应窗口大小(可选,提升体验)
window.addEventListener('resize', () => {
chartInstance?.resize();
});
};
const load = (d: ChartLineData) => {
if(d){
const options = createLineChartOption({
title: `能量优势保持时间窗口 - ${d.name}`,
blueName: props.blueName as string,
redName: props.redName as string,
xAxisData: d.xAxisData,
blueData: d.blueData,
redData: d.redData,
xAxisDataVisible: true,
labelVisible: false,
});
nextTick(() => initChart(options));
} else {
if (chartInstance) {
chartInstance.dispose();
}
}
};
watch(() => props.datas, (n: ChartLineData | undefined) => n && load(n), { deep: true, immediate: true });
return {
chartContainer
};
}
});
</script>

View File

@@ -1,97 +0,0 @@
<template>
<div class="ks-model-chart-item" ref="chartContainer">
<a-carousel
arrows
:dots="false"
:slides-to-show="1"
:slides-to-scroll="1"
arrow="always"
:autoplay="false"
class="chart-carousel"
>
<template #prevArrow>
<div class="custom-slick-arrow prev-arrow" style="z-index: 1">
<left-circle-outlined />
</div>
</template>
<template #nextArrow>
<div class="custom-slick-arrow next-arrow">
<right-circle-outlined />
</div>
</template>
<div class="slick-slide-item" v-for="d in realDatas">
<div style="height: 500px">
<Charts006Impl :datas="d" :blueName="blueName" :redName="redName"/>
</div>
</div>
</a-carousel>
</div>
</template>
<script lang="ts">
import { defineComponent, type PropType, ref, watch } from 'vue';
import type { ModelDeductionData } from '../types';
import type {ChartLineData} from './types';
import { LeftCircleOutlined, RightCircleOutlined } from '@ant-design/icons-vue';
import Charts006Impl from './charts-006-impl.vue'
export default defineComponent({
components: { RightCircleOutlined, LeftCircleOutlined ,Charts006Impl},
props: {
datas: {
type: Array as PropType<ModelDeductionData[]>,
default: [],
},
redName: {
type: String as PropType<String>,
default: '红方',
},
blueName: {
type: String as PropType<String>,
default: '蓝方',
},
},
setup(props) {
const realDatas = ref<ChartLineData[]>([])
const defaultValues: number[] = []
const parseJson = (v: any)=> {
let values: number[] = []
try{
values = JSON.parse(v as string) as number[];
} catch (e: any) {
console.error('error',e);
}
return values ?? []
}
const load = (d: ModelDeductionData[]) => {
realDatas.value = [];
let dv:ChartLineData[] = [];
if (d) {
d.forEach(item => {
dv.push({
name: `轮数${item.currentEpisode}`,
xAxisData: [`轮数${item.currentEpisode}`],
blueData: parseJson(item.energyAdvantage),
redData: parseJson(item.energyAdvantage),
options: {},
deduction: item,
})
});
}
realDatas.value = dv;
console.error(realDatas.value)
};
watch(() => props.datas, (n: ModelDeductionData[]) => load(n), { deep: true, immediate: true });
return {
realDatas
};
}
});
</script>

View File

@@ -1,87 +0,0 @@
<template>
<div class="ks-model-chart-item-child" style="width:50%;display: block;float:left;position: relative">
<div class="ks-model-chart-item-wrapper" ref="chartContainer" style="height:350px;"></div>
<div class="ks-model-chart-item-description">
<span class="pre">{{ lastItem?.blueWinRounds ?? 0}} {{ lastItem?.redWinRounds ?? 0}}</span>
<span class="total">{{ deductionPod.totalRound??0 }}</span>
</div>
</div>
</template>
<script lang="ts">
import { defineComponent, nextTick, type PropType, ref, watch } from 'vue';
import * as echarts from 'echarts';
import type { ModelDeductionData, DeductionPod } from '../types';
import { createPieChartOption } from './pie-options';
export default defineComponent({
props: {
datas: {
type: Array as PropType<ModelDeductionData[]>,
default: [],
},
deductionPod: {
type: [Object] as PropType<DeductionPod|null | undefined>,
},
redName: {
type: String as PropType<String>,
default: '红方',
},
blueName: {
type: String as PropType<String>,
default: '蓝方',
},
},
setup(props) {
const chartContainer = ref<HTMLElement | null>(null);
let chartInstance: echarts.ECharts | null = null;
const deductionPod = ref<Partial<DeductionPod>>({})
const lastItem = ref<ModelDeductionData|null | undefined>(null)
const initChart = (option: any) => {
if (!chartContainer.value) return;
if (chartInstance) {
chartInstance.dispose();
}
chartInstance = echarts.init(chartContainer.value);
chartInstance.setOption(option);
// 自适应窗口大小(可选,提升体验)
window.addEventListener('resize', () => {
chartInstance?.resize();
});
};
const load = (d: ModelDeductionData[]) => {
const blueName = props.blueName ?? '蓝方';
const redName = props.redName ?? '红方';
let pre = 0;
lastItem.value = null;
if (d && d.length >= 1) {
lastItem.value = d[d.length - 1] as ModelDeductionData;
const mineRounds = lastItem.value?.blueWinRounds ?? 0;
const totalRound = props.deductionPod?.totalRound ?? 0;
if (totalRound > 0) {
pre = Number((mineRounds / totalRound * 100).toFixed(2));
}
console.error('blue',mineRounds,totalRound)
}
const options = createPieChartOption(`${blueName}胜率`, 'blue', pre, `${blueName}胜率`, blueName as string, redName as string);
nextTick(() => initChart(options));
};
watch(() => props.datas, (n: ModelDeductionData[]) => load(n), { deep: true, immediate: true });
watch(() => props.deductionPod, (n: DeductionPod | null| undefined ) => deductionPod.value = n ?? {}, { deep: true, immediate: true });
return {
lastItem,
deductionPod,
chartContainer
};
}
});
</script>

View File

@@ -1,246 +0,0 @@
<template>
<a-modal :open="visible" style="width: 98%" class="ks-charts-modal" centered :footer="false" @cancel="handleCancel">
<template #title>
<a-space>
<span class="ks-charts-modal-icon"></span>
<span class="ks-charts-modal-title">指标效果对比</span>
</a-space>
</template>
<div class="ks-model-charts">
<a-card class="ks-model-chart-card">
<template #title>
<a-space>
<span class="ks-model-chart-card-icon model-icon"></span>
<span>多维度算法指标对比</span>
</a-space>
</template>
<a-row :gutter="15">
<a-col :span="8">
<Chart001 :datas="datas"/>
</a-col>
<a-col :span="8">
<Chart002 :datas="datas"/>
</a-col>
<a-col :span="8">
<Chart003 :datas="datas"/>
</a-col>
</a-row>
</a-card>
<a-card class="ks-model-chart-card">
<template #title>
<a-space>
<span class="ks-model-chart-card-icon grid-icon"></span>
<span>多维度仿真推演效果对比</span>
</a-space>
</template>
<a-row :gutter="15">
<a-col :span="24">
<div class="ks-model-chart-item" style="height:380px;">
<ChartRed :datas="datas"/>
<ChartBlue :datas="datas"/>
</div>
</a-col>
</a-row>
<a-row :gutter="15">
<a-col :span="12">
<Chart004 :datas="datas"/>
</a-col>
<a-col :span="12">
<Chart005 :datas="datas"/>
</a-col>
</a-row>
<a-row :gutter="15">
<a-col :span="12">
<Chart006 :datas="datas"/>
</a-col>
<a-col :span="12">
<Chart007 :datas="datas"/>
</a-col>
<a-col :span="12">
<Chart008 :datas="datas"/>
</a-col>
<a-col :span="12">
<Chart009 :datas="datas"/>
</a-col>
</a-row>
</a-card>
</div>
</a-modal>
</template>
<script lang="ts">
import { defineComponent, type PropType, ref, watch } from 'vue';
import Chart001 from './charts-001.vue';
import Chart002 from './charts-002.vue';
import Chart003 from './charts-003.vue';
import Chart004 from './charts-004.vue';
import Chart005 from './charts-005.vue';
import Chart006 from './charts-006.vue';
import Chart007 from './charts-007.vue';
import Chart008 from './charts-008.vue';
import Chart009 from './charts-009.vue';
import ChartBlue from './charts-blue.vue';
import ChartRed from './charts-red.vue';
import type { DeductionPod, ModelDeductionData } from '../types';
import { findChartsDataById } from '../api';
export default defineComponent(({
components: {
Chart001,
Chart002,
Chart003,
Chart004,
Chart005,
Chart006,
Chart007,
Chart008,
Chart009,
ChartBlue,
ChartRed,
},
props: {
visible: {
type: Boolean,
},
deduction: {
type: [Object, null, undefined] as PropType<DeductionPod | null | undefined>,
},
},
emits: ['cancel'],
setup(props, { emit }) {
const deduction = ref<DeductionPod | null | undefined>(props.deduction as DeductionPod);
const datas = ref<ModelDeductionData[]>([]);
const handleCancel = () => {
emit('cancel');
};
const load = (n: DeductionPod | null | undefined) => {
deduction.value = n;
if (n?.deductionId) {
findChartsDataById(n.deductionId).then(r => {
datas.value = r.data ?? [];
console.error(n, datas.value);
});
}
};
watch(() => props.deduction, (n: DeductionPod | null | undefined) => {
load(n);
}, { deep: true, immediate: true });
return {
handleCancel,
datas,
};
},
}));
</script>
<!--<style lang="less">-->
<!--.ks-charts-modal{-->
<!-- background: url('@/assets/icons/bg-model-builder-canvas.png') center / 100% 100%;-->
<!-- .ant-modal-content{-->
<!-- padding:0;-->
<!-- border: 1px solid #041a3c;-->
<!-- }-->
<!-- .ant-modal-header{-->
<!-- height: 55px;-->
<!-- line-height: 50px;-->
<!-- background: #041125;-->
<!-- background: linear-gradient(359deg, #010c1d 1%, #041a3c 55%);-->
<!-- border-radius: 0;-->
<!-- }-->
<!-- .ant-modal-close {-->
<!-- position: absolute;-->
<!-- top: 13px;-->
<!-- }-->
<!-- .ks-charts-modal-title,-->
<!-- .ant-modal-title {-->
<!-- line-height: 55px;-->
<!-- font-size:16px;-->
<!-- }-->
<!-- .ant-modal-body{-->
<!-- height: 90vh;-->
<!-- overflow: auto;-->
<!-- border-top: 1px solid #181d26;-->
<!-- background: #041125;-->
<!-- }-->
<!-- .ks-charts-modal-icon{-->
<!-- background: url('@/assets/icons/m-03.png') center / 100% 100%;-->
<!-- width: 30px;-->
<!-- height:30px;-->
<!-- display:block;-->
<!-- }-->
<!--}-->
<!--.ks-model-chart-card {-->
<!-- border-color: #161c26;-->
<!-- border-radius: 0;-->
<!-- margin-bottom: 15px;-->
<!-- background: transparent;-->
<!-- .ks-model-chart-card-icon{-->
<!-- width: 30px;-->
<!-- height:30px;-->
<!-- display:block;-->
<!-- &.grid-icon{-->
<!-- background: url('@/assets/icons/icon-grid.png') center / 100% 100%;-->
<!-- }-->
<!-- &.model-icon{-->
<!-- background: url('@/assets/icons/icon-model-input.png') center / 100% 100%;-->
<!-- }-->
<!-- }-->
<!-- .ant-card-head {-->
<!-- border-color: #161c26;-->
<!-- color: #eee;-->
<!-- border-radius: 0;-->
<!-- background: linear-gradient(359deg, #010c1d 1%, #041a3c 55%);-->
<!-- }-->
<!-- .ks-model-chart-item {-->
<!-- height: 500px;-->
<!-- padding: 15px;-->
<!-- border: 1px solid #0a2651;-->
<!-- margin-bottom: 15px;-->
<!-- color: #eee;-->
<!-- border-radius: 2px;-->
<!-- background: linear-gradient(359deg, #010c1d 1%, #041a3c 55%);-->
<!-- &.size-small{-->
<!-- height: 300px;-->
<!-- }-->
<!-- &:hover{-->
<!-- border-color: #2f3b4e;-->
<!-- cursor: pointer;-->
<!-- }-->
<!-- .ant-statistic-title {-->
<!-- color: #eee;-->
<!-- }-->
<!-- }-->
<!-- .ks-model-chart-item-description{-->
<!-- display:inline-block;-->
<!-- width: 100%;-->
<!-- text-align: center;-->
<!-- position: absolute;-->
<!-- bottom: 0px;-->
<!-- left: 0%;-->
<!-- span{-->
<!-- display:inline-block;-->
<!-- width: 100%;-->
<!-- font-weight: bold;-->
<!-- }-->
<!-- }-->
<!--}-->
<!--</style>-->

View File

@@ -1,87 +0,0 @@
<template>
<div class="ks-model-chart-item-child" style="width:50%;display: block;float:left;position: relative">
<div class="ks-model-chart-item-wrapper" ref="chartContainer" style="height:350px;"></div>
<div class="ks-model-chart-item-description">
<span class="pre">{{ lastItem?.redWinRounds ?? 0}} {{ lastItem?.blueWinRounds ?? 0}}</span>
<span class="total">{{ deductionPod.totalRound??0 }}</span>
</div>
</div>
</template>
<script lang="ts">
import { defineComponent, nextTick, type PropType, ref, watch } from 'vue';
import * as echarts from 'echarts';
import type { ModelDeductionData, DeductionPod } from '../types';
import { createPieChartOption } from './pie-options';
export default defineComponent({
props: {
datas: {
type: Array as PropType<ModelDeductionData[]>,
default: [],
},
deductionPod: {
type: [Object] as PropType<DeductionPod|null | undefined>,
},
redName: {
type: String as PropType<String>,
default: '红方',
},
blueName: {
type: String as PropType<String>,
default: '蓝方',
},
},
setup(props) {
const chartContainer = ref<HTMLElement | null>(null);
let chartInstance: echarts.ECharts | null = null;
const deductionPod = ref<Partial<DeductionPod>>({})
const lastItem = ref<ModelDeductionData|null | undefined>(null)
const initChart = (option: any) => {
if (!chartContainer.value) return;
if (chartInstance) {
chartInstance.dispose();
}
chartInstance = echarts.init(chartContainer.value);
chartInstance.setOption(option);
// 自适应窗口大小(可选,提升体验)
window.addEventListener('resize', () => {
chartInstance?.resize();
});
};
const load = (d: ModelDeductionData[]) => {
const blueName = props.blueName ?? '蓝方';
const redName = props.redName ?? '红方';
let pre = 0;
lastItem.value = null;
if (d && d.length >= 1) {
lastItem.value = d[d.length - 1] as ModelDeductionData;
const mineRounds = lastItem.value?.redWinRounds ?? 0;
const totalRound = props.deductionPod?.totalRound ?? 0;
if (totalRound > 0) {
pre = Number((mineRounds / totalRound * 100).toFixed(2));
}
console.error('red',mineRounds,totalRound)
}
const options = createPieChartOption(`${redName}胜率`, 'red', pre, `${redName}胜率`, blueName as string, redName as string);
nextTick(() => initChart(options));
};
watch(() => props.datas, (n: ModelDeductionData[]) => load(n), { deep: true, immediate: true });
watch(() => props.deductionPod, (n: DeductionPod | null| undefined ) => deductionPod.value = n ?? {}, { deep: true, immediate: true });
return {
lastItem,
deductionPod,
chartContainer
};
}
});
</script>

View File

@@ -1,376 +0,0 @@
<template>
<Layout>
<a-card class="ks-page-card ks-charts-wrapper">
<template #title>
<a-space>
<span class="point"></span>
<span class="text">指标效果对比</span>
<a-tooltip placement="top">
<template #title>
返回
</template>
<a-button class="ks-page-card-goback" size="small" @click="goback">
<RollbackOutlined />
<span>返回</span>
</a-button>
</a-tooltip>
</a-space>
</template>
<div class="ks-scrollable">
<div class="ks-model-charts" style="height: 80vh;position: relative;overflow: auto">
<a-card class="ks-model-chart-card ks-model-chart-card-carousel">
<template #title>
<a-space>
<span class="ks-model-chart-card-icon model-icon"></span>
<span>多维度算法指标对比</span>
</a-space>
</template>
<a-carousel
arrows
:dots="false"
:slides-to-show="3"
:slides-to-scroll="1"
arrow="always"
:autoplay="false"
class="chart-carousel"
>
<template #prevArrow>
<div class="custom-slick-arrow prev-arrow" style="z-index: 1">
<left-circle-outlined />
</div>
</template>
<template #nextArrow>
<div class="custom-slick-arrow next-arrow">
<right-circle-outlined />
</div>
</template>
<div class="slick-slide-item">
<Chart001 :datas="datas" :redName="redName" :blueName="blueName"/>
</div>
<div class="slick-slide-item">
<Chart0021 :datas="datas" :redName="redName" :blueName="blueName"/>
</div>
<div class="slick-slide-item">
<Chart0022 :datas="datas" :redName="redName" :blueName="blueName"/>
</div>
<div class="slick-slide-item">
<Chart0023 :datas="datas" :redName="redName" :blueName="blueName"/>
</div>
<div class="slick-slide-item">
<Chart0024 :datas="datas" :redName="redName" :blueName="blueName"/>
</div>
<div class="slick-slide-item">
<Chart003 :datas="datas" :redName="redName" :blueName="blueName"/>
</div>
</a-carousel>
</a-card>
<a-card class="ks-model-chart-card">
<template #title>
<a-space>
<span class="ks-model-chart-card-icon grid-icon"></span>
<span>多维度仿真推演效果对比</span>
</a-space>
</template>
<a-row :gutter="15">
<a-col :span="24">
<div class="ks-model-chart-item" style="height:380px;">
<ChartRed :datas="datas" :deduction-pod="deductionPodDetails" :redName="redName" :blueName="blueName"/>
<ChartBlue :datas="datas" :deduction-pod="deductionPodDetails" :redName="redName" :blueName="blueName"/>
</div>
</a-col>
</a-row>
<a-row :gutter="15">
<a-col :span="12">
<Chart004 :datas="datas" :redName="redName" :blueName="blueName"/>
</a-col>
<a-col :span="12">
<Chart005 :datas="datas" :redName="redName" :blueName="blueName"/>
</a-col>
</a-row>
<a-row :gutter="15">
<!-- <a-col :span="12">-->
<!-- <Chart006 :datas="datas" :redName="redName" :blueName="blueName"/>-->
<!-- </a-col>-->
<a-col :span="12">
<Chart007 :datas="datas" :redName="redName" :blueName="blueName"/>
</a-col>
<a-col :span="12">
<Chart008 :datas="datas" :redName="redName" :blueName="blueName"/>
</a-col>
<!-- <a-col :span="12">-->
<!-- <Chart009 :datas="datas" :redName="redName" :blueName="blueName"/>-->
<!-- </a-col>-->
</a-row>
</a-card>
</div>
</div>
</a-card>
</Layout>
</template>
<script lang="ts">
import { defineComponent, type PropType, ref, watch } from 'vue';
import { LeftCircleOutlined, RightCircleOutlined, RollbackOutlined } from '@ant-design/icons-vue';
import {useRouter} from 'vue-router'
import Chart001 from './charts-001.vue';
import Chart002 from './charts-002.vue';
import Chart0021 from './charts-002-1.vue';
import Chart0022 from './charts-002-2.vue';
import Chart0023 from './charts-002-3.vue';
import Chart0024 from './charts-002-4.vue';
import Chart003 from './charts-003.vue';
import Chart004 from './charts-004.vue';
import Chart005 from './charts-005.vue';
import Chart006 from './charts-006.vue';
import Chart007 from './charts-007.vue';
import Chart008 from './charts-008.vue';
import Chart009 from './charts-009.vue';
import ChartBlue from './charts-blue.vue';
import ChartRed from './charts-red.vue';
import Layout from '../../layout.vue'
import type { DeductionPod, ModelDeductionData } from '../types';
import { findChartsDataById, findOneModelDeductionDetails } from '../api';
export default defineComponent({
components: {
RollbackOutlined,
Layout,
LeftCircleOutlined,
RightCircleOutlined,
Chart001,
Chart002,
Chart0021,
Chart0022,
Chart0023,
Chart0024,
Chart003,
Chart004,
Chart005,
Chart006,
Chart007,
Chart008,
Chart009,
ChartBlue,
ChartRed,
},
props: {
visible: {
type: Boolean,
},
deduction: {
type: [Object, null, undefined] as PropType<DeductionPod | null | undefined>,
},
},
emits: ['cancel'],
setup(_props, { emit }) {
const router = useRouter();
const datas = ref<ModelDeductionData[]>([]);
const deductionPodDetails = ref<DeductionPod | null | undefined>(null);
const blueName = ref<string>('蓝方')
const redName = ref<string>('红方')
const handleCancel = () => {
emit('cancel');
};
const goback = () => {
router.push({
path: '/app/ai/applications/gambling',
})
}
const load = (n: any) => {
deductionPodDetails.value = null
if (n?.params?.id) {
findOneModelDeductionDetails(n?.params?.id).then(rv=> {
deductionPodDetails.value = rv.data;
blueName.value = rv.data?.blueName ?? '蓝方';
redName.value = rv.data?.redName ?? '红方';
if(rv.data.deductionId) {
findChartsDataById(rv.data.deductionId).then(r => {
datas.value = (r.data ?? []).reverse();
console.error(n, datas.value);
});
}
})
}
};
watch(() => router.currentRoute.value, (n:any) => {
load(n);
}, { deep: true, immediate: true });
return {
goback,
deductionPodDetails,
handleCancel,
datas,
blueName,
redName,
};
},
});
</script>
<style lang="less">
.ks-charts-modal{
background: url('@/assets/icons/bg-model-builder-canvas.png') center / 100% 100%;
.ant-modal-content{
padding:0;
border: 1px solid #041a3c;
}
.ant-modal-header{
height: 55px;
line-height: 50px;
background: #041125;
background: linear-gradient(359deg, #010c1d 1%, #041a3c 55%);
border-radius: 0;
}
.ant-modal-close {
position: absolute;
top: 13px;
}
.ks-charts-modal-title,
.ant-modal-title {
line-height: 55px;
font-size:16px;
}
.ant-modal-body{
height: 90vh;
overflow: auto;
border-top: 1px solid #181d26;
background: #041125;
}
.ks-charts-modal-icon{
background: url('@/assets/icons/m-03.png') center / 100% 100%;
width: 30px;
height:30px;
display:block;
}
}
.ks-model-chart-card {
border-color: #161c26;
border-radius: 0;
margin-bottom: 15px;
background: transparent;
position: relative;
.ks-model-chart-card-icon{
width: 30px;
height:30px;
display:block;
&.grid-icon{
background: url('@/assets/icons/icon-grid.png') center / 100% 100%;
}
&.model-icon{
background: url('@/assets/icons/icon-model-input.png') center / 100% 100%;
}
}
.ant-card-head {
border-color: #161c26;
color: #eee;
border-radius: 0;
background: linear-gradient(359deg, #010c1d 1%, #041a3c 55%);
}
.ks-model-chart-item {
height: 500px;
display: block;
width: 100%;
padding: 15px;
border: 1px solid #0a2651;
margin-bottom: 15px;
color: #eee;
border-radius: 2px;
position: relative;
background: linear-gradient(359deg, #010c1d 1%, #041a3c 55%);
&.size-small{
height: 300px;
}
&:hover{
border-color: #2f3b4e;
cursor: pointer;
}
.ant-statistic-title {
color: #eee;
}
}
&.ks-model-chart-card-carousel{
.ks-model-chart-item{
margin-bottom: 0;
}
}
.ks-model-chart-item-description{
display:inline-block;
width: 100%;
text-align: center;
position: absolute;
bottom: 0px;
left: 0%;
span{
display:inline-block;
width: 100%;
font-weight: bold;
}
}
}
.chart-carousel {
position: relative;
.slick-slide-item {
width: calc(100% / 3 - 5px);
margin: 0 5px;
box-sizing: border-box;
padding: 0 10px;
position: relative;
}
// 自定义箭头样式优化(适配深色主题)
.custom-slick-arrow {
position: absolute;
top: 50%;
transform: translateY(-50%);
width: 35px;
height: 35px;
font-size: 30px;
color: #eee;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: all 0.3s ease;
opacity: 0.3;
z-index: 20;
&:before {
display: none;
}
&:hover {
color: #fff;
opacity: 0.9;
}
&.prev-arrow {
left: 0px;
z-index: 20;
}
&.next-arrow {
right: 0px;
z-index: 20;
}
}
}
</style>

View File

@@ -1,110 +0,0 @@
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2026 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
export const commonAxisConfig = {
axisLabel: {
color: '#eee',
fontSize: 12
},
axisLine: {
lineStyle: {
color: '#1e3150'
}
},
axisTick: {
lineStyle: {
color: '#1e3150'
}
},
splitLine: {
lineStyle: {
color: 'rgba(255, 255, 255, 0.1)'
}
}
};
export const getRadialGradient = (colorStart: string, colorEnd: string) => {
return {
type: 'radial', // 径向渐变(饼图首选)
x: 0.5, // 渐变中心x坐标0-10.5为饼图中心)
y: 0.5, // 渐变中心y坐标
r: 0.5, // 渐变半径0-10.5适配饼图内半径到外半径)
colorStops: [
{ offset: 0, color: colorStart }, // 中心颜色(深)
{ offset: 1, color: colorEnd } // 边缘颜色(浅)
],
global: false // 局部渐变(仅作用于当前扇区)
};
};
export const getVerticalGradient = (colorStart: string, colorEnd: string) => {
return {
type: 'linear',
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{ offset: 0, color: colorStart }, // 顶部颜色(深)
{ offset: 1, color: colorEnd } // 底部颜色(浅)
]
};
};
export const xAxisConfig = {
splitLine: {
show: true,
lineStyle: {
color: 'rgba(255, 255, 255, 0.1)' // 网格线颜色(半透明白色)
}
},
axisLabel: {
color: '#eee',
textStyle: {
color: '#EEE', // 标题字体颜色
fontSize: 14
}
},
axisLine: {
show: true,
lineStyle: {
color: '#1e3150' // X轴线颜色可选
},
textStyle: {
color: '#EEE', // 标题字体颜色
fontSize: 14
}
},
}
export const yAxisConfig = {
splitLine: {
show: true,
lineStyle: {
color: 'rgba(255, 255, 255, 0.1)' // 网格线颜色(半透明白色)
}
},
axisLabel: {
color: '#eee',
textStyle: {
color: '#EEE', // 标题字体颜色
fontSize: 14
}
},
axisLine: {
show: true,
lineStyle: {
color: '#1e3150' // X轴线颜色可选
},
textStyle: {
color: '#EEE', // 标题字体颜色
fontSize: 14
}
},
}

View File

@@ -1,265 +0,0 @@
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2026 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
import { xAxisConfig } from './config';
import type { ChartOption } from './types';
export interface LineChartOption extends ChartOption{
}
export const createLineChartOption = (options: LineChartOption = {}) => {
let blueName = options.blueName ?? '蓝方';
let redName = options.redName ?? '红方';
return {
title: {
text: options.title,
textStyle: {
color: '#EEE', // 标题字体颜色
fontSize: 16,
},
},
tooltip: {
trigger: 'axis',
textStyle: {
color: '#999', // 提示框字体颜色
},
},
grid: {
left: '1%',
right: '5%',
bottom: options.xAxisDataVisible ? '15%' : '10%',
containLabel: true,
},
legend: {
data: [blueName, redName],
textStyle: {
color: '#ddd',
fontSize: 14,
},
},
xAxis: {
show: options.xAxisDataVisible,
type: 'category',
data: options.xAxisData,
boundaryGap: [0.1, 0.1],
...xAxisConfig,
},
yAxis: {
type: 'value',
boundaryGap: [0.1, 0.1],
...xAxisConfig,
},
series: [
{
name: blueName,
type: 'line',
// stack: 'Total',
data: options.blueData,
lineStyle: {
color: '#409EFF',
width: 2,
},
itemStyle: {
color: '#409EFF',
},
emphasis: {
itemStyle: {
color: 'blue', // 高亮时填充色(白色)
borderColor: '#409EFF', // 高亮时边框色
borderWidth: 4,
},
symbolSize: 12, // 高亮时圆点放大
},
label: {
show: options.labelVisible, // 开启数值显示
position: 'top', // 数值显示在柱子顶部可选top/inside/outside/bottom等
textStyle: {
color: '#eee', // 数值文字颜色
fontSize: 12, // 数值文字大小
},
},
},
{
name: redName,
type: 'line',
// stack: 'Total',
data: options.redData,
lineStyle: {
color: '#bc1f1f',
width: 2,
},
itemStyle: {
color: '#bc1f1f',
},
emphasis: {
itemStyle: {
color: 'blue', // 高亮时填充色(白色)
borderColor: 'red', // 高亮时边框色
borderWidth: 4,
},
symbolSize: 12, // 高亮时圆点放大
},
label: {
show: options.labelVisible, // 开启数值显示
position: 'top', // 数值显示在柱子顶部可选top/inside/outside/bottom等
textStyle: {
color: '#eee', // 数值文字颜色
fontSize: 12, // 数值文字大小
},
},
},
],
};
};
// line-options.ts
export interface ChartOptimizationOptions {
showAllSymbol?: boolean;
animation?: boolean;
large?: boolean;
progressive?: number;
progressiveThreshold?: number;
}
export const createOptimizedLineChartOption = (
title: string,
xAxisData: string[],
blueData: number[],
redData: number[],
optimization: ChartOptimizationOptions = {}
): echarts.EChartsOption => {
const {
showAllSymbol = false,
animation = false,
large = true,
progressive = 500,
progressiveThreshold = 1000,
} = optimization;
return {
title: {
text: title,
left: 'center',
textStyle: {
fontSize: 16,
fontWeight: 'bold'
}
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross'
},
// 大数据时优化tooltip性能
confine: true,
appendToBody: true,
},
legend: {
data: ['蓝方轨迹', '红方轨迹'],
bottom: 10
},
grid: {
left: '3%',
right: '4%',
bottom: '15%',
top: '15%',
containLabel: true
},
xAxis: {
type: 'category',
data: xAxisData,
axisLabel: {
rotate: 45,
// 减少标签显示密度
interval: (index: number) => index % 50 === 0,
},
// 大数据优化
splitLine: {
show: false
}
},
yAxis: {
type: 'value',
name: '归一化值',
// 大数据优化
splitLine: {
lineStyle: {
type: 'dashed'
}
}
},
dataZoom: [
{
type: 'inside',
start: 0,
end: 100,
minValueSpan: 10
},
{
show: true,
type: 'slider',
top: '90%',
start: 0,
end: 100
}
],
series: [
{
name: '蓝方轨迹',
type: 'line',
data: blueData,
smooth: false, // 大数据时关闭平滑,提高性能
lineStyle: {
width: 1 // 减小线宽
},
itemStyle: {
color: '#1890ff'
},
// 性能优化配置
showSymbol: showAllSymbol,
symbol: 'circle',
symbolSize: 2, // 减小符号大小
animation: animation,
animationThreshold: 2000,
animationDuration: 1000,
animationEasing: 'cubicOut',
// 大数据模式优化
progressive: progressive,
progressiveThreshold: progressiveThreshold,
progressiveChunkMode: 'mod',
// 采样策略
sampling: 'lttb', // 使用LTTB采样算法保留趋势特征
},
{
name: '红方轨迹',
type: 'line',
data: redData,
smooth: false,
lineStyle: {
width: 1
},
itemStyle: {
color: '#ff4d4f'
},
showSymbol: showAllSymbol,
symbol: 'circle',
symbolSize: 2,
animation: animation,
animationThreshold: 2000,
animationDuration: 1000,
animationEasing: 'cubicOut',
progressive: progressive,
progressiveThreshold: progressiveThreshold,
progressiveChunkMode: 'mod',
sampling: 'lttb',
}
]
};
};

View File

@@ -1,173 +0,0 @@
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2026 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
// 限定核心取值范围,同时保留扩展空间
export type PieChartSide = 'blue' | 'red' | string
export const createPieChartOption = (
title: string,
side: PieChartSide,
progressPercent: number | null,
centerText: string,
blueName: string,
redName: string,
) => {
// 定义基础颜色常量,提升可读性
const RED = '#bc1f1f';
const BLUE = '#205aae';
let color: string[];
// side=blue → 已占用(第一个元素)=红色,未占用(第二个)=蓝色
// side=red → 已占用(第一个元素)=蓝色,未占用(第二个)=红色
if (side === 'blue') {
color = [RED, BLUE];
} else if (side === 'red') {
color = [BLUE, RED];
} else {
// 兼容其他字符串值,使用默认逻辑
color = [RED, BLUE];
}
let blueNameText = blueName ?? '蓝方';
let redNameText = redName ?? '红方';
// 处理 null 值,避免显示 null%
const safeProgressPercent = Number(Number(progressPercent ?? 0).toFixed(2));
const realData = [
{ value: safeProgressPercent, name: side === 'blue' ? redNameText : blueNameText },
{ value: Number(Number(100 - safeProgressPercent).toFixed(2)), name: side === 'blue' ? blueNameText : redNameText }
]
// 核心修改1文本截取逻辑 - 只显示前4个字符
const displayText = centerText.length > 4 ? `${centerText.substring(0, 4)}...` : centerText;
// 保存完整文本用于tooltip显示
const fullCenterText = centerText;
console.error('realData',realData)
return {
title: {
text: title,
textStyle: {
color: '#eee',
fontSize: 16
}
},
tooltip: {
trigger: 'item',
textStyle: {
color: '#999'
},
// 核心修改2自定义tooltip格式化内容显示完整文本
formatter: (params: any) => {
return `
<div style="text-align: center;">
<div>${params.name}: ${params.value}%</div>
<div style="margin-top: 4px;">${fullCenterText}</div>
</div>
`;
}
},
grid: {
left: '1%',
right: '5%',
bottom: '1%',
top: '30%',
containLabel: true
},
xAxis: {
show: false,
axisLabel: {
color: '#eee',
textStyle: {
color: '#EEE', // 标题字体颜色
fontSize: 14
}
},
axisLine: {
lineStyle: {
color: '#eee' // X轴线颜色可选
},
textStyle: {
color: '#EEE', // 标题字体颜色
fontSize: 14
}
},
},
yAxis: {
show: false,
axisLabel: {
color: '#eee',
textStyle: {
color: '#EEE', // 标题字体颜色
fontSize: 14
}
},
axisLine: {
lineStyle: {
color: '#eee' // X轴线颜色可选
},
textStyle: {
color: '#EEE', // 标题字体颜色
fontSize: 14
}
},
},
series: [
{
type: 'pie',
radius: ['40%', '60%'],
center: ['50%', '50%'],
data: realData,
color: color,
itemStyle: {
borderWidth: 0
},
// 启用饼图中心标签
label: {
show: true,
position: 'center',
// 核心修改3使用截取后的文本显示
formatter: `{a|${safeProgressPercent}%}\n{b|${displayText}}`,
rich: {
a: {
fontSize: 28,
fontWeight: 'bold',
color: '#eee',
lineHeight: 36
},
b: {
fontSize: 16,
color: '#ccc',
lineHeight: 24
}
}
},
// 禁用外部标签
labelLine: {
show: false
},
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)'
},
// 悬停时也显示中心标签
label: {
show: true,
fontSize: 28,
fontWeight: 'bold'
}
}
}
]
};
};

View File

@@ -1,126 +0,0 @@
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2026 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
import { xAxisConfig } from './config';
import type { ChartOption } from './types';
export interface ScatterChartOption extends ChartOption{
}
// 自定义三角形路径(调整尺寸适配显示)
export const triangleSymbol = 'path://M0,-6 L6,6 L-6,6 Z';
export const createScatterChartOption = (options: ScatterChartOption) => {
let blueName = options.blueName ?? '蓝方';
let redName = options.redName ?? '红方';
return {
title: {
text: options.title,
textStyle: {
color: '#eee',
fontSize: 16
}
},
tooltip: {
trigger: 'axis',
textStyle: {
color: '#999'
}
},
grid: {
left: '1%',
right: '5%',
bottom: '15%',
containLabel: true
},
legend: {
data: [blueName, redName],
textStyle: {
color: '#ddd',
fontSize: 14
}
},
xAxis: {
type: 'category',
data: options.xAxisData,
boundaryGap: [0.1, 0.1],
...xAxisConfig
},
yAxis: {
type: 'value',
boundaryGap: [0.1, 0.5],
...xAxisConfig
},
series: [
{
name: blueName,
type: 'scatter',
data: options.blueData,
symbol: 'circle', // 显式指定蓝方使用圆点ECharts默认也是circle显式设置更清晰
symbolSize: 8, // 圆点大小
itemStyle: {
color: '#409EFF' // 圆点颜色
},
emphasis: {
itemStyle: {
color: 'white',
borderColor: '#409EFF',
borderWidth: 2
},
symbolSize: 12
},
// 数值标签配置 - 显示在圆点上方
label: {
show: false,
position: 'top',
formatter: '{c}', // 直接显示数据值
textStyle: {
color: '#eee',
fontSize: 12,
fontWeight: 'bold'
},
offset: [0, -10] // 调整偏移量,让标签在圆点上方显示更美观
}
// 移除了markPoint配置去掉额外的三角形
},
{
name: redName,
type: 'scatter',
data: options.redData,
symbol: triangleSymbol, // 红方使用自定义三角形
symbolSize: 12, // 三角形尺寸(比原圆点稍大,保证视觉清晰)
itemStyle: {
color: '#bc1f1f' // 三角形颜色
},
emphasis: {
itemStyle: {
color: 'white',
borderColor: '#bc1f1f',
borderWidth: 2
},
symbolSize: 16 // 高亮时三角形放大
},
// 红方的数值标签配置
label: {
show: false,
position: 'top',
formatter: '{c}', // 直接显示数据值
textStyle: {
color: '#eee',
fontSize: 12,
fontWeight: 'bold'
},
offset: [0, -15] // 三角形高度更高,标签偏移量稍大
}
},
]
}
};

View File

@@ -1,30 +0,0 @@
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2026 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
import type { ModelDeductionData } from '../types';
export interface ChartOption {
title?: string,
blueName?: string|undefined,
redName?: string|undefined,
xAxisData?: string[],
blueData?: any[],
redData?: any[],
xAxisDataVisible?: boolean,
labelVisible?: boolean,
}
export interface ChartLineData {
name: string,
xAxisData: string[],
blueData: number[],
redData: number [],
options: any,
deduction: ModelDeductionData,
}

View File

@@ -1,25 +0,0 @@
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2026 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
export const downSampleData = (data: number[], targetCount = 200): number[] => {
if (!data.length || data.length <= targetCount) return data;
const step = Math.ceil(data.length / targetCount);
const sampledData: number[] = [];
for (let i = 0; i < data.length; i += step) {
sampledData.push(data[i] as any);
}
if (sampledData[sampledData.length - 1] !== data[data.length - 1]) {
sampledData[Number(sampledData?.length - 1)] = data[data.length - 1] as number;
}
return sampledData;
};

View File

@@ -1,35 +0,0 @@
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2026 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
import type { ModelDeduction } from './types';
export const defaultModelDeduction = {
// 推演记录ID
id: null,
deductionId: null,
// 部署模型路径
deploymentModelPath: null,
// 对抗轮数配置
competitionRound: null,
// 对抗场次配置
competitionSession: 1,
// 推演倍数设置
deductionMultiple: 1,
// 并发调度配置
balanceStrategy: 1,
// 对抗模式选择
competitionMode: 1,
// 蓝方名称
blueNames: null,
// 红方名称
redNames: null,
// 数据状态1-正常0-已删除)
status: null,
stopped: false,
} as ModelDeduction;

View File

@@ -1,673 +0,0 @@
<template>
<Layout>
<a-card class="ks-page-card ks-cards-wrapper">
<template #title>
<a-space>
<span class="point"></span>
<span class="text">博弈竞赛单元运行环境</span>
</a-space>
</template>
<div class="ks-scrollable">
<a-row :gutter="15">
<a-col :span="8">
<!-- 基础配置卡片 -->
<a-card data-step="0" title="基础配置" class="ks-apps-card ks-top-apps-card">
<a-form
:model="modelDeduction"
autocomplete="off"
layout="horizontal"
:label-col="{span: 6}"
name="basic"
>
<a-form-item
label="部署模型选择"
name="deploymentModelPath"
>
<Finder :path="modelDeduction.deploymentModelPath"
@select="(p: string|null) => modelDeduction.deploymentModelPath = p" />
</a-form-item>
<a-form-item
label="对抗轮数配置"
name="competitionRound"
>
<a-input v-model:value="modelDeduction.competitionRound" placeholder="对抗轮数配置" style="width: 100%" />
</a-form-item>
<a-form-item
label="对抗场次配置"
name="competitionSession"
>
<a-input-number min="1" v-model:value="modelDeduction.competitionSession" placeholder="对抗场次配置" style="width: 100%" />
</a-form-item>
<a-form-item
label="推演倍数设置"
name="deductionMultiple"
>
<a-form-item-rest>
<a-flex>
<a-slider v-model:value="modelDeduction.deductionMultiple" :max="1000" :min="0" style="width:100%;" />
<a-input-number v-model:value="modelDeduction.deductionMultiple" :min="0" :max="1000" style="margin-left: 10px; width: 120px;" />
<span style="width: 80px; margin-left: 5px;color:#eee; line-height: 34px;"> / 1000</span>
</a-flex>
</a-form-item-rest>
</a-form-item>
<a-form-item
label="对抗模式选择"
name="competitionMode"
>
<a-select placeholder="请选择对抗模式" v-model:value="modelDeduction.competitionMode"
@change="(v: number | undefined | null)=> modelDeduction.competitionMode = v">
<a-select-option :value="1">循环赛</a-select-option>
<a-select-option :value="2">瑞士轮</a-select-option>
<a-select-option :value="3">单败淘汰赛</a-select-option>
<a-select-option :value="4">双败淘汰赛</a-select-option>
</a-select>
</a-form-item>
<a-form-item
label="并发调度配置"
name="balanceStrategy"
>
<a-select placeholder="并发调度配置" v-model:value="modelDeduction.balanceStrategy"
@change="(v: number | undefined | null)=> modelDeduction.balanceStrategy = v">
<a-select-option :value="1">均衡调度策略</a-select-option>
<a-select-option :value="2">集约调度策略</a-select-option>
<a-select-option :value="3">优先调度策略</a-select-option>
<a-select-option :value="4">触发调度策略</a-select-option>
</a-select>
</a-form-item>
</a-form>
</a-card>
<!-- 对抗配置卡片 -->
<a-card data-step="0" title="对抗配置" class="ks-apps-card ks-bottom-apps-card">
<a-form
autocomplete="off"
layout="horizontal"
:label-col="{span: 6}"
name="basic"
>
<a-form-item
label="蓝方"
name="taskName"
>
<div class="counter-wrapper">
<div class="counter-wrapper-item" v-for="i in blueCounter" :key="`blue-${i}`">
<a-row :gutter="15">
<a-col :span="19">
<Finder :only-directory="false" @select="(_p: any, f: any)=> blueNames[i] = f.name"/>
</a-col>
<a-col :span="5" v-if="i == 1">
<a-space>
<plus-circle-outlined @click="()=> add('blue')"/>
<minus-circle-outlined @click="()=> minus('blue')"/>
</a-space>
</a-col>
</a-row>
</div>
</div>
</a-form-item>
<a-form-item
label="红方"
name="t"
>
<div class="counter-wrapper">
<div class="counter-wrapper-item" v-for="i in redCounter" :key="`red-${i}`">
<a-row :gutter="15">
<a-col :span="19">
<Finder :only-directory="false" @select="(_p: any, f: any)=> redNames[i] = f.name"/>
</a-col>
<a-col :span="5" v-if="i == 1">
<a-space>
<plus-circle-outlined @click="()=> add('red')"/>
<minus-circle-outlined @click="()=> minus('red')"/>
</a-space>
</a-col>
</a-row>
</div>
</div>
</a-form-item>
</a-form>
</a-card>
</a-col>
<a-col :span="16">
<!-- 智能博弈空战卡片 -->
<a-card data-step="0" class="ks-pks-card ks-pk-apps-card">
<template #title>
<a-flex :gap="8">
<span style="margin-top: 5px;color:#eee;font-size:16px">智能博弈空战</span>
<span style="color:#999;font-size: 15px;line-height: 32px;margin-left: 40px;">
当前场次 {{ deductionPods.length }} 队伍数: {{ deductionPods.length * 2 }}
</span>
<a-button style="margin-left: auto; color:#fff;" @click="()=> startLoop()">
<a-flex>
<PlayCircleOutlined/>
<span style="margin-left: 10px;">对抗开始</span>
</a-flex>
</a-button>
<a-button style="margin-left: 15px;color:#fff;" @click="()=> rankingModelVisible = true">
<a-flex>
<OrderedListOutlined/>
<span style="margin-left: 10px;">排名统计</span>
</a-flex>
</a-button>
</a-flex>
</template>
<div class="w-full mt-2" style="margin-top: 15px;">
<a-row :gutter="15">
<a-col :span="8" v-for="(item,i) in deductionPods" :key="`pod-${item.id}`">
<a-card class="ks-pk-card" hoverable>
<template #title>
<a-flex>
<span class="ks-card-title"> {{i + 1}} </span>
</a-flex>
</template>
<div class="pk-wrapper">
<div class="pk-overlay" @click="()=> handleClickPkCard(item)"></div>
<div class="pk-teams" @click="()=> handleClickPkCard(item)">
<span class="left-team">
<a-tooltip placement="bottom">
<template #title>
{{item.blueName ?? `蓝方${i+1}`}}
</template>
{{getTeamName(item.blueName,'blue', i + 1)}}
</a-tooltip>
</span>
<span class="right-team">
<a-tooltip placement="bottom">
<template #title>
{{item.redName ?? `红方${i+1}`}}
</template>
{{getTeamName(item.redName,'red', i + 1)}}
</a-tooltip>
</span>
</div>
<div class="pk-footer">
<a-flex>
<a-progress
:percent="item.targetPercent"
:stroke-width="6"
style="margin-right: 30px;"
></a-progress>
<a-button :disabled="item.targetPercent < 100" class="pk-details-btn" size="small" @click="()=> handleDetails(item)">
对抗详情
</a-button>
</a-flex>
</div>
</div>
<template #extra class="pk-actions">
<a-space>
<span class="icon-action eye" @click="()=> handleTermStatusPopoverVisible(item)" style="margin-right: -5px;"></span>
<a-popover title="" trigger="click" v-model:open="item.termStatusPopoverVisible">
<template #content>
<a-flex>
<span style="width: 100px;text-align: right;">仿真运行状态: </span>
<span style="margin-left: 10px;">{{item.statusName ?? '-'}}</span>
</a-flex>
</template>
</a-popover>
<!-- <a-popover title="" trigger="click" v-if="item?.metricsParsed">-->
<!-- <span class="icon-action eye"></span>-->
<!-- <template #content v-if="item?.metricsParsed">-->
<!-- <a-flex>-->
<!-- <span style="width: 100px;text-align: right;">本轮总奖励: </span>-->
<!-- <span style="margin-left: 10px;">{{ item?.metricsParsed?.reward ?? '-' }}</span>-->
<!-- </a-flex>-->
<!-- <a-flex>-->
<!-- <span style="width: 100px;text-align: right;">本轮生存步数: </span>-->
<!-- <span style="margin-left: 10px;">{{ item?.metricsParsed?.steps ?? '-' }}</span>-->
<!-- </a-flex>-->
<!-- <template v-if="item?.metricsParsed?.details">-->
<!-- <a-flex>-->
<!-- <span style="width: 100px;text-align: right;">开火奖励累计值: </span>-->
<!-- <span style="margin-left: 10px;">{{ item.metricsParsed?.details.fire_reward ?? '-' }}</span>-->
<!-- </a-flex>-->
<!-- <a-flex>-->
<!-- <span style="width: 100px;text-align: right;">越界惩罚累计值: </span>-->
<!-- <span style="margin-left: 10px;">{{ item?.metricsParsed?.details.boundary_penalty ?? '-' }}</span>-->
<!-- </a-flex>-->
<!-- </template>-->
<!-- </template>-->
<!-- </a-popover>-->
<a-popconfirm
ok-text="确定"
cancel-text="取消"
@confirm="()=> confirmPause(item)"
>
<template #title>
确定{{ item.simulationStatus === 1 ? '暂停' : '开始' }}
</template>
<span :class="['icon-action', item.simulationStatus === 1 ? 'pause' : 'start']">
</span>
</a-popconfirm>
<a-popconfirm
title="确定删除?"
ok-text="确定"
cancel-text="取消"
@confirm="()=> confirmDelete(item)"
>
<span class="icon-action delete"></span>
</a-popconfirm>
</a-space>
</template>
</a-card>
</a-col>
</a-row>
</div>
</a-card>
</a-col>
</a-row>
</div>
</a-card>
<ChartsModal :deduction="selectedDeduction" :visible="chartsModalVisible" @cancel="()=> chartsModalVisible = false" />
<RankingModel :visible="rankingModelVisible" @cancel="()=> rankingModelVisible = false"/>
</Layout>
</template>
<script lang="ts" setup>
import { onMounted, onUnmounted, ref } from 'vue';
import {useRouter} from 'vue-router'
import { message } from 'ant-design-vue';
import Layout from '../layout.vue';
import { MinusCircleOutlined, OrderedListOutlined, PlayCircleOutlined, PlusCircleOutlined } from '@ant-design/icons-vue';
import RankingModel from './ranking-modal.vue';
import { createModelDeduction, deleteModelDeduction, findDeductionPodResult, runDeductionPodAfsimControl } from './api';
import type { DeductionPod, DeductionPodMetrics, ModelDeduction } from './types';
import Finder from '../finder.vue';
import { defaultModelDeduction } from './config';
import ChartsModal from './charts/charts-modal.vue';
import type { NullableString } from '@/types';
const chartsModalVisible = ref<boolean>(false);
const router = useRouter();
// 排名弹窗显隐
const rankingModelVisible = ref<boolean>(false)
// 红蓝方计数器
const redCounter = ref<number>(1);
const blueCounter = ref<number>(1);
const blueNames = ref<string[]>([])
const redNames = ref<string[]>([])
// 模型推演配置
const modelDeduction = ref<ModelDeduction>({ ...defaultModelDeduction });
// 推演Pods数据扩展类型增加进度更新定时器
const deductionPods = ref<(DeductionPod & {
animatePercent: number; // 动画进度值
targetPercent: number; // 目标进度值
stopped: boolean; // 是否暂停
progressTimer: any; // 动画定时器
updateTimer: any; // 进度更新定时器
})[]>([]);
// 心跳方法定时器标识
const heartbeatTimer = ref<any | null>(null);
const selectedDeduction = ref<DeductionPod | null | undefined>(null);
const getTeamName = (name: NullableString | undefined, side: string, level: number = 1): string => {
if(name){
if(name.length>3){
return name.substring(0,2) + '...';
}
return name;
}
return `${side === 'red' ? '红方' : '蓝方'}${level}`
}
const parseNumberPercent = (source: number|null , target: number|null) : number => {
if(source && target){
try{
return Number(Number((source/ target) * 100).toFixed(2));
} catch (e: any){
console.error(e);
}
}
return 0;
}
const handleDetails = (item: Partial<DeductionPod>) => {
// chartsModalVisible.value = true;
// selectedDeduction.value = JSON.parse(JSON.stringify(item));
router.push({
path: `/app/ai/applications/gambling/${item.id}/charts`
})
};
/**
* 随机更新进度值(核心修改:优化初始启动逻辑)
* @param pod 单个pod实例
*/
const randomUpdateProgress = (pod: any) => {
// 如果暂停或进度已到100%,直接返回
if (pod.stopped || pod.animatePercent >= 100) {
return;
}
// 随机生成下次更新时间1-3秒
const randomInterval = 1000 + Math.random() * 2000;
// 随机生成进度增长量1-5%
const randomIncrement = 1 + Math.random() * 4;
pod.updateTimer = setTimeout(() => {
// 计算新的目标进度不超过100%
pod.targetPercent = Math.min(pod.animatePercent + randomIncrement, 100);
// 启动进度动画
animateProgress(pod, pod.targetPercent);
// 递归调用,实现持续更新
randomUpdateProgress(pod);
}, randomInterval);
};
/**
* 暂停/开始进度更新
* @param item 单个pod实例
*/
const confirmPause = (item: any) => {
item.simulationStatus = item.simulationStatus === 1 ? 2 : 1;
runDeductionPodAfsimControl({
jobId: item.jobId,
afsimHostIp: item.afsimHostIp,
afsimNodePort81: item.afsimNodePort81,
type: item.simulationStatus, // 1-恢复仿真2-暂停仿真3-查询状态)
}).then(r=> {
message.info(r.msg);
if(r.code === 200) {
item.stopped = !item.stopped;
}
if(r.data?.stateDescription){
item.statusName = r.data.stateDescription;
}
})
// if (item.stopped) {
// // 暂停:清除进度更新定时器
// if (item.updateTimer) {
// clearTimeout(item.updateTimer);
// item.updateTimer = null;
// }
// message.info('已暂停');
// } else {
// // 开始:重新启动进度更新
// randomUpdateProgress(item);
// message.info('已恢复');
// }
};
const handleTermStatusPopoverVisible = (item: Partial<DeductionPod>)=> {
item.termStatusPopoverVisible = ! item.termStatusPopoverVisible;
runDeductionPodAfsimControl({
jobId: item.jobId,
afsimHostIp: item.afsimHostIp,
afsimNodePort81: item.afsimNodePort81,
type: 3, // 1-恢复仿真2-暂停仿真3-查询状态)
}).then(r=> {
message.info(r.msg);
if(r.data.stateDescription){
item.statusName = r.data.stateDescription;
}
})
}
/**
* 删除pod同时清除相关定时器
* @param item 单个pod实例
*/
const confirmDelete = (item: any) => {
console.error('confirmDelete', item);
// 清除该pod的所有定时器
if (item.updateTimer) clearTimeout(item.updateTimer);
if (item.progressTimer) clearInterval(item.progressTimer);
deleteModelDeduction(item.id as number).then(res => {
if (res.code === 200) {
message.info('删除成功.');
loadData();
}
});
};
// 进度条平滑动画函数(保留原有逻辑)
const animateProgress = (pod: any, targetPercent: number) => {
targetPercent = Math.max(0, Math.min(100, Number(targetPercent) || 0));
if (typeof pod.animatePercent !== 'number') {
pod.animatePercent = 0;
}
const step = 0.5;
if (pod.progressTimer) {
clearInterval(pod.progressTimer);
}
if (Math.abs(pod.animatePercent - targetPercent) < step) {
pod.animatePercent = targetPercent;
return;
}
pod.progressTimer = setInterval(() => {
if (pod.animatePercent < targetPercent) {
pod.animatePercent = Math.min(pod.animatePercent + step, targetPercent);
} else {
pod.animatePercent = Math.max(pod.animatePercent - step, targetPercent);
}
if (Math.abs(pod.animatePercent - targetPercent) < step) {
pod.animatePercent = targetPercent;
clearInterval(pod.progressTimer);
pod.progressTimer = null;
}
}, 30);
};
// 点击PK卡片打开链接保留原有逻辑
const handleClickPkCard = (item: DeductionPod) => {
if (item?.afsimHostIp && item?.afsimNodePort6901) {
let url = `${item.afsimHostIp}:${item.afsimNodePort6901}`;
if(!url.startsWith('http://') && !url.startsWith('https://')) {
url = 'https://' + url;
}
const newWindow = window.open(url);
if (!newWindow) {
message.warning('窗口打开失败,请检查浏览器弹窗设置');
}
} else {
message.warning('缺少IP或端口信息无法打开链接');
}
};
const refresh = () => {
if (deductionPods.value) {
deductionPods.value.forEach(podItem => {
console.info('refresh', podItem);
randomUpdateProgress(podItem);
});
}
};
// 加载数据方法核心修改确保每个pod初始化后立即启动进度更新
const loadData = () => {
findDeductionPodResult().then(r => {
let rows: DeductionPod[] = Object.values(r.data ?? []) as DeductionPod[];
const newPods: any[] = [];
rows.forEach(row=> {
let metricsParsed: DeductionPodMetrics | null = null;
try {
const metricsStr = row?.metrics?.toString() ?? '';
metricsParsed = metricsStr ? JSON.parse(metricsStr) as DeductionPodMetrics : null;
} catch (e: any) {
console.warn('解析 metrics 失败:', e);
}
// 初始化进度相关参数默认不暂停进度从0开始
const podItem = {
...row,
metricsParsed,
fake: false,
stopped: false, // 默认不暂停,页面加载后直接运行
targetPercent: parseNumberPercent(row.currentRound, row.totalRound), // 初始目标进度
animatePercent: 0, // 初始动画进度
progressTimer: null, // 动画定时器
updateTimer: null, // 进度更新定时器
statusName: null,
termStatusPopoverVisible: false,
};
newPods.push(podItem);
})
// setTimeout(() => refresh(), 1000);
deductionPods.value = newPods;
console.log('最终 deductionPods 数据:', deductionPods.value);
});
};
// 心跳方法(加载数据)
const heartbeat = () => {
loadData();
};
// 增加红蓝方计数器
const add = (side: string)=> {
if('blue' === side){
blueCounter.value ++;
} else {
redCounter.value ++;
}
};
// 减少红蓝方计数器
const minus = (side: string)=> {
if('blue' === side){
blueCounter.value = Math.max(1, blueCounter.value - 1);
blueNames.value = blueNames.value.splice(blueNames.value.length-1,1);
} else {
redCounter.value = Math.max(1, redCounter.value - 1);
redNames.value = redNames.value.splice(redNames.value.length-1,1);
}
};
// 开始对抗
const startLoop = () => {
modelDeduction.value.redNames = redNames.value.filter(v=> v).join(',')
modelDeduction.value.blueNames = blueNames.value.filter(v=> v).join(',')
createModelDeduction(modelDeduction.value).then(res => {
if (res.code === 200) {
message.success('对抗已开始');
if (heartbeatTimer.value) {
clearInterval(heartbeatTimer.value);
}
heartbeat();
heartbeatTimer.value = setInterval(() => {
heartbeat();
}, 10000);
} else if (res.msg) {
message.error(res.msg);
}
}).catch(err => {
console.error('提交配置失败:', err);
message.error('提交配置失败,请重试');
});
};
// 组件挂载时加载初始数据(页面加载完成后自动执行,触发进度模拟)
onMounted(() => {
// 页面挂载后立即加载数据数据加载完成后自动启动所有Pods的进度更新
loadData();
});
heartbeatTimer.value = setInterval(() => {
loadData();
}, 3000);
// 组件卸载时清除所有定时器(防止内存泄漏,增强版)
onUnmounted(() => {
// 清除心跳定时器
if (heartbeatTimer.value) {
clearInterval(heartbeatTimer.value);
}
// 清除所有pod的定时器
// deductionPods.value.forEach(pod => {
// if (pod.progressTimer) clearInterval(pod.progressTimer);
// if (pod.updateTimer) clearTimeout(pod.updateTimer);
// });
// 清空pods数据避免残留
deductionPods.value = [];
});
</script>
<style lang="less">
.bg-wrapper .ant-card {
&.ks-apps-card{
&.ks-top-apps-card {
margin-bottom:15px!important;
&> .ant-card-body{
height: 35vh;
overflow: hidden;
.ant-form-item{
margin-bottom:15px;
}
}
}
&.ks-bottom-apps-card{
margin-bottom:0px!important;
&> .ant-card-body{
height: 32vh;
overflow: auto;
.ant-form-item{
margin-bottom:15px;
}
}
}
}
&.ks-pk-apps-card{
&> .ant-card-body{
height: 74vh;
}
}
.counter-wrapper{
border: 1px solid #475f71;
padding: 15px;
border-radius: 2px;
.counter-wrapper-item{
margin-bottom:15px;
text-align: left;
.anticon{
color:#a2b1ba;
cursor: pointer;
font-size: 18px;
line-height: 30px;
display: block;
}
&:last-child{
margin-bottom:0;
}
}
}
}
// 进度条动画样式优化(增强平滑度)
.ant-progress-inner {
transition: width 0.05s ease-in-out;
}
.ant-progress-bg {
transition: width 0.05s ease-in-out;
}
</style>

View File

@@ -1,692 +0,0 @@
<template>
<a-modal :open="visible" class="ks-ranking-modal" centered width="98%" :footer="null" @cancel="handleCancel">
<div class="modal-overlay"></div>
<div class="ranking-container">
<!-- 表头 -->
<div class="table-header">
<div class="header-row">
<div class="header-cell rank">排名</div>
<div class="header-cell team">团队</div>
<div class="header-cell red-win-rate">红方胜率</div>
<div class="header-cell blue-win-rate">蓝方胜率</div>
<div class="header-cell red-matches">红方场次</div>
<div class="header-cell blue-matches">蓝方场次</div>
<div class="header-cell invalid-matches">博弈关键节点</div>
<div class="header-cell total-score">总分</div>
<div class="header-cell total-win-rate">总胜率</div>
</div>
</div>
<!-- 排行榜主体 -->
<div class="ranking-body">
<template v-for="(team, index) in sortedTeams">
<div
class="team-row"
:class="[team.isFlipping ? 'flipping' : '', indexClasses[index] ? indexClasses[index] : '']"
:style="getRowStyle(index)"
>
<div class="row-front">
<div class="cell rank" :class="getRankClass(team.rank)">
<span class="rank-number">{{ team.rank }}</span>
<!-- <span v-if="team.rankChange !== 0" class="rank-change" :class="getChangeClass(team.rankChange)">-->
<!-- {{ getChangeSymbol(team.rankChange) }}-->
<!-- </span>-->
</div>
<div class="cell team">
<div class="team-info">
<div class="team-name">{{ team.name }}</div>
</div>
</div>
<div class="cell red-win-rate">
{{ String(team.redWinRate).substring(0, 5) }}%
</div>
<div class="cell blue-win-rate">
{{ String(team.blueWinRate).substring(0, 5) }}%
</div>
<div class="cell red-matches">{{ team.redMatches }}</div>
<div class="cell blue-matches">{{ team.blueMatches }}</div>
<div class="cell invalid-matches">{{ team.invalidMatches }}</div>
<div class="cell total-score">{{ team.totalScore }}</div>
<div class="cell total-win-rate">
{{ String(team.totalWinRate).substring(0, 5) }}%
</div>
</div>
<!-- 行背面翻转时显示 -->
<div class="row-back">
<div class="back-content">
<div class="back-title">团队详情</div>
<div class="back-stats">
<div>总场次: {{ team.totalMatches }}</div>
<div>红方胜场: {{ team.redWins }}</div>
<div>蓝方胜场: {{ team.blueWins }}</div>
<div>连续胜场: {{ team.winStreak }}</div>
</div>
</div>
</div>
</div>
</template>
</div>
<!-- 控制面板 -->
<!-- <div class="control-panel">-->
<!-- <button @click="toggleAutoRefresh" :class="{ active: autoRefresh }">-->
<!-- {{ autoRefresh ? '暂停更新' : '开始更新' }}-->
<!-- </button>-->
<!-- <button @click="manualUpdate">手动更新排名</button>-->
<!-- <button @click="triggerFlip">手动翻转</button>-->
<!-- <div class="timer-display">-->
<!-- 下次更新: {{ nextUpdateTime }}-->
<!-- </div>-->
<!-- </div>-->
</div>
<template #title>
<div class="header-export-button">
<a-tooltip title="排名结果导出" placement="bottom">
<CloudDownloadOutlined class="download-icon" @click="handleExport"/>
<!-- <span style="margin-left:10px;">排名结果导出</span>-->
</a-tooltip>
</div>
</template>
</a-modal>
</template>
<script lang="ts">
import { computed, defineComponent, onMounted, onUnmounted, ref, type CSSProperties, type SetupContext } from 'vue';
import {CloudDownloadOutlined} from '@ant-design/icons-vue';
// 定义团队数据接口
interface Team {
id: number;
name: string;
rank: number;
redWinRate: number;
blueWinRate: number;
redMatches: number;
blueMatches: number;
invalidMatches: string;
totalScore: number;
totalWinRate: number;
rankChange: number;
isFlipping?: boolean;
// 计算属性实例getter
totalMatches: number;
redWins: number;
blueWins: number;
winStreak: number;
}
// 定义Props类型
interface RankProps {
visible: boolean;
}
// 定义Emits类型
type RankEmits = {
cancel: []; // 无参数的cancel事件
};
// 团队数据(添加类型注解)
const teams = ref<Team[]>([
{ id: 1, name: '团队3', rank: 1, redWinRate: 85, blueWinRate: 72, redMatches: 20, blueMatches: 18, invalidMatches: "2:30'50''", totalScore: 95, totalWinRate: 78, rankChange: 0,
totalMatches: 0, redWins: 0, blueWins: 0, winStreak: 0 },
{ id: 2, name: '红方', rank: 2, redWinRate: 78, blueWinRate: 81, redMatches: 22, blueMatches: 20, invalidMatches: "1:31'30''", totalScore: 92, totalWinRate: 79, rankChange: 0,
totalMatches: 0, redWins: 0, blueWins: 0, winStreak: 0 },
{ id: 3, name: '团队3', rank: 3, redWinRate: 80, blueWinRate: 75, redMatches: 18, blueMatches: 16, invalidMatches: "2:10'22''", totalScore: 90, totalWinRate: 77, rankChange: 0,
totalMatches: 0, redWins: 0, blueWins: 0, winStreak: 0 },
{ id: 4, name: '团队4', rank: 4, redWinRate: 72, blueWinRate: 85, redMatches: 19, blueMatches: 21, invalidMatches: "3:01'12''", totalScore: 88, totalWinRate: 76, rankChange: 0,
totalMatches: 0, redWins: 0, blueWins: 0, winStreak: 0 },
{ id: 5, name: '团队8', rank: 5, redWinRate: 68, blueWinRate: 79, redMatches: 17, blueMatches: 19, invalidMatches: "2:45'21''", totalScore: 85, totalWinRate: 73, rankChange: 0,
totalMatches: 0, redWins: 0, blueWins: 0, winStreak: 0 },
{ id: 6, name: '团队5', rank: 6, redWinRate: 75, blueWinRate: 70, redMatches: 16, blueMatches: 15, invalidMatches: "1:02'33''", totalScore: 82, totalWinRate: 72, rankChange: 0,
totalMatches: 0, redWins: 0, blueWins: 0, winStreak: 0 },
{ id: 7, name: '团队7', rank: 7, redWinRate: 70, blueWinRate: 65, redMatches: 14, blueMatches: 13, invalidMatches: "3:20'10''", totalScore: 78, totalWinRate: 68, rankChange: 0,
totalMatches: 0, redWins: 0, blueWins: 0, winStreak: 0 },
{ id: 8, name: '团队6', rank: 8, redWinRate: 65, blueWinRate: 72, redMatches: 12, blueMatches: 14, invalidMatches: "2:33'16''", totalScore: 75, totalWinRate: 67, rankChange: 0,
totalMatches: 0, redWins: 0, blueWins: 0, winStreak: 0 },
{ id: 9, name: '蓝方0', rank: 9, redWinRate: 60, blueWinRate: 68, redMatches: 10, blueMatches: 12, invalidMatches: "2:12'54''", totalScore: 70, totalWinRate: 63, rankChange: 0,
totalMatches: 0, redWins: 0, blueWins: 0, winStreak: 0 },
{ id: 10, name: '团队9', rank: 10, redWinRate: 55, blueWinRate: 60, redMatches: 8, blueMatches: 10, invalidMatches: "3:01'02''", totalScore: 65, totalWinRate: 58, rankChange: 0,
totalMatches: 0, redWins: 0, blueWins: 0, winStreak: 0 },
]);
export default defineComponent({
components: {
CloudDownloadOutlined,
},
props: {
visible: {
type: Boolean,
required: true
},
},
emits: {
cancel: () => true
},
setup(_props: RankProps, { emit }: SetupContext<RankEmits>) {
const autoRefresh = ref<boolean>(true);
const nextUpdateTime = ref<number>(30);
let rankTimer: any | null = null;
let flipTimer: any | null = null;
let countdownTimer: any | null = null;
const indexClasses: Record<number, string> = {
0: 'first-row',
1: 'second-row',
2: 'third-row',
};
const sortedTeams = computed<Team[]>(() => {
return [...teams.value].sort((a, b) => a.rank - b.rank);
});
const getRowStyle = (index: number): CSSProperties => {
const delay = index * 0.1;
return {
'--flip-delay': `${delay}s`,
};
};
// 获取排名样式类
const getRankClass = (rank: number): string => {
if (rank === 1) return 'rank-first';
if (rank === 2) return 'rank-second';
if (rank === 3) return 'rank-third';
return '';
};
// 获取变化样式类
const getChangeClass = (change: number): string => {
if (change > 0) return 'change-up';
if (change < 0) return 'change-down';
return '';
};
// 获取变化符号
const getChangeSymbol = (change: number): string => {
if (change > 0) return `${change}`;
if (change < 0) return `${Math.abs(change)}`;
return '-';
};
// 手动更新排名
const manualUpdate = (): void => {
updateRankings();
};
// 手动触发翻转
const triggerFlip = (): void => {
teams.value.forEach(team => {
team.isFlipping = true;
setTimeout(() => {
team.isFlipping = false;
}, 600);
});
};
// 切换自动更新
const toggleAutoRefresh = (): void => {
autoRefresh.value = !autoRefresh.value;
if (autoRefresh.value) {
startTimers();
} else {
clearTimers();
}
};
// 更新排名逻辑
const updateRankings = (): void => {
// 保存旧排名Record类型key为team.idvalue为rank
const oldRanks: Record<number, number> = teams.value.reduce((acc, team) => {
acc[team.id] = team.rank;
return acc;
}, {} as Record<number, number>);
// 随机打乱并重新分配排名
const shuffled: Team[] = [...teams.value]
.sort(() => Math.random() - 0.5)
.map((team, index) => ({
...team,
rank: index + 1,
// 随机更新一些数据(保持数值范围合理性)
redWinRate: Math.min(100, Math.max(50, team.redWinRate + (Math.random() * 10 - 5))),
blueWinRate: Math.min(100, Math.max(50, team.blueWinRate + (Math.random() * 10 - 5))),
redMatches: team.redMatches + Math.floor(Math.random() * 3),
blueMatches: team.blueMatches + Math.floor(Math.random() * 2),
totalScore: team.totalScore + Math.floor(Math.random() * 5),
totalWinRate: Math.min(100, Math.max(50, team.totalWinRate + (Math.random() * 8 - 4))),
}))
.map(team => {
// 计算排名变化
const oldRank = oldRanks[team.id] as number;
team.rankChange = oldRank - team.rank;
return team;
});
teams.value = shuffled;
};
// 翻转动画
const flipRows = (): void => {
teams.value.forEach(team => {
team.isFlipping = true;
setTimeout(() => {
team.isFlipping = false;
}, 600);
});
};
// 开始定时器
const startTimers = (): void => {
// 排名更新定时器30秒
rankTimer = setInterval(() => {
updateRankings();
}, 30000);
// 翻转定时器15秒
flipTimer = setInterval(() => {
flipRows();
}, 15000);
// 倒计时显示
nextUpdateTime.value = 30;
countdownTimer = setInterval(() => {
nextUpdateTime.value--;
if (nextUpdateTime.value <= 0) {
nextUpdateTime.value = 30;
}
}, 1000);
};
// 清除定时器
const clearTimers = (): void => {
if (rankTimer) clearInterval(rankTimer);
if (flipTimer) clearInterval(flipTimer);
if (countdownTimer) clearInterval(countdownTimer);
// 重置定时器变量
rankTimer = null;
flipTimer = null;
countdownTimer = null;
};
// 生命周期:挂载时初始化
onMounted(() => {
// 为每个团队添加计算属性实例getter
teams.value = teams.value.map(team => ({
...team,
isFlipping: false,
get totalMatches() {
// 注意invalidMatches是时间字符串这里原逻辑有问题暂时保持原有写法
return this.redMatches + this.blueMatches + this.invalidMatches.length;
},
get redWins() {
return Math.round(this.redMatches * this.redWinRate / 100);
},
get blueWins() {
return Math.round(this.blueMatches * this.blueWinRate / 100);
},
get winStreak() {
return Math.floor(Math.random() * 10) + 1;
},
}));
if (autoRefresh.value) {
startTimers();
}
});
// 生命周期:卸载时清理
onUnmounted(() => {
clearTimers();
});
// 取消事件处理
const handleCancel = (): void => emit('cancel');
const handleExport = () => {
try {
// 创建临时a标签用于触发下载
const link = document.createElement('a');
// 设置导出接口地址如果有URL参数可直接拼接/api/xxx?startTime=2026-01-01
link.href = '/api/modelDeduction/downloadRankData';
// 自定义下载文件名(后端也可通过响应头覆盖此值)
link.download = '排名数据.xlsx';
// 部分浏览器需要将a标签加入DOM才能触发下载
document.body.appendChild(link);
// 触发点击下载
link.click();
// 下载完成后移除临时标签清理DOM
document.body.removeChild(link);
} catch (error) {
// 异常捕获,给用户友好提示
console.error('导出失败:', error);
alert('数据导出失败,请稍后重试!');
}
};
return {
handleCancel,
indexClasses,
sortedTeams,
getRowStyle,
getRankClass,
getChangeClass,
toggleAutoRefresh,
autoRefresh,
manualUpdate,
triggerFlip,
nextUpdateTime,
getChangeSymbol,
handleExport,
};
},
});
</script>
<style lang="less">
.ks-ranking-modal {
position: relative;
background: #0d1f34;
background: url('@/assets/rank/titled-container.png') center / 100% 100%;
.ant-modal-close {
right: 65px;
top: 65px;
}
.ant-modal-content{
position: relative;
}
.export-button{
position: absolute;
right: 60px;
bottom: 40px;
}
.header-export-button{
position: absolute;
right: 100px;
top: 68px;
.download-icon{
cursor: pointer;
width: 23px;
height: 23px;
font-size: 14px;
border-radius: 50%;
border: 1px solid #10e5ff;
text-align: center;
display: block;
line-height: 20px;
color: #10e5ff;
}
}
//.modal-overlay {
// background: #000000b0;
// position: absolute;
// width: 100%;
// height: 100%;
// z-index: -1;
//}
.ranking-container {
padding: 10px 30px;
}
.table-header {
background: rgba(255, 255, 255, 0.05);
margin-top: 100px;
margin-bottom: 10px;
}
.header-row {
display: grid;
grid-template-columns: 0.8fr 1.5fr 1.2fr 1.2fr 1fr 1fr 1fr 0.8fr 1.2fr;
padding: 15px 20px;
gap: 10px;
}
.header-cell {
color: #8da2c0;
font-weight: bold;
font-size: 13px;
text-transform: uppercase;
letter-spacing: 1px;
&.rank{
margin-left: 15px;
}
}
.ranking-body {
min-height: 600px;
}
.team-row {
background: rgba(255, 255, 255, 0.05);
border-radius: 8px;
margin-bottom: 8px;
position: relative;
transform-style: preserve-3d;
transition: transform 0.6s ease;
transform-origin: center center;
height: 50px;
overflow: hidden;
background: url('@/assets/rank/bg-3.png') center / 100% 100%;
.rank-number {
width: 60px;
height: 40px;
text-align: center;
font-size: 18px;
color: #fff;
line-height: 40px;
}
&.first-row {
background: url('@/assets/rank/bg-1.png') center / 100% 100%;
.rank-number {
background: url('@/assets/rank/icon-1.png') center / 100% 100%;
}
}
&.second-row {
background: url('@/assets/rank/bg-2.png') center / 100% 100%;
.rank-number {
background: url('@/assets/rank/icon-2.png') center / 100% 100%;
}
}
&.third-row {
.rank-number {
background: url('@/assets/rank/icon-3.png') center / 100% 100%;
}
}
}
.team-row.flipping {
transform: rotateX(180deg);
transition-delay: var(--flip-delay);
}
.row-front,
.row-back {
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden;
display: grid;
grid-template-columns: 0.8fr 1.5fr 1.2fr 1.2fr 1fr 1fr 1fr 0.8fr 1.2fr;
padding: 0 20px;
gap: 10px;
align-items: center;
}
.row-back {
background: linear-gradient(135deg, #4a00e0 0%, #8e2de2 100%);
transform: rotateX(180deg);
color: white;
border-radius: 8px;
}
.back-content {
grid-column: 1 / -1;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 20px;
}
.back-title {
font-size: 18px;
font-weight: bold;
}
.back-stats {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 10px 30px;
font-size: 14px;
}
.rank,
.cell {
color: #fff;
font-size: 14px;
display: flex;
align-items: center;
}
//.rank {
// font-weight: bold;
// font-size: 18px;
// justify-content: center;
// position: relative;
//}
.rank-first {
color: #ffd700;
}
.rank-second {
color: #c0c0c0;
}
.rank-third {
color: #cd7f32;
}
.rank-number {
margin-right: 5px;
}
.rank-change {
font-size: 12px;
padding: 2px 6px;
border-radius: 10px;
background: rgba(255, 255, 255, 0.1);
}
.change-up {
color: #4CAF50;
}
.change-down {
color: #f44336;
}
.team-info {
display: flex;
flex-direction: column;
}
.team-name {
font-weight: bold;
margin-bottom: 4px;
}
.team-id {
font-size: 11px;
color: #8da2c0;
}
.progress-bar {
background: rgba(255, 255, 255, 0.1);
height: 20px;
border-radius: 10px;
overflow: hidden;
position: relative;
}
.progress-bar.blue .progress-fill {
background: linear-gradient(90deg, #2196F3, #03A9F4);
}
.progress-bar.total .progress-fill {
background: linear-gradient(90deg, #FF9800, #FFC107);
}
.progress-fill {
height: 100%;
background: linear-gradient(90deg, #f44336, #ff9800);
border-radius: 10px;
transition: width 0.3s ease;
}
.progress-text {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
font-size: 12px;
color: white;
font-weight: bold;
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.control-panel {
display: flex;
justify-content: center;
gap: 15px;
margin-top: 25px;
padding-top: 20px;
border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.control-panel button {
padding: 10px 20px;
border: none;
border-radius: 6px;
background: rgba(255, 255, 255, 0.1);
color: white;
cursor: pointer;
transition: all 0.3s ease;
font-size: 14px;
}
.control-panel button:hover {
background: rgba(255, 255, 255, 0.2);
transform: translateY(-2px);
}
.control-panel button.active {
background: linear-gradient(135deg, #4a00e0, #8e2de2);
}
.timer-display {
display: flex;
align-items: center;
padding: 0 20px;
background: rgba(255, 255, 255, 0.05);
border-radius: 6px;
color: #8da2c0;
font-size: 14px;
}
}
</style>

View File

@@ -1,222 +0,0 @@
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2026 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
import type { ApiDataResponse, NullableString } from '@/types';
export interface DeductionPodMetricsDetails {
// 开火奖励累计值
fire_reward: NullableString;
// 接近敌机奖励累计值
approach_reward: NullableString;
// 越界惩罚累计值
boundary_penalty: NullableString;
lock_reward: NullableString;
damage_reward: NullableString;
// 胜利奖励值
win_bonus: NullableString;
[key: string]: unknown;
}
export interface DeductionPodMetrics {
// 本轮总奖励。该 Episode 获得的总分。
reward: NullableString;
// 本轮生存步数。该 Episode 持续的步数,
steps: number;
// 胜负判定。1 表示胜利0表示失败/平局。
is_win: number;
// 环境分项奖励明细。包含环境返回的所有细分奖励项(动态字段)。
details: null | DeductionPodMetricsDetails;
[key: string]: unknown;
}
export interface DeductionPod {
id: number;
// 关联推演ID
deductionId: number;
// RayJob名称
jobName: NullableString;
// RayJob主机IP
jobHostIp: NullableString;
// 8000端口映射
jobNodePort8000: NullableString;
// 8265端口映射
jobNodePort8265: NullableString;
// Afsim主机IP
afsimHostIp: NullableString;
// 6901端口映射
afsimNodePort6901: NullableString;
// 50051端口映射
afsimNodePort50051: NullableString;
// 状态1-正常0-已删除)
status: number;
// 推演任务Job_ID
jobId: NullableString;
// 总轮数
totalRound: number;
// 当前轮数
currentRound: number;
// 内部详细指标,JSON格式
metrics: NullableString;
// 红方名称
redName: NullableString,
// 蓝方名称
blueName: NullableString;
// 仿真状态1-运行2-暂停)
simulationStatus: Number;
metricsParsed: null | DeductionPodMetrics;
[key: string]: unknown;
}
export interface DeductionPodResult extends ApiDataResponse<DeductionPod[]> {
}
export interface ModelDeduction {
// 推演记录ID
id: number | null,
deductionId: number | null,
// 部署模型路径
deploymentModelPath: NullableString,
// 对抗轮数配置
competitionRound: NullableString,
// 对抗场次配置
competitionSession: number,
// 并发调度配置
balanceStrategy: NullableString | number | undefined,
// 推演倍数设置
deductionMultiple: number,
// 对抗模式选择
competitionMode: NullableString | number | undefined | null,
// 数据状态1-正常0-已删除)
status: number | null,
// 蓝方名称
blueNames: NullableString,
// 红方名称
redNames: NullableString,
stopped: boolean;
[key: string]: unknown;
}
export interface ModelDeductionData {
id: number | null,
// 关联Pod信息ID
deductionPodId: number,
// 当前轮数
currentEpisode: number,
// 累计总步数
totalSteps: number,
// 蓝方总开火次数
fireTimesBlue: number,
// 红方总开火次数
fireTimesRed: number,
// 蓝方本轮回报
episodeReturnsBlue: number,
// 红方本轮回报
episodeReturnsRed: number,
// 当前轮次生存步数
episodeLengths: number,
// 胜负历史
winHistory: NullableString,
// 蓝方最近10轮平均回报
avgReturn1Last10: number,
// 蓝方最近100轮平均回报
avgReturn1Last100: number,
// 红方最近10轮平均回报
avgReturn2Last10: number,
// 红方最近100轮平均回报
avgReturn2Last100: number,
// 平均每轮步数
avgEpisodeLength: number,
// 蓝方胜率
winRate: number,
// 蓝方败率
lossRate: number,
// 平局率
drawRate: number,
// 当前轮步数
stepInEpisode: number,
// 蓝方回报分量详情
returnComponentsBlue: NullableString,
// 红方回报分量详情
returnComponentsRed: NullableString,
// 蓝方本轮惩罚值
returnDelnatyBlue: number,
// 红方本轮惩罚值
returnDelnatyRed: number,
// 蓝方每轮弹药消耗量
fireConsumeBlue: number,
// 红方每轮弹药消耗量
fireConsumeRed: number,
// 蓝方本轮首次开火时间步
firstFireTimeBlue: number,
// 红方本轮首次开火时间步
firstFireTimeRed: number,
// 蓝方攻击持续时间
attackTimeBlue: number,
// 蓝方生存步数
episodeLengthsBlue: number | null,
// 红方生存步数
episodeLengthsRed: number | null,
// 蓝方胜次数
blueWinRounds: number,
// 红方胜次数
redWinRounds: number,
// 红方攻击持续时间
attackTimeRed: number,
// 能量优势序列JSON数组1=优势0=劣势)
energyAdvantage: NullableString,
// 蓝方轨迹纬度序列JSON数组
trajectoryBlueLat: NullableString,
// 蓝方轨迹经度序列JSON数组
trajectoryBlueLon: NullableString,
// 蓝方轨迹高度序列JSON数组
trajectoryBlueAlt: NullableString,
// 红方轨迹纬度序列JSON数组
trajectoryRedLat: NullableString,
// 红方轨迹经度序列JSON数组
trajectoryRedLon: NullableString,
// 红方轨迹高度序列JSON数组
trajectoryRedAlt: NullableString,
// 状态1-正常0-已删除)
status: number,
// 创建者
createBy: NullableString,
// 创建时间
createTime: NullableString,
// 备注
remark: NullableString,
normalizedBlueTrajectory: number[];
normalizedRedTrajectory: number[];
[key: string]: unknown;
}
export interface ModelDeductionDataResponse extends ApiDataResponse<ModelDeductionData[]> {
}
export interface ModelDeductionDetailsResponse extends ApiDataResponse<DeductionPod> {
}
export interface ModelDeductionPodStatus {
status: NullableString,
state: NullableString,
stateDescription: NullableString,
}
export interface ModelDeductionPodStatusResponse extends ApiDataResponse<ModelDeductionPodStatus> {
}

View File

@@ -1,22 +0,0 @@
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2026 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
import type { NullableString } from '@/types';
export interface DraggableElement {
id: number | null,
key?: NullableString,
name: NullableString,
description: NullableString,
category: NullableString,
draggable: boolean,
parent?: DraggableElement,
children: DraggableElement[]
[key: string]: unknown;
}

View File

@@ -1,322 +0,0 @@
<template>
<a-dropdown :trigger="['contextmenu']" @openChange="handleVisibleChange">
<a-card
:class="[
'ks-designer-node',
`ks-designer-${element?.category ?? 'model'}-node`
]"
hoverable
>
<template #title>
<a-space>
<span class="ks-designer-node-icon"></span>
<span class="ks-designer-node-title">{{ element?.name ?? '-' }}</span>
</a-space>
</template>
<!-- 节点内容区域 -->
<div class="w-full" v-if="element?.category !== 'component'">
<div class="ks-designer-node-content">
<div
v-for="(item, index) in element?.element?.children || []"
:key="item.id || index"
class="ks-designer-node-row"
>
<div
:data-port="`in-${item.id || index}`"
:title="`入桩: ${item.name}`"
class="port port-in"
magnet="passive"
></div>
<!-- child名称 -->
<div class="ks-designer-node-name">
{{ item.name }}
</div>
<!-- 右侧出桩只能作为连线源 -->
<div
:data-port="`out-${item.id || index}`"
:title="`出桩: ${item.name}`"
class="port port-out"
magnet="active"
></div>
</div>
<div v-if="!(element?.element?.children && element?.element?.children?.length > 0)" class="ks-designer-node-row">
<div class="port port-in" data-port="in-0" magnet="passive"></div>
<div class="ks-designer-node-name">
{{ element?.name ?? '-' }}
</div>
<div class="port port-out" data-port="out-0" magnet="active"></div>
</div>
</div>
</div>
<div class="w-full" v-else>
<p>隐藏纬度: {{ element?.parameters?.hiddenLatitude ?? '-' }}</p>
<p>激活函数: {{ element?.parameters?.activationFunction ?? '-' }}</p>
</div>
</a-card>
<template #overlay>
<a-menu @click="handleMenuClick">
<a-menu-item key="delete">
<template #icon>
<DeleteOutlined />
</template>
删除
</a-menu-item>
</a-menu>
</template>
</a-dropdown>
</template>
<script lang="ts">
import { defineComponent, onMounted, onUnmounted, ref } from 'vue';
import { elementProps } from './props';
import type { ModelElement } from '../model/types';
import { DeleteOutlined, SettingOutlined } from '@ant-design/icons-vue';
import type { Graph } from '@antv/x6';
export default defineComponent({
name: 'ModelElement',
components: {
SettingOutlined,
DeleteOutlined,
},
props: elementProps,
setup(_props) {
const element = ref<ModelElement | null>(
_props.node ? (_props.node.getData() as ModelElement) : null,
);
const updateKey = ref(0);
const isMenuVisible = ref(false);
// 获取画布实例
const getGraph = (): Graph | null => {
return _props.graph as Graph || null;
};
// 监听节点数据变化
const handleDataChange = () => {
if (_props.node) {
element.value = _props.node.getData() as ModelElement;
} else {
element.value = null;
}
updateKey.value++;
};
const handleVisibleChange = (visible: boolean) => {
isMenuVisible.value = visible;
};
const handleMenuClick = ({ key }: { key: string }) => {
if (key === 'delete') {
handleDelete();
}
};
const handleDelete = () => {
if (!_props.node) return;
const graph = getGraph();
if (graph) {
try {
// 先删除关联边
const connectedEdges = graph.getConnectedEdges(_props.node);
connectedEdges.forEach(edge => graph.removeEdge(edge));
// 再删除节点
graph.removeNode(_props.node);
console.info(`节点 ${_props.node.id} 已删除`);
} catch (error) {
console.error('删除节点失败:', error);
}
}
isMenuVisible.value = false;
};
onMounted(() => {
_props.node?.on('change:data', handleDataChange);
});
onUnmounted(() => {
_props.node?.off('change:data', handleDataChange);
});
return {
element,
handleMenuClick,
handleVisibleChange,
};
},
});
</script>
<style lang="less">
.ks-designer-node {
background: linear-gradient(150deg, #093866 1%, #1f69b3 55%);
border: 0;
border-radius: 8px;
width: 100%;
height: 100%;
cursor: pointer;
position: relative;
.ant-card-head {
border: 0;
height: 38px;
min-height: 38px;
border-radius: 0;
color: #ddd;
font-size: 12px;
font-weight: normal;
padding: 0 20px;
}
.ks-designer-node-icon {
width: 15px;
height: 15px;
display: block;
position: absolute;
left: 8px;
top: 13px;
background: url('@/assets/icons/model-4.svg') center / 100% 100%;
}
.ks-designer-node-title {
font-size: 13px;
}
.ant-card-body {
color: #fff;
height: calc(100% - 38px);
border-radius: 0;
font-size: 12px;
padding: 8px 15px;
overflow-y: auto;
border-top: 1px solid #195693;
}
&.ks-designer-task-node {
background: linear-gradient(150deg, #20421b 1%, #4a6646 55%);
.ant-card-body {
border-top: 1px solid #466741;
}
.ks-designer-node-icon {
background: url('@/assets/icons/m-02.png') center / 100% 100%;
}
}
&.ks-designer-input-node {
background: linear-gradient(150deg, #083058 1%, #1e5d9b 55%);
.ant-card-body {
border-top: 1px solid #105ca7;
}
.ks-designer-node-icon {
background: url('@/assets/icons/icon-model-input.png') center / 100% 100%;
}
}
&.ks-designer-action-node {
background: linear-gradient(150deg, #343207 1%, #485010 55%);
.ant-card-body {
border-top: 1px solid #59550e;
}
.ks-designer-node-icon {
background: url('@/assets/icons/bg-fk-point.png') center / 100% 100%;
}
}
&.ks-designer-component-node {
background: linear-gradient(150deg, #06226b 1%, #1a43a7 55%);
.ant-card-body {
border-top: 1px solid #26448c;
}
}
&.ks-designer-control-node {
background: linear-gradient(150deg, #1d4f32 1%, #326a5d 55%);
.ant-card-body {
border-top: 1px solid #326a5d;
}
.ks-designer-node-icon {
background: url('@/assets/icons/bg-model-builder-card-title.png') center / 100% 100%;
}
}
// 连接桩容器样式
.ks-designer-node-content {
width: 100%;
display: flex;
flex-direction: column;
gap: 4px; // 每个child行之间的间距
}
// 每个child行包含左右桩+文本)
.ks-designer-node-row {
width: 100%;
display: flex;
align-items: center;
position: relative;
height: 24px; // 固定行高,保证桩对齐
}
// 连接桩基础样式
.port {
width: 12px;
height: 12px;
border-radius: 50%;
cursor: crosshair;
flex-shrink: 0;
box-shadow: 0 0 0 2px rgb(74 114 214 / 80%);
z-index: 10; // 确保桩在最上层
// X6 标记为可连线的磁体
magnet: true;
}
// 左侧入桩样式
.port-in {
background-color: #093866; // 青色:入桩
margin-right: 8px; // 与文本的间距
//border: 1px solid #093866;
// X6 只能作为连线目标(入)
magnet: passive;
box-shadow: none;
width: 20px;
height: 20px;
display: block;
background: url('@/assets/icons/point.svg') center / 100% 100%;
}
// 右侧出桩样式
.port-out {
margin-left: 8px; // 与文本的间距
margin-right: 5px;
// X6 只能作为连线源(出)
magnet: active;
box-shadow: none;
width: 20px;
height: 20px;
display: block;
background: url('@/assets/icons/arrow-right.svg') center / 100% 100%;
}
// 节点文本样式
.ks-designer-node-name {
flex: 1; // 占满中间空间
line-height: 24px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
</style>

View File

@@ -1,81 +0,0 @@
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2026 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
export const menuMap = [
{
key: '0',
title: '工程空间',
children: [
{
key: '0-1',
title: '工程管理',
path: '/app/ai/project/management',
},
{
key: '0-2',
title: '新建/自定义',
path: '/app/ai/project/create',
},
],
},
{
key: '1',
title: '智能体构建工具',
children: [
{
key: '1-1',
title: '智能体管理',
path: '/app/ai/model/management',
},
],
},
{
key: '2',
title: 'AI模型训练',
children: [
{
key: '2-0',
title: '训练任务管理',
path: '/app/ai/training/task/management',
},
{
key: '2-1',
title: '训练任务配置',
path: '/app/ai/training/task/configurer',
},
// {
// key: '2-4',
// title: '训练任务监控',
// path: '/app/ai/training/task/monitor',
// },
],
},
{
key: '3',
title: '博弈竞赛应用',
children: [
{
key: '3-1',
title: '博弈竞赛单元运行环境',
path: '/app/ai/applications/gambling',
},
{
key: '3-2',
title: '仿真测试推演脚本',
type: 'open-script-window'
},
],
},
{
key: '2-3',
title: '训练资源监控',
path: '/app/ai/training/resources/monitor',
children: []
},
];

View File

@@ -1,47 +0,0 @@
<template>
<Wrapper>
<div class="w-screen min-h-screen flex justify-center items-center p-5 box-border">
<div class="text-center flex flex-col gap-6 items-center">
<h1 class="m-0 text-4xl font-normal text-gray-900">智能体研发训练一体化工具</h1>
<div class="flex justify-center">
<a-space class="mt-6 mb-6">
<a-button class="w-[100px]" type="primary">控制台</a-button>
<a-button class="w-[100px]">帮助文档</a-button>
</a-space>
</div>
<div class="text-left flex flex-col gap-6 items-center">
<a-row :gutter="40">
<a-col :span="8">
<a-card :bordered="false" class="dashboard-card h-[150px]" title="开发" @click="gotoPage('/app/ai/model/design')">
模型构建学习算法和训练方法配置
</a-card>
</a-col>
<a-col :span="8">
<a-card :bordered="false" class="dashboard-card h-[150px]" title="训练" @click="gotoPage('/app/ai/training')">
模型部署训练配置与评估可视化
</a-card>
</a-col>
<a-col :span="8">
<a-card :bordered="false" class="dashboard-card h-[150px]" title="应用" @click="gotoPage('/app/ai/applications')">
模型发布应用推理优化
</a-card>
</a-col>
</a-row>
</div>
</div>
</div>
</Wrapper>
</template>
<script setup>
import { Wrapper } from '@/wrapper';
import { useRouter } from 'vue-router';
const router = useRouter();
const gotoPage = (path) => {
router.push({
path: path,
});
};
</script>

View File

@@ -1,274 +0,0 @@
<template>
<div class="ks-finder">
<a-input-search
v-model:value="currentPath"
:placeholder="placeholder"
:readonly="true"
:size="size"
@search="openFinder"
>
<!-- <template #enterButton>-->
<!-- <a-button>Custom</a-button>-->
<!-- </template>-->
</a-input-search>
<a-modal @cancel="()=> modalVisible = false" class="ks-finder-modal" :open="modalVisible" :title="title" centered width="50%">
<div class="ks-finder-list">
<a-row :gutter="15">
<a-col :span="4" v-for="file in files">
<div :class="['ks-finder-item',currentPath === file.path ? 'selected' : '']"
@click="()=> handleClick(file)"
@dblclick="()=> handleDbclick(file)">
<a-tooltip>
<template #title>
{{ file.name }}
</template>
<div class="ks-finder-item-icon">
<FolderFilled v-if="file.directory" />
<FileOutlined v-else />
</div>
</a-tooltip>
<div class="ks-finder-item-name">
{{ getFilename(file.name) }}
</div>
</div>
</a-col>
</a-row>
</div>
<template #footer>
<a-space>
<a-button style="width:120px;" @click="()=> handleCancel()">取消</a-button>
<a-button style="width:120px;" @click="()=> handleSelect()">确定</a-button>
</a-space>
</template>
</a-modal>
</div>
</template>
<script lang="ts">
import { defineComponent, ref, watch } from 'vue';
import { message } from 'ant-design-vue';
import { FileOutlined, FolderFilled } from '@ant-design/icons-vue';
import { findFinderBrowser } from './api';
import type { FinderBrowser } from './types';
import type { NullableString } from '@/types';
export default defineComponent({
components: {
FileOutlined,
FolderFilled,
},
props: {
visible: {
type: Boolean,
default: false,
},
disabled: {
type: Boolean,
default: false,
},
clearable: {
type: Boolean,
default: true,
},
onlyDirectory: {
type: Boolean,
default: true,
},
required: {
type: Boolean,
default: true,
},
path: {
type: [String, null],
default: null,
},
size: {
type: String,
default: null,
},
title: {
type: String,
default: '请选择保存路径',
},
placeholder: {
type: String,
default: '请选择保存路径',
},
},
emits: ['cancel', 'select'],
setup(props, { emit }) {
const modalVisible = ref<boolean>(props.visible);
const currentPath = ref<string>(props.path ?? '');
const files = ref<FinderBrowser[]>([]);
const currentFile = ref<FinderBrowser|null>(null)
const openFinder = () => {
modalVisible.value = true;
};
const loadPaths = (_p: string = '') => {
files.value = [
{
name: 'home',
path: '/home',
directory: true,
children: []
},
];
if(!props.onlyDirectory){
files.value.push(...[
{
name: '空战博弈智能体模型1-100轮.pth',
path: '/空战博弈智能体模型1-100轮.pth',
directory: false,
children: []
},
{
name: '空战博弈智能体模型1-1000轮.pth',
path: '/空战博弈智能体模型1-1000轮.pth',
directory: false,
children: []
},
])
}
// findFinderBrowser(p).then(r => {
// files.value = r.data ?? [];
// });
};
watch(() => props.path, (n: any) => {
currentPath.value = n;
loadPaths(n);
});
watch(() => props.visible, (n: boolean) => {
modalVisible.value = true;
});
const getFilename = (n: NullableString) => {
if (n) {
return n.length > 20 ? (n.substring(0, 24) + '...') : n;
}
return n;
};
const handleClick = (file: FinderBrowser) => {
currentPath.value = file.path;
currentFile.value = file;
};
const handleDbclick = (file: FinderBrowser) => {
// loadPaths(file.path);
};
const handleCancel = () => {
emit('cancel');
modalVisible.value = false;
};
const handleSelect = () => {
if (props.required && !currentPath.value) {
message.error('请选择文件.');
return;
}
modalVisible.value = false;
emit('select', currentPath.value, currentFile.value);
};
loadPaths();
return {
modalVisible,
currentPath,
openFinder,
files,
loadPaths,
getFilename,
handleClick,
handleDbclick,
handleCancel,
handleSelect,
};
},
});
</script>
<style lang="less">
.ks-finder-modal {
.ant-modal-content {
height: 68vh;
}
.ant-modal-close {
position: absolute;
top: 30px;
}
.ant-modal-header {
height: 48px;
.ant-modal-title {
line-height: 50px;
}
}
.ant-modal-body {
}
.ks-finder-list {
overflow-x: hidden;
overflow-y: auto;
border: 1px solid #1c2136;
padding: 15px;
height: 50vh;
}
.ks-finder-item {
text-align: center;
cursor: pointer;
height: 120px;
border: 1px solid transparent;
padding: 10px;
margin-bottom: 15px;
&:hover {
border-color: #4e4f70;
.anticon {
color: #99d8fb;
}
}
&.selected {
border-color: #4e4f70;
.anticon {
color: #fff;
}
}
}
.ks-finder-item-icon {
height: 70px;
width: 100%;
.anticon {
margin-bottom: 5px;
color: #6abfef;
font-size: 70px;
}
.anticon-file {
font-size: 50px;
}
}
.ks-finder-item-name {
color: #a2b1ba;
font-size: 12px;
}
}
</style>

View File

@@ -1,77 +0,0 @@
<template>
<a-layout-header class="ks-layout-header">
<a-flex>
<div class="ks-layout-header-logo">
<router-link :to="{path: '/app/ai/project/management'}">博弈竞赛环境</router-link>
</div>
<div class="ks-layout-header-actions">
<span class="dev top active">开发</span>
<span class="training bottom">训练</span>
<span class="apps top">博弈对抗</span>
</div>
<div class="ks-layout-header-right">
<a-space size="large">
<span><QuestionCircleOutlined /> 帮助文档</span>
<span>{{ currentDateTime }}</span>
</a-space>
<a-space style="margin-left: 20px;cursor: pointer">
<a-dropdown trigger="click">
<a-avatar style="background: #132f6c">
{{ displayName?.charAt(0) }}
</a-avatar>
<template #overlay>
<a-menu @click="handleLogout">
<a-menu-item key="logout">
退出登录
</a-menu-item>
</a-menu>
</template>
</a-dropdown>
</a-space>
</div>
</a-flex>
</a-layout-header>
</template>
<script lang="ts" setup>
import { computed, onUnmounted, ref } from 'vue';
import { useRouter } from 'vue-router';
import { QuestionCircleOutlined } from '@ant-design/icons-vue';
import { formatDatetime } from '@/utils/datetime';
import { useUserSession } from '@/hooks';
const router = useRouter();
const session = useUserSession();
const avatar = ref<string | null>(null);
avatar.value = session?.details.value?.user?.avatar ?? null;
const displayName = computed((): string => {
let value = session?.details.value?.user?.nickName ?? session?.details.value?.user?.userName;
if (value) {
return value as string;
}
return '';
});
const currentDateTime = ref('');
const updateCurrentDateTime = () => {
currentDateTime.value = formatDatetime(new Date());
};
updateCurrentDateTime();
const timer = setInterval(updateCurrentDateTime, 1000);
const handleLogout = () => {
session.logout().then(() => {
router.push({
path: '/signin',
});
});
};
onUnmounted(() => {
clearInterval(timer);
});
</script>

View File

@@ -1,47 +0,0 @@
<template>
<Wrapper>
<a-layout :class="['bg-transparent', collapsed ? 'sidebar-collapsed' : '']" style="background: transparent;transition: all 0.2s, background 0s;">
<Header />
<a-layout class="ks-layout-body">
<slot name="body">
<Sidebar v-if="!collapsed"/>
<a-layout-content class="ks-layout-main">
<div class="ks-layout-container">
<slot></slot>
</div>
</a-layout-content>
</slot>
</a-layout>
</a-layout>
<a-float-button
shape="circle"
type="primary"
:style="{
left: '30px',
}"
@click="()=> collapsed = !collapsed"
>
<template #icon>
<a-tooltip>
<template #title>
{{collapsed ? '展开' : '收起'}}菜单
</template>
<MenuUnfoldOutlined v-if="collapsed"/>
<MenuFoldOutlined v-else/>
</a-tooltip>
</template>
</a-float-button>
</Wrapper>
</template>
<script lang="ts" setup>
import {ref} from 'vue'
import {MenuUnfoldOutlined, MenuFoldOutlined} from '@ant-design/icons-vue';
import Sidebar from './sidebar.vue';
import Header from './header.vue';
import { Wrapper } from '@/components/wrapper';
const collapsed = ref<boolean>(false);
</script>

View File

@@ -1,58 +0,0 @@
<template>
<template v-if="menu.children && menu.children.length > 0">
<a-sub-menu :key="menu.key">
<template #title>
<span>{{ menu.title }}</span>
</template>
<Menu
v-for="child in menu.children"
:key="child.key"
:menu="child"
@click="handleChildClick"
/>
</a-sub-menu>
</template>
<a-menu-item
v-else
:key="menu.key"
@click="handleLeafClick"
>
<span class="ks-menu-item-label">{{ menu.title }}</span>
</a-menu-item>
</template>
<script lang="ts" setup>
// 定义菜单项的类型(与父组件保持一致)
export interface MenuItem {
key: string;
title: string;
path?: string;
type?: string;
children?: MenuItem[];
hidden?: boolean;
}
// 定义组件的 props
const props = defineProps<{
menu: MenuItem; // 单个菜单项数据
}>();
// 定义组件的事件
const emit = defineEmits<{
(e: 'click', menuItem: MenuItem): void; // 点击事件,传递菜单项
}>();
/**
* 处理叶子菜单点击
*/
const handleLeafClick = () => {
emit('click', props.menu);
};
/**
* 处理子菜单点击(递归传递)
*/
const handleChildClick = (menuItem: MenuItem) => {
emit('click', menuItem);
};
</script>

View File

@@ -1,47 +0,0 @@
<template>
<a-card class="ks-model-builder-card algorithm-card">
<template #title>
<span class="ks-model-builder-title-icon icon-grid"></span>智能体算法组件
</template>
<div class="w-full">
<a-form layout="vertical">
<a-form-item label="模糊规则类">
<a-tooltip placement="right">
<template #title>模糊规则类核心围绕隶属度函数模糊规则类型推理方法去模糊化应用场景展开涵盖经典与拓展类型</template>
<a-select show-search v-model:value="fuzzyValue">
<a-select-option :value="item.id" v-for="item in fuzzy">{{item.name}}</a-select-option>
</a-select>
</a-tooltip>
</a-form-item>
<a-form-item label="启发式算法类">
<a-tooltip placement="right">
<template #title>启发式算法类分为传统启发式元启发式拓展启发式覆盖搜索优化迭代全场景</template>
<a-select show-search v-model:value="heuristicValue">
<a-select-option :value="item.id" v-for="item in heuristic">{{item.name}}</a-select-option>
</a-select>
</a-tooltip>
</a-form-item>
<a-form-item label="神经网络类">
<a-tooltip placement="right">
<template #title>神经网络类围绕网络结构激活函数训练策略应用场景展开涵盖经典与深度学习模型</template>
<a-select show-search v-model:value="neuralValue">
<a-select-option :value="item.id" v-for="item in neural">{{item.name}}</a-select-option>
</a-select>
</a-tooltip>
</a-form-item>
</a-form>
</div>
</a-card>
</template>
<script setup lang="ts">
import {ref} from 'vue';
import fuzzy from './rules/fuzzy.json';
import heuristic from './rules/heuristic.json';
import neural from './rules/neural.json';
const fuzzyValue = ref<number>(1);
const heuristicValue = ref<number>(1);
const neuralValue = ref<number>(1);
</script>

View File

@@ -1,48 +0,0 @@
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2025 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
import request from '@/utils/request';
import type { Model, ModelQueryResult, ModelResult, NetworkModelResult, ObservationType, ObservationTypeResult, RewardDesign, RewardDesignResult } from './types';
import type { ApiDataResponse, BasicResponse } from '@/types';
export const findAllNetworkModel = (): Promise<NetworkModelResult> => {
return request.get<NetworkModelResult>('/networkModel/all');
};
export const findRewardDesignByQuery = (query: Partial<RewardDesign> = {}): Promise<RewardDesignResult> => {
return request.get<RewardDesignResult>('/rewardDesign/list', query);
};
export const findObservationTypeByQuery = (query: Partial<ObservationType> = {}): Promise<ObservationTypeResult> => {
return request.get<ObservationTypeResult>('/observationType/list', query);
};
export const findModelByQuery = (query: Partial<Model> = {}): Promise<ModelQueryResult> => {
return request.get<ModelQueryResult>('/model/list', query);
};
export const findAllModels = (): Promise<ApiDataResponse<Model[]>> => {
return request.get<ApiDataResponse<Model[]>>('/model/all');
};
export const findOneModelById = (id: number | string): Promise<ModelResult> => {
return request.get<ModelResult>(`/model/get/${id}`);
};
export const createModel = (rt: Partial<Model>): Promise<BasicResponse> => {
return request.postJson<BasicResponse>('/model/add', rt);
};
export const updateModel = (rt: Partial<Model>): Promise<BasicResponse> => {
return request.putJson<BasicResponse>('/model/edit', rt);
};
export const deleteModel = (id: number | string): Promise<BasicResponse> => {
return request.delete<BasicResponse>(`/model/logic/${id}`);
};

View File

@@ -1,148 +0,0 @@
<template>
<div class="ks-draggable-builder-right-inputs">
<div class="ks-draggable-items w-full">
<ul class="ks-draggable-item-list">
<!-- 父级列表项 -->
<li v-for="item in inputs" class="ks-draggable-item">
<div class="ks-draggable-item-holder"></div>
<div
class="ks-draggable-item-label"
draggable="true"
@dragend="handleDragEnd"
@dragstart="handleDragStart($event, item)"
>
{{ item.name }}
</div>
<ul class="ks-draggable-item-list">
<li class="ks-draggable-item" v-for="children in item.children">
<div class="ks-draggable-item-holder"></div>
<div
class="ks-draggable-item-label"
draggable="true"
@dragend="handleDragEnd"
@dragstart="handleDragStart($event, children, item)"
>
{{ children.name }}
</div>
</li>
</ul>
</li>
</ul>
</div>
</div>
</template>
<script lang="ts">
import { defineComponent, type PropType } from 'vue';
import { CheckOutlined } from '@ant-design/icons-vue';
import { type ElementInput } from './inputs';
export default defineComponent({
components: { CheckOutlined },
props: {
inputs: { type: [Array] as PropType<ElementInput[]>, required: false, default: () => [] },
},
emits: ['element-drag-end', 'element-drag-start'],
setup(_props, { emit }) {
const handleDragEnd = (e: DragEvent) => {
emit('element-drag-end', e);
};
const handleDragStart = (e: DragEvent, nm: ElementInput, parent?: ElementInput) => {
nm.parent = parent ? {
id: parent?.id,
key: parent?.key,
name: parent?.name,
description: parent?.description,
category: parent?.category,
children: [],
draggable: true,
} : undefined;
emit('element-drag-start', e, nm);
};
return {
handleDragEnd,
handleDragStart,
};
},
});
</script>
<style lang="less">
.ks-draggable-item-list {
margin: 0;
padding: 0;
list-style: none;
position: relative;
.ks-draggable-item {
margin: 0;
padding: 0;
display: block;
width: 100%;
/* 移除float: left避免布局异常影响拖拽事件 */
position: relative;
margin-top: 10px;
z-index: 2;
&:last-child {
margin-bottom: 0;
}
}
.ks-draggable-item-list {
padding-left: 80px;
width: 100%;
display: block;
/* 移除float: left */
position: relative;
z-index: 2;
&:before {
display: block;
content: " ";
position: absolute;
height: 100%;
width: 1px;
background: #0d385f;
bottom: 0;
top: -16px;
left: 40px;
z-index: 1;
}
.ks-draggable-item-holder {
position: absolute;
left: -40px;
width: 35px;
height: 1px;
background: #0d385f;
top: 50%;
}
}
.ks-draggable-item-label {
text-align: center;
padding: 5px 15px;
background: #0c385f;
border: 1px solid #0c385f;
cursor: grab; /* 改为grab提示可拖拽 */
transition: all 0.3s;
position: relative;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
width: 60%;
z-index: 2;
border-radius: 2px;
&:hover {
background: linear-gradient(359deg, #082f56 1%, #144f88 55%);
}
&:active {
cursor: grabbing; /* 拖拽中光标变化 */
}
}
}
</style>

View File

@@ -1,90 +0,0 @@
<template>
<a-card class="ks-model-builder-card">
<template #title>
<span class="ks-model-builder-title-icon icon-grid"></span>智能体模型组件
</template>
<div class="w-full">
<div
v-for="nm in networkModels"
:key="nm.id"
class="ks-model-drag-item"
@dragend="handleDragEnd"
@dragstart="handleDragStart($event, nm)"
>
<img :alt="nm.name ?? '-'" class="icon" src="@/assets/icons/model-4.svg" />
<span class="desc">{{ nm.name }}</span>
</div>
</div>
</a-card>
</template>
<script lang="ts">
import { defineComponent, onMounted, ref } from 'vue';
import { CheckCircleOutlined, CheckOutlined, CodeOutlined, RollbackOutlined, SaveOutlined } from '@ant-design/icons-vue';
import { safePreventDefault, safeStopPropagation } from '@/utils/event';
import BuilderRight from './builder-right.vue';
import type { NetworkModel } from './types';
import { findAllNetworkModel } from './api';
import type { DraggableElement } from '../builder/element';
export default defineComponent({
components: {
CodeOutlined,
BuilderRight,
SaveOutlined,
CheckCircleOutlined,
CheckOutlined,
RollbackOutlined,
},
emits: ['element-drag-end', 'element-drag-start'],
setup(_props, { emit }) {
const networkModels = ref<NetworkModel[]>([]);
const loadNetworkModels = () => {
findAllNetworkModel().then(r => {
console.info('loadNetworkModels', r);
if (r.code === 200) {
networkModels.value = r.data ?? [];
}
});
};
const handleDragEnd = (e: DragEvent) => {
safePreventDefault(e);
safeStopPropagation(e);
console.log('拖动结束');
emit('element-drag-end', e);
};
const handleDragStart = (e: DragEvent, nm: NetworkModel) => {
const element: DraggableElement = {
id: nm.id,
key: null,
name: nm.name,
description: nm.name,
draggable: true,
category: 'component',
original: nm,
children: []
};
emit('element-drag-start', e, element);
};
const init = () => {
console.info('init');
loadNetworkModels();
};
// 初始化
onMounted(() => {
init();
});
return {
networkModels,
handleDragEnd,
handleDragStart,
};
},
});
</script>

View File

@@ -1,88 +0,0 @@
<template>
<div class="control-container flex text-center w-full">
<div class="control-wrapper">
<h3 class="control-title">任务类</h3>
<div class="control-items">
<div v-for="item in taskInputs"
class="ks-model-item control-item"
draggable="true"
@dragend="handleDragEnd"
@dragstart="handleDragStart($event, item)">
{{ item.name }}
</div>
</div>
</div>
<div class="control-wrapper">
<h3 class="control-title">机动控制类</h3>
<div class="control-items">
<div v-for="item in controlInputs"
class="ks-model-item control-item"
draggable="true"
@dragend="handleDragEnd"
@dragstart="handleDragStart($event, item)">
{{ item.name }}
</div>
</div>
</div>
<div class="control-wrapper">
<h3 class="control-title">飞行参数类</h3>
<div class="control-items">
<div v-for="item in flyInputs"
class="ks-model-item control-item"
draggable="true"
@dragend="handleDragEnd"
@dragstart="handleDragStart($event, item)">
{{ item.name }}
</div>
</div>
</div>
</div>
</template>
<script lang="ts">
import { defineComponent, type PropType } from 'vue';
import { CheckOutlined } from '@ant-design/icons-vue';
import type { ModelElement, SavedGraphData } from './types';
import type { Graph, Node, NodeProperties } from '@antv/x6';
import BuilderInputs from './builder-inputs.vue';
import { controlInputs, flyInputs, taskInputs } from './control-options';
import type { ElementInput } from './inputs';
export default defineComponent({
components: { CheckOutlined, BuilderInputs },
props: {
node: { type: [Object, null] as PropType<Node<NodeProperties> | null | undefined>, required: false },
graph: { type: [Object, null] as PropType<Graph | null | undefined>, required: true },
element: { type: [Object, null] as PropType<ModelElement | null | undefined>, required: false },
saved: { type: Object as PropType<SavedGraphData>, required: false },
},
emits: ['element-drag-end', 'element-drag-start'],
setup(_props, { emit }) {
const handleDragEnd = (e: DragEvent) => {
emit('element-drag-end', e);
};
const handleDragStart = (e: DragEvent, nm: ElementInput, parent?: ElementInput) => {
nm.parent = parent ? {
id: parent?.id,
key: parent?.key,
name: parent?.name,
description: parent?.description,
category: parent?.category,
children: [],
draggable: true,
} : undefined;
emit('element-drag-start', e, nm);
};
return {
handleDragEnd,
handleDragStart,
taskInputs,
controlInputs,
flyInputs,
};
},
});
</script>

View File

@@ -1,60 +0,0 @@
<template>
<div class="control-container text-center w-full">
<a-row :gutter="6">
<a-col :span="12" v-for="item in managerInputs">
<div class="ks-model-item" style="width:100%;"
draggable="true"
@dragend="handleDragEnd"
@dragstart="handleDragStart($event, item)">
{{ item.name }}
</div>
</a-col>
</a-row>
</div>
</template>
<script lang="ts">
import { defineComponent, type PropType } from 'vue';
import { CheckOutlined } from '@ant-design/icons-vue';
import type { ModelElement, SavedGraphData } from './types';
import type { Graph, Node, NodeProperties } from '@antv/x6';
import BuilderInputs from './builder-inputs.vue';
import { managerInputs } from './control-options';
import type { ElementInput } from './inputs';
export default defineComponent({
components: { CheckOutlined, BuilderInputs },
props: {
node: { type: [Object, null] as PropType<Node<NodeProperties> | null | undefined>, required: false },
graph: { type: [Object, null] as PropType<Graph | null | undefined>, required: true },
element: { type: [Object, null] as PropType<ModelElement | null | undefined>, required: false },
saved: { type: Object as PropType<SavedGraphData>, required: false },
},
emits: ['element-drag-end', 'element-drag-start'],
setup(_props, { emit }) {
const handleDragEnd = (e: DragEvent) => {
emit('element-drag-end', e);
};
const handleDragStart = (e: DragEvent, nm: ElementInput, parent?: ElementInput) => {
nm.parent = parent ? {
id: parent?.id,
key: parent?.key,
name: parent?.name,
description: parent?.description,
category: parent?.category,
children: [],
draggable: true,
} : undefined;
emit('element-drag-start', e, nm);
};
return {
handleDragEnd,
handleDragStart,
managerInputs,
};
},
});
</script>

View File

@@ -1,49 +0,0 @@
<template>
<BuilderInputs
:inputs="elementInputs"
@element-drag-start="(e:any,v:any,d:any)=> $emit('element-drag-start',e,v,d)"
@element-drag-end="(e:any,v:any)=> $emit('element-drag-end',e,v)"
/>
</template>
<script lang="ts">
import { defineComponent, onMounted, type PropType, ref } from 'vue';
import { CheckOutlined } from '@ant-design/icons-vue';
import type { ModelElement, SavedGraphData } from './types';
import type { Graph, Node, NodeProperties } from '@antv/x6';
import { type ElementInput, resolveElementInputs } from './inputs';
import BuilderInputs from './builder-inputs.vue';
export default defineComponent({
components: { CheckOutlined, BuilderInputs },
props: {
node: { type: [Object, null] as PropType<Node<NodeProperties> | null | undefined>, required: false },
graph: { type: [Object, null] as PropType<Graph | null | undefined>, required: true },
element: { type: [Object, null] as PropType<ModelElement | null | undefined>, required: false },
saved: { type: Object as PropType<SavedGraphData>, required: false },
},
emits: ['element-drag-end', 'element-drag-start'],
setup(_props, { emit }) {
const elementInputs = ref<ElementInput[]>([]);
const loadInputs = () => {
elementInputs.value = [];
resolveElementInputs().then(r => {
elementInputs.value = r;
console.log('elementInputs.value', elementInputs.value);
});
};
const load = () => {
loadInputs();
};
onMounted(() => load());
return {
elementInputs,
};
},
});
</script>

View File

@@ -1,376 +0,0 @@
<template>
<div class="ks-model-builder-right">
<!-- 顶部标签页 -->
<a-tabs v-model:activeKey="activeTopTabsKey" :class="['ks-model-builder-tabs parameters-tabs', currentElement ? 'multiply' : '']">
<template #leftExtra>
<span class="ks-model-builder-title-icon icon-input"></span>
</template>
<a-tab-pane key="1" tab="输出态势接口">
<!-- <a-flex class="w-full mb-1">-->
<!-- <a-select style="width: 77%"></a-select>-->
<!-- <a-button style="margin-left: auto">导入</a-button>-->
<!-- </a-flex>-->
<div class="observation-items w-full">
<a-row :gutter="6">
<a-col v-for="ot in observationTypes" :key="ot.id" :span="12">
<a-tooltip placement="left" trigger="click">
<template #title>
<p>名称: {{ ot.typeName }}</p>
<p>说明: {{ ot.description }}</p>
</template>
<div
:class="['ks-model-item', savedGraphData.observations.some(sot => sot.id === ot.id) ? 'selected' : '']"
style="width:100%; cursor: pointer"
@click="toggleObservationType(ot)"
>
{{ ot.typeName }}
</div>
</a-tooltip>
</a-col>
</a-row>
</div>
<div class="w-full">
<div class="ks-model-item selected-total-item" style="margin-top:2px;">
已选择 {{ savedGraphData.observations.length }} 组组件
</div>
</div>
</a-tab-pane>
<a-tab-pane key="2" tab="参数设置" v-if="currentElement">
<a-form
:label-col="{span:6}"
:model="currentElementParameters"
autocomplete="off"
layout="horizontal"
name="basic"
>
<a-form-item label="隐藏纬度" name="hiddenLatitude">
<a-input v-model:value="currentElementParameters.hiddenLatitude" placeholder="请输入隐藏纬度" />
</a-form-item>
<a-form-item label="激活函数" name="activationFunction">
<a-select v-model:value="currentElementParameters.activationFunction" placeholder="请选择激活函数">
<a-select-option value="relu">relu</a-select-option>
<a-select-option value="tahn">tahn</a-select-option>
</a-select>
</a-form-item>
</a-form>
</a-tab-pane>
</a-tabs>
<!-- 底部标签页动作空间设计 -->
<a-tabs v-model:activeKey="activeBottomTabs2Key" class="ks-model-builder-tabs design-tabs">
<template #leftExtra>
<span class="ks-model-builder-title-icon icon-input"></span>
</template>
<a-tab-pane key="1" tab="接收控制指令接口">
<div class="w-full">
<a-space>
<a-button size="small" type="primary" @click="addActionSpace">添加</a-button>
</a-space>
<a-table
:columns="actionSpaceColumns"
:dataSource="savedGraphData.actionSpaces"
:pagination="false"
:scroll="{ x: 600 }"
class="mt-1"
row-key="id"
size="small"
style="overflow-y:auto;height:20vh;"
>
<template #bodyCell="{column, record, index}">
<template v-if="column.dataIndex === 'index'">
{{ index + 1 }}
</template>
<template v-if="column.dataIndex === 'entry'">
<a-select v-model:value="record.entry" size="small" style="width:80px;" @change="()=> updateModel()">
<a-select-option value="f16">F16</a-select-option>
</a-select>
</template>
<template v-if="column.dataIndex === 'type'">
<a-select v-model:value="record.type" size="small" style="width:80px;" @change="()=> updateModel()">
<a-select-option value="1">机动</a-select-option>
</a-select>
</template>
<template v-if="column.dataIndex === 'args'">
<div class="w-full mb-2">
<a-space>
<span>俯仰角</span>
<a-input-number v-model:value="record.args.pitch.min" max="180" min="-180" size="small" style="width:60px;" @change="()=> updateModel()"/>
-
<a-input-number v-model:value="record.args.pitch.max" max="180" min="-180" size="small" style="width:60px;" @change="()=> updateModel()"/>
</a-space>
</div>
<div class="w-full mb-2">
<a-space>
<span>偏航角</span>
<a-input-number v-model:value="record.args.yaw.min" max="180" min="-180" size="small" style="width:60px;" @change="()=> updateModel()"/>
-
<a-input-number v-model:value="record.args.yaw.max" max="180" min="-180" size="small" style="width:60px;" @change="()=> updateModel()"/>
</a-space>
</div>
<div class="w-full mb-2">
<a-space>
<span>滚转角</span>
<a-input-number v-model:value="record.args.roll.min" max="180" min="-180" size="small" style="width:60px;" @change="()=> updateModel()"/>
-
<a-input-number v-model:value="record.args.roll.max" max="180" min="-180" size="small" style="width:60px;" @change="()=> updateModel()"/>
</a-space>
</div>
</template>
<template v-if="column.dataIndex === '_actions'">
<a-button
class="btn-link-delete"
danger
size="small"
type="text"
@click="deleteActionSpace(record.id)"
>
删除
</a-button>
</template>
</template>
</a-table>
</div>
</a-tab-pane>
</a-tabs>
<!-- 底部标签页奖励函数 -->
<a-tabs v-model:activeKey="activeBottomTabsKey" class="ks-model-builder-tabs design-tabs">
<template #leftExtra>
<span class="ks-model-builder-title-icon icon-input"></span>
</template>
<a-tab-pane key="1" tab="奖励函数设计">
<div class="reward-items w-full">
<a-row :gutter="6">
<a-col v-for="rd in rewardDesigns" :key="rd.id" :span="12">
<a-tooltip placement="left" trigger="click">
<template #title>
<p>名称: {{ rd.name }}</p>
<p>说明: {{ rd.description }}</p>
</template>
<div
:class="['ks-model-item', savedGraphData.rewards.some(sot => sot.id === rd.id) ? 'selected' : '']"
style="width:100%; cursor: pointer"
@click="toggleRewardDesign(rd)"
>
{{ rd.name }}
</div>
</a-tooltip>
</a-col>
</a-row>
<div class="w-full">
<div class="ks-model-item selected-total-item" style="margin-top:2px;">
已选择 {{ savedGraphData.rewards.length }} 组组件
</div>
</div>
</div>
</a-tab-pane>
</a-tabs>
</div>
</template>
<script lang="ts">
import { defineComponent, onMounted, type PropType, ref, watch } from 'vue';
import { CheckOutlined } from '@ant-design/icons-vue';
import type { ModelElement, ModelParameters, ObservationType, RewardDesign, SavedGraphData } from './types';
import { findObservationTypeByQuery, findRewardDesignByQuery } from './api';
import type { Graph, Node, NodeProperties } from '@antv/x6';
import { generateKey } from '@/utils/strings';
import {defaultSavedGraphData} from './config'
const actionSpaceColumns = [
{ title: '序号', dataIndex: 'index', key: 'index', width: 40 },
{ title: '动作实体', dataIndex: 'entry', key: 'entry', width: 80 },
{ title: '动作类型', dataIndex: 'type', key: 'type', width: 80 },
{ title: '动作参数', dataIndex: 'args', key: 'args', width: 200 },
{ title: '操作', dataIndex: '_actions', key: '_actions', width: 60 },
];
export default defineComponent({
components: { CheckOutlined },
props: {
node: { type: [Object, null] as PropType<Node<NodeProperties> | null | undefined>, required: false },
graph: { type: [Object, null] as PropType<Graph | null | undefined>, required: true },
element: { type: [Object, null] as PropType<ModelElement | null | undefined>, required: false },
saved: { type: Object as PropType<SavedGraphData>, required: false },
},
emits: ['update-element','update-model'],
setup(props, { emit }) {
const activeTopTabsKey = ref<string>('1');
const activeBottomTabsKey = ref<string>('1');
const activeBottomTabs2Key = ref<string>('1');
const savedGraphData = ref<SavedGraphData>(props.saved ? props.saved : {...defaultSavedGraphData});
const resolveModelParameters = (ele?: ModelElement | null): ModelParameters => {
if (!ele || !ele.parameters) {
return {
hiddenLatitude: null,
activationFunction: 'relu',
};
}
return {
hiddenLatitude: ele.parameters.hiddenLatitude ?? '33',
activationFunction: ele.parameters.activationFunction ?? 'relu',
};
};
const currentNode = ref<Node | null>(props.node ?? null);
const currentElement = ref<ModelElement | null>(null);
const currentElementParameters = ref<ModelParameters>(resolveModelParameters());
const observationTypes = ref<ObservationType[]>([]);
const rewardDesigns = ref<RewardDesign[]>([]);
const loadObservationTypes = () => {
findObservationTypeByQuery().then(r => {
observationTypes.value = r.rows ?? [];
});
};
const loadRewardDesigns = () => {
findRewardDesignByQuery().then(r => {
rewardDesigns.value = r.rows ?? [];
});
};
const load = () => {
loadObservationTypes();
loadRewardDesigns();
};
const resolveNode = (n?: Node | null | undefined) => {
currentNode.value = n ?? null;
if (n) {
const data = n.getData();
if (data) {
currentElement.value = data as ModelElement;
currentElementParameters.value = resolveModelParameters(currentElement.value);
}
} else {
currentElement.value = null;
currentElementParameters.value = resolveModelParameters();
}
};
const resolveGraph = (d?: SavedGraphData | null | undefined)=> {
savedGraphData.value = JSON.parse(JSON.stringify({...defaultSavedGraphData, ...d ?? {}}))
}
const updateNode = () => {
if (currentNode.value && currentElement.value) {
const newElement = JSON.parse(JSON.stringify({
...currentElement.value,
parameters: currentElementParameters.value,
})) as ModelElement;
emit('update-element', newElement);
currentNode.value.replaceData(newElement);
}
};
const updateModel = ()=> {
console.info('update model', savedGraphData.value)
emit('update-model',JSON.parse(JSON.stringify(savedGraphData.value || {})))
}
const toggleObservationType = (ot: ObservationType) => {
const index = savedGraphData.value.observations.findIndex(sot => sot.id === ot.id);
if (index > -1) {
savedGraphData.value.observations.splice(index, 1);
} else {
savedGraphData.value.observations.push(ot);
}
updateModel();
};
const toggleRewardDesign = (rd: RewardDesign) => {
const index = savedGraphData.value.rewards.findIndex(srd => srd.id === rd.id);
if (index > -1) {
savedGraphData.value.rewards.splice(index, 1);
} else {
savedGraphData.value.rewards.push(rd);
}
updateModel();
};
const addActionSpace = () => {
savedGraphData.value.actionSpaces.push({
id: generateKey('action_space'), // 添加唯一ID
entry: 'f16',
type: '1',
args: {
// 俯仰角
pitch: {
min: 0,
max: 0,
},
// 偏航角
yaw: {
min: 0,
max: 0,
},
// 滚转角
roll: {
min: 0,
max: 0,
},
},
});
updateModel();
};
const deleteActionSpace = (id: string) => {
const idx = savedGraphData.value.actionSpaces.findIndex(item => item.id === id);
if (idx > -1) {
// 使用 splice 确保响应式更新
savedGraphData.value.actionSpaces.splice(idx, 1);
// 确保数组引用改变,触发 watch
savedGraphData.value.actionSpaces = [...savedGraphData.value.actionSpaces];
updateModel();
// 立即更新节点
console.info(`已删除动作空间项 id=${id}`);
}
};
watch(
() => props.node,
(n?: Node | null | undefined) => resolveNode(n),
{ deep: true, immediate: true },
);
watch(
() => props.saved,
(n?: SavedGraphData | null | undefined) => resolveGraph(n),
{ deep: true, immediate: true },
);
watch(() => currentElementParameters.value, () => updateNode(), { deep: true });
// watch(() => savedGraphData.value, () => updateModel(), { deep: true });
onMounted(() => load());
return {
actionSpaceColumns,
activeTopTabsKey,
activeBottomTabsKey,
activeBottomTabs2Key,
currentElement,
observationTypes,
rewardDesigns,
currentElementParameters,
toggleObservationType,
toggleRewardDesign,
addActionSpace,
deleteActionSpace,
savedGraphData,
updateModel,
};
},
});
</script>

View File

@@ -1,281 +0,0 @@
<template>
<div class="ks-model-builder-right">
<!-- 顶部标签页 -->
<a-tabs v-model:activeKey="activeTopTabsKey" :class="['ks-model-builder-tabs parameters-tabs', currentElement ? 'multiply' : '']">
<template #leftExtra>
<span class="ks-model-builder-title-icon icon-input"></span>
</template>
<a-tab-pane key="1" tab="输出态势接口">
<BuilderRightSituation
:element="element"
:graph="graph"
:node="node"
:saved="savedGraphData"
@element-drag-start="(e: any, v:any, p: any)=> $emit('element-drag-start', e, v, p)"
@element-drag-end="(e:any)=> $emit('element-drag-end', e)"
/>
</a-tab-pane>
<a-tab-pane key="2" tab="参数设置" v-if="currentElement">
<a-form
:label-col="{span:6}"
:model="currentElementParameters"
autocomplete="off"
layout="horizontal"
name="basic"
>
<a-form-item label="隐藏纬度" name="hiddenLatitude">
<a-input v-model:value="currentElementParameters.hiddenLatitude" placeholder="请输入隐藏纬度" />
</a-form-item>
<a-form-item label="激活函数" name="activationFunction">
<a-select v-model:value="currentElementParameters.activationFunction" placeholder="请选择激活函数">
<a-select-option value="relu">relu</a-select-option>
<a-select-option value="tahn">tahn</a-select-option>
</a-select>
</a-form-item>
</a-form>
</a-tab-pane>
</a-tabs>
<!-- 底部标签页:动作空间设计 -->
<a-tabs v-model:activeKey="activeBottomTabs2Key" class="ks-model-builder-tabs design-tabs">
<template #leftExtra>
<span class="ks-model-builder-title-icon icon-input"></span>
</template>
<a-tab-pane key="1" tab="接收控制指令接口">
<BuilderRightControl
:element="element"
:graph="graph"
:node="node"
:saved="savedGraphData"
@element-drag-start="(e: any, v:any, p: any)=> $emit('element-drag-start', e, v, p)"
@element-drag-end="(e:any)=> $emit('element-drag-end', e)"
/>
</a-tab-pane>
</a-tabs>
<!-- 底部标签页:奖励函数 -->
<a-tabs v-model:activeKey="activeBottomTabsKey" class="ks-model-builder-tabs design-tabs">
<template #leftExtra>
<span class="ks-model-builder-title-icon icon-input"></span>
</template>
<a-tab-pane key="1" tab="容器控制管理接口">
<BuilderRightManager
:element="element"
:graph="graph"
:node="node"
:saved="savedGraphData"
@element-drag-start="(e: any, v:any, p: any)=> $emit('element-drag-start', e, v, p)"
@element-drag-end="(e:any)=> $emit('element-drag-end', e)"
/>
</a-tab-pane>
</a-tabs>
</div>
</template>
<script lang="ts">
import { defineComponent, onMounted, type PropType, ref, watch } from 'vue';
import { CheckOutlined } from '@ant-design/icons-vue';
import type { ModelElement, ModelParameters, ObservationType, RewardDesign, SavedGraphData } from './types';
import { findObservationTypeByQuery, findRewardDesignByQuery } from './api';
import type { Graph, Node, NodeProperties } from '@antv/x6';
import { generateKey } from '@/utils/strings';
import { defaultSavedGraphData } from './config';
import BuilderRightSituation from './builder-right-situation.vue';
import BuilderRightControl from './builder-right-control.vue';
import BuilderRightManager from './builder-right-manager.vue'
const actionSpaceColumns = [
{ title: '序号', dataIndex: 'index', key: 'index', width: 40 },
{ title: '动作实体', dataIndex: 'entry', key: 'entry', width: 80 },
{ title: '动作类型', dataIndex: 'type', key: 'type', width: 80 },
{ title: '动作参数', dataIndex: 'args', key: 'args', width: 200 },
{ title: '操作', dataIndex: '_actions', key: '_actions', width: 60 },
];
export default defineComponent({
components: { CheckOutlined, BuilderRightSituation, BuilderRightControl,BuilderRightManager },
props: {
node: { type: [Object, null] as PropType<Node<NodeProperties> | null | undefined>, required: false },
graph: { type: [Object, null] as PropType<Graph | null | undefined>, required: true },
element: { type: [Object, null] as PropType<ModelElement | null | undefined>, required: false },
saved: { type: Object as PropType<SavedGraphData>, required: false },
},
emits: ['update-element', 'update-model', 'element-drag-end', 'element-drag-start'],
setup(props, { emit }) {
const activeTopTabsKey = ref<string>('1');
const activeBottomTabsKey = ref<string>('1');
const activeBottomTabs2Key = ref<string>('1');
const savedGraphData = ref<SavedGraphData>(props.saved ? props.saved : {...defaultSavedGraphData});
const resolveModelParameters = (ele?: ModelElement | null): ModelParameters => {
if (!ele || !ele.parameters) {
return {
hiddenLatitude: null,
activationFunction: 'relu',
};
}
return {
hiddenLatitude: ele.parameters.hiddenLatitude ?? '33',
activationFunction: ele.parameters.activationFunction ?? 'relu',
};
};
const currentNode = ref<Node | null>(props.node ?? null);
const currentElement = ref<ModelElement | null>(null);
const currentElementParameters = ref<ModelParameters>(resolveModelParameters());
const observationTypes = ref<ObservationType[]>([]);
const rewardDesigns = ref<RewardDesign[]>([]);
const loadObservationTypes = () => {
findObservationTypeByQuery().then(r => {
observationTypes.value = r.rows ?? [];
});
};
const loadRewardDesigns = () => {
findRewardDesignByQuery().then(r => {
rewardDesigns.value = r.rows ?? [];
});
};
const load = () => {
loadObservationTypes();
loadRewardDesigns();
};
const resolveNode = (n?: Node | null | undefined) => {
currentNode.value = n ?? null;
if (n) {
const data = n.getData();
if (data) {
currentElement.value = data as ModelElement;
currentElementParameters.value = resolveModelParameters(currentElement.value);
}
} else {
currentElement.value = null;
currentElementParameters.value = resolveModelParameters();
}
};
const resolveGraph = (d?: SavedGraphData | null | undefined)=> {
savedGraphData.value = JSON.parse(JSON.stringify({...defaultSavedGraphData, ...d ?? {}}))
}
const updateNode = () => {
if (currentNode.value && currentElement.value) {
const newElement = JSON.parse(JSON.stringify({
...currentElement.value,
parameters: currentElementParameters.value,
})) as ModelElement;
emit('update-element', newElement);
currentNode.value.replaceData(newElement);
}
};
const updateModel = ()=> {
console.info('update model', savedGraphData.value)
emit('update-model',JSON.parse(JSON.stringify(savedGraphData.value || {})))
}
const toggleObservationType = (ot: ObservationType) => {
const index = savedGraphData.value.observations.findIndex(sot => sot.id === ot.id);
if (index > -1) {
savedGraphData.value.observations.splice(index, 1);
} else {
savedGraphData.value.observations.push(ot);
}
updateModel();
};
const toggleRewardDesign = (rd: RewardDesign) => {
const index = savedGraphData.value.rewards.findIndex(srd => srd.id === rd.id);
if (index > -1) {
savedGraphData.value.rewards.splice(index, 1);
} else {
savedGraphData.value.rewards.push(rd);
}
updateModel();
};
const addActionSpace = () => {
savedGraphData.value.actionSpaces.push({
id: generateKey('action_space'), // 添加唯一ID
entry: 'f16',
type: '1',
args: {
// 俯仰角
pitch: {
min: 0,
max: 0,
},
// 偏航角
yaw: {
min: 0,
max: 0,
},
// 滚转角
roll: {
min: 0,
max: 0,
},
},
});
updateModel();
};
const deleteActionSpace = (id: string) => {
const idx = savedGraphData.value.actionSpaces.findIndex(item => item.id === id);
if (idx > -1) {
// 使用 splice 确保响应式更新
savedGraphData.value.actionSpaces.splice(idx, 1);
// 确保数组引用改变,触发 watch
savedGraphData.value.actionSpaces = [...savedGraphData.value.actionSpaces];
updateModel();
// 立即更新节点
console.info(`已删除动作空间项 id=${id}`);
}
};
watch(
() => props.node,
(n?: Node | null | undefined) => resolveNode(n),
{ deep: true, immediate: true },
);
watch(
() => props.saved,
(n?: SavedGraphData | null | undefined) => resolveGraph(n),
{ deep: true, immediate: true },
);
watch(() => currentElementParameters.value, () => updateNode(), { deep: true });
// watch(() => savedGraphData.value, () => updateModel(), { deep: true });
onMounted(() => load());
return {
actionSpaceColumns,
activeTopTabsKey,
activeBottomTabsKey,
activeBottomTabs2Key,
currentElement,
observationTypes,
rewardDesigns,
currentElementParameters,
toggleObservationType,
toggleRewardDesign,
addActionSpace,
deleteActionSpace,
savedGraphData,
updateModel,
};
},
});
</script>

View File

@@ -1,511 +0,0 @@
<template>
<Wrapper>
<a-layout class="bg-transparent" style="background: transparent">
<Header />
<a-layout class="ks-layout-body">
<slot name="body">
<div class="ks-model-builder-body">
<div class="ks-model-builder-left">
<a-card v-if="currentModel" class="ks-model-builder-card" style="height: 18vh;min-height: 18vh;">
<template #title>
<span class="ks-model-builder-title-icon icon-model"></span>智能体模型信息
</template>
<div class="w-full">
<a-flex class="mb-2">
<span style="width:80px; text-align: left; padding-right: 1px;">智能体名称: </span>
<span>{{ currentModel.name }}</span>
</a-flex>
<a-flex class="mb-2">
<span style="width:80px; text-align: left; padding-right: 1px;">所属工程: </span>
<span>{{ currentModel.projectSpaceName ?? '-' }}</span>
</a-flex>
<a-flex class="mb-2">
<span style="width:80px; text-align: left; padding-right: 1px;">创建时间: </span>
<span>{{ currentModel.createTime ?? '-' }}</span>
</a-flex>
<a-flex class="mb-2">
<span style="width:80px; text-align: left; padding-right: 1px;">模型描述: </span>
<span>{{ currentModel.description ?? '-' }}</span>
</a-flex>
</div>
</a-card>
<BuilderLeftComponents
@element-drag-end="handleDragEnd"
@element-drag-start="handleDragStart"
/>
<AlgorithmCard />
</div>
<div class="ks-model-builder-content">
<div class="ks-model-builder-actions">
<a-space>
<a-tooltip placement="top">
<template #title>
返回
</template>
<a-button class="ks-model-builder-goback" size="small" @click="goback">
<RollbackOutlined />
<span>返回</span>
</a-button>
</a-tooltip>
<a-tooltip v-if="graph && currentModel" placement="top">
<template #title>
保存
</template>
<a-popconfirm
title="确定保存?"
@confirm="handleSave"
>
<a-button class="ks-model-builder-save" size="small">
<CheckOutlined />
<span>保存</span>
</a-button>
</a-popconfirm>
</a-tooltip>
</a-space>
</div>
<div
ref="canvas"
class="ks-model-builder-canvas"
@dragenter="handleDragEnter"
@dragleave="handleDragLeave"
@drop="handleDrop"
@dragover.prevent
></div>
<TeleportContainer />
</div>
<BuilderRight
v-if="graph"
:element="selectedModelElement"
:saved="savedGraphData"
:graph="graph as any"
:node="selectedModelNode as any"
@element-drag-end="handleDragEnd"
@element-drag-start="handleDragStart"
@update-model="handleUpdateModel"
/>
</div>
</slot>
</a-layout>
</a-layout>
</Wrapper>
</template>
<script lang="ts">
import { defineComponent, nextTick, onBeforeUnmount, onMounted, ref } from 'vue';
import { message } from 'ant-design-vue';
import { getTeleport } from '@antv/x6-vue-shape';
import { Edge, Graph, Node, type NodeProperties } from '@antv/x6';
import { useRouter } from 'vue-router';
import { CheckCircleOutlined, CheckOutlined, CodeOutlined, RollbackOutlined, SaveOutlined } from '@ant-design/icons-vue';
import { Wrapper } from '@/components/wrapper';
import { safePreventDefault, safeStopPropagation } from '@/utils/event';
import Header from '../header.vue';
import BuilderRight from './builder-right.vue';
import { useGraphCanvas } from '../builder/hooks';
import { registerNodeElement } from '../builder/register';
import type { Model, ModelElement, SavedGraphData } from './types';
import { findOneModelById, updateModel } from './api';
import { defaultSavedGraphData } from './config';
import AlgorithmCard from './algorithm-card.vue';
import BuilderLeftComponents from './builder-left-components.vue';
import type { DraggableElement } from '../builder/element';
import { createLineOptions } from '../builder/line';
import { createDraggableElement, createModelNode } from './utils';
const TeleportContainer = defineComponent(getTeleport());
registerNodeElement();
export default defineComponent({
components: {
AlgorithmCard,
CodeOutlined,
Wrapper,
Header,
BuilderRight,
SaveOutlined,
CheckCircleOutlined,
CheckOutlined,
RollbackOutlined,
TeleportContainer,
BuilderLeftComponents,
},
setup() {
const router = useRouter();
const canvas = ref<HTMLDivElement | null>(null);
const graph = ref<Graph | null>(null);
const currentZoom = ref<number>(1);
const draggedNodeData = ref<DraggableElement | null>(null);
const isDraggingOver = ref(false);
const currentModel = ref<Model | null>(null);
const selectedModelNode = ref<Node<NodeProperties> | null>(null);
const selectedModelElement = ref<ModelElement | null>(null);
const savedGraphData = ref<SavedGraphData>({...defaultSavedGraphData});
const goback = () => {
router.push({
path: '/app/ai/model/management',
});
};
const gobackWithError = (msg: string = '模型不存在') => {
message.error(msg);
goback();
};
const {
handleGraphEvent,
createCanvas,
zoomIn,
zoomOut,
fitToScreen,
centerContent,
resizeCanvas,
} = useGraphCanvas();
// 处理拖动开始
const handleDragStart = (e: DragEvent, nm: DraggableElement) => {
draggedNodeData.value = nm;
console.error('handleDragStart', nm);
if (e.dataTransfer) {
e.dataTransfer.setData('text/plain', JSON.stringify(draggedNodeData.value));
e.dataTransfer.effectAllowed = 'copyMove';
const dragPreview = document.createElement('div');
dragPreview.textContent = draggedNodeData.value.name || '';
dragPreview.style.cssText = `
position: absolute;
top: -1000px;
padding: 6px 12px;
background: #3b82f6;
color: white;
border-radius: 6px;
font-size: 12px;
font-weight: 500;
`;
document.body.appendChild(dragPreview);
e.dataTransfer.setDragImage(dragPreview, dragPreview.offsetWidth / 2, dragPreview.offsetHeight / 2);
setTimeout(() => document.body.removeChild(dragPreview), 0);
}
console.log('开始拖动:', nm);
};
// 处理拖动结束
const handleDragEnd = (e: DragEvent) => {
safePreventDefault(e);
safeStopPropagation(e);
isDraggingOver.value = false;
console.log('拖动结束');
};
// 处理拖动进入
const handleDragEnter = (e: DragEvent) => {
safePreventDefault(e);
safeStopPropagation(e);
isDraggingOver.value = true;
};
const executeAnimate = () => {
// setTimeout(() => {
// if(graph.value){
// graph.value?.getEdges().forEach((edge: Edge) => {
// edge.attr('line/strokeDasharray', '40,4')
// edge.attr('line/style/animation', 'running-line 30s infinite linear')
// })
// }
// }, 500)
}
handleGraphEvent('edge:added', () => {
executeAnimate();
});
// 处理拖动离开
const handleDragLeave = (e: DragEvent) => {
safePreventDefault(e);
safeStopPropagation(e);
console.error('handleDragLeave', e);
if (canvas.value && e.relatedTarget &&
typeof e.relatedTarget === 'object' &&
'nodeType' in e.relatedTarget) {
// 使用 Element 类型而不是 x6 的 Node 类型
if (!canvas.value.contains(e.relatedTarget as Element)) {
isDraggingOver.value = false;
}
}
};
// 处理放置
const handleDrop = (e: DragEvent) => {
console.info('handleDrop', e);
safePreventDefault(e);
safeStopPropagation(e);
isDraggingOver.value = false;
if (!graph.value || !canvas.value || !draggedNodeData.value) {
console.error('无法放置节点: 缺少必要数据');
return;
}
try {
// 获取拖动的数据
const data = draggedNodeData.value as DraggableElement;
// 计算相对于画布的位置(考虑缩放)
const rect = canvas.value.getBoundingClientRect();
const scale = currentZoom.value || 1;
const x = (e.clientX - rect.left) / scale;
const y = (e.clientY - rect.top) / scale;
console.log('放置节点:', { ...data, x, y });
// 创建节点数据
const nodeData: ModelElement = createDraggableElement(data, x, y);
// 创建节点
const node = createModelNode(nodeData);
console.info('create node: ', nodeData, node);
// 将节点添加到画布
graph.value?.addNode(node as any);
console.log('节点已添加到画布:', node.id);
// 重置拖动数据
draggedNodeData.value = null;
} catch (error) {
console.error('放置节点时出错:', error);
}
};
const createElements = () => {
console.info('createElements', savedGraphData.value);
if (savedGraphData.value && graph.value) {
if (savedGraphData.value.nodes) {
savedGraphData.value.nodes.forEach(ele => {
const node = createModelNode(ele);
console.info('create node: ', ele);
// 将节点添加到画布
graph.value?.addNode(node as Node);
});
}
if (savedGraphData.value.edges) {
// 然后添加所有边,确保包含桩点信息
setTimeout(()=> {
savedGraphData.value.edges.forEach(edgeData => {
graph.value?.addEdge({
...edgeData,
...createLineOptions(),
});
});
}, 100) // 延迟一会儿,免得连线错位
}
}
};
// 初始化X6画布
const initGraph = () => {
if (!canvas.value) {
console.error('画布容器不存在');
return;
}
try {
graph.value = createCanvas(canvas.value);
console.log('画布初始化成功');
createElements();
// 监听缩放变化
handleGraphEvent('scale', ({ sx }: { sx: number }) => {
currentZoom.value = sx;
});
handleGraphEvent('blank:click', (args: any) => {
selectedModelNode.value = null;
selectedModelElement.value = null;
});
handleGraphEvent('node:click', (args: any) => {
const node = args.node as Node<NodeProperties>;
const newElement = node.getData() as ModelElement;
selectedModelNode.value = node;
selectedModelElement.value = null;
nextTick(() => {
selectedModelElement.value = newElement;
});
});
// 监听节点鼠标事件,显示/隐藏连接点
handleGraphEvent('node:mouseenter', (_ctx: any) => {
});
handleGraphEvent('node:mouseleave', (_ctx: any) => {
});
} catch (error) {
console.error('初始化画布失败:', error);
}
};
// 监听窗口大小变化
const handleResize = () => {
nextTick(() => {
resizeCanvas();
});
};
const init = () => {
console.info('init');
// 确保DOM渲染完成后再初始化画布
nextTick(() => {
initGraph();
window.addEventListener('resize', handleResize);
console.log('组件挂载完成');
});
};
const loadModel = () => {
const routeParams = router.currentRoute.value.params;
const id = routeParams.id;
if (id) {
findOneModelById(id as string).then(r => {
if (r.code === 200 && r.data) {
currentModel.value = r.data;
try {
const configInfo = r.data.configInfo;
if (configInfo && typeof configInfo === 'string') {
const parsedData = JSON.parse(configInfo);
savedGraphData.value = parsedData as SavedGraphData;
} else {
savedGraphData.value = r.data.configInfo ? r.data.configInfo as unknown as SavedGraphData : {...defaultSavedGraphData};
}
} catch (e: any) {
console.error('parse elements error, cause: ', e);
savedGraphData.value = {...defaultSavedGraphData};
}
init();
} else {
gobackWithError();
}
});
} else {
gobackWithError();
}
};
const handleUpdateModel = (saved: Partial<SavedGraphData>) => {
if (saved) {
savedGraphData.value = {
...savedGraphData.value,
...saved,
};
console.error(savedGraphData.value)
}
};
const handleSave = () => {
const nodesData: ModelElement[] = [];
const nodes = graph.value?.getNodes() as Node[];
if (nodes) {
nodes.forEach(node => {
const nodeData = node.getData() as ModelElement;
const newElement = {
...nodeData,
position: node.getPosition(),
width: node.getSize().width,
height: node.getSize().height,
};
nodesData.push(newElement);
});
}
const edges: any[] = [];
const graphEdges = graph.value?.getEdges() ?? [] as Edge[];
graphEdges.forEach(edge => {
edges.push({
id: edge.id,
source: edge.getSource() ?? null,
target: edge.getTarget() ?? null,
// 保存边的属性
attrs: edge.getAttrs() ?? {},
// 保存边的其他选项
router: edge.getRouter() ?? {},
connector: edge.getConnector() ?? null,
vertices: edge.getVertices() ?? [],
});
});
const graphData: SavedGraphData = {
...savedGraphData.value ?? {},
nodes: nodesData,
edges,
};
console.info('save graphData', graphData);
if (!currentModel.value) {
message.error('当前模型不存在');
return;
}
const newModel: Model = {
...currentModel.value,
configInfo: JSON.stringify(graphData),
};
updateModel(newModel).then(r => {
if (r.code === 200) {
message.success('修改成功.');
} else {
message.error(r.msg ?? '修改失败.');
}
});
};
// 初始化
onMounted(() => {
loadModel();
});
// 清理
onBeforeUnmount(() => {
window.removeEventListener('resize', handleResize);
if (graph.value) {
console.log('画布已销毁');
}
});
return {
currentModel,
selectedModelElement,
selectedModelNode,
savedGraphData,
graph,
canvas,
goback,
zoomIn,
zoomOut,
fitToScreen,
centerContent,
handleDragStart,
handleDragEnd,
handleDragEnter,
handleDragLeave,
handleDrop,
isDraggingOver,
handleSave,
handleUpdateModel,
};
},
});
</script>

View File

@@ -1,208 +0,0 @@
<template>
<Layout>
<a-card class="ks-page-card" title="模型组件设置">
<div class="ks-scrollable" style="height: 80.2vh;overflow-y: auto;padding-right: 10px">
<a-tabs v-model:activeKey="activeKey" class="ks-page-tabs">
<a-tab-pane key="1" tab="模型输入设置">
<a-form
autocomplete="off"
layout="vertical"
name="basic"
>
<a-row>
<a-col :span="16">
<a-form-item name="taskName">
<a-input-group compact>
<a-input style="width: 300px" />
<a-button type="primary">导入</a-button>
</a-input-group>
</a-form-item>
<a-form-item label="已选择1个字段" name="taskName">
<a-space size="middle">
<div class="btn-field selected">速度
<CloseCircleOutlined />
</div>
<div class="btn-field">导弹量
<CloseCircleOutlined />
</div>
<div class="btn-field">速度1
<CloseCircleOutlined />
</div>
<div class="btn-field">导弹量1
<CloseCircleOutlined />
</div>
</a-space>
</a-form-item>
<a-form-item label="可选字段" name="taskName">
<a-row>
<a-col :span="5">
<a-space>
<div class="btn-field gold">速度</div>
<PlusCircleOutlined class="icon-gold" />
</a-space>
</a-col>
<a-col :span="5">
<a-space>
<div class="btn-field gold">速度</div>
<PlusCircleOutlined class="icon-gold" />
</a-space>
</a-col>
<a-col :span="5">
<a-space>
<div class="btn-field gold">速度</div>
<PlusCircleOutlined class="icon-gold" />
</a-space>
</a-col>
</a-row>
</a-form-item>
<a-form-item label="自定义字段" name="taskName">
<a-row>
<a-col :span="16">
<a-space>
<a-input style="width: 300px"></a-input>
<PlusCircleOutlined class="icon-gold" />
</a-space>
</a-col>
</a-row>
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-tab-pane>
<a-tab-pane key="2" tab="参数设置">
<a-form
autocomplete="off"
layout="vertical"
name="basic"
>
<a-row>
<a-col :span="16">
<a-form-item label="模型参数" name="taskName">
<a-input style="width: 300px"></a-input>
</a-form-item>
<a-form-item label="模型参数" name="taskName">
<a-input style="width: 300px"></a-input>
</a-form-item>
<a-form-item label="模型参数" name="taskName">
<a-input style="width: 300px"></a-input>
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-tab-pane>
<a-tab-pane key="3" tab="动作空间设置">
<a-space class="mb-6">
<a-button style="width: 120px" type="primary">增加</a-button>
<a-button style="width: 120px">删除</a-button>
</a-space>
<a-table
:columns="columns"
:dataSource="dataSource"
size="small"
>
<template #bodyCell='{ column }'>
<a-space v-if="column.dataIndex === '_actions'">
<a-button class="btn-link-edit" size="small" type="link">编辑</a-button>
<a-button class="btn-link-delete" danger size="small" type="link">删除</a-button>
<a-button class="btn-link-detail" size="small" type="link">详情</a-button>
</a-space>
</template>
</a-table>
</a-tab-pane>
<!-- <a-tab-pane key="4" tab="奖励函数设置">-->
<!-- </a-tab-pane>-->
</a-tabs>
</div>
</a-card>
</Layout>
</template>
<script lang="ts" setup>
import Layout from '../layout.vue';
import { ref } from 'vue';
import { CloseCircleOutlined, PlusCircleOutlined } from '@ant-design/icons-vue';
const activeKey = ref('1');
const dataSource = [
{
index: '1',
key: '1',
name: '工程001',
age: '-',
address: '-',
status: '✅ 运行中',
createdAt: '2025-12-12 12:12:12',
},
{
index: '2',
key: '2',
name: '工程002',
age: '-',
address: '-',
status: '✅ 运行中',
createdAt: '2025-12-12 12:12:12',
},
];
const columns = [
{
title: '序号',
dataIndex: 'index',
key: 'index',
},
{
title: '名称',
dataIndex: 'name',
key: 'name',
},
{
title: '动作类型',
dataIndex: 'age',
key: 'age',
},
{
title: '参数1',
dataIndex: 'address',
key: 'address',
},
{
title: '参数2',
dataIndex: 'status',
key: 'status',
},
{
title: '操作',
dataIndex: '_actions',
key: '_actions',
},
];
</script>

View File

@@ -1,65 +0,0 @@
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2025 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
import type { TableColumnType } from 'ant-design-vue';
import type { Model, SavedGraphData } from './types';
export const defaultSavedGraphData = {
nodes: [],
edges: [],
observations: [],
rewards: [],
actionSpaces: [],
} as SavedGraphData
export const modelColumns: TableColumnType<Model>[] = [
{
title: '序号',
dataIndex: 'index',
key: 'index',
},
{
title: '智能体名称',
dataIndex: 'name',
key: 'name',
},
{
title: '所属工程',
dataIndex: 'projectSpaceName',
key: 'projectSpaceName',
},
{
title: '智能体描述',
dataIndex: 'description',
key: 'description',
},
{
title: '存储位置',
dataIndex: 'storageLocation',
key: 'storageLocation',
},
{
title: '操作',
dataIndex: '_actions',
key: '_actions',
width: 100,
},
];
export const defaultModel: Model = {
id: 0,
projectId: undefined,
projectSpaceName: null,
name: null,
description: null,
storageLocation: null,
configInfo: null,
status: 1,
createTime: null,
};

View File

@@ -1,264 +0,0 @@
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2026 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
import type { ElementInput } from './inputs';
export const taskInputs: ElementInput[] = [
{
id: null,
name: '空中扫荡',
description: '',
category: 'task',
draggable: true,
children: [],
},
{
id: null,
name: '战斗巡逻',
description: '',
category: 'task',
draggable: true,
children: [],
},
{
id: null,
name: '空中护航',
description: '',
category: 'task',
draggable: true,
children: [],
},
{
id: null,
name: '空中加油',
description: '',
category: 'task',
draggable: true,
children: [],
},
{
id: null,
name: '侦察监视',
description: '',
category: 'task',
draggable: true,
children: [],
},
{
id: null,
name: '压制防空',
description: '',
category: 'task',
draggable: true,
children: [],
},
];
export const controlInputs: ElementInput[] = [
{
id: null,
name: '追击',
description: '',
category: 'control',
draggable: true,
children: [],
},
{
id: null,
name: '开火',
description: '',
category: 'control',
draggable: true,
children: [],
},
{
id: null,
name: '偏置',
description: '',
category: 'control',
draggable: true,
children: [],
},
{
id: null,
name: '脱离',
description: '',
category: 'control',
draggable: true,
children: [],
},
{
id: null,
name: '目视追击',
description: '',
category: 'control',
draggable: true,
children: [],
},
{
id: null,
name: '夹击追击',
description: '',
category: 'control',
draggable: true,
children: [],
},
{
id: null,
name: '交替脱离',
description: '',
category: 'control',
draggable: true,
children: [],
},
{
id: null,
name: '交替追击',
description: '',
category: 'control',
draggable: true,
children: [],
},
{
id: null,
name: '航线巡逻',
description: '',
category: 'control',
draggable: true,
children: [],
},
];
export const flyInputs: ElementInput[] = [
{
id: null,
name: '滚转角',
description: '',
category: 'parameter',
draggable: true,
children: [],
},
{
id: null,
name: '俯仰角',
description: '',
category: 'parameter',
draggable: true,
children: [],
},
{
id: null,
name: '偏航角',
description: '',
category: 'parameter',
draggable: true,
children: [],
},
{
id: null,
name: '油门',
description: '',
category: 'parameter',
draggable: true,
children: [],
},
{
id: null,
name: '开火',
description: '',
category: 'parameter',
draggable: true,
children: [],
},
{
id: null,
name: '飞行到点/位',
description: '',
category: 'parameter',
draggable: true,
children: [],
},
{
id: null,
name: '飞行到位置',
description: '',
category: 'parameter',
draggable: true,
children: [],
},
{
id: null,
name: '飞行到高度',
description: '',
category: 'parameter',
draggable: true,
children: [],
},
{
id: null,
name: '转头',
description: '',
category: 'parameter',
draggable: true,
children: [],
},
{
id: null,
name: '相对斜距转向',
description: '',
category: 'parameter',
draggable: true,
children: [],
},
{
id: null,
name: '指定速度',
description: '',
category: 'parameter',
draggable: true,
children: [],
},
];
export const managerInputs: ElementInput[] = [
{
id: null,
name: '启动',
description: '',
category: 'action',
draggable: true,
children: [],
},
{
id: null,
name: '恢复',
description: '',
category: 'action',
draggable: true,
children: [],
},
{
id: null,
name: '暂停',
description: '',
category: 'action',
draggable: true,
children: [],
},
{
id: null,
name: '删除',
description: '',
category: 'action',
draggable: true,
children: [],
}
];

View File

@@ -1,8 +0,0 @@
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2026 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/

View File

@@ -1,186 +0,0 @@
/*
* This file is part of the kernelstudio package.
*
* (c) 2014-2026 zlin <admin@kernelstudio.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
import { findObservationTypeByQuery } from './api';
import type { DraggableElement } from '../builder/element';
export interface ElementInput extends DraggableElement {
[key: string]: unknown;
}
export const defaultBasicInputs: ElementInput[] = [
{
id: null,
name: '基础状态',
description: null,
draggable: true,
category: 'input',
children:[
{
id: null,
name: '时间数据',
description: null,
draggable: true,
category: 'input',
children:[]
},
{
id: null,
name: '阵营数据',
description: null,
draggable: true,
category: 'input',
children:[]
}
]
}
]
export const defaultManeuverInputs: ElementInput[] = [
{
id: null,
name: '机动状态',
description: null,
draggable: true,
category: 'input',
children:[]
}
]
export const defaultWeaponInputs: ElementInput[] = [
{
id: null,
name: '武器状态',
description: null,
draggable: true,
category: 'input',
children:[
{
id: null,
name: '挂载武器',
description: null,
draggable: true,
category: 'input',
children:[]
},
{
id: null,
name: '导弹状态',
description: null,
draggable: true,
category: 'input',
children:[]
}
]
}
]
export const defaultSensorInputs: ElementInput[] = [
{
id: null,
name: '传感器状态',
description: null,
draggable: true,
category: 'input',
children:[
{
id: null,
name: '传感器名称',
description: null,
draggable: true,
category: 'input',
children:[]
},
{
id: null,
name: '类型信息',
description: null,
draggable: true,
category: 'input',
children:[]
},
{
id: null,
name: '激活状态',
description: null,
draggable: true,
category: 'input',
children:[]
}
]
}
]
export const defaultFuelInputs: ElementInput[] = [
{
id: null,
name: '燃油状态',
description: null,
draggable: true,
category: 'input',
children:[
{
id: null,
name: '当前燃油',
description: null,
draggable: true,
category: 'input',
children:[]
},
{
id: null,
name: '当前油耗',
description: null,
draggable: true,
category: 'input',
children:[]
},
]
}
]
export const resolveElementInputs = () : Promise<ElementInput[]>=> {
return new Promise((resolve,reject)=> {
findObservationTypeByQuery().then(r => {
let items = [];
let item: ElementInput = {
id: null,
name: '机动状态',
description: null,
draggable: true,
category: 'input',
children:[]
};
if(r.rows){
r.rows.forEach(i=> {
item.children.push({
name: i.typeName,
id: i.id,
description: i.description,
draggable: true,
category: 'input',
children: [],
})
})
}
items.push(item);
resolve([
...defaultBasicInputs,
...items,
...defaultWeaponInputs,
...defaultSensorInputs,
...defaultFuelInputs,
])
}).catch((e:any)=> {
reject(e);
});
})
}

Some files were not shown because too many files have changed in this diff Show More