From 4dc1a1d7fe20606b28902b6ac3f895ff3dba62ad Mon Sep 17 00:00:00 2001 From: xiyidaiwa Date: Mon, 17 Aug 2026 23:00:14 +0800 Subject: [PATCH 1/6] =?UTF-8?q?feat(settings):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=AD=97=E4=BD=93=E5=A4=A7=E5=B0=8F=E8=AE=BE=E7=BD=AE=EF=BC=88?= =?UTF-8?q?=E4=BB=85=E5=AD=97=E5=8F=B7=E6=A1=A3=E4=BD=8D=EF=BC=8C=E4=B8=8D?= =?UTF-8?q?=E5=90=AB=E6=95=B4=E4=BD=93=E7=BC=A9=E6=94=BE/=E5=AD=97?= =?UTF-8?q?=E4=BD=93=E6=97=8F=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 src/global/displaySettings.ts:small/medium/large/xlarge 四档 → html 15/16/17/18px, localStorage(spark-store-font-size) 持久化,applyFontSize 写 html font-size 全局联动 rem 字号类 - App.vue onMounted 最前 initFontSize()(与 initTagPriorityStrategy 同级,防字号闪烁) - SettingsModal.vue 新增「字体大小」卡片(4 档分段按钮 + 预览),selectFontSize 即时应用+持久化 - 用户确认范围:仅字号档位,整体缩放与字体族切换本期不做 - vue-tsc/lint/打包均通过 --- debian/changelog | 2 +- src/App.vue | 3 ++ src/components/SettingsModal.vue | 73 +++++++++++++++++++++++++++++++ src/global/displaySettings.ts | 75 ++++++++++++++++++++++++++++++++ 4 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 src/global/displaySettings.ts diff --git a/debian/changelog b/debian/changelog index 8fb4c320..b78193f9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -spark-store (5.3.0.1) UNRELEASED; urgency=medium +spark-store (5.3.0.2-test) UNRELEASED; urgency=medium * Initial release. diff --git a/src/App.vue b/src/App.vue index abd3b205..e9ed680b 100644 --- a/src/App.vue +++ b/src/App.vue @@ -344,6 +344,7 @@ import ReviewUserProfileModal from "./components/ReviewUserProfileModal.vue"; import WindowTitleBar from "./components/WindowTitleBar.vue"; import SubmitterWindow from "./components/SubmitterWindow.vue"; import { initTagPriorityStrategy } from "./global/tagPriority"; +import { initFontSize } from "./global/displaySettings"; import { FLARUM_BASE_URL, FLARUM_REGISTER_URL, @@ -1052,6 +1053,8 @@ onMounted(async () => { // 应用启动即锁定标签优先显示策略的真实持久化值,避免依赖详情页挂载顺序 // 导致先读到内存默认值 "auto" 再懒加载的竞态窗口。 initTagPriorityStrategy(); + // 恢复并应用持久化的字体大小档位(仅字号),避免渲染瞬间默认字号闪烁。 + initFontSize(); initTheme(); updateCenterStore.bind(); diff --git a/src/components/SettingsModal.vue b/src/components/SettingsModal.vue index 7cc55d35..f14110c8 100644 --- a/src/components/SettingsModal.vue +++ b/src/components/SettingsModal.vue @@ -163,6 +163,56 @@ + + +
+
+
+ +
+
+

+ 字体大小 +

+

+ 调整全局界面字体大小(仅字号) +

+
+ +
+

+ 预览:星火应用商店 Spark Store 123 +

+
+
+
@@ -185,6 +235,12 @@ import { setTagPriorityStrategy, type TagPriorityStrategy, } from "../global/tagPriority"; +import { + getFontSize, + setFontSize, + FONT_SIZE_OPTIONS, + type FontSizeOption, +} from "../global/displaySettings"; const props = defineProps<{ show: boolean; @@ -206,6 +262,9 @@ const strategyOptions: Array<{ value: TagPriorityStrategy; label: string }> = [ { value: "apm", label: "APM 优先" }, ]; +// 字体大小档位选项(小 / 标准 / 大 / 特大) +const fontSizeOptions = FONT_SIZE_OPTIONS; + const tagPriorityStrategy = ref("auto"); // 加载标签优先显示策略(从持久化读取) @@ -219,6 +278,19 @@ const selectStrategy = (value: TagPriorityStrategy) => { setTagPriorityStrategy(value); }; +// 字体大小档位(仅字号,不含整体缩放/字体族) +const fontSize = ref("medium"); + +const loadFontSize = () => { + fontSize.value = getFontSize(); +}; + +// 选择并保存字号档位(立即应用到 html,全局 rem 字号类联动) +const selectFontSize = (value: FontSizeOption) => { + fontSize.value = value; + setFontSize(value); +}; + const settings = ref({ enableUpdateCheck: true, enableCreateDesktop: true, @@ -279,6 +351,7 @@ watch( if (newVal) { loadSettings(); loadTagPriority(); + loadFontSize(); } }, ); diff --git a/src/global/displaySettings.ts b/src/global/displaySettings.ts new file mode 100644 index 00000000..e34bcc71 --- /dev/null +++ b/src/global/displaySettings.ts @@ -0,0 +1,75 @@ +/** + * 显示设置:全局字体大小档位(仅字号,不含整体缩放/字体族)。 + * + * 实现原理:Tailwind 4 的 `text-*` 字号类均为 rem 单位(如 text-sm = 0.875rem), + * 因此修改根元素 `html` 的 font-size 即可让全部 rem 字号类联动缩放。 + * 取值范围:14px(小) ~ 18px(特大),默认 16px(标准)。 + * + * 持久化:localStorage key = "spark-store-font-size",存档位枚举字符串。 + */ +export type FontSizeOption = "small" | "medium" | "large" | "xlarge"; + +interface FontSizeMeta { + /** 应用到 html 的 font-size(px) */ + px: number; + label: string; +} + +export const FONT_SIZE_OPTIONS: Array<{ + value: FontSizeOption; + label: string; +}> = [ + { value: "small", label: "小" }, + { value: "medium", label: "标准" }, + { value: "large", label: "大" }, + { value: "xlarge", label: "特大" }, +]; + +// 各档位对应的根字号。medium 保持现状 16px,向上放大、向下略缩。 +const FONT_SIZE_MAP: Record = { + small: { px: 15, label: "小" }, + medium: { px: 16, label: "标准" }, + large: { px: 17, label: "大" }, + xlarge: { px: 18, label: "特大" }, +}; + +const FONT_SIZE_STORAGE_KEY = "spark-store-font-size"; +const DEFAULT_FONT_SIZE: FontSizeOption = "medium"; + +const isValidFontSize = (v: unknown): v is FontSizeOption => + typeof v === "string" && v in FONT_SIZE_MAP; + +/** 读取持久化的字号档位(无/非法时回退默认「标准」) */ +export const getFontSize = (): FontSizeOption => { + try { + const raw = localStorage.getItem(FONT_SIZE_STORAGE_KEY); + if (isValidFontSize(raw)) return raw; + } catch { + // localStorage 不可用时忽略,使用默认 + } + return DEFAULT_FONT_SIZE; +}; + +/** 将字号档位应用到根元素 html(写入 inline font-size) */ +export const applyFontSize = (option: FontSizeOption): void => { + const meta = FONT_SIZE_MAP[option] ?? FONT_SIZE_MAP[DEFAULT_FONT_SIZE]; + document.documentElement.style.fontSize = `${meta.px}px`; +}; + +/** 选择并持久化字号档位,同时立即应用 */ +export const setFontSize = (option: FontSizeOption): void => { + applyFontSize(option); + try { + localStorage.setItem(FONT_SIZE_STORAGE_KEY, option); + } catch { + // 持久化失败时仍已应用当前会话,忽略写入错误 + } +}; + +/** + * 应用启动时初始化:从持久化恢复并使用,避免渲染瞬间闪烁。 + * 应在 App.vue 的 onMounted 最前调用(与 initTagPriorityStrategy 同级)。 + */ +export const initFontSize = (): void => { + applyFontSize(getFontSize()); +}; From 7b658e9dd1d2844f4b5b8dad87d111d2fd5503e3 Mon Sep 17 00:00:00 2001 From: xiyidaiwa Date: Mon, 17 Aug 2026 23:15:18 +0800 Subject: [PATCH 2/6] =?UTF-8?q?fix(ui):=20=E5=B0=86=E5=9B=BA=E5=AE=9A=20px?= =?UTF-8?q?=20=E5=AD=97=E5=8F=B7=E6=94=B9=E4=B8=BA=20rem=EF=BC=8C=E8=AE=A9?= =?UTF-8?q?=E5=85=A8=E5=B1=80=E5=AD=97=E4=BD=93=E5=A4=A7=E5=B0=8F=E6=A1=A3?= =?UTF-8?q?=E4=BD=8D=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 用户反馈首页红框区域(横幅标题/副标题)没随字号档位变大。 原因是多处使用了 Tailwind 固定 px 任意值(text-[10px]/[11px]/[12px]/[13px]/[15px]), 它们不随 html font-size 缩放。统一替换为等效 rem 任意值: 10px → 0.625rem, 11px → 0.6875rem, 12px → 0.75rem, 13px → 0.8125rem, 15px → 0.9375rem 涉及 8 个 Vue 组件,保证字号档位全局联动(仍保持 16px 基准下的原视觉大小)。 vue-tsc 通过,打包成功;HomeView.vue 原有 emit 未使用 lint 错误未动。 --- debian/changelog | 2 +- src/components/AppCard.vue | 16 +++++----- src/components/HomeView.vue | 6 ++-- src/components/InstalledAppsModal.vue | 22 ++++++------- src/components/RankingAppRow.vue | 9 +++--- src/components/SettingsModal.vue | 2 +- src/components/SourceLabel.vue | 2 +- src/components/WindowTitleBar.vue | 2 +- .../update-center/UpdateCenterItem.vue | 31 +++++++++---------- 9 files changed, 45 insertions(+), 47 deletions(-) diff --git a/debian/changelog b/debian/changelog index b78193f9..c79d5081 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -spark-store (5.3.0.2-test) UNRELEASED; urgency=medium +spark-store (5.3.0.3-test) UNRELEASED; urgency=medium * Initial release. diff --git a/src/components/AppCard.vue b/src/components/AppCard.vue index 82de7541..f5fdb567 100644 --- a/src/components/AppCard.vue +++ b/src/components/AppCard.vue @@ -39,20 +39,20 @@
SPARK/APM