拆分大文件
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
|
||||
// 管理后台协议统一收口在 shared-contracts,避免页面脚本和 Rust handler 各自手拼字段。
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AdminLoginRequest {
|
||||
@@ -8,6 +9,7 @@ pub struct AdminLoginRequest {
|
||||
pub password: String,
|
||||
}
|
||||
|
||||
// 登录成功后返回管理员访问令牌与基础会话信息。
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AdminLoginResponse {
|
||||
@@ -15,6 +17,7 @@ pub struct AdminLoginResponse {
|
||||
pub admin: AdminSessionPayload,
|
||||
}
|
||||
|
||||
// 管理员会话只暴露页面展示和鉴权调试所需的最小字段。
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AdminSessionPayload {
|
||||
@@ -26,12 +29,14 @@ pub struct AdminSessionPayload {
|
||||
pub expires_at: String,
|
||||
}
|
||||
|
||||
// 页面恢复登录态时读取当前管理员会话。
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AdminMeResponse {
|
||||
pub admin: AdminSessionPayload,
|
||||
}
|
||||
|
||||
// 后台概览统一返回服务信息与数据库信息两块,前端不再额外拼装。
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AdminOverviewResponse {
|
||||
@@ -39,6 +44,7 @@ pub struct AdminOverviewResponse {
|
||||
pub database: AdminDatabaseOverviewPayload,
|
||||
}
|
||||
|
||||
// 服务概览描述当前 api-server 与 SpacetimeDB 连接配置。
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AdminServiceOverviewPayload {
|
||||
@@ -50,6 +56,7 @@ pub struct AdminServiceOverviewPayload {
|
||||
pub spacetime_database: String,
|
||||
}
|
||||
|
||||
// 数据库概览返回真实数据库元信息、表清单与统计错误。
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AdminDatabaseOverviewPayload {
|
||||
@@ -61,6 +68,7 @@ pub struct AdminDatabaseOverviewPayload {
|
||||
pub fetch_errors: Vec<String>,
|
||||
}
|
||||
|
||||
// 单表统计允许成功和失败并存,避免某张表失败导致整页概览不可用。
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AdminDatabaseTableStatPayload {
|
||||
@@ -69,6 +77,7 @@ pub struct AdminDatabaseTableStatPayload {
|
||||
pub error_message: Option<String>,
|
||||
}
|
||||
|
||||
// 调试请求只允许同源路径、受控请求头和有限请求体。
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AdminDebugHttpRequest {
|
||||
@@ -78,6 +87,7 @@ pub struct AdminDebugHttpRequest {
|
||||
pub body: Option<String>,
|
||||
}
|
||||
|
||||
// 调试请求头使用显式结构,避免页面直接塞任意对象。
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AdminDebugHeaderInput {
|
||||
@@ -85,6 +95,7 @@ pub struct AdminDebugHeaderInput {
|
||||
pub value: String,
|
||||
}
|
||||
|
||||
// 调试响应回显状态、响应头与文本/JSON 预览,便于后台排查接口问题。
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct AdminDebugHttpResponse {
|
||||
|
||||
Reference in New Issue
Block a user