|
|
@@ -235,15 +235,15 @@ class JobRun extends ModelCore
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 获取任务参数
|
|
|
+ * 获取任务参数 - 直接反序列化payload原样展示
|
|
|
*/
|
|
|
public function getJobParametersAttribute(): string
|
|
|
{
|
|
|
if (!$this->payload) {
|
|
|
- return '';
|
|
|
+ return '无参数';
|
|
|
}
|
|
|
|
|
|
- // 尝试解析payload
|
|
|
+ // 尝试反序列化payload
|
|
|
$payload = $this->payload;
|
|
|
|
|
|
// 如果是字符串,尝试反序列化
|
|
|
@@ -256,46 +256,56 @@ class JobRun extends ModelCore
|
|
|
try {
|
|
|
$unserialized = unserialize($payload);
|
|
|
if (is_array($unserialized)) {
|
|
|
- $payload = $unserialized;
|
|
|
+ return $this->formatArrayForDisplay($unserialized);
|
|
|
}
|
|
|
} catch (\Exception) {
|
|
|
- // 反序列化失败,保持原样
|
|
|
+ // 反序列化失败,返回原始字符串
|
|
|
+ return $payload;
|
|
|
}
|
|
|
} else {
|
|
|
// 尝试JSON解码
|
|
|
$decoded = json_decode($payload, true);
|
|
|
if (json_last_error() === JSON_ERROR_NONE) {
|
|
|
- $payload = $decoded;
|
|
|
+ return $this->formatArrayForDisplay($decoded);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 如果已经是数组,直接格式化
|
|
|
if (is_array($payload)) {
|
|
|
- $params = [];
|
|
|
-
|
|
|
- foreach ($payload as $key => $value) {
|
|
|
- if ($key === 'runtime') {
|
|
|
- $params['运行时间'] = round($value, 3) . 's';
|
|
|
- } else {
|
|
|
- $params[$key] = is_scalar($value) ? $value : json_encode($value);
|
|
|
- }
|
|
|
- }
|
|
|
+ return $this->formatArrayForDisplay($payload);
|
|
|
+ }
|
|
|
|
|
|
- if (empty($params)) {
|
|
|
- return '无参数';
|
|
|
- }
|
|
|
+ // 其他情况返回原始内容
|
|
|
+ return is_scalar($payload) ? (string)$payload : json_encode($payload);
|
|
|
+ }
|
|
|
|
|
|
- $result = [];
|
|
|
- foreach ($params as $key => $value) {
|
|
|
- $result[] = "{$key}: {$value}";
|
|
|
+ /**
|
|
|
+ * 格式化数组为显示字符串
|
|
|
+ */
|
|
|
+ private function formatArrayForDisplay(array $data): string
|
|
|
+ {
|
|
|
+ $result = [];
|
|
|
+
|
|
|
+ foreach ($data as $key => $value) {
|
|
|
+ if (is_array($value)) {
|
|
|
+ $result[] = $key . ': ' . json_encode($value, JSON_UNESCAPED_UNICODE);
|
|
|
+ } elseif (is_object($value)) {
|
|
|
+ $result[] = $key . ': ' . json_encode($value, JSON_UNESCAPED_UNICODE);
|
|
|
+ } elseif (is_bool($value)) {
|
|
|
+ $result[] = $key . ': ' . ($value ? 'true' : 'false');
|
|
|
+ } elseif (is_null($value)) {
|
|
|
+ $result[] = $key . ': null';
|
|
|
+ } else {
|
|
|
+ $result[] = $key . ': ' . $value;
|
|
|
}
|
|
|
-
|
|
|
- return implode(', ', $result);
|
|
|
}
|
|
|
|
|
|
- return $payload ?: '无参数';
|
|
|
+ return implode(', ', $result);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 获取简化的任务参数(用于列表显示)
|
|
|
*/
|