fix(production-readiness): audit fixes — duplicate useState + route mismatch + stale @reserved
Some checks failed
CI / Build Frontend (push) Has been cancelled
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled

- ChatArea.tsx: remove duplicate useState(searchOpen) declaration on line 70
- scheduled_task/mod.rs: fix route from /api/scheduler/tasks to /api/v1/scheduler/tasks
  (matches admin-v2 service baseURL pattern and all other modules)
- scheduled_task/handlers.rs: remove @reserved annotations (now has Admin V2 frontend)
- scheduled_task/handlers.rs: update doc comments with correct /api/v1/ paths
This commit is contained in:
iven
2026-04-03 21:41:30 +08:00
parent 4281ce35b4
commit 264dc75b2c
3 changed files with 13 additions and 13 deletions

View File

@@ -10,8 +10,8 @@ use crate::error::SaasResult;
use crate::auth::types::AuthContext; use crate::auth::types::AuthContext;
use super::{types::*, service}; use super::{types::*, service};
/// POST /api/scheduler/tasks — 创建定时任务 /// POST /api/v1/scheduler/tasks — 创建定时任务
// @reserved - no frontend caller
pub async fn create_task( pub async fn create_task(
State(state): State<AppState>, State(state): State<AppState>,
Extension(ctx): Extension<AuthContext>, Extension(ctx): Extension<AuthContext>,
@@ -39,8 +39,8 @@ pub async fn create_task(
Ok((StatusCode::CREATED, Json(resp))) Ok((StatusCode::CREATED, Json(resp)))
} }
/// GET /api/scheduler/tasks — 列出定时任务 /// GET /api/v1/scheduler/tasks — 列出定时任务
// @reserved - no frontend caller
pub async fn list_tasks( pub async fn list_tasks(
State(state): State<AppState>, State(state): State<AppState>,
Extension(ctx): Extension<AuthContext>, Extension(ctx): Extension<AuthContext>,
@@ -49,8 +49,8 @@ pub async fn list_tasks(
Ok(Json(tasks)) Ok(Json(tasks))
} }
/// GET /api/scheduler/tasks/:id — 获取单个定时任务 /// GET /api/v1/scheduler/tasks/:id — 获取单个定时任务
// @reserved - no frontend caller
pub async fn get_task( pub async fn get_task(
State(state): State<AppState>, State(state): State<AppState>,
Extension(ctx): Extension<AuthContext>, Extension(ctx): Extension<AuthContext>,
@@ -60,8 +60,8 @@ pub async fn get_task(
Ok(Json(task)) Ok(Json(task))
} }
/// PATCH /api/scheduler/tasks/:id — 更新定时任务 /// PATCH /api/v1/scheduler/tasks/:id — 更新定时任务
// @reserved - no frontend caller
pub async fn update_task( pub async fn update_task(
State(state): State<AppState>, State(state): State<AppState>,
Extension(ctx): Extension<AuthContext>, Extension(ctx): Extension<AuthContext>,
@@ -72,8 +72,8 @@ pub async fn update_task(
Ok(Json(task)) Ok(Json(task))
} }
/// DELETE /api/scheduler/tasks/:id — 删除定时任务 /// DELETE /api/v1/scheduler/tasks/:id — 删除定时任务
// @reserved - no frontend caller
pub async fn delete_task( pub async fn delete_task(
State(state): State<AppState>, State(state): State<AppState>,
Extension(ctx): Extension<AuthContext>, Extension(ctx): Extension<AuthContext>,

View File

@@ -10,6 +10,6 @@ use crate::state::AppState;
/// 定时任务路由 (需要认证) /// 定时任务路由 (需要认证)
pub fn routes() -> axum::Router<AppState> { pub fn routes() -> axum::Router<AppState> {
axum::Router::new() axum::Router::new()
.route("/api/scheduler/tasks", get(handlers::list_tasks).post(handlers::create_task)) .route("/api/v1/scheduler/tasks", get(handlers::list_tasks).post(handlers::create_task))
.route("/api/scheduler/tasks/:id", get(handlers::get_task).patch(handlers::update_task).delete(handlers::delete_task)) .route("/api/v1/scheduler/tasks/:id", get(handlers::get_task).patch(handlers::update_task).delete(handlers::delete_task))
} }

View File

@@ -67,7 +67,7 @@ export function ChatArea() {
const [input, setInput] = useState(''); const [input, setInput] = useState('');
const [pendingFiles, setPendingFiles] = useState<File[]>([]); const [pendingFiles, setPendingFiles] = useState<File[]>([]);
const [searchOpen, setSearchOpen] = useState(false); const [searchOpen, setSearchOpen] = useState(false); const [searchOpen, setSearchOpen] = useState(false);
const scrollRef = useRef<HTMLDivElement>(null); const scrollRef = useRef<HTMLDivElement>(null);
const textareaRef = useRef<HTMLTextAreaElement>(null); const textareaRef = useRef<HTMLTextAreaElement>(null);
const messageRefs = useRef<Map<string, HTMLDivElement>>(new Map()); const messageRefs = useRef<Map<string, HTMLDivElement>>(new Map());