Browse Source

feat(AiWork): 宝箱配置页面功能扩展和显示优化- 增加消耗组、奖励组、条件组的详细内容展示
- 实现组名称的可点击跳转功能
-修复颜色对比度和枚举常量等问题
- 优化数据预加载和关联关系命名
- 提升页面显示效果和用户体验

notfff 7 months ago
parent
commit
da352377b9

+ 43 - 6
AiWork/2025年06月/041947-修复宝箱配置页面显示异常问题.md

@@ -128,13 +128,50 @@ git commit -m "修复宝箱配置页面显示异常问题
 - 解决消耗组/奖励组/条件组名称无法正常显示的问题"
 ```
 
+## 功能扩展
+
+在修复基本显示问题后,进一步增加了消耗组/奖励组/条件组的内容展示和关联访问功能:
+
+### 1. **增加详细内容展示列**
+- **消耗组详情列**:显示具体的消耗项目和数量
+- **奖励组详情列**:显示奖励项目、数量范围、权重和必中状态
+- **条件组详情列**:显示条件类型和具体要求
+
+### 2. **实现可点击跳转功能**
+- 消耗组/奖励组/条件组名称都变为可点击链接
+- 点击后跳转到对应的详情页面
+- 提供完整的关联访问体验
+
+### 3. **修复相关问题**
+- 修复消耗组控制器中标签显示的对比色计算问题
+- 修复`CONSUME_TYPE::FUND`枚举常量错误(改为`FUND_CONFIG`)
+- 优化预加载,包含子项目数据(consumeItems、rewardItems、conditionItems)
+
+### 4. **技术改进**
+- 使用Grid的`link()`方法实现可点击跳转
+- 使用模型的格式化方法显示详细内容
+- 创建公共静态方法`calculateContrastColor`处理颜色对比度
+- 正确处理关联关系的命名(camelCase vs snake_case)
+
+## 最终效果
+
+现在宝箱配置页面完美显示了:
+
+1. **基本信息**:宝箱名称、ID、状态等
+2. **可点击的组名称**:消耗组、奖励组、条件组都可以点击跳转
+3. **详细内容展示**:
+   - 消耗组:物品 萝卜 × 500、物品 辣椒 × 500
+   - 奖励组:物品 萝卜 × 200-2000 (权重: 50.00, 非必中)
+   - 条件组:全部满足 土地等级 普通土地 ≥ 1
+4. **完整的关联访问**:点击任何组名称都能跳转到详情页面
+
 ## 总结
 
-本次修复成功解决了宝箱配置页面的显示异常问题:
+本次任务成功解决了宝箱配置页面的显示异常问题,并大幅增强了用户体验
 
-1. **根本原因**:Eloquent关联数据预加载时机错误
-2. **解决方法**:调整预加载调用位置到Grid配置开始
-3. **附加优化**:清理未使用的代码,提升代码质量
-4. **验证结果**:页面显示完全正常,性能得到优化
+1. **根本原因**:Eloquent关联数据预加载时机错误和关联关系命名不一致
+2. **解决方法**:调整预加载调用位置,统一使用camelCase关联关系命名
+3. **功能扩展**:增加详细内容展示和关联访问功能
+4. **验证结果**:页面显示完全正常,功能完整,用户体验优秀
 
-这个问题提醒我们在使用Laravel Eloquent关联查询时,必须注意预加载的时机,确保在访问关联数据之前就已经正确设置了预加载。
+这个问题提醒我们在使用Laravel Eloquent关联查询时,必须注意预加载的时机和关联关系的命名规范,确保在访问关联数据之前就已经正确设置了预加载。

+ 1 - 0
UCore/Model/RequestLog.php

@@ -19,6 +19,7 @@ use UCore\ModelCore;
  * @property   string  $headers
  * @property   string  $method  请求类型
  * @property   string  $request_unid
+ * @property   string  $run_unid
  * @property   string  $response  返回消息
  * @property   string  $ipaddress  ip地址
  * @property   int  $user_id  用户ID

+ 1 - 1
app/Module/AppGame/HttpControllers/ProtobufController.php

@@ -80,7 +80,7 @@ class ProtobufController extends Controller
             }
             \Illuminate\Support\Facades\Log::debug('Proto请求信息-json', json_decode($request->serializeToJsonString(),true));
 
-            $requestLogger->setProtobufJson($request->serializeToJsonString());
+            $requestLogger->setProtobuf($request);
             // 获取路由配置
             $config = config('proto_route');
             if (empty($config['routes'])) {

+ 6 - 2
app/Module/System/Services/RequestLogger.php

@@ -5,6 +5,7 @@ namespace App\Module\System\Services;
 use Google\Protobuf\Internal\Message;
 use Illuminate\Http\Request as HttpRequest;
 use UCore\Model\RequestLog;
+use Uraus\Kku\Request;
 
 
 class RequestLogger
@@ -26,6 +27,7 @@ class RequestLogger
 
         // 初始化请求日志
         $this->requestLog->request_unid = RUN_UNIQID;
+        $this->requestLog->run_unid     = RUN_UNIQID;
         $this->requestLog->path         = $httpRequest->path();
         $this->requestLog->method       = $httpRequest->method();
         $this->requestLog->headers      = json_encode($httpRequest->headers->all());
@@ -62,9 +64,11 @@ class RequestLogger
         $this->requestLog->run_ms = intval(($endTime - $startTime) * 1000);
     }
 
-    public function setProtobufJson(string $jsonData)
+    public function setProtobuf(Request $request)
     {
-        $this->requestLog->protobuf_json = $jsonData;
+        $jsonData = $request->serializeToJsonString();
+        $this->requestLog->protobuf_json = $jsonData ;
+        $this->requestLog->request_unid  = $request->getRequestUnid();
     }
 
     public function __destruct()