iflow-feishu 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/core/card-builder.js +31 -7
package/package.json
CHANGED
package/src/core/card-builder.js
CHANGED
|
@@ -2,6 +2,33 @@
|
|
|
2
2
|
* 卡片构建器
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* 格式化时间显示
|
|
7
|
+
* @param {number} ms - 毫秒数
|
|
8
|
+
* @returns {string} 格式化的时间字符串 (h m s 格式)
|
|
9
|
+
*/
|
|
10
|
+
function formatTime(ms) {
|
|
11
|
+
if (ms < 1000) {
|
|
12
|
+
return `${ms}ms`;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const totalSeconds = Math.floor(ms / 1000);
|
|
16
|
+
const seconds = totalSeconds % 60;
|
|
17
|
+
const totalMinutes = Math.floor(totalSeconds / 60);
|
|
18
|
+
const minutes = totalMinutes % 60;
|
|
19
|
+
const hours = Math.floor(totalMinutes / 60);
|
|
20
|
+
|
|
21
|
+
if (hours > 0) {
|
|
22
|
+
return `${hours}h ${minutes}m ${seconds}s`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (minutes > 0) {
|
|
26
|
+
return `${minutes}m ${seconds}s`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return `${seconds}s`;
|
|
30
|
+
}
|
|
31
|
+
|
|
5
32
|
class CardBuilder {
|
|
6
33
|
buildMarkdownCard(text) {
|
|
7
34
|
// 预处理 Markdown 内容,确保列表格式正确
|
|
@@ -20,11 +47,10 @@ class CardBuilder {
|
|
|
20
47
|
if (reasoning && reasoning.trim()) {
|
|
21
48
|
let thinkingStatus = '';
|
|
22
49
|
if (isThinking) {
|
|
23
|
-
const timeStr = thinkingTime !== null ? `(${(thinkingTime
|
|
50
|
+
const timeStr = thinkingTime !== null ? `(${formatTime(thinkingTime)})` : '';
|
|
24
51
|
thinkingStatus = `💭 思考中 ${timeStr}`;
|
|
25
52
|
} else if (thinkingTime !== null) {
|
|
26
|
-
|
|
27
|
-
thinkingStatus = `💭 思考完成 (${timeStr})`;
|
|
53
|
+
thinkingStatus = `💭 思考完成 (${formatTime(thinkingTime)})`;
|
|
28
54
|
}
|
|
29
55
|
|
|
30
56
|
let titleContent = '';
|
|
@@ -51,11 +77,9 @@ class CardBuilder {
|
|
|
51
77
|
if (content !== null || responseTime !== null || isGenerating) {
|
|
52
78
|
let responseTitle = '📝 回复';
|
|
53
79
|
if (isGenerating && responseTime !== null) {
|
|
54
|
-
|
|
55
|
-
responseTitle = `📝 Doing (${timeStr})`;
|
|
80
|
+
responseTitle = `📝 Doing (${formatTime(responseTime)})`;
|
|
56
81
|
} else if (!isGenerating && responseTime !== null) {
|
|
57
|
-
|
|
58
|
-
responseTitle = `📝 Done (${timeStr})`;
|
|
82
|
+
responseTitle = `📝 Done (${formatTime(responseTime)})`;
|
|
59
83
|
}
|
|
60
84
|
|
|
61
85
|
let titleContent = '';
|