fix(usage): align table width and reduce default window size

- stretch the usage table to match card width
- set the default window size to 1280 × 800
- migrate the legacy default window dimensions
- add coverage for window size migration
This commit is contained in:
lzt404 committed 2026-08-26 01:56:46 +08:00
1 parent a662d35876
commit 58e58df374
6 files changed
+43 -8

No files matched your search

+12 -1
View File
@@ -1584,7 +1584,18 @@ pub(crate) fn sanitize_gui_config(config: &mut GuiConfigFile) -> Result<bool, St
config.routing_session_affinity_ttl = routing_session_affinity_ttl;
changed = true;
}
let window_size = configured_window_size(config);
let window_size = configured_window_size(config).map(|size| {
if size.width == LEGACY_DEFAULT_MAIN_WINDOW_WIDTH
&& size.height == LEGACY_DEFAULT_MAIN_WINDOW_HEIGHT
{
SavedWindowSize {
width: DEFAULT_MAIN_WINDOW_WIDTH,
height: DEFAULT_MAIN_WINDOW_HEIGHT,
}
} else {
size
}
});
let normalized_width = window_size.map(|size| size.width);
let normalized_height = window_size.map(|size| size.height);
if config.window_width != normalized_width || config.window_height != normalized_height {
+4 -2
View File
@@ -124,8 +124,10 @@ const LEGACY_GUI_CONFIG_FILE: &str = "cpa-gui.yaml";
const MIN_MAIN_WINDOW_WIDTH: u32 = 640;
const MIN_MAIN_WINDOW_HEIGHT: u32 = 600;
const MAX_SAVED_WINDOW_DIMENSION: u32 = 16_384;
const DEFAULT_MAIN_WINDOW_WIDTH: u32 = 1531;
const DEFAULT_MAIN_WINDOW_HEIGHT: u32 = 891;
const DEFAULT_MAIN_WINDOW_WIDTH: u32 = 1280;
const DEFAULT_MAIN_WINDOW_HEIGHT: u32 = 800;
const LEGACY_DEFAULT_MAIN_WINDOW_WIDTH: u32 = 1531;
const LEGACY_DEFAULT_MAIN_WINDOW_HEIGHT: u32 = 891;
const OAUTH_DIR_NAME: &str = "oauth";
const DEFAULT_AUTH_DIR: &str = "../oauth";
const DEFAULT_API_KEY: &str = "123456";
+15 -2
View File
@@ -84,8 +84,8 @@ fn gui_config_defaults_are_stable() {
assert!(content.contains("start-core-on-launch = true"));
assert!(content.contains("silent-start = false"));
assert!(content.contains("close-behavior = \"ask\""));
assert!(content.contains("window-width = 1531"));
assert!(content.contains("window-height = 891"));
assert!(content.contains("window-width = 1280"));
assert!(content.contains("window-height = 800"));
assert!(content.contains("auth-dir = \"../oauth\""));
assert!(content.contains("[[api-keys]]"));
assert!(content.contains("key = \"123456\""));
@@ -170,6 +170,19 @@ fn gui_window_size_is_clamped_and_requires_both_dimensions() {
assert_eq!(config.window_height, None);
}
#[test]
fn legacy_default_window_size_migrates_to_current_default() {
let mut config = GuiConfigFile {
window_width: Some(LEGACY_DEFAULT_MAIN_WINDOW_WIDTH),
window_height: Some(LEGACY_DEFAULT_MAIN_WINDOW_HEIGHT),
..GuiConfigFile::default()
};
assert!(sanitize_gui_config(&mut config).unwrap());
assert_eq!(config.window_width, Some(DEFAULT_MAIN_WINDOW_WIDTH));
assert_eq!(config.window_height, Some(DEFAULT_MAIN_WINDOW_HEIGHT));
}
#[test]
fn physical_window_size_uses_display_scale_and_ignores_minimized_sizes() {
let physical_size = tauri::PhysicalSize::new(1500, 1000);
+2 -2
View File
@@ -13,8 +13,8 @@
{
"label": "main",
"title": "EasyCLIProxyAPI",
"width": 1531,
"height": 891,
"width": 1280,
"height": 800,
"minWidth": 640,
"minHeight": 600,
"visible": false
+4 -1
View File
@@ -1556,7 +1556,10 @@ function EventsView({
{events.items.length ? (
<div ref={tableWrapRef} className="usage-table-wrap">
<table className="usage-events-table" style={{ width: `${totalTableWidth}px` }}>
<table
className="usage-events-table"
style={{ width: `max(100%, ${totalTableWidth}px)` }}
>
<colgroup>
{visibleColumns.map((col) => (
<col key={col.key} style={{ width: `${widths[col.key]}px` }} />
+6
View File
@@ -6617,8 +6617,12 @@ textarea:focus-visible {
.usage-records-page {
display: grid;
width: 100%;
max-width: 100%;
min-width: 0;
gap: 12px;
align-content: start;
justify-items: stretch;
}
.usage-topbar {
@@ -7199,6 +7203,8 @@ textarea:focus-visible {
/* Events Tab (请求明细) */
.usage-events-panel {
display: flex;
width: 100%;
max-width: 100%;
min-height: 0;
padding: 0;
flex-direction: column;