改成英文界面

This commit is contained in:
Kevin Wong
2026-01-15 15:06:32 +08:00
parent 15728dfdaf
commit e376769627

View File

@@ -5,36 +5,37 @@ import threading
import os import os
def main(page: ft.Page): def main(page: ft.Page):
# --- 1. 强制窗口尺寸与初始化 --- # --- 1. Window Configuration ---
page.title = "PathWarp" page.title = "PathWarp"
page.theme_mode = ft.ThemeMode.DARK page.theme_mode = ft.ThemeMode.DARK
page.window.width = 320 # 宽度进一步压缩 page.window.width = 320
page.window.height = 360 # 高度大幅压缩 page.window.height = 360
page.window.resizable = False # 禁止缩放,保持精致 page.window.resizable = False
page.window.always_on_top = True # 既然是工具,建议悬浮在最前 page.window.always_on_top = True
page.padding = 10 page.padding = 10
page.spacing = 10 page.spacing = 10
# 窗口居中启动 # Center the window on startup
page.window.center() page.window.center()
# 设置图标 # Set Window Icon
if os.path.exists("logo.ico"): if os.path.exists("logo.ico"):
page.window.icon = "logo.ico" page.window.icon = "logo.ico"
# --- 2. 核心转换逻辑 --- # --- 2. Path Conversion Logic ---
def do_convert(win_path): def do_convert(win_path):
if not win_path: return None if not win_path: return None
p = win_path.strip().strip('"').strip("'") p = win_path.strip().strip('"').strip("'")
if p.lower().startswith("w:"): if p.lower().startswith("w:"):
rel = p[2:].lstrip("\\") rel = p[2:].lstrip("\\")
# Your Samba mapping: W:\ -> /home/rongye/ProgramFiles/
return f"/home/rongye/ProgramFiles/{rel.replace('\\', '/')}" return f"/home/rongye/ProgramFiles/{rel.replace('\\', '/')}"
return None return None
# --- 3. 精简 UI 组件 --- # --- 3. UI Components ---
input_field = ft.TextField( input_field = ft.TextField(
label="Windows 路径", label="Windows Path",
hint_text=r"W:\...", hint_text=r"e.g. W:\Project\Main",
text_size=12, text_size=12,
height=45, height=45,
border_color=ft.Colors.CYAN_800, border_color=ft.Colors.CYAN_800,
@@ -43,7 +44,7 @@ def main(page: ft.Page):
) )
result_field = ft.TextField( result_field = ft.TextField(
label="Ubuntu 路径", label="Ubuntu Path",
read_only=True, read_only=True,
text_size=12, text_size=12,
height=45, height=45,
@@ -63,11 +64,11 @@ def main(page: ft.Page):
status_text.value = f"Copied: {time.strftime('%H:%M:%S')}" status_text.value = f"Copied: {time.strftime('%H:%M:%S')}"
status_text.color = ft.Colors.GREEN_400 status_text.color = ft.Colors.GREEN_400
else: else:
status_text.value = "Invalid Path" status_text.value = "Error: Invalid Path"
status_text.color = ft.Colors.RED_400 status_text.color = ft.Colors.RED_400
page.update() page.update()
# --- 4. 后台监听 --- # --- 4. Background Clipboard Monitor ---
stop_listen = threading.Event() stop_listen = threading.Event()
def listen_clip(): def listen_clip():
last_clip = "" last_clip = ""
@@ -91,13 +92,15 @@ def main(page: ft.Page):
if listen_switch.value: if listen_switch.value:
stop_listen.clear() stop_listen.clear()
threading.Thread(target=listen_clip, daemon=True).start() threading.Thread(target=listen_clip, daemon=True).start()
status_text.value = "Monitoring..."
else: else:
stop_listen.set() stop_listen.set()
status_text.value = "Stopped"
page.update() page.update()
listen_switch = ft.Switch(label="自动捕获", value=False, on_change=toggle_listen, scale=0.7) listen_switch = ft.Switch(label="Auto Monitor", value=False, on_change=toggle_listen, scale=0.7)
# --- 5. 极致紧凑布局 --- # --- 5. Compact Layout ---
page.add( page.add(
ft.Column([ ft.Column([
ft.Row([ ft.Row([
@@ -108,7 +111,7 @@ def main(page: ft.Page):
input_field, input_field,
ft.FilledButton( ft.FilledButton(
"立即转换", "Convert & Copy",
on_click=convert_click, on_click=convert_click,
width=320, width=320,
height=40, height=40,