Files
tauri-meeting/src-tauri/src/window/create_main_window.rs
O昵称重要吗O 78af453fe1 chore: 初始化项目基础结构和资源文件
- 添加项目图标文件(app-icon.png、各平台图标)
- 配置开发环境文件(.env、.nvmrc、.npmrc)
- 添加静态资源文件(背景图片、字体、音频)
- 初始化Tauri后端结构(build.rs、main.rs、模块文件)
- 配置前端项目结构(TypeScript、Vue组件、样式)
- 添加Node.js API服务基础结构
- 配置构建和开发工具(vite、prettier、gitignore)
2026-03-13 10:03:05 +08:00

41 lines
1.4 KiB
Rust

use crate::constants::{common::APP_NAME, window::*};
use crate::window::{util::show_windows_by_label, WindowLabel};
use tauri::{AppHandle, Runtime, WebviewUrl, WebviewWindowBuilder};
/// 根据tauri.conf.json配置创建主窗口
pub async fn create_main_window_impl<R: Runtime>(app: &AppHandle<R>) -> Result<(), String> {
// 检查是否已经存在主窗口
if show_windows_by_label(app, WindowLabel::MAIN) {
return Ok(());
}
let label = WindowLabel::MAIN.as_ref();
// 根据tauri.conf.json配置创建主窗口
let _window = WebviewWindowBuilder::new(app, label, WebviewUrl::App("index.html".into()))
.title(APP_NAME)
.inner_size(MAIN_WINDOW_WIDTH, MAIN_WINDOW_HEIGHT)
.resizable(true)
.fullscreen(false)
.decorations(false)
.transparent(true)
.always_on_top(false)
.center()
.shadow(true)
.devtools(true)
.zoom_hotkeys_enabled(true)
.focusable(true)
.accept_first_mouse(true)
.visible(true)
.build()
.map_err(|e| format!("创建主窗口失败: {}", e))?;
// 设置窗口圆角效果
#[cfg(any(target_os = "windows", target_os = "macos"))]
{
use tauri::window::{Color, EffectsBuilder};
let _ = _window.set_effects(Some(EffectsBuilder::new().radius(WINDOW_CORNER_RADIUS).color(Color(0, 0, 0, 255)).build()));
}
Ok(())
}