'commit'
This commit is contained in:
@@ -194,12 +194,37 @@ createApp({
|
||||
textStyle: { color: "#94a3b8" },
|
||||
top: 10
|
||||
},
|
||||
grid: { left: 50, right: 30, top: 60, bottom: 40 },
|
||||
grid: { left: 50, right: 30, top: 60, bottom: 60 },
|
||||
xAxis: {
|
||||
type: "category",
|
||||
data: data.dates.map(d => d.split('-').slice(1).join('/')), // Show MM/DD
|
||||
axisLine: { lineStyle: { color: "#475569" } },
|
||||
axisLabel: { color: "#94a3b8" }
|
||||
type: 'category',
|
||||
data: data.dates,
|
||||
axisLabel: {
|
||||
show: true,
|
||||
color: '#94a3b8',
|
||||
interval: function(index, value) {
|
||||
// 强制显示 00:00, 06:00, 12:00, 18:00
|
||||
if (value && value.includes(' ')) {
|
||||
const time = value.split(' ')[1];
|
||||
return time === '00:00' || time === '06:00' || time === '12:00' || time === '18:00';
|
||||
}
|
||||
return index % 6 === 0; // 每6个点显示一个(对应 6 小时)
|
||||
},
|
||||
formatter: function(value) {
|
||||
if (!value) return '';
|
||||
const parts = value.split(' ');
|
||||
if (parts.length === 2) {
|
||||
const time = parts[1];
|
||||
// 如果是零点,显示日期和时间
|
||||
if (time === '00:00') {
|
||||
return parts[0] + '\n' + time;
|
||||
}
|
||||
return time;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
},
|
||||
axisLine: { lineStyle: { color: '#334155' } },
|
||||
axisTick: { show: true, lineStyle: { color: '#334155' } }
|
||||
},
|
||||
yAxis: {
|
||||
type: "value",
|
||||
|
||||
@@ -62,43 +62,41 @@ createApp({
|
||||
if (!text) return '';
|
||||
|
||||
try {
|
||||
// 1. 处理 LaTeX (简单替换,先处理 $$ 再处理 $)
|
||||
let processedText = text;
|
||||
|
||||
// 处理块级 LaTeX: $$ ... $$
|
||||
processedText = processedText.replace(/\$\$\s*([\s\S]*?)\s*\$\$/g, (match, formula) => {
|
||||
try {
|
||||
if (typeof katex !== 'undefined') {
|
||||
// 1. 处理 LaTeX
|
||||
if (typeof katex !== 'undefined') {
|
||||
// 处理块级 LaTeX: $$ ... $$
|
||||
processedText = processedText.replace(/\$\$\s*([\s\S]*?)\s*\$\$/g, (match, formula) => {
|
||||
try {
|
||||
return '<div class="katex-block">' + katex.renderToString(formula, { displayMode: true, throwOnError: false }) + '</div>';
|
||||
}
|
||||
return match;
|
||||
} catch (e) {
|
||||
return match;
|
||||
}
|
||||
});
|
||||
|
||||
// 处理行内 LaTeX: $ ... $
|
||||
processedText = processedText.replace(/\$([^\$\n]+?)\$/g, (match, formula) => {
|
||||
try {
|
||||
if (typeof katex !== 'undefined') {
|
||||
} catch (e) { return match; }
|
||||
});
|
||||
|
||||
// 处理行内 LaTeX: $ ... $
|
||||
processedText = processedText.replace(/\$([^\$\n]+?)\$/g, (match, formula) => {
|
||||
try {
|
||||
return katex.renderToString(formula, { displayMode: false, throwOnError: false });
|
||||
}
|
||||
return match;
|
||||
} catch (e) {
|
||||
return match;
|
||||
}
|
||||
});
|
||||
} catch (e) { return match; }
|
||||
});
|
||||
}
|
||||
|
||||
// 2. 使用 marked 解析 Markdown
|
||||
if (typeof marked !== 'undefined') {
|
||||
// marked v12+ 使用 marked.parse
|
||||
return marked.parse(processedText);
|
||||
} else {
|
||||
// 降级使用之前的 simpleMarkdown
|
||||
// 降级使用 simpleMarkdown
|
||||
return simpleMarkdown(processedText);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Markdown/LaTeX rendering error:', e);
|
||||
return text;
|
||||
console.error('Markdown rendering error:', e);
|
||||
// 最后的兜底:如果 marked 报错,尝试用 simpleMarkdown
|
||||
try {
|
||||
return simpleMarkdown(text);
|
||||
} catch (e2) {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user