From 9aae3c8d589f69a62b077e01ad51361fcc451d7d Mon Sep 17 00:00:00 2001 From: Nixevol Date: Thu, 19 Nov 2026 15:34:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=89=93=E5=8D=A1=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E9=80=9A=E6=A0=8F=E5=B7=A6=E5=AF=B9=E9=BD=90?= =?UTF-8?q?=E5=B9=B6=E5=8E=BB=E6=8E=89=E5=85=B3=E4=BA=8E=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bin/punchlog-ui.rs | 2 +- ui/app.slint | 242 +++++++++++++++++++---------------------- 2 files changed, 114 insertions(+), 130 deletions(-) diff --git a/src/bin/punchlog-ui.rs b/src/bin/punchlog-ui.rs index 6f13ce2..3fdda96 100644 --- a/src/bin/punchlog-ui.rs +++ b/src/bin/punchlog-ui.rs @@ -48,7 +48,7 @@ fn show(ui: &MainWindow, loaded: punchlog::Result) { hours: format!("{:.1}h", day.hours).into(), status: day.status.label().into(), site: site.into(), - memo: memo.into(), + memo: memo.replace(" / ", "\n").into(), problem: day.status.is_problem(), } }) diff --git a/ui/app.slint b/ui/app.slint index 56f887a..62b513e 100644 --- a/ui/app.slint +++ b/ui/app.slint @@ -1,5 +1,3 @@ -import { AboutSlint } from "std-widgets.slint"; - export struct DayRow { date: string, mark: string, @@ -13,75 +11,76 @@ export struct DayRow { component Hairline inherits Rectangle { height: 1px; - background: #e4e4e1; + background: #e6e6e3; } -component DayBlock inherits HorizontalLayout { +component DayBlock inherits VerticalLayout { in property day; - spacing: 0; + width: 100%; + padding-left: 28px; + padding-right: 28px; + padding-top: 18px; + padding-bottom: 18px; + spacing: 8px; + alignment: start; - Rectangle { - width: 2px; - background: day.problem ? #161616 : transparent; + HorizontalLayout { + width: 100%; + spacing: 20px; + alignment: center; + + Text { + text: day.date; + width: 56px; + font-size: 15px; + font-weight: 600; + color: #1a1a1a; + } + Text { + text: day.time; + width: 112px; + font-size: 13px; + color: #6a6a6a; + vertical-alignment: center; + } + Text { + text: day.hours; + width: 48px; + font-size: 13px; + color: #6a6a6a; + vertical-alignment: center; + } + if day.mark != "": Text { + text: day.mark; + font-size: 13px; + color: #6a6a6a; + vertical-alignment: center; + } + Rectangle { horizontal-stretch: 1; } + Text { + text: day.status; + font-size: 13px; + color: day.problem ? #1a1a1a : #6a6a6a; + vertical-alignment: center; + } } - VerticalLayout { - padding-left: 18px; - padding-right: 20px; - padding-top: 16px; - padding-bottom: 16px; - spacing: 6px; - alignment: start; + if day.site != "": Text { + text: day.site; + width: 100%; + wrap: word-wrap; + font-size: 12px; + color: #8a8a8a; + horizontal-alignment: left; + } - HorizontalLayout { - spacing: 10px; - alignment: center; - Text { - text: day.date; - font-size: 15px; - font-weight: 600; - color: #161616; - } - if day.mark != "": Text { - text: day.mark; - font-size: 12px; - color: #8a8a8a; - vertical-alignment: center; - } - Rectangle { horizontal-stretch: 1; } - Text { - text: day.time; - font-size: 12px; - color: #6e6e6e; - vertical-alignment: center; - } - Text { - text: day.hours; - font-size: 12px; - color: #6e6e6e; - vertical-alignment: center; - } - Text { - text: day.status; - font-size: 12px; - color: #161616; - vertical-alignment: center; - } - } - - if day.site != "": Text { - text: day.site; - wrap: word-wrap; - font-size: 12px; - color: #8a8a8a; - } - - if day.memo != "": Text { - text: day.memo; - wrap: word-wrap; - font-size: 14px; - color: #161616; - } + if day.memo != "": Text { + text: day.memo; + width: 100%; + wrap: word-wrap; + font-size: 14px; + color: #1a1a1a; + horizontal-alignment: left; } } @@ -89,101 +88,86 @@ export component MainWindow inherits Window { in property <[DayRow]> days; in property range; in property error; - in-out property about: false; callback refresh(); title: "打卡"; - preferred-width: 920px; - preferred-height: 680px; + preferred-width: 880px; + preferred-height: 720px; background: #f7f7f5; default-font-family: "Segoe UI"; VerticalLayout { + width: 100%; + height: 100%; spacing: 0; - Rectangle { - height: 52px; - HorizontalLayout { - padding-left: 20px; - padding-right: 20px; - spacing: 16px; - alignment: center; - Text { - text: "打卡"; - font-size: 16px; - font-weight: 600; - color: #161616; - } - Text { - text: root.range; - font-size: 12px; - color: #8a8a8a; - vertical-alignment: center; - } - Rectangle { horizontal-stretch: 1; } - Text { - text: "刷新"; - font-size: 12px; - color: #161616; - vertical-alignment: center; - TouchArea { clicked => { root.refresh(); } } - } - Text { - text: "关于"; - font-size: 12px; - color: #161616; - vertical-alignment: center; - TouchArea { clicked => { root.about = !root.about; } } - } + HorizontalLayout { + width: 100%; + height: 56px; + padding-left: 28px; + padding-right: 28px; + spacing: 20px; + alignment: center; + + Text { + text: "打卡"; + font-size: 16px; + font-weight: 600; + color: #1a1a1a; + } + Text { + text: root.range; + font-size: 13px; + color: #8a8a8a; + vertical-alignment: center; + } + Rectangle { horizontal-stretch: 1; } + Text { + text: "刷新"; + font-size: 13px; + color: #1a1a1a; + vertical-alignment: center; + TouchArea { clicked => { root.refresh(); } } } } Hairline {} if root.error != "": VerticalLayout { - padding: 20px; - Text { - text: root.error; - wrap: word-wrap; - font-size: 13px; - color: #161616; - } - } - - if root.about: VerticalLayout { - padding: 24px; - spacing: 16px; + width: 100%; + padding: 28px; alignment: start; Text { - text: "关于"; - font-size: 15px; - font-weight: 600; - color: #161616; - } - AboutSlint {} - Text { - text: "返回"; - font-size: 12px; - color: #161616; - TouchArea { clicked => { root.about = false; } } + text: root.error; + width: 100%; + wrap: word-wrap; + font-size: 14px; + color: #1a1a1a; + horizontal-alignment: left; } } - if !root.about && root.error == "" && root.days.length == 0: VerticalLayout { - padding: 20px; + if root.error == "" && root.days.length == 0: VerticalLayout { + width: 100%; + padding: 28px; + alignment: start; Text { text: "这一周没有打卡记录。"; - font-size: 13px; + font-size: 14px; color: #8a8a8a; } } - if !root.about && root.error == "" && root.days.length > 0: Flickable { + if root.error == "" && root.days.length > 0: Flickable { + width: 100%; vertical-stretch: 1; content-height: list.preferred-height; list := VerticalLayout { - width: parent.width; + width: 100%; + alignment: start; for day in root.days: VerticalLayout { + width: 100%; + spacing: 0; DayBlock { day: day; } Hairline {} }