feat: sync docs chart with README chart (Vega-Lite)
This commit is contained in:
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
> 
|
> 
|
||||||
|
|
||||||
### 📈 Growth & Trends (Last 14 Days)
|
### 📈 Total Downloads Trend
|
||||||

|

|
||||||
|
|
||||||
> *Blue: Downloads | Purple: Views (Real-time dynamic)*
|
> *Blue: Downloads | Purple: Views (Real-time dynamic)*
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
> 
|
> 
|
||||||
|
|
||||||
### 📈 增长与趋势 (Last 14 Days)
|
### 📈 总下载量累计趋势
|
||||||

|

|
||||||
|
|
||||||
> *蓝色: 总下载量 | 紫色: 总浏览量 (实时动态生成)*
|
> *蓝色: 总下载量 | 紫色: 总浏览量 (实时动态生成)*
|
||||||
|
|
||||||
|
|||||||
@@ -1159,22 +1159,14 @@ class OpenWebUIStats:
|
|||||||
if not new_chart:
|
if not new_chart:
|
||||||
return
|
return
|
||||||
|
|
||||||
# 查找并在 "### 📈" 开头的段落替换图表
|
# 匹配 ### 📈 ... \n\n
|
||||||
# 假设图表是在 "### 📈 Total Downloads Trend" 或 "### 📈 总下载量累计趋势" 之后
|
# 兼容 docs 中使用 Trend 或 Activity 作为 alt text
|
||||||
# 并且是以  格式存在
|
pattern = r"(### 📈.*?\n)(!\[.*?\]\(.*?\))"
|
||||||
|
|
||||||
# 简单起见,我们查找整个图表块并替换
|
|
||||||
# 匹配 ### 📈 ... \n\n
|
|
||||||
pattern = r"(### 📈.*?\n)(!\[Activity\]\(.*?\))"
|
|
||||||
|
|
||||||
def replace_chart(match):
|
|
||||||
title_line = match.group(1) # 保留标题行
|
|
||||||
# new_chart 包含了标题行,所以我们需要提取 url 部分或者直接用 new_chart 替换整个块
|
|
||||||
# generate_activity_chart 返回的是: ### 📈 Title\n
|
|
||||||
return new_chart
|
|
||||||
|
|
||||||
if re.search(pattern, content, re.DOTALL):
|
if re.search(pattern, content, re.DOTALL):
|
||||||
content = re.sub(pattern, replace_chart, content, flags=re.DOTALL)
|
# generate_activity_chart 返回的是完整块: ### 📈 Title\n
|
||||||
|
# 我们直接用新块替换整个旧块
|
||||||
|
content = re.sub(pattern, new_chart, content, flags=re.DOTALL)
|
||||||
|
|
||||||
with open(doc_path, "w", encoding="utf-8") as f:
|
with open(doc_path, "w", encoding="utf-8") as f:
|
||||||
f.write(content)
|
f.write(content)
|
||||||
|
|||||||
Reference in New Issue
Block a user