feat(mini): add dockable compact client

This commit is contained in:
2026-07-22 18:34:20 +08:00
parent 4a82efc984
commit a23a110758
26 changed files with 7615 additions and 0 deletions

4394
apps/mini/src-tauri/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,18 @@
[package]
name = "senlinai-mini"
version = "1.0.0"
description = "森林AI 迷你停靠客户端"
authors = ["森林AI"]
edition = "2021"
[lib]
name = "senlinai_mini_lib"
crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies]
tauri-build = { version = "2", features = [] }
[dependencies]
tauri = { version = "2", features = [] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"

View File

@@ -0,0 +1,3 @@
fn main() {
tauri_build::build()
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 926 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -0,0 +1,33 @@
use tauri::{PhysicalPosition, Window};
#[tauri::command]
fn dock_window(window: Window, side: String) -> Result<(), String> {
let monitor = window
.current_monitor()
.map_err(|error| error.to_string())?
.ok_or_else(|| "无法识别当前屏幕".to_string())?;
let window_size = window.outer_size().map_err(|error| error.to_string())?;
let monitor_position = monitor.position();
let monitor_size = monitor.size();
let x = if side == "left" {
monitor_position.x
} else {
monitor_position.x + monitor_size.width as i32 - window_size.width as i32
};
window
.set_position(PhysicalPosition::new(x, monitor_position.y))
.map_err(|error| error.to_string())?;
window
.set_always_on_top(true)
.map_err(|error| error.to_string())?;
Ok(())
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![dock_window])
.run(tauri::generate_context!())
.expect("failed to run 森林AI Mini");
}

View File

@@ -0,0 +1,3 @@
fn main() {
senlinai_mini_lib::run();
}

View File

@@ -0,0 +1,41 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "森林AI Mini",
"version": "1.0.0",
"identifier": "ai.senlin.mini",
"build": {
"frontendDist": "../dist",
"devUrl": "http://localhost:5180",
"beforeDevCommand": "npm run dev",
"beforeBuildCommand": "npm run build"
},
"app": {
"windows": [
{
"label": "main",
"title": "森林AI Mini",
"width": 420,
"height": 820,
"minWidth": 360,
"minHeight": 640,
"resizable": true,
"alwaysOnTop": true,
"center": false
}
],
"security": {
"csp": "default-src 'self'; img-src 'self' asset: https: data:; style-src 'self' 'unsafe-inline'; connect-src http://* https://*"
}
},
"bundle": {
"active": true,
"targets": "all",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
]
}
}