From 1729b9db4d27e8c008e1d2aa1627de7cc3803188 Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Thu, 3 Sep 2026 20:13:01 -0600 Subject: [PATCH] =?UTF-8?q?fix(=E9=A2=98=E7=9B=AE=E5=88=97=E8=A1=A8):=20?= =?UTF-8?q?=E6=8E=92=E5=BA=8F=E4=B8=8B=E6=8B=89=E6=A1=86=E4=B8=8D=E5=86=8D?= =?UTF-8?q?=E5=A4=9A=E5=87=BA=E4=B8=80=E6=A0=B9=E6=BB=9A=E5=8A=A8=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原来那行 :dropdown-style 是无效的 —— NSelect 没有这个 prop(只有 menu-props),写了会当普通属性掉到根节点上。真正卡高度的是 naive-ui InternalSelectMenu 主题里的 height: calc(var(--n-option-height) * 7.6), 作用在菜单内部的 .n-scrollbar 上。8 条排序项 280px 超出 258.4px 半条, 逼出一根只能滚 22px 的滚动条。 改走 theme-overrides,按选项条数算高度,以后加减排序项自动跟着走。 Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01Sy3L9zJHiSNFyNC3ZbMwdj --- apps/web/src/oj/problem/list.vue | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/apps/web/src/oj/problem/list.vue b/apps/web/src/oj/problem/list.vue index 32516b2..b96bed7 100644 --- a/apps/web/src/oj/problem/list.vue +++ b/apps/web/src/oj/problem/list.vue @@ -47,6 +47,19 @@ const sortOptions = [ { label: "语法检查", value: "ast" }, ] +// naive-ui 下拉菜单默认只给 7.6 个选项的高度(InternalSelectMenu 主题里的 +// height: calc(var(--n-option-height) * 7.6)),8 条排序正好多出半条,逼出一根 +// 只能滚两像素的滚动条。按实际条数放开,+8px 是菜单自己的上下内边距。 +// 注意:NSelect 没有 dropdown-style 这个 prop,写了会当普通属性掉到根节点上 +// 不起作用;控制高度只能走 peers.InternalSelectMenu。 +const sortMenuTheme = { + peers: { + InternalSelectMenu: { + height: `calc(var(--n-option-height) * ${sortOptions.length} + 8px)`, + }, + }, +} + const router = useRouter() const userStore = useUserStore() @@ -250,7 +263,7 @@ function rowProps(row: ProblemFiltered) { style="width: 120px" v-model:value="query.sort" :options="sortOptions" - :dropdown-style="{ maxHeight: 'unset' }" + :theme-overrides="sortMenuTheme" />