feat(mini): add dockable compact client
This commit is contained in:
4394
apps/mini/src-tauri/Cargo.lock
generated
Normal file
4394
apps/mini/src-tauri/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
18
apps/mini/src-tauri/Cargo.toml
Normal file
18
apps/mini/src-tauri/Cargo.toml
Normal 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"
|
||||
3
apps/mini/src-tauri/build.rs
Normal file
3
apps/mini/src-tauri/build.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
tauri_build::build()
|
||||
}
|
||||
BIN
apps/mini/src-tauri/icons/128x128.png
Normal file
BIN
apps/mini/src-tauri/icons/128x128.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.3 KiB |
BIN
apps/mini/src-tauri/icons/128x128@2x.png
Normal file
BIN
apps/mini/src-tauri/icons/128x128@2x.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.8 KiB |
BIN
apps/mini/src-tauri/icons/32x32.png
Normal file
BIN
apps/mini/src-tauri/icons/32x32.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 926 B |
BIN
apps/mini/src-tauri/icons/icon.icns
Normal file
BIN
apps/mini/src-tauri/icons/icon.icns
Normal file
Binary file not shown.
BIN
apps/mini/src-tauri/icons/icon.ico
Normal file
BIN
apps/mini/src-tauri/icons/icon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
33
apps/mini/src-tauri/src/lib.rs
Normal file
33
apps/mini/src-tauri/src/lib.rs
Normal 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");
|
||||
}
|
||||
3
apps/mini/src-tauri/src/main.rs
Normal file
3
apps/mini/src-tauri/src/main.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
senlinai_mini_lib::run();
|
||||
}
|
||||
41
apps/mini/src-tauri/tauri.conf.json
Normal file
41
apps/mini/src-tauri/tauri.conf.json
Normal 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"
|
||||
]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user