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

feat:sse消息分片

parent a119005a
...@@ -583,22 +583,45 @@ const processSSEStreamResponse = async (stream: ReadableStream | null) => { ...@@ -583,22 +583,45 @@ const processSSEStreamResponse = async (stream: ReadableStream | null) => {
const decoder = new TextDecoder(); const decoder = new TextDecoder();
try { try {
let fullData = '';
let isCollecting = false;
while (true) { while (true) {
const { done, value } = await reader.read(); const { done, value } = await reader.read();
if (done) break; if (done) break;
const chunk = decoder.decode(value, { stream: true }); const chunk = decoder.decode(value, { stream: true });
const lines = chunk.split('\n'); const lines = chunk.split('\n');
for (const line of lines) { for (const line of lines) {
if (line.startsWith('data: ')) { if (line.startsWith('data: ')) {
try { try {
const data = JSON.parse(line.slice(6)); // 移除'data: '前缀 if (line.startsWith('data: 0')) {
// 使用现有的SSE消息处理函数 isCollecting = true;
handleSSEMessage(data); 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) { } catch (e) {
loading.value = false; 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) => { ...@@ -287,6 +287,18 @@ const renderCellContent = (header: string, value: any, record: any) => {
return ''; return '';
} }
} }
// 如果是数字列,进行格式化
if (isNumericColumn(header)) {
// 判断value是否为数字(字符串)
if (!isNaN(Number(value))) {
// 格式化数字(字符串)
return formatNumber(Number(value));
} else {
// 非数字,直接返回原始值
return value;
}
}
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