diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 24e4ec0..b0a0dd7 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -12,6 +12,10 @@ "core:window:allow-minimize", "core:window:allow-start-dragging", "core:window:allow-toggle-maximize", - "core:window:allow-internal-toggle-maximize" + "core:window:allow-internal-toggle-maximize", + "dialog:default", + "dialog:allow-message", + "dialog:allow-ask", + "dialog:allow-confirm" ] } diff --git a/src-tauri/src/commands/resource_category.rs b/src-tauri/src/commands/resource_category.rs index 7ddc2b4..528ff9a 100644 --- a/src-tauri/src/commands/resource_category.rs +++ b/src-tauri/src/commands/resource_category.rs @@ -1,6 +1,6 @@ use serde::{Deserialize, Serialize}; use tauri::{command, AppHandle}; -use crate::python_executor::{execute_python_command, PythonExecutorConfig}; +use crate::python_executor::execute_python_command; #[derive(Debug, Serialize, Deserialize)] pub struct CreateCategoryRequest { @@ -94,10 +94,11 @@ pub async fn delete_resource_category(app: AppHandle, category_id: String) -> Re #[command] pub async fn search_resource_categories(app: AppHandle, keyword: String) -> Result { let args = vec![ + "-m".to_string(), "python_core.services.resource_category_manager".to_string(), "search_categories".to_string(), keyword, ]; - + execute_python_command(app, &args, None).await } diff --git a/src/pages/ResourceCategoryPage.tsx b/src/pages/ResourceCategoryPage.tsx index 83b4b4b..dd152e2 100644 --- a/src/pages/ResourceCategoryPage.tsx +++ b/src/pages/ResourceCategoryPage.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect } from 'react' -import { Plus, Edit, Trash2, Search, Save, X, Palette } from 'lucide-react' +import { Plus, Edit, Trash2, Search, Save, X } from 'lucide-react' import { ResourceCategoryService, ResourceCategory } from '../services/resourceCategoryService' const ResourceCategoryPage: React.FC = () => { @@ -49,11 +49,10 @@ const ResourceCategoryPage: React.FC = () => { setShowCreateForm(false) setFormData({ title: '', ai_prompt: '', color: '#FF6B6B' }) } else { - alert('创建失败: ' + (response.msg || '未知错误')) + console.error('创建失败:', response.msg || '未知错误') } } catch (error) { console.error('Failed to create category:', error) - alert('创建失败: ' + (error instanceof Error ? error.message : '未知错误')) } } @@ -70,11 +69,10 @@ const ResourceCategoryPage: React.FC = () => { setEditingCategory(null) setFormData({ title: '', ai_prompt: '', color: '#FF6B6B' }) } else { - alert('更新失败: ' + (response.msg || '未知错误')) + console.error('更新失败:', response.msg || '未知错误') } } catch (error) { console.error('Failed to update category:', error) - alert('更新失败: ' + (error instanceof Error ? error.message : '未知错误')) } } @@ -86,11 +84,10 @@ const ResourceCategoryPage: React.FC = () => { if (response.status) { setCategories(categories.filter(cat => cat.id !== categoryId)) } else { - alert('删除失败: ' + (response.msg || '未知错误')) + console.error('删除失败:', response.msg || '未知错误') } } catch (error) { console.error('Failed to delete category:', error) - alert('删除失败: ' + (error instanceof Error ? error.message : '未知错误')) } }