feat(app): present a readable terminal startup panel

This commit is contained in:
AAA committed 2026-11-07 17:26:36 -04:00
1 parent 5bc3186aa6
commit 7a1fc9b45c
1 file changed
+31 -2
+31 -2
View File
@@ -69,6 +69,33 @@ const PACKAGE_TARGET: &str = match option_env!("PIIK_BUILD_TARGET") {
None => "",
};
fn startup_panel(version: &str, revision: &str, port: u16) -> String {
let revision = if revision.len() == 40 && revision.bytes().all(|byte| byte.is_ascii_hexdigit())
{
&revision[..7]
} else {
revision
};
// The shared terminal TV's static wink needs neither ANSI nor a redraw loop.
format!(
r#"
\ /
.----v----. Piik App
| o - | {version}
'---------' Build {revision}
/ \
App launcher / App 启动页
http://127.0.0.1:{port}/client
Share and chat in your browser.
在浏览器中分享和聊天。
Ctrl+C to quit / 按 Ctrl+C 正常退出
"#
)
}
pub struct Config {
pub data_root: PathBuf,
pub assets: PathBuf,
@@ -360,9 +387,11 @@ pub async fn serve(
.layer(DefaultBodyLimit::max(MAX_REQUEST_BYTES))
.layer(middleware::from_fn_with_state(app.clone(), access))
.with_state(app.clone());
eprintln!("Piik App {BUILD_VERSION}\nBuild {BUILD_REVISION}");
eprint!(
"{}",
startup_panel(BUILD_VERSION, BUILD_REVISION, address.port())
);
eprintln!("App room socket listening on {address}");
eprintln!("Open Piik App: {entry}");
if let Some(ready) = ready {
let _ = ready.send(entry.clone());
}