chore: completely remove ostp-control bundling from server and build script

This commit is contained in:
ospab 2026-06-17 03:37:41 +03:00
parent f08240cf58
commit 0231ef8a6e
2 changed files with 2 additions and 52 deletions

View File

@ -172,42 +172,8 @@ fn api_unauthorized<T: Serialize>() -> (StatusCode, Json<ApiResponse<T>>) {
(StatusCode::UNAUTHORIZED, Json(ApiResponse { ok: false, data: None, error: Some("unauthorized".to_string()) }))
}
#[derive(RustEmbed)]
#[folder = "../ostp-control/dist/"]
struct Assets;
async fn static_handler(State(state): State<ApiState>, uri: Uri) -> impl IntoResponse {
let mut path = uri.path();
let webpath = state.webpath.trim_matches('/');
let prefix = if webpath.is_empty() {
"/panel".to_string()
} else {
format!("/{}", webpath)
};
if path.starts_with(&prefix) {
path = &path[prefix.len()..];
}
path = path.trim_start_matches('/');
if path.is_empty() || path == "index.html" {
path = "index.html";
}
match Assets::get(path) {
Some(content) => {
let mime = mime_guess::from_path(path).first_or_octet_stream();
([(header::CONTENT_TYPE, mime.as_ref())], content.data).into_response()
}
None => {
if let Some(index) = Assets::get("index.html") {
([(header::CONTENT_TYPE, "text/html")], index.data).into_response()
} else {
(StatusCode::NOT_FOUND, "404 Not Found").into_response()
}
}
}
async fn static_handler(State(_state): State<ApiState>, _uri: Uri) -> impl IntoResponse {
(StatusCode::NOT_FOUND, "Control panel not bundled").into_response()
}
// ── API router ───────────────────────────────────────────────────────────────

View File

@ -58,15 +58,6 @@ if (Test-Path $CargoToml) {
Write-Output " [ok] Updated tauri.conf.json"
}
# Bump React Control Panel
$PackageJson = Join-Path $ProjectRoot "ostp-control\package.json"
if (Test-Path $PackageJson) {
$PkgContent = [System.IO.File]::ReadAllText($PackageJson)
$PkgRegex = [regex] '"version":\s*"[^"]+"'
$PkgContent = $PkgRegex.Replace($PkgContent, ('"version": "' + $Version + '"'), 1)
[System.IO.File]::WriteAllText($PackageJson, $PkgContent)
Write-Output " [ok] Updated package.json"
}
# Bump Flutter App
$Pubspec = Join-Path $ProjectRoot "ostp-flutter\pubspec.yaml"
@ -83,13 +74,6 @@ if (Test-Path $CargoToml) {
}
}
# --- Pre-flight: frontend build ---
Write-Output ""
Write-Output "Building frontend control panel..."
Push-Location (Join-Path $ProjectRoot "ostp-control")
& npm install | Out-Null
& npm run build | Out-Null
Pop-Location
# --- Pre-flight: cargo check ---
Write-Output ""