Merge branch 'feature/REQ-5965' into dev

This commit is contained in:
wangli 2025-11-19 15:54:46 +08:00
commit b28b2871fc
2 changed files with 20 additions and 3 deletions

View File

@ -19,6 +19,7 @@ import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.runtime.ProcessInstance;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.CollectionUtils;
@ -37,6 +38,7 @@ import java.util.Objects;
import static cn.axzo.workflow.common.code.BpmnInstanceRespCode.PROCESS_INSTANCE_NOT_EXISTS;
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_INITIATOR;
import static cn.axzo.workflow.common.constant.StarterConstants.K8S_POD_NAME_SPACE;
import static cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum.PROCESSING;
/**
@ -62,6 +64,8 @@ public class DangerOperationController {
private ExtAxProcessLogService processLogService;
@Resource
private AuthCodeService authCodeService;
@Resource
private Environment environment;
// 显示表单页面
@GetMapping("/web/process/form")
@ -69,6 +73,9 @@ public class DangerOperationController {
// 检查session中是否已验证授权码
Boolean isAuthenticated = (Boolean) session.getAttribute("isAuthenticated");
model.addAttribute("isAuthenticated", isAuthenticated != null && isAuthenticated);
String myPodNamespace = environment.getProperty(K8S_POD_NAME_SPACE);
model.addAttribute("apiBaseUrl", StringUtils.hasText(myPodNamespace) ? "/workflow-engine" : "");
// 可以在这里添加需要传递到页面的数据
return "form"; // 对应templates目录下的form.html
}

View File

@ -67,6 +67,14 @@
<script th:inline="javascript">
const ctx = [[@{/}]]; // 自动获取servlet.context.path
</script>
<!-- 在<head>中添加通过Thymeleaf读取后端传递的环境变量推荐 -->
<script th:inline="javascript">
// 后端通过Model传递K8S服务名配置本地默认空K8S环境注入服务名
const apiBaseUrl = [[${apiBaseUrl}]] || '';
// 完整请求路径 = 基础路径 + 接口相对路径
const getFullUrl = (relativePath) => `${apiBaseUrl}${relativePath}`;
</script>
</head>
<body class="bg-gray-50 font-inter min-h-screen flex flex-col">
<!-- 顶部导航 -->
@ -112,7 +120,8 @@
</div>
<!-- 输入授权码表单 -->
<form id="authForm" th:action="@{/web/process/validate-auth}" method="post" class="space-y-6">
<form id="authForm" th:action="${apiBaseUrl} + @{/web/process/validate-auth}" method="post"
class="space-y-6">
<!-- 授权码输入 -->
<div class="form-group">
<label for="authCode" class="block text-sm font-medium text-gray-700 mb-1">
@ -549,7 +558,7 @@
try {
// 使用全局上下文路径变量拼接URL
const url = `${ctx}web/process/get-auth-code?password=${encodeURIComponent(password)}`;
const url = getFullUrl(`${ctx}web/process/get-auth-code?password=${encodeURIComponent(password)}`);
// 保持POST请求方式参数通过URL查询参数传递
const response = await fetch(url, {
@ -615,8 +624,9 @@
};
try {
const fullActionUrl = getFullUrl(this.action);
// 使用全局上下文路径变量
const response = await fetch(this.action, {
const response = await fetch(fullActionUrl, {
method: this.method,
headers: {
'Content-Type': 'application/json',