Commit 4fbf0b04 authored by 水玉婷's avatar 水玉婷
Browse files

feat:sse消息分片

parent a119005a
......@@ -583,22 +583,45 @@ const processSSEStreamResponse = async (stream: ReadableStream | null) => {
const decoder = new TextDecoder();
try {
let fullData = '';
let isCollecting = false;
while (true) {
const { done, value } = await reader.read();
if (done) break;
const chunk = decoder.decode(value, { stream: true });
const lines = chunk.split('\n');
const lines = chunk.split('\n');
for (const line of lines) {
if (line.startsWith('data: ')) {
try {
const data = JSON.parse(line.slice(6)); // 移除'data: '前缀
// 使用现有的SSE消息处理函数
handleSSEMessage(data);
if (line.startsWith('data: 0')) {
isCollecting = true;
fullData += line.slice(7); // 移除 'data:��缀
} else if (line.startsWith('data: 1')) {
if (isCollecting) {
// 遇到1的停止,整合成完整JSON
fullData += line.slice(7); // 移除 'data: 1 ' 前缀
// 确保有数据才处理
if (fullData.trim()) {
const data = JSON.parse(fullData);
handleSSEMessage(data);
}
isCollecting = false;
fullData = '';
}else{
fullData = line.slice(7)
const data = JSON.parse(fullData);
handleSSEMessage(data);
isCollecting = false;
fullData = '';
}
}
} catch (e) {
loading.value = false;
console.warn('解析SSE数据失败:');
isCollecting = false;
fullData = '';
console.warn('解析SSE数据失败:', e);
}
}
}
......
......@@ -287,6 +287,18 @@ const renderCellContent = (header: string, value: any, record: any) => {
return '';
}
}
// 如果是数字列,进行格式化
if (isNumericColumn(header)) {
// 判断value是否为数字(字符串)
if (!isNaN(Number(value))) {
// 格式化数字(字符串)
return formatNumber(Number(value));
} else {
// 非数字,直接返回原始值
return value;
}
}
return value;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment