refactor(public, services): improve HTML structure and optimize CSV service logging

This commit is contained in:
wood chen 2024-11-16 05:45:24 +08:00
parent 61e84d87b8
commit a4d6890a78
2 changed files with 35 additions and 27 deletions

View File

@ -14,7 +14,8 @@
</style>
<script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/markdown-it/12.3.2/markdown-it.min.js"></script>
<script defer src="https://analytics.czl.net/script.js" data-website-id="67f71dbc-799c-46b6-9c23-b1b012daef65"></script>
<script defer src="https://analytics.czl.net/script.js"
data-website-id="67f71dbc-799c-46b6-9c23-b1b012daef65"></script>
</head>
<body>
@ -132,33 +133,40 @@
});
let detailHtml = `
<table>
<thead>
<tr>
<th>接口</th>
<th>今日调用</th>
<th>总调用</th>
<th>查看</th>
</tr>
</thead>
<tbody>
`;
<table>
<thead>
<tr>
<th>接口</th>
<th>今日调用</th>
<th>总调用</th>
<th>URL数量</th>
<th>查看</th>
</tr>
</thead>
<tbody>
`;
// 同时加载URL统计数据
const urlStatsResponse = await fetch('/urlstats');
const urlStats = await urlStatsResponse.json();
sortedEndpoints.forEach(([endpoint, stat]) => {
const urlCount = urlStats[endpoint]?.total_urls || 0;
detailHtml += `
<tr>
<td>
<a href="javascript:void(0)"
onclick="copyToClipboard('${endpoint}')"
class="endpoint-link"
title="点击复制链接">
${getDisplayName(endpoint, endpointConfig)}
</a>
</td>
<td>${stat.today_calls}</td>
<td>${stat.total_calls}</td>
<td><a href="${endpoint}" target="_blank" rel="noopener noreferrer">👀</a></td>
</tr>
<tr>
<td>
<a href="javascript:void(0)"
onclick="copyToClipboard('${endpoint}')"
class="endpoint-link"
title="点击复制链接">
${getDisplayName(endpoint, endpointConfig)}
</a>
</td>
<td>${stat.today_calls}</td>
<td>${stat.total_calls}</td>
<td>${urlCount}</td>
<td><a href="${endpoint}" target="_blank" rel="noopener noreferrer">👀</a></td>
</tr>
`;
});

View File

@ -121,14 +121,14 @@ func LoadCSVPaths() error {
}
func GetCSVContent(path string) (*models.URLSelector, error) {
log.Printf("开始获取CSV内容: %s", path)
// log.Printf("开始获取CSV内容: %s", path)
Mu.RLock()
selector, exists := csvCache[path]
Mu.RUnlock()
if exists {
log.Printf("从缓存中获取到CSV内容: %s", path)
// log.Printf("从缓存中获取到CSV内容: %s", path)
return selector, nil
}