feat: Refactor service management scripts to use a unified dev script
- Added package.json to manage development scripts. - Updated restart-services.ps1 to call the new dev script for starting services. - Refactored start-admin.ps1, start-backend.ps1, start-frontend.ps1, and start-mcp.ps1 to utilize the dev script for starting respective services. - Enhanced stop-services.ps1 to improve process termination logic by matching command patterns.
This commit is contained in:
@@ -167,6 +167,7 @@ struct ReviewRow {
|
||||
description: String,
|
||||
tags_input: String,
|
||||
cover: String,
|
||||
link_url: String,
|
||||
api_url: String,
|
||||
}
|
||||
|
||||
@@ -205,6 +206,7 @@ pub struct ReviewForm {
|
||||
description: String,
|
||||
tags: String,
|
||||
cover: String,
|
||||
link_url: String,
|
||||
}
|
||||
|
||||
fn url_encode(value: &str) -> String {
|
||||
@@ -704,6 +706,7 @@ pub async fn posts_create(
|
||||
tags: parse_tag_input(&form.tags),
|
||||
post_type: normalize_admin_text(&form.post_type),
|
||||
image: Some(normalize_admin_text(&form.image)),
|
||||
images: Vec::new(),
|
||||
pinned: form.pinned.is_some(),
|
||||
published: form.published.is_some(),
|
||||
},
|
||||
@@ -818,8 +821,14 @@ pub async fn comments_admin(
|
||||
let text_filter = normalized_filter_value(query.q.as_deref());
|
||||
|
||||
let total_count = items.len();
|
||||
let article_count = items.iter().filter(|comment| comment.scope != "paragraph").count();
|
||||
let paragraph_count = items.iter().filter(|comment| comment.scope == "paragraph").count();
|
||||
let article_count = items
|
||||
.iter()
|
||||
.filter(|comment| comment.scope != "paragraph")
|
||||
.count();
|
||||
let paragraph_count = items
|
||||
.iter()
|
||||
.filter(|comment| comment.scope == "paragraph")
|
||||
.count();
|
||||
let pending_count = items
|
||||
.iter()
|
||||
.filter(|comment| !comment.approved.unwrap_or(false))
|
||||
@@ -827,12 +836,7 @@ pub async fn comments_admin(
|
||||
|
||||
let author_by_id = items
|
||||
.iter()
|
||||
.map(|comment| {
|
||||
(
|
||||
comment.id,
|
||||
non_empty(comment.author.as_deref(), "匿名"),
|
||||
)
|
||||
})
|
||||
.map(|comment| (comment.id, non_empty(comment.author.as_deref(), "匿名")))
|
||||
.collect::<BTreeMap<_, _>>();
|
||||
|
||||
let post_options = items
|
||||
@@ -1263,6 +1267,7 @@ pub async fn reviews_admin(
|
||||
description: non_empty(review.description.as_deref(), ""),
|
||||
tags_input: review_tags_input(review.tags.as_deref()),
|
||||
cover: non_empty(review.cover.as_deref(), "🎮"),
|
||||
link_url: non_empty(review.link_url.as_deref(), ""),
|
||||
api_url: format!("/api/reviews/{}", review.id),
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
@@ -1290,6 +1295,7 @@ pub async fn reviews_admin(
|
||||
"description": "",
|
||||
"tags": "",
|
||||
"cover": "🎮",
|
||||
"link_url": "",
|
||||
}),
|
||||
);
|
||||
context.insert("rows".into(), json!(rows));
|
||||
@@ -1314,6 +1320,10 @@ pub async fn reviews_create(
|
||||
serde_json::to_string(&parse_review_tags(&form.tags)).unwrap_or_default(),
|
||||
)),
|
||||
cover: Set(Some(normalize_admin_text(&form.cover))),
|
||||
link_url: Set({
|
||||
let value = normalize_admin_text(&form.link_url);
|
||||
(!value.is_empty()).then_some(value)
|
||||
}),
|
||||
..Default::default()
|
||||
}
|
||||
.insert(&ctx.db)
|
||||
@@ -1345,6 +1355,10 @@ pub async fn reviews_update(
|
||||
serde_json::to_string(&parse_review_tags(&form.tags)).unwrap_or_default(),
|
||||
));
|
||||
model.cover = Set(Some(normalize_admin_text(&form.cover)));
|
||||
model.link_url = Set({
|
||||
let value = normalize_admin_text(&form.link_url);
|
||||
(!value.is_empty()).then_some(value)
|
||||
});
|
||||
let _ = model.update(&ctx.db).await?;
|
||||
|
||||
Ok(format::redirect("/admin/reviews"))
|
||||
|
||||
Reference in New Issue
Block a user