mirror of
https://github.com/amtoaer/bili-sync.git
synced 2026-09-05 23:49:53 +08:00
chore: 大幅缩减构建结果的二进制文件体积 (#356)
This commit is contained in:
Generated
+111
-26
@@ -43,6 +43,21 @@ version = "0.1.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd"
|
checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "alloc-no-stdlib"
|
||||||
|
version = "2.0.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "alloc-stdlib"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece"
|
||||||
|
dependencies = [
|
||||||
|
"alloc-no-stdlib",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "allocator-api2"
|
name = "allocator-api2"
|
||||||
version = "0.2.16"
|
version = "0.2.16"
|
||||||
@@ -438,6 +453,12 @@ version = "1.6.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"
|
checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "base85rs"
|
||||||
|
version = "0.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "87678d33a2af71f019ed11f52db246ca6c5557edee2cccbe689676d1ad9c6b5a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bigdecimal"
|
name = "bigdecimal"
|
||||||
version = "0.4.7"
|
version = "0.4.7"
|
||||||
@@ -478,7 +499,6 @@ dependencies = [
|
|||||||
"leaky-bucket",
|
"leaky-bucket",
|
||||||
"md5",
|
"md5",
|
||||||
"memchr",
|
"memchr",
|
||||||
"mime_guess",
|
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"prost",
|
"prost",
|
||||||
"quick-xml",
|
"quick-xml",
|
||||||
@@ -486,7 +506,7 @@ dependencies = [
|
|||||||
"regex",
|
"regex",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"rsa",
|
"rsa",
|
||||||
"rust-embed",
|
"rust-embed-for-web",
|
||||||
"sea-orm",
|
"sea-orm",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@@ -596,6 +616,37 @@ dependencies = [
|
|||||||
"syn_derive",
|
"syn_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "brotli"
|
||||||
|
version = "6.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "74f7971dbd9326d58187408ab83117d8ac1bb9c17b085fdacd1cf2f598719b6b"
|
||||||
|
dependencies = [
|
||||||
|
"alloc-no-stdlib",
|
||||||
|
"alloc-stdlib",
|
||||||
|
"brotli-decompressor",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "brotli-decompressor"
|
||||||
|
version = "4.0.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a334ef7c9e23abf0ce748e8cd309037da93e606ad52eb372e4ce327a0dcfbdfd"
|
||||||
|
dependencies = [
|
||||||
|
"alloc-no-stdlib",
|
||||||
|
"alloc-stdlib",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bstr"
|
||||||
|
version = "1.12.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "234113d19d0d7d613b40e86fb654acf958910802bcceab913a4f9e7cda03b1a4"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "built"
|
name = "built"
|
||||||
version = "0.7.7"
|
version = "0.7.7"
|
||||||
@@ -1321,6 +1372,19 @@ version = "0.3.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "globset"
|
||||||
|
version = "0.4.16"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "54a1028dfc5f5df5da8a56a73e6c153c9a9708ec57232470703592a3f18e49f5"
|
||||||
|
dependencies = [
|
||||||
|
"aho-corasick",
|
||||||
|
"bstr",
|
||||||
|
"log",
|
||||||
|
"regex-automata 0.4.9",
|
||||||
|
"regex-syntax 0.8.5",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gloo-timers"
|
name = "gloo-timers"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
@@ -1967,6 +2031,16 @@ dependencies = [
|
|||||||
"windows-sys 0.52.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "new_mime_guess"
|
||||||
|
version = "4.0.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "02a2dfb3559d53e90b709376af1c379462f7fb3085a0177deb73e6ea0d99eff4"
|
||||||
|
dependencies = [
|
||||||
|
"mime",
|
||||||
|
"unicase",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu-ansi-term"
|
name = "nu-ansi-term"
|
||||||
version = "0.46.0"
|
version = "0.46.0"
|
||||||
@@ -2727,35 +2801,41 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rust-embed"
|
name = "rust-embed-for-web"
|
||||||
version = "8.7.2"
|
version = "11.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/amtoaer/rust-embed-for-web?tag=v1.0.0#b6eeb475cbe1ad5cae02d5373a1bba12ea58a869"
|
||||||
checksum = "025908b8682a26ba8d12f6f2d66b987584a4a87bc024abc5bbc12553a8cd178a"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rust-embed-impl",
|
"rust-embed-for-web-impl",
|
||||||
"rust-embed-utils",
|
"rust-embed-for-web-utils",
|
||||||
"walkdir",
|
"walkdir",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rust-embed-impl"
|
name = "rust-embed-for-web-impl"
|
||||||
version = "8.7.2"
|
version = "11.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/amtoaer/rust-embed-for-web?tag=v1.0.0#b6eeb475cbe1ad5cae02d5373a1bba12ea58a869"
|
||||||
checksum = "6065f1a4392b71819ec1ea1df1120673418bf386f50de1d6f54204d836d4349c"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"brotli",
|
||||||
|
"flate2",
|
||||||
|
"globset",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"rust-embed-utils",
|
"rust-embed-for-web-utils",
|
||||||
|
"shellexpand",
|
||||||
"syn 2.0.96",
|
"syn 2.0.96",
|
||||||
"walkdir",
|
"walkdir",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rust-embed-utils"
|
name = "rust-embed-for-web-utils"
|
||||||
version = "8.7.2"
|
version = "11.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/amtoaer/rust-embed-for-web?tag=v1.0.0#b6eeb475cbe1ad5cae02d5373a1bba12ea58a869"
|
||||||
checksum = "f6cc0c81648b20b70c491ff8cce00c1c3b223bb8ed2b5d41f0e54c6c4c0a3594"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"base85rs",
|
||||||
|
"chrono",
|
||||||
|
"enum_dispatch",
|
||||||
|
"globset",
|
||||||
|
"new_mime_guess",
|
||||||
"sha2",
|
"sha2",
|
||||||
"walkdir",
|
"walkdir",
|
||||||
]
|
]
|
||||||
@@ -3128,6 +3208,15 @@ dependencies = [
|
|||||||
"lazy_static",
|
"lazy_static",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "shellexpand"
|
||||||
|
version = "3.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8b1fdf65dd6331831494dd616b30351c38e96e45921a27745cf98490458b90bb"
|
||||||
|
dependencies = [
|
||||||
|
"dirs",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "shlex"
|
name = "shlex"
|
||||||
version = "1.3.0"
|
version = "1.3.0"
|
||||||
@@ -3949,8 +4038,7 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "utoipa"
|
name = "utoipa"
|
||||||
version = "5.3.1"
|
version = "5.3.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/amtoaer/utoipa.git?tag=v1.0.1#6d66603333218fe4d0f36e40fc662628c6682a79"
|
||||||
checksum = "435c6f69ef38c9017b4b4eea965dfb91e71e53d869e896db40d1cf2441dd75c0"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -3961,8 +4049,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "utoipa-gen"
|
name = "utoipa-gen"
|
||||||
version = "5.3.1"
|
version = "5.3.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/amtoaer/utoipa.git?tag=v1.0.1#6d66603333218fe4d0f36e40fc662628c6682a79"
|
||||||
checksum = "a77d306bc75294fd52f3e99b13ece67c02c1a2789190a6f31d32f736624326f7"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -3973,14 +4060,13 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "utoipa-swagger-ui"
|
name = "utoipa-swagger-ui"
|
||||||
version = "9.0.0"
|
version = "9.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/amtoaer/utoipa.git?tag=v1.0.1#6d66603333218fe4d0f36e40fc662628c6682a79"
|
||||||
checksum = "161166ec520c50144922a625d8bc4925cc801b2dda958ab69878527c0e5c5d61"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"axum",
|
"axum",
|
||||||
"base64",
|
"base64",
|
||||||
"mime_guess",
|
"mime_guess",
|
||||||
"regex",
|
"regex",
|
||||||
"rust-embed",
|
"rust-embed-for-web",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"url",
|
"url",
|
||||||
@@ -3992,8 +4078,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "utoipa-swagger-ui-vendored"
|
name = "utoipa-swagger-ui-vendored"
|
||||||
version = "0.1.2"
|
version = "0.1.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/amtoaer/utoipa.git?tag=v1.0.1#6d66603333218fe4d0f36e40fc662628c6682a79"
|
||||||
checksum = "e2eebbbfe4093922c2b6734d7c679ebfebd704a0d7e56dfcb0d05818ce28977d"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uuid"
|
name = "uuid"
|
||||||
|
|||||||
+8
-4
@@ -37,7 +37,6 @@ hex = "0.4.3"
|
|||||||
leaky-bucket = "1.1.2"
|
leaky-bucket = "1.1.2"
|
||||||
md5 = "0.7.0"
|
md5 = "0.7.0"
|
||||||
memchr = "2.7.4"
|
memchr = "2.7.4"
|
||||||
mime_guess = "2.0.5"
|
|
||||||
once_cell = "1.21.3"
|
once_cell = "1.21.3"
|
||||||
prost = "0.13.5"
|
prost = "0.13.5"
|
||||||
quick-xml = { version = "0.37.5", features = ["async-tokio"] }
|
quick-xml = { version = "0.37.5", features = ["async-tokio"] }
|
||||||
@@ -53,7 +52,7 @@ reqwest = { version = "0.12.15", features = [
|
|||||||
"stream",
|
"stream",
|
||||||
], default-features = false }
|
], default-features = false }
|
||||||
rsa = { version = "0.9.8", features = ["sha2"] }
|
rsa = { version = "0.9.8", features = ["sha2"] }
|
||||||
rust-embed = "8.7.2"
|
rust-embed-for-web = { git = "https://github.com/amtoaer/rust-embed-for-web", tag = "v1.0.0" }
|
||||||
sea-orm = { version = "1.1.11", features = [
|
sea-orm = { version = "1.1.11", features = [
|
||||||
"macros",
|
"macros",
|
||||||
"runtime-tokio-rustls",
|
"runtime-tokio-rustls",
|
||||||
@@ -71,8 +70,13 @@ toml = "0.8.22"
|
|||||||
tower = "0.5.2"
|
tower = "0.5.2"
|
||||||
tracing = "0.1.41"
|
tracing = "0.1.41"
|
||||||
tracing-subscriber = { version = "0.3.19", features = ["chrono"] }
|
tracing-subscriber = { version = "0.3.19", features = ["chrono"] }
|
||||||
utoipa = { version = "5.3.1", features = ["axum_extras"] }
|
utoipa = { git = "https://github.com/amtoaer/utoipa.git", tag = "v1.0.1", features = [
|
||||||
utoipa-swagger-ui = { version = "9.0.0", features = ["axum", "vendored"] }
|
"axum_extras",
|
||||||
|
] }
|
||||||
|
utoipa-swagger-ui = { git = "https://github.com/amtoaer/utoipa.git", tag = "v1.0.1", features = [
|
||||||
|
"axum",
|
||||||
|
"vendored",
|
||||||
|
] }
|
||||||
validator = { version = "0.20.0", features = ["derive"] }
|
validator = { version = "0.20.0", features = ["derive"] }
|
||||||
|
|
||||||
[workspace.metadata.release]
|
[workspace.metadata.release]
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ hex = { workspace = true }
|
|||||||
leaky-bucket = { workspace = true }
|
leaky-bucket = { workspace = true }
|
||||||
md5 = { workspace = true }
|
md5 = { workspace = true }
|
||||||
memchr = { workspace = true }
|
memchr = { workspace = true }
|
||||||
mime_guess = { workspace = true }
|
|
||||||
once_cell = { workspace = true }
|
once_cell = { workspace = true }
|
||||||
prost = { workspace = true }
|
prost = { workspace = true }
|
||||||
quick-xml = { workspace = true }
|
quick-xml = { workspace = true }
|
||||||
@@ -37,7 +36,7 @@ rand = { workspace = true }
|
|||||||
regex = { workspace = true }
|
regex = { workspace = true }
|
||||||
reqwest = { workspace = true }
|
reqwest = { workspace = true }
|
||||||
rsa = { workspace = true }
|
rsa = { workspace = true }
|
||||||
rust-embed = { workspace = true }
|
rust-embed-for-web = { workspace = true }
|
||||||
sea-orm = { workspace = true }
|
sea-orm = { workspace = true }
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
serde_json = { workspace = true }
|
serde_json = { workspace = true }
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ use utoipa::OpenApi;
|
|||||||
use crate::api::auth::OpenAPIAuth;
|
use crate::api::auth::OpenAPIAuth;
|
||||||
use crate::api::error::InnerApiError;
|
use crate::api::error::InnerApiError;
|
||||||
use crate::api::helper::{update_page_download_status, update_video_download_status};
|
use crate::api::helper::{update_page_download_status, update_video_download_status};
|
||||||
use crate::api::request::{ResetVideoStatusRequest, VideosRequest};
|
use crate::api::request::{UpdateVideoStatusRequest, VideosRequest};
|
||||||
use crate::api::response::{
|
use crate::api::response::{
|
||||||
PageInfo, ResetAllVideosResponse, ResetVideoResponse, ResetVideoStatusResponse, VideoInfo, VideoResponse,
|
PageInfo, ResetAllVideosResponse, ResetVideoResponse, UpdateVideoStatusResponse, VideoInfo, VideoResponse,
|
||||||
VideoSource, VideoSourcesResponse, VideosResponse,
|
VideoSource, VideoSourcesResponse, VideosResponse,
|
||||||
};
|
};
|
||||||
use crate::api::wrapper::{ApiError, ApiResponse, ValidatedJson};
|
use crate::api::wrapper::{ApiError, ApiResponse, ValidatedJson};
|
||||||
@@ -24,7 +24,7 @@ use crate::utils::status::{PageStatus, VideoStatus};
|
|||||||
|
|
||||||
#[derive(OpenApi)]
|
#[derive(OpenApi)]
|
||||||
#[openapi(
|
#[openapi(
|
||||||
paths(get_video_sources, get_videos, get_video, reset_video, reset_all_videos, reset_video_status),
|
paths(get_video_sources, get_videos, get_video, reset_video, reset_all_videos, update_video_status),
|
||||||
modifiers(&OpenAPIAuth),
|
modifiers(&OpenAPIAuth),
|
||||||
security(
|
security(
|
||||||
("Token" = []),
|
("Token" = []),
|
||||||
@@ -284,20 +284,20 @@ pub async fn reset_all_videos(
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 重置指定视频及其分页的指定状态位
|
/// 更新特定视频及其所含分页的状态位
|
||||||
#[utoipa::path(
|
#[utoipa::path(
|
||||||
post,
|
post,
|
||||||
path = "/api/videos/{id}/reset-status",
|
path = "/api/videos/{id}/update-status",
|
||||||
request_body = ResetVideoStatusRequest,
|
request_body = UpdateVideoStatusRequest,
|
||||||
responses(
|
responses(
|
||||||
(status = 200, body = ApiResponse<ResetVideoStatusResponse>),
|
(status = 200, body = ApiResponse<UpdateVideoStatusResponse>),
|
||||||
)
|
)
|
||||||
)]
|
)]
|
||||||
pub async fn reset_video_status(
|
pub async fn update_video_status(
|
||||||
Path(id): Path<i32>,
|
Path(id): Path<i32>,
|
||||||
Extension(db): Extension<Arc<DatabaseConnection>>,
|
Extension(db): Extension<Arc<DatabaseConnection>>,
|
||||||
ValidatedJson(request): ValidatedJson<ResetVideoStatusRequest>,
|
ValidatedJson(request): ValidatedJson<UpdateVideoStatusRequest>,
|
||||||
) -> Result<ApiResponse<ResetVideoStatusResponse>, ApiError> {
|
) -> Result<ApiResponse<UpdateVideoStatusResponse>, ApiError> {
|
||||||
let (video_info, mut pages_info) = tokio::try_join!(
|
let (video_info, mut pages_info) = tokio::try_join!(
|
||||||
video::Entity::find_by_id(id)
|
video::Entity::find_by_id(id)
|
||||||
.into_partial_model::<VideoInfo>()
|
.into_partial_model::<VideoInfo>()
|
||||||
@@ -343,7 +343,7 @@ pub async fn reset_video_status(
|
|||||||
}
|
}
|
||||||
txn.commit().await?;
|
txn.commit().await?;
|
||||||
}
|
}
|
||||||
Ok(ApiResponse::ok(ResetVideoStatusResponse {
|
Ok(ApiResponse::ok(UpdateVideoStatusResponse {
|
||||||
success: has_video_updates || has_page_updates,
|
success: has_video_updates || has_page_updates,
|
||||||
video: video_info,
|
video: video_info,
|
||||||
pages: pages_info,
|
pages: pages_info,
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ pub struct PageStatusUpdate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, ToSchema, Validate)]
|
#[derive(Deserialize, ToSchema, Validate)]
|
||||||
pub struct ResetVideoStatusRequest {
|
pub struct UpdateVideoStatusRequest {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
#[validate(nested)]
|
#[validate(nested)]
|
||||||
pub video_updates: Vec<StatusUpdate>,
|
pub video_updates: Vec<StatusUpdate>,
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ pub struct ResetAllVideosResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, ToSchema)]
|
#[derive(Serialize, ToSchema)]
|
||||||
pub struct ResetVideoStatusResponse {
|
pub struct UpdateVideoStatusResponse {
|
||||||
pub success: bool,
|
pub success: bool,
|
||||||
pub video: VideoInfo,
|
pub video: VideoInfo,
|
||||||
pub pages: Vec<PageInfo>,
|
pub pages: Vec<PageInfo>,
|
||||||
@@ -58,6 +58,7 @@ pub struct VideoInfo {
|
|||||||
pub id: i32,
|
pub id: i32,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub upper_name: String,
|
pub upper_name: String,
|
||||||
|
#[schema(value_type = [u32; 5])]
|
||||||
#[serde(serialize_with = "serde_video_download_status")]
|
#[serde(serialize_with = "serde_video_download_status")]
|
||||||
pub download_status: u32,
|
pub download_status: u32,
|
||||||
}
|
}
|
||||||
@@ -69,6 +70,7 @@ pub struct PageInfo {
|
|||||||
pub video_id: i32,
|
pub video_id: i32,
|
||||||
pub pid: i32,
|
pub pid: i32,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
#[schema(value_type = [u32; 5])]
|
||||||
#[serde(serialize_with = "serde_page_download_status")]
|
#[serde(serialize_with = "serde_page_download_status")]
|
||||||
pub download_status: u32,
|
pub download_status: u32,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,27 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
|
use axum::body::Body;
|
||||||
use axum::extract::Request;
|
use axum::extract::Request;
|
||||||
use axum::http::{Uri, header};
|
use axum::http::{Response, Uri, header};
|
||||||
use axum::response::IntoResponse;
|
use axum::response::IntoResponse;
|
||||||
use axum::routing::{get, post};
|
use axum::routing::{get, post};
|
||||||
use axum::{Extension, Router, ServiceExt, middleware};
|
use axum::{Extension, Router, ServiceExt, middleware};
|
||||||
use reqwest::StatusCode;
|
use reqwest::StatusCode;
|
||||||
use rust_embed::Embed;
|
use rust_embed_for_web::{EmbedableFile, RustEmbed};
|
||||||
use sea_orm::DatabaseConnection;
|
use sea_orm::DatabaseConnection;
|
||||||
use utoipa::OpenApi;
|
use utoipa::OpenApi;
|
||||||
use utoipa_swagger_ui::{Config, SwaggerUi};
|
use utoipa_swagger_ui::{Config, SwaggerUi};
|
||||||
|
|
||||||
use crate::api::auth;
|
use crate::api::auth;
|
||||||
use crate::api::handler::{
|
use crate::api::handler::{
|
||||||
ApiDoc, get_video, get_video_sources, get_videos, reset_all_videos, reset_video, reset_video_status,
|
ApiDoc, get_video, get_video_sources, get_videos, reset_all_videos, reset_video, update_video_status,
|
||||||
};
|
};
|
||||||
use crate::config::CONFIG;
|
use crate::config::CONFIG;
|
||||||
|
|
||||||
#[derive(Embed)]
|
#[derive(RustEmbed)]
|
||||||
|
#[preserve_source = false]
|
||||||
|
#[gzip = false]
|
||||||
#[folder = "../../web/build"]
|
#[folder = "../../web/build"]
|
||||||
struct Asset;
|
struct Asset;
|
||||||
|
|
||||||
@@ -28,7 +31,7 @@ pub async fn http_server(database_connection: Arc<DatabaseConnection>) -> Result
|
|||||||
.route("/api/videos", get(get_videos))
|
.route("/api/videos", get(get_videos))
|
||||||
.route("/api/videos/{id}", get(get_video))
|
.route("/api/videos/{id}", get(get_video))
|
||||||
.route("/api/videos/{id}/reset", post(reset_video))
|
.route("/api/videos/{id}/reset", post(reset_video))
|
||||||
.route("/api/videos/{id}/reset-status", post(reset_video_status))
|
.route("/api/videos/{id}/update-status", post(update_video_status))
|
||||||
.route("/api/videos/reset-all", post(reset_all_videos))
|
.route("/api/videos/reset-all", post(reset_all_videos))
|
||||||
.merge(
|
.merge(
|
||||||
SwaggerUi::new("/swagger-ui/")
|
SwaggerUi::new("/swagger-ui/")
|
||||||
@@ -55,11 +58,19 @@ async fn frontend_files(uri: Uri) -> impl IntoResponse {
|
|||||||
if path.is_empty() || Asset::get(path).is_none() {
|
if path.is_empty() || Asset::get(path).is_none() {
|
||||||
path = "index.html";
|
path = "index.html";
|
||||||
}
|
}
|
||||||
match Asset::get(path) {
|
let Some(content) = Asset::get(path) else {
|
||||||
Some(content) => {
|
return (StatusCode::NOT_FOUND, "404 Not Found").into_response();
|
||||||
let mime = mime_guess::from_path(path).first_or_octet_stream();
|
};
|
||||||
([(header::CONTENT_TYPE, mime.as_ref())], content.data).into_response()
|
Response::builder()
|
||||||
}
|
.status(StatusCode::OK)
|
||||||
None => (StatusCode::NOT_FOUND, "404 Not Found").into_response(),
|
.header(
|
||||||
}
|
header::CONTENT_TYPE,
|
||||||
|
content.mime_type().as_deref().unwrap_or("application/octet-stream"),
|
||||||
|
)
|
||||||
|
.header(header::CONTENT_ENCODING, "br")
|
||||||
|
// safety: `RustEmbed` will always generate br-compressed files if the feature is enabled
|
||||||
|
.body(Body::from(content.data_br().unwrap()))
|
||||||
|
.unwrap_or_else(|_| {
|
||||||
|
return (StatusCode::INTERNAL_SERVER_ERROR, "500 Internal Server Error").into_response();
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-8
@@ -6,8 +6,8 @@ import type {
|
|||||||
VideoResponse,
|
VideoResponse,
|
||||||
ResetVideoResponse,
|
ResetVideoResponse,
|
||||||
ResetAllVideosResponse,
|
ResetAllVideosResponse,
|
||||||
ResetVideoStatusRequest,
|
UpdateVideoStatusRequest,
|
||||||
ResetVideoStatusResponse,
|
UpdateVideoStatusResponse,
|
||||||
ApiError
|
ApiError
|
||||||
} from './types';
|
} from './types';
|
||||||
|
|
||||||
@@ -162,11 +162,11 @@ class ApiClient {
|
|||||||
* @param id 视频 ID
|
* @param id 视频 ID
|
||||||
* @param request 重置请求参数
|
* @param request 重置请求参数
|
||||||
*/
|
*/
|
||||||
async resetVideoStatus(
|
async updateVideoStatus(
|
||||||
id: number,
|
id: number,
|
||||||
request: ResetVideoStatusRequest
|
request: UpdateVideoStatusRequest
|
||||||
): Promise<ApiResponse<ResetVideoStatusResponse>> {
|
): Promise<ApiResponse<UpdateVideoStatusResponse>> {
|
||||||
return this.post<ResetVideoStatusResponse>(`/videos/${id}/reset-status`, request);
|
return this.post<UpdateVideoStatusResponse>(`/videos/${id}/update-status`, request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,8 +203,8 @@ export const api = {
|
|||||||
/**
|
/**
|
||||||
* 重置视频状态位
|
* 重置视频状态位
|
||||||
*/
|
*/
|
||||||
resetVideoStatus: (id: number, request: ResetVideoStatusRequest) =>
|
updateVideoStatus: (id: number, request: UpdateVideoStatusRequest) =>
|
||||||
apiClient.resetVideoStatus(id, request),
|
apiClient.updateVideoStatus(id, request),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置认证 token
|
* 设置认证 token
|
||||||
|
|||||||
@@ -9,14 +9,14 @@
|
|||||||
SheetTitle
|
SheetTitle
|
||||||
} from '$lib/components/ui/sheet/index.js';
|
} from '$lib/components/ui/sheet/index.js';
|
||||||
import StatusTaskCard from './status-task-card.svelte';
|
import StatusTaskCard from './status-task-card.svelte';
|
||||||
import type { VideoInfo, PageInfo, StatusUpdate, ResetVideoStatusRequest } from '$lib/types';
|
import type { VideoInfo, PageInfo, StatusUpdate, UpdateVideoStatusRequest } from '$lib/types';
|
||||||
import { toast } from 'svelte-sonner';
|
import { toast } from 'svelte-sonner';
|
||||||
|
|
||||||
export let open = false;
|
export let open = false;
|
||||||
export let video: VideoInfo;
|
export let video: VideoInfo;
|
||||||
export let pages: PageInfo[] = [];
|
export let pages: PageInfo[] = [];
|
||||||
export let loading = false;
|
export let loading = false;
|
||||||
export let onsubmit: (request: ResetVideoStatusRequest) => void;
|
export let onsubmit: (request: UpdateVideoStatusRequest) => void;
|
||||||
|
|
||||||
// 视频任务名称(与后端 VideoStatus 对应)
|
// 视频任务名称(与后端 VideoStatus 对应)
|
||||||
const videoTaskNames = ['视频封面', '视频信息', 'UP主头像', 'UP主信息', '分P下载'];
|
const videoTaskNames = ['视频封面', '视频信息', 'UP主头像', 'UP主信息', '分P下载'];
|
||||||
@@ -109,8 +109,8 @@
|
|||||||
return hasVideoChanges() || hasPageChanges();
|
return hasVideoChanges() || hasPageChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildRequest(): ResetVideoStatusRequest {
|
function buildRequest(): UpdateVideoStatusRequest {
|
||||||
const request: ResetVideoStatusRequest = {};
|
const request: UpdateVideoStatusRequest = {};
|
||||||
|
|
||||||
// 构建视频状态更新
|
// 构建视频状态更新
|
||||||
if (hasVideoChanges()) {
|
if (hasVideoChanges()) {
|
||||||
|
|||||||
@@ -91,13 +91,13 @@ export interface PageStatusUpdate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 重置视频状态请求类型
|
// 重置视频状态请求类型
|
||||||
export interface ResetVideoStatusRequest {
|
export interface UpdateVideoStatusRequest {
|
||||||
video_updates?: StatusUpdate[];
|
video_updates?: StatusUpdate[];
|
||||||
page_updates?: PageStatusUpdate[];
|
page_updates?: PageStatusUpdate[];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重置视频状态响应类型
|
// 重置视频状态响应类型
|
||||||
export interface ResetVideoStatusResponse {
|
export interface UpdateVideoStatusResponse {
|
||||||
success: boolean;
|
success: boolean;
|
||||||
video: VideoInfo;
|
video: VideoInfo;
|
||||||
pages: PageInfo[];
|
pages: PageInfo[];
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { Button } from '$lib/components/ui/button/index.js';
|
import { Button } from '$lib/components/ui/button/index.js';
|
||||||
import api from '$lib/api';
|
import api from '$lib/api';
|
||||||
import type { ApiError, VideoResponse, ResetVideoStatusRequest } from '$lib/types';
|
import type { ApiError, VideoResponse, UpdateVideoStatusRequest } from '$lib/types';
|
||||||
import RotateCcwIcon from '@lucide/svelte/icons/rotate-ccw';
|
import RotateCcwIcon from '@lucide/svelte/icons/rotate-ccw';
|
||||||
import EditIcon from '@lucide/svelte/icons/edit';
|
import EditIcon from '@lucide/svelte/icons/edit';
|
||||||
import { setBreadcrumb } from '$lib/stores/breadcrumb';
|
import { setBreadcrumb } from '$lib/stores/breadcrumb';
|
||||||
@@ -60,12 +60,12 @@
|
|||||||
loadVideoDetail();
|
loadVideoDetail();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleStatusEditorSubmit(request: ResetVideoStatusRequest) {
|
async function handleStatusEditorSubmit(request: UpdateVideoStatusRequest) {
|
||||||
if (!videoData) return;
|
if (!videoData) return;
|
||||||
|
|
||||||
statusEditorLoading = true;
|
statusEditorLoading = true;
|
||||||
try {
|
try {
|
||||||
const result = await api.resetVideoStatus(videoData.video.id, request);
|
const result = await api.updateVideoStatus(videoData.video.id, request);
|
||||||
const data = result.data;
|
const data = result.data;
|
||||||
|
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
|
|||||||
Reference in New Issue
Block a user