mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-02-03 11:31:53 +08:00
feat(video): 事务化切换与前端统一编排,增强视频输入格式支持
- 后端:切换事务+transition_id,/stream/mode 返回 switching/transition_id 与实际 codec - 事件:新增 mode_switching/mode_ready,config/webrtc_ready/mode_changed 关联事务 - 编码/格式:扩展 NV21/NV16/NV24/RGB/BGR 输入与转换链路,RKMPP direct input 优化 - 前端:useVideoSession 统一切换,失败回退真实切回 MJPEG,菜单格式同步修复 - 清理:useVideoStream 降级为 MJPEG-only
This commit is contained in:
@@ -46,7 +46,10 @@ pub async fn auth_middleware(
|
||||
if !state.config.is_initialized() {
|
||||
// Allow access to setup endpoints when not initialized
|
||||
let path = request.uri().path();
|
||||
if path.starts_with("/api/setup") || path == "/api/info" || path.starts_with("/") && !path.starts_with("/api/") {
|
||||
if path.starts_with("/api/setup")
|
||||
|| path == "/api/info"
|
||||
|| path.starts_with("/") && !path.starts_with("/api/")
|
||||
{
|
||||
return Ok(next.run(request).await);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
pub mod middleware;
|
||||
mod password;
|
||||
mod session;
|
||||
mod user;
|
||||
pub mod middleware;
|
||||
|
||||
pub use middleware::{auth_middleware, require_admin, AuthLayer, SESSION_COOKIE};
|
||||
pub use password::{hash_password, verify_password};
|
||||
pub use session::{Session, SessionStore};
|
||||
pub use user::{User, UserStore};
|
||||
pub use middleware::{AuthLayer, SESSION_COOKIE, auth_middleware, require_admin};
|
||||
|
||||
@@ -3,8 +3,8 @@ use serde::{Deserialize, Serialize};
|
||||
use sqlx::{Pool, Sqlite};
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::error::{AppError, Result};
|
||||
use super::password::{hash_password, verify_password};
|
||||
use crate::error::{AppError, Result};
|
||||
|
||||
/// User row type from database
|
||||
type UserRow = (String, String, String, i32, String, String);
|
||||
@@ -134,14 +134,13 @@ impl UserStore {
|
||||
let password_hash = hash_password(new_password)?;
|
||||
let now = Utc::now();
|
||||
|
||||
let result = sqlx::query(
|
||||
"UPDATE users SET password_hash = ?1, updated_at = ?2 WHERE id = ?3",
|
||||
)
|
||||
.bind(&password_hash)
|
||||
.bind(now.to_rfc3339())
|
||||
.bind(user_id)
|
||||
.execute(&self.pool)
|
||||
.await?;
|
||||
let result =
|
||||
sqlx::query("UPDATE users SET password_hash = ?1, updated_at = ?2 WHERE id = ?3")
|
||||
.bind(&password_hash)
|
||||
.bind(now.to_rfc3339())
|
||||
.bind(user_id)
|
||||
.execute(&self.pool)
|
||||
.await?;
|
||||
|
||||
if result.rows_affected() == 0 {
|
||||
return Err(AppError::NotFound("User not found".to_string()));
|
||||
|
||||
Reference in New Issue
Block a user