Skip to content

Commit e3dcd73

Browse files
committed
Fixed: Fixes an issue where users were unable to edit paths
1 parent 3ca0874 commit e3dcd73

File tree

6 files changed

+66
-47
lines changed

6 files changed

+66
-47
lines changed

src-tauri/src/commands/get_assets.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ pub async fn get_assets(
8888
if !assets_data.success {
8989
error!("获取 Asset 数据失败");
9090
error!("返回的 status 为 {}", assets_data.status);
91+
9192
let _ = app.emit("get-asset-failure", json!({ "status": assets_data.status }));
9293
return;
9394
}

src-tauri/src/commands/get_setting.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub async fn get_setting(app: AppHandle, site: String, cookie_header: String) {
1010

1111
if !setting_data.success {
1212
error!("获取 Setting 数据失败");
13+
1314
let _ = app.emit(
1415
"get-setting-failure",
1516
json!({ "status": setting_data.status }),

src-tauri/src/commands/logout.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ pub async fn logout(app: AppHandle, name: String, origin: String) -> Result<(),
2828
.join("\n");
2929

3030
if script.is_empty() {
31-
warn!("未找到可清除的非 httpOnly Cookies站点: {}", origin);
31+
warn!("未找到可清除的非 httpOnly Cookies 站点: {}", origin);
3232
} else {
33+
// eval 注入脚本清除 cookie
3334
window.eval(&script).map_err(|e| e.to_string())?;
35+
3436
info!(
35-
"已清除 {} 个可见 Cookies共匹配 {} 个,站点: {}",
37+
"已清除 {} 个可见 Cookies(共匹配 {} 个),站点: {}",
3638
cleared, total, origin
3739
);
3840
}

src-tauri/src/utils.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ pub async fn get_window_cookies(
4949
let win = get_window_with_retry(app, window_label, 10)
5050
.await
5151
.ok_or_else(|| format!("window '{}' not found after retries", window_label))?;
52+
5253
// 允许传入裸域名/IP,失败时默认补全 https:// 再解析
5354
let url = Url::parse(origin)
5455
.or_else(|_| Url::parse(&format!("https://{}", origin)))
@@ -182,8 +183,12 @@ pub async fn to_api_response(
182183

183184
/// 初始化并持久化窗口尺寸(存逻辑尺寸 DIP),避免跨显示器缩放导致的视觉尺寸变化。
184185
/// - 存储:逻辑像素宽高(width/height,DIP)
185-
/// - 恢复:直接按逻辑尺寸 set_size;若仅有旧的物理像素存档(width_px/height_px),则按当前缩放换算为逻辑尺寸后再设置。
186-
/// - 原理:始终以设备无关像素(DIP)为基准持久化,跨不同 DPI 显示器打开时视觉大小保持一致。
186+
///
187+
/// - 恢复:
188+
/// 直接按逻辑尺寸 set_size;若仅有旧的物理像素存档(width_px/height_px),则按当前缩放换算为逻辑尺寸后再设置。
189+
/// Tauri/底层窗口系统会根据 当前屏幕的 scale factor,自动把逻辑尺寸换算成物理像素
190+
///
191+
/// - 原理:逻辑像素 × 缩放比 = 物理像素; 只在 “尺寸变化/应用打开” 时关心缩放比,中间存的永远是逻辑尺寸
187192
pub fn setup_window_size_persistence(win: WebviewWindow) {
188193
// 恢复上次保存的尺寸
189194
if let Err(e) = restore_window_size(&win) {
@@ -212,20 +217,22 @@ fn save_window_logical_size(app: &AppHandle, width: f64, height: f64) -> Result<
212217
let store = app
213218
.store("app_data.json")
214219
.map_err(|e| format!("open store failed: {}", e))?;
220+
215221
store.set(
216222
"window_size",
217223
serde_json::json!({
218224
"width": width,
219225
"height": height,
220226
}),
221227
);
228+
222229
store
223230
.save()
224231
.map_err(|e| format!("store save failed: {}", e))
225232
}
226233

227234
fn restore_window_size(win: &WebviewWindow) -> Result<(), String> {
228-
let app = win.app_handle();
235+
let app: &AppHandle = win.app_handle();
229236
let store = app
230237
.store("app_data.json")
231238
.map_err(|e| format!("open store failed: {}", e))?;
@@ -261,10 +268,10 @@ fn restore_window_size(win: &WebviewWindow) -> Result<(), String> {
261268
let w = width_logical.max(1.0);
262269
let h = height_logical.max(1.0);
263270

264-
// set_size 存储 DPI
265271
win.set_size(tauri::Size::Logical(LogicalSize::new(w, h)))
266272
.map_err(|e| format!("set_size failed: {}", e))?;
267273

268274
let _ = save_window_logical_size(&app, w, h);
275+
269276
Ok(())
270277
}

ui/assets/images/toadOracle.png

15.2 KB
Loading

ui/components/SettingItems/settingItems.vue

Lines changed: 49 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,48 @@
22
import type { ConfigItem } from "~/types/index";
33
44
// 批量导入所有图片资源
5-
const imageModules = import.meta.glob<{ default: string }>('@/assets/images/*.png', { eager: true });
6-
7-
// 辅助函数:从路径中获取文件名(不含扩展名)
8-
const getImageByName = (filename: string): string | undefined => {
9-
for (const path in imageModules) {
10-
if (path.includes(`/${filename}.png`)) {
11-
return imageModules[path]?.default;
12-
}
13-
}
14-
return undefined;
15-
};
5+
const imageModules = import.meta.glob<{ default: string }>("@/assets/images/*.png", { eager: true });
166
177
const props = defineProps<{
188
item: ConfigItem;
199
protocol?: string;
2010
selected?: boolean;
2111
}>();
2212
23-
// 创建图片映射表 - 映射应用名称到图片文件名
24-
const imagesMap: Record<string, string | undefined> = {
25-
iterm: getImageByName('item2'),
26-
dbeaver: getImageByName('dbeaver'),
27-
mstsc: getImageByName('mstsc'),
28-
terminal: getImageByName('terminal'),
29-
vncviewer: getImageByName('realvnc'),
30-
tigervnc: getImageByName('tigerVnc'),
31-
securefx: getImageByName('securecrt'),
32-
securecrt: getImageByName('securecrt'),
33-
another_redis: getImageByName('another_redis'),
34-
mongo_compass: getImageByName('mongodb'),
35-
xshell: getImageByName('xshell'),
36-
mobaxterm: getImageByName('mobaxterm'),
37-
putty: getImageByName('putty'),
38-
winscp: getImageByName('winscp'),
39-
xftp: getImageByName('xftp'),
40-
xfreerdp: getImageByName('xfreerdp'),
41-
remmina: getImageByName('remmina'),
42-
plsql: getImageByName('plsql'),
43-
ssms17: getImageByName('ssms17'),
44-
resp: getImageByName('resp'),
45-
navicat17: getImageByName('navicat17'),
46-
royalts: getImageByName('royalts'),
47-
windows_rdm: getImageByName('windows_rdm'),
48-
};
49-
5013
const emit = defineEmits<{ (e: "toggle", value: boolean): void }>();
5114
5215
const { t, locale } = useI18n();
5316
const { isWindows } = usePlatform();
5417
const { language } = useSettingManager();
55-
const { setAppConfig } = useSettingManager();
18+
const { setAppConfig } = useSettingManager();\
19+
20+
const imagesMap: Record<string, string | undefined> = {
21+
iterm: getImageByName("item2"),
22+
dbeaver: getImageByName("dbeaver"),
23+
mstsc: getImageByName("mstsc"),
24+
terminal: getImageByName("terminal"),
25+
vncviewer: getImageByName("realvnc"),
26+
tigervnc: getImageByName("tigerVnc"),
27+
securefx: getImageByName("securecrt"),
28+
securecrt: getImageByName("securecrt"),
29+
another_redis: getImageByName("another_redis"),
30+
mongo_compass: getImageByName("mongodb"),
31+
xshell: getImageByName("xshell"),
32+
mobaxterm: getImageByName("mobaxterm"),
33+
putty: getImageByName("putty"),
34+
winscp: getImageByName("winscp"),
35+
xftp: getImageByName("xftp"),
36+
xfreerdp: getImageByName("xfreerdp"),
37+
remmina: getImageByName("remmina"),
38+
plsql: getImageByName("plsql"),
39+
ssms17: getImageByName("ssms17"),
40+
resp: getImageByName("resp"),
41+
navicat17: getImageByName("navicat17"),
42+
royalts: getImageByName("royalts"),
43+
windows_rdm: getImageByName("windows_rdm"),
44+
toad: getImageByName("toadOracle")
45+
};
46+
5647
5748
const commentText = computed(() => {
5849
const lang = language.value || (locale?.value as string) || "en";
@@ -66,8 +57,16 @@ const isWindowsPathPickTarget = computed(() => {
6657
return props.item?.is_internal === false && isWindows.value;
6758
});
6859
69-
const canToggle = computed(() => !!(props.item?.path && props.item.path.trim()))
60+
const canToggle = computed(() => !!(props.item?.path && props.item.path.trim()));
7061
62+
function getImageByName (filename: string): string | undefined {
63+
for (const path in imageModules) {
64+
if (path.includes(`/${filename}.png`)) {
65+
return imageModules[path]?.default;
66+
}
67+
}
68+
return undefined;
69+
};
7170
7271
const onSwitch = (v: boolean) => {
7372
if (!canToggle.value) return;
@@ -101,6 +100,13 @@ const selectExecutablePath = async () => {
101100
console.error("select executable failed", e);
102101
}
103102
};
103+
104+
// 在 Windows 下,已选择路径后仍允许点击展示区域以重新选择
105+
const onPathClick = () => {
106+
if (isWindowsPathPickTarget.value) {
107+
selectExecutablePath();
108+
}
109+
};
104110
</script>
105111

106112
<template>
@@ -124,8 +130,10 @@ const selectExecutablePath = async () => {
124130
</template>
125131
<template v-else>
126132
<div
127-
class="inline-flex items-center text-xs text-gray-600 dark:text-gray-300 bg-gray-100/80 dark:bg-white/10 rounded px-2 py-1 max-w-[22rem] md:max-w-[28rem] truncate"
133+
class="inline-flex items-center text-xs text-gray-600 dark:text-gray-300 bg-gray-100/80 dark:bg-white/10 rounded px-2 py-1 max-w-88 md:max-w-md truncate"
134+
:class="{ 'cursor-pointer hover:bg-gray-200/60 dark:hover:bg-white/15': isWindowsPathPickTarget }"
128135
:title="props.item.path || '-'"
136+
@click="onPathClick"
129137
>
130138
<span class="truncate">{{ props.item.path || "-" }}</span>
131139
</div>

0 commit comments

Comments
 (0)