mirror of
https://github.com/aiclientproxy/proxycast.git
synced 2026-09-24 23:10:56 +08:00
fix: 移除 Flow Monitor 窗口尺寸选项
- 从 WindowSize 移除 flow_monitor()、ultra_wide()、four_k() 方法 - 从 WindowSizeOption::all_options() 移除 Flow Monitor 等选项,保留 4 个选项 - 移除 resize_for_flow_monitor 和 toggle_window_size 命令 - 更新 runner.rs 移除已删除命令的注册 - 更新 window.ts 移除相关 API 方法 - 更新 constants.ts 移除 flow_monitor 窗口尺寸偏好 - FlowMonitorPage 已在之前移除窗口尺寸菜单 Closes #126
This commit is contained in:
@@ -989,9 +989,7 @@ pub fn run() {
|
||||
// Window control commands
|
||||
commands::window_cmd::get_window_size,
|
||||
commands::window_cmd::set_window_size,
|
||||
commands::window_cmd::resize_for_flow_monitor,
|
||||
commands::window_cmd::restore_window_size,
|
||||
commands::window_cmd::toggle_window_size,
|
||||
commands::window_cmd::center_window,
|
||||
commands::window_cmd::get_window_size_options,
|
||||
commands::window_cmd::set_window_size_by_option,
|
||||
|
||||
@@ -22,14 +22,6 @@ impl WindowSize {
|
||||
}
|
||||
}
|
||||
|
||||
/// Flow Monitor 优化大小(更宽更高,适合数据展示)
|
||||
pub fn flow_monitor() -> Self {
|
||||
Self {
|
||||
width: 1600,
|
||||
height: 1000,
|
||||
}
|
||||
}
|
||||
|
||||
/// 紧凑模式
|
||||
pub fn compact() -> Self {
|
||||
Self {
|
||||
@@ -53,22 +45,6 @@ impl WindowSize {
|
||||
height: 1440,
|
||||
}
|
||||
}
|
||||
|
||||
/// 4K 模式
|
||||
pub fn ultra_wide() -> Self {
|
||||
Self {
|
||||
width: 3440,
|
||||
height: 1440,
|
||||
}
|
||||
}
|
||||
|
||||
/// 4K 标准模式
|
||||
pub fn four_k() -> Self {
|
||||
Self {
|
||||
width: 3840,
|
||||
height: 2160,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 窗口大小选项
|
||||
@@ -96,12 +72,6 @@ impl WindowSizeOption {
|
||||
description: "1200×800 - 日常使用".to_string(),
|
||||
size: WindowSize::default(),
|
||||
},
|
||||
Self {
|
||||
id: "flow_monitor".to_string(),
|
||||
name: "Flow Monitor".to_string(),
|
||||
description: "1600×1000 - 数据展示优化".to_string(),
|
||||
size: WindowSize::flow_monitor(),
|
||||
},
|
||||
Self {
|
||||
id: "large".to_string(),
|
||||
name: "大屏模式".to_string(),
|
||||
@@ -114,18 +84,6 @@ impl WindowSizeOption {
|
||||
description: "2560×1440 - 超大屏幕".to_string(),
|
||||
size: WindowSize::extra_large(),
|
||||
},
|
||||
Self {
|
||||
id: "ultra_wide".to_string(),
|
||||
name: "超宽屏模式".to_string(),
|
||||
description: "3440×1440 - 超宽屏显示".to_string(),
|
||||
size: WindowSize::ultra_wide(),
|
||||
},
|
||||
Self {
|
||||
id: "four_k".to_string(),
|
||||
name: "4K 模式".to_string(),
|
||||
description: "3840×2160 - 4K 显示器".to_string(),
|
||||
size: WindowSize::four_k(),
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -256,26 +214,6 @@ pub async fn set_window_size(app: AppHandle, size: WindowSize) -> Result<(), Str
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// 切换到 Flow Monitor 优化大小
|
||||
///
|
||||
/// # Arguments
|
||||
/// * `app` - Tauri AppHandle
|
||||
///
|
||||
/// # Returns
|
||||
/// * `Ok(WindowSize)` - 成功时返回之前的窗口大小
|
||||
/// * `Err(String)` - 失败时返回错误消息
|
||||
#[tauri::command]
|
||||
pub async fn resize_for_flow_monitor(app: AppHandle) -> Result<WindowSize, String> {
|
||||
// 先获取当前大小,用于恢复
|
||||
let current_size = get_window_size(app.clone()).await?;
|
||||
|
||||
// 设置为 Flow Monitor 优化大小
|
||||
let flow_monitor_size = WindowSize::flow_monitor();
|
||||
set_window_size(app, flow_monitor_size).await?;
|
||||
|
||||
Ok(current_size)
|
||||
}
|
||||
|
||||
/// 恢复窗口到指定大小
|
||||
///
|
||||
/// # Arguments
|
||||
@@ -290,36 +228,6 @@ pub async fn restore_window_size(app: AppHandle, size: WindowSize) -> Result<(),
|
||||
set_window_size(app, size).await
|
||||
}
|
||||
|
||||
/// 切换窗口大小(在默认大小和 Flow Monitor 大小之间切换)
|
||||
///
|
||||
/// # Arguments
|
||||
/// * `app` - Tauri AppHandle
|
||||
///
|
||||
/// # Returns
|
||||
/// * `Ok(bool)` - 成功时返回是否切换到了 Flow Monitor 大小
|
||||
/// * `Err(String)` - 失败时返回错误消息
|
||||
#[tauri::command]
|
||||
pub async fn toggle_window_size(app: AppHandle) -> Result<bool, String> {
|
||||
let current_size = get_window_size(app.clone()).await?;
|
||||
let flow_monitor_size = WindowSize::flow_monitor();
|
||||
let default_size = WindowSize::default();
|
||||
|
||||
// 判断当前是否接近 Flow Monitor 大小(允许一些误差)
|
||||
let is_flow_monitor_size = (current_size.width as i32 - flow_monitor_size.width as i32).abs()
|
||||
< 50
|
||||
&& (current_size.height as i32 - flow_monitor_size.height as i32).abs() < 50;
|
||||
|
||||
if is_flow_monitor_size {
|
||||
// 当前是 Flow Monitor 大小,切换到默认大小
|
||||
set_window_size(app, default_size).await?;
|
||||
Ok(false)
|
||||
} else {
|
||||
// 当前不是 Flow Monitor 大小,切换到 Flow Monitor 大小
|
||||
set_window_size(app, flow_monitor_size).await?;
|
||||
Ok(true)
|
||||
}
|
||||
}
|
||||
|
||||
/// 居中窗口
|
||||
///
|
||||
/// # Arguments
|
||||
@@ -349,10 +257,6 @@ mod tests {
|
||||
assert_eq!(default.width, 1200);
|
||||
assert_eq!(default.height, 800);
|
||||
|
||||
let flow_monitor = WindowSize::flow_monitor();
|
||||
assert_eq!(flow_monitor.width, 1600);
|
||||
assert_eq!(flow_monitor.height, 1000);
|
||||
|
||||
let compact = WindowSize::compact();
|
||||
assert_eq!(compact.width, 1000);
|
||||
assert_eq!(compact.height, 700);
|
||||
@@ -364,20 +268,12 @@ mod tests {
|
||||
let extra_large = WindowSize::extra_large();
|
||||
assert_eq!(extra_large.width, 2560);
|
||||
assert_eq!(extra_large.height, 1440);
|
||||
|
||||
let ultra_wide = WindowSize::ultra_wide();
|
||||
assert_eq!(ultra_wide.width, 3440);
|
||||
assert_eq!(ultra_wide.height, 1440);
|
||||
|
||||
let four_k = WindowSize::four_k();
|
||||
assert_eq!(four_k.width, 3840);
|
||||
assert_eq!(four_k.height, 2160);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_window_size_options() {
|
||||
let options = WindowSizeOption::all_options();
|
||||
assert_eq!(options.len(), 7);
|
||||
assert_eq!(options.len(), 4);
|
||||
|
||||
// 验证每个选项都有有效的 ID 和名称
|
||||
for option in &options {
|
||||
|
||||
@@ -122,7 +122,6 @@ export const STORAGE_KEYS = {
|
||||
export type WindowSizePreference =
|
||||
| "compact"
|
||||
| "default"
|
||||
| "flow_monitor"
|
||||
| "large"
|
||||
| "fullscreen";
|
||||
|
||||
@@ -152,12 +151,6 @@ export const windowSizeOptions: WindowSizeOptionConfig[] = [
|
||||
description: "1200×800 - 日常使用",
|
||||
icon: Monitor,
|
||||
},
|
||||
{
|
||||
id: "flow_monitor",
|
||||
name: "Flow Monitor",
|
||||
description: "1600×1000 - 数据展示优化",
|
||||
icon: Activity,
|
||||
},
|
||||
{
|
||||
id: "large",
|
||||
name: "大屏模式",
|
||||
|
||||
@@ -83,33 +83,6 @@ export const windowApi = {
|
||||
return safeInvoke("is_fullscreen");
|
||||
},
|
||||
|
||||
/**
|
||||
* 切换到 Flow Monitor 优化大小
|
||||
*
|
||||
* @returns 之前的窗口大小(用于恢复)
|
||||
*/
|
||||
async resizeForFlowMonitor(): Promise<WindowSize> {
|
||||
return safeInvoke("resize_for_flow_monitor");
|
||||
},
|
||||
|
||||
/**
|
||||
* 恢复窗口到指定大小
|
||||
*
|
||||
* @param size - 要恢复的窗口大小
|
||||
*/
|
||||
async restoreWindowSize(size: WindowSize): Promise<void> {
|
||||
return safeInvoke("restore_window_size", { size });
|
||||
},
|
||||
|
||||
/**
|
||||
* 切换窗口大小(在默认大小和 Flow Monitor 大小之间切换)
|
||||
*
|
||||
* @returns 是否切换到了 Flow Monitor 大小
|
||||
*/
|
||||
async toggleWindowSize(): Promise<boolean> {
|
||||
return safeInvoke("toggle_window_size");
|
||||
},
|
||||
|
||||
/**
|
||||
* 居中窗口
|
||||
*/
|
||||
@@ -128,20 +101,11 @@ export const WindowSizes = {
|
||||
/** 默认窗口大小 */
|
||||
default: { width: 1200, height: 800 } as WindowSize,
|
||||
|
||||
/** Flow Monitor 优化大小 */
|
||||
flowMonitor: { width: 1600, height: 1000 } as WindowSize,
|
||||
|
||||
/** 大屏模式 */
|
||||
large: { width: 1920, height: 1200 } as WindowSize,
|
||||
|
||||
/** 超大屏模式 */
|
||||
extraLarge: { width: 2560, height: 1440 } as WindowSize,
|
||||
|
||||
/** 超宽屏模式 */
|
||||
ultraWide: { width: 3440, height: 1440 } as WindowSize,
|
||||
|
||||
/** 4K 模式 */
|
||||
fourK: { width: 3840, height: 2160 } as WindowSize,
|
||||
};
|
||||
|
||||
export default windowApi;
|
||||
|
||||
@@ -1,14 +1,5 @@
|
||||
import { useState, useCallback, useEffect } from "react";
|
||||
import {
|
||||
Activity,
|
||||
Download,
|
||||
BarChart3,
|
||||
List,
|
||||
ChevronDown,
|
||||
Monitor,
|
||||
Maximize,
|
||||
Trash2,
|
||||
} from "lucide-react";
|
||||
import { useState, useCallback } from "react";
|
||||
import { Activity, Download, BarChart3, List, Trash2 } from "lucide-react";
|
||||
import {
|
||||
FlowList,
|
||||
FlowFilters,
|
||||
@@ -22,7 +13,6 @@ import {
|
||||
type FlowFilter,
|
||||
type ExportFormat,
|
||||
} from "@/lib/api/flowMonitor";
|
||||
import { windowApi, type WindowSizeOption } from "@/lib/api/window";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
type ViewMode = "list" | "stats";
|
||||
@@ -47,48 +37,6 @@ export function FlowMonitorPage() {
|
||||
// 刷新计数器(用于触发子组件刷新)
|
||||
const [refreshKey, setRefreshKey] = useState(0);
|
||||
|
||||
// 窗口大小状态
|
||||
const [windowSizeOptions, setWindowSizeOptions] = useState<
|
||||
WindowSizeOption[]
|
||||
>([]);
|
||||
const [isFullscreen, setIsFullscreen] = useState(false);
|
||||
const [showWindowMenu, setShowWindowMenu] = useState(false);
|
||||
|
||||
// 初始化窗口大小选项
|
||||
useEffect(() => {
|
||||
const loadWindowOptions = async () => {
|
||||
try {
|
||||
const options = await windowApi.getWindowSizeOptions();
|
||||
setWindowSizeOptions(options);
|
||||
|
||||
// 检查是否处于全屏模式
|
||||
const fullscreen = await windowApi.isFullscreen();
|
||||
setIsFullscreen(fullscreen);
|
||||
} catch (error) {
|
||||
console.error("加载窗口选项失败:", error);
|
||||
}
|
||||
};
|
||||
|
||||
loadWindowOptions();
|
||||
}, []);
|
||||
|
||||
// 点击外部关闭窗口菜单
|
||||
useEffect(() => {
|
||||
const handleClickOutside = (event: MouseEvent) => {
|
||||
if (showWindowMenu) {
|
||||
const target = event.target as Element;
|
||||
if (!target.closest(".window-menu-container")) {
|
||||
setShowWindowMenu(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
document.addEventListener("mousedown", handleClickOutside);
|
||||
return () => {
|
||||
document.removeEventListener("mousedown", handleClickOutside);
|
||||
};
|
||||
}, [showWindowMenu]);
|
||||
|
||||
// 处理 Flow 选择
|
||||
const handleFlowSelect = useCallback((flow: LLMFlow) => {
|
||||
setSelectedFlow(flow);
|
||||
@@ -125,27 +73,6 @@ export function FlowMonitorPage() {
|
||||
setRefreshKey((prev) => prev + 1);
|
||||
}, []);
|
||||
|
||||
// 设置窗口大小
|
||||
const handleSetWindowSize = useCallback(async (optionId: string) => {
|
||||
try {
|
||||
await windowApi.setWindowSizeByOption(optionId);
|
||||
setShowWindowMenu(false);
|
||||
} catch (error) {
|
||||
console.error("设置窗口大小失败:", error);
|
||||
}
|
||||
}, []);
|
||||
|
||||
// 切换全屏模式
|
||||
const handleToggleFullscreen = useCallback(async () => {
|
||||
try {
|
||||
const newFullscreenState = await windowApi.toggleFullscreen();
|
||||
setIsFullscreen(newFullscreenState);
|
||||
setShowWindowMenu(false);
|
||||
} catch (error) {
|
||||
console.error("切换全屏模式失败:", error);
|
||||
}
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{/* 页面头部 */}
|
||||
@@ -188,59 +115,6 @@ export function FlowMonitorPage() {
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* 窗口大小调整下拉菜单 */}
|
||||
<div className="relative window-menu-container">
|
||||
<button
|
||||
onClick={() => setShowWindowMenu(!showWindowMenu)}
|
||||
className="flex items-center gap-1 rounded-lg border px-3 py-2 text-sm hover:bg-muted"
|
||||
title="调整窗口大小"
|
||||
>
|
||||
<Monitor className="h-4 w-4" />
|
||||
窗口
|
||||
<ChevronDown className="h-3 w-3" />
|
||||
</button>
|
||||
|
||||
{showWindowMenu && (
|
||||
<div className="absolute right-0 top-full mt-1 z-[100] min-w-[200px] rounded-lg border bg-background p-1 shadow-xl">
|
||||
{/* 窗口大小选项 */}
|
||||
<div className="px-2 py-1 text-xs font-medium text-muted-foreground">
|
||||
窗口大小
|
||||
</div>
|
||||
{windowSizeOptions.map((option) => (
|
||||
<button
|
||||
key={option.id}
|
||||
onClick={() => handleSetWindowSize(option.id)}
|
||||
className="w-full text-left px-2 py-1.5 text-sm rounded hover:bg-accent hover:text-accent-foreground"
|
||||
>
|
||||
<div className="font-medium">{option.name}</div>
|
||||
<div className="text-xs text-muted-foreground">
|
||||
{option.description}
|
||||
</div>
|
||||
</button>
|
||||
))}
|
||||
|
||||
{/* 分隔线 */}
|
||||
<div className="my-1 h-px bg-border" />
|
||||
|
||||
{/* 全屏选项 */}
|
||||
<button
|
||||
onClick={handleToggleFullscreen}
|
||||
className="w-full text-left px-2 py-1.5 text-sm rounded hover:bg-accent hover:text-accent-foreground flex items-center gap-2"
|
||||
>
|
||||
<Maximize className="h-4 w-4" />
|
||||
<div>
|
||||
<div className="font-medium">
|
||||
{isFullscreen ? "退出全屏" : "全屏模式"}
|
||||
</div>
|
||||
<div className="text-xs text-muted-foreground">
|
||||
{isFullscreen ? "返回窗口模式" : "使用整个屏幕"}
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 导出按钮 */}
|
||||
<button
|
||||
onClick={handleBatchExport}
|
||||
|
||||
Reference in New Issue
Block a user