click subpath
This commit is contained in:
@@ -292,6 +292,8 @@ function AnalyticsContent() {
|
||||
const [selectedProjectIds, setSelectedProjectIds] = useState<string[]>([]);
|
||||
// 添加标签名称状态 - 用于在UI中显示和API请求
|
||||
const [selectedTagNames, setSelectedTagNames] = useState<string[]>([]);
|
||||
// 添加子路径筛选状态
|
||||
const [selectedSubpath, setSelectedSubpath] = useState<string>('');
|
||||
// 添加分页状态
|
||||
const [currentPage, setCurrentPage] = useState<number>(1);
|
||||
const [pageSize, setPageSize] = useState<number>(10);
|
||||
@@ -377,6 +379,11 @@ function AnalyticsContent() {
|
||||
params.append('tagName', tagName);
|
||||
});
|
||||
}
|
||||
|
||||
// 添加子路径筛选参数
|
||||
if (selectedSubpath) {
|
||||
params.append('subpath', selectedSubpath);
|
||||
}
|
||||
|
||||
// 记录构建的 URL,以确保参数正确包含
|
||||
const summaryUrl = `${baseUrl}/summary?${params.toString()}`;
|
||||
@@ -446,7 +453,7 @@ function AnalyticsContent() {
|
||||
};
|
||||
|
||||
fetchData();
|
||||
}, [dateRange, selectedTeamIds, selectedProjectIds, selectedTagNames, currentPage, pageSize, selectedShortUrl, shouldFetchData]);
|
||||
}, [dateRange, selectedTeamIds, selectedProjectIds, selectedTagNames, selectedSubpath, currentPage, pageSize, selectedShortUrl, shouldFetchData]);
|
||||
|
||||
// Function to clear the shorturl filter
|
||||
const handleClearShortUrlFilter = () => {
|
||||
@@ -467,6 +474,19 @@ function AnalyticsContent() {
|
||||
window.location.href = newUrl.toString();
|
||||
};
|
||||
|
||||
// 清除子路径筛选
|
||||
const handleClearSubpathFilter = () => {
|
||||
setSelectedSubpath('');
|
||||
};
|
||||
|
||||
// 处理子路径点击
|
||||
const handlePathClick = (path: string) => {
|
||||
console.log('Path clicked:', path);
|
||||
setSelectedSubpath(path);
|
||||
// 重置到第一页
|
||||
setCurrentPage(1);
|
||||
};
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center min-h-screen">
|
||||
@@ -553,6 +573,23 @@ function AnalyticsContent() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 如果有选定的 subpath,显示提示 */}
|
||||
{selectedSubpath && (
|
||||
<div className="bg-blue-100 text-blue-800 px-3 py-2 rounded-md text-sm flex items-center justify-between">
|
||||
<div>
|
||||
<span>Filtered by Channel:</span>
|
||||
<span className="ml-2 font-medium">{selectedSubpath}</span>
|
||||
</div>
|
||||
<button
|
||||
onClick={handleClearSubpathFilter}
|
||||
className="ml-3 text-blue-700 hover:text-blue-900 p-1 rounded-full hover:bg-blue-200"
|
||||
aria-label="Clear subpath filter"
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 只在没有选中 shorturl 时显示筛选选择器 */}
|
||||
{!selectedShortUrl && (
|
||||
<>
|
||||
@@ -670,6 +707,7 @@ function AnalyticsContent() {
|
||||
projectIds={selectedProjectIds}
|
||||
tagIds={selectedTagNames}
|
||||
linkId={selectedShortUrl?.externalId}
|
||||
subpath={selectedSubpath}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -681,6 +719,7 @@ function AnalyticsContent() {
|
||||
startTime={format(dateRange.from, "yyyy-MM-dd'T'HH:mm:ss'Z'")}
|
||||
endTime={format(dateRange.to, "yyyy-MM-dd'T'HH:mm:ss'Z'")}
|
||||
linkId={selectedShortUrl.externalId}
|
||||
onPathClick={handlePathClick}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user