fix: 提升 get_files per_page 限制从 20 到 100
问题: - Core API 现在调用 MarkBase API 获取所有文件 - 但 Studio 的 get_files 还是使用 per_page=20 - 导致 Library 只显示 20 个文件,不显示所有未注册文件 修复: - per_page 从 20 提升到 100 - Core API 现在支持更大的 page_size - 确保多页获取逻辑正确 影响: - Library 可以显示更多文件 - 减少请求次数(100 vs 20) - 更好的用户体验 测试: ✅ 编译通过 ✅ 多页获取逻辑正确
This commit is contained in:
@@ -218,9 +218,9 @@ async fn search_agents(query: String, conversation_id: Option<String>) -> Result
|
||||
|
||||
#[tauri::command(rename_all = "camelCase")]
|
||||
async fn get_files(args: GetFilesArgs) -> Result<Vec<FileInfo>, String> {
|
||||
let page_size = args.page_size;
|
||||
let max_files = args.page_size;
|
||||
let client = get_client();
|
||||
let per_page = 20; // API 限制最大 20
|
||||
let per_page = 100; // Core API 现在支持更大的 page_size
|
||||
|
||||
// 获取第一页并获取总数
|
||||
let url = format!("{}/api/v1/files?api_key={}&page=1&per_page={}", CORE_API, API_KEY, per_page);
|
||||
@@ -233,6 +233,9 @@ async fn get_files(args: GetFilesArgs) -> Result<Vec<FileInfo>, String> {
|
||||
// 解析第一页的文件
|
||||
if let Some(files_array) = json["data"].as_array() {
|
||||
for f in files_array {
|
||||
if all_files.len() >= max_files {
|
||||
break;
|
||||
}
|
||||
if let Some(file_info) = parse_file_info(f) {
|
||||
all_files.push(file_info);
|
||||
}
|
||||
@@ -243,11 +246,10 @@ async fn get_files(args: GetFilesArgs) -> Result<Vec<FileInfo>, String> {
|
||||
let total_pages = (total + per_page - 1) / per_page;
|
||||
|
||||
// 获取剩余页(如果有限制)
|
||||
let max_files = std::cmp::min(page_size, total);
|
||||
let max_pages = (max_files + per_page - 1) / per_page;
|
||||
|
||||
for page in 2..=max_pages.min(total_pages) {
|
||||
if all_files.len() >= page_size {
|
||||
if all_files.len() >= max_files {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -257,7 +259,7 @@ async fn get_files(args: GetFilesArgs) -> Result<Vec<FileInfo>, String> {
|
||||
|
||||
if let Some(files_array) = json["data"].as_array() {
|
||||
for f in files_array {
|
||||
if all_files.len() >= page_size {
|
||||
if all_files.len() >= max_files {
|
||||
break;
|
||||
}
|
||||
if let Some(file_info) = parse_file_info(f) {
|
||||
|
||||
Reference in New Issue
Block a user