close
Skip to content

perf(UI): 修复「自定义 CSS 字体」开启时修改「全局字体」卡顿#665

Merged
imsyy merged 1 commit intoimsyy:devfrom
MoYingJi:pr/fix-fk
Dec 26, 2025
Merged

perf(UI): 修复「自定义 CSS 字体」开启时修改「全局字体」卡顿#665
imsyy merged 1 commit intoimsyy:devfrom
MoYingJi:pr/fix-fk

Conversation

@MoYingJi
Copy link
Copy Markdown
Collaborator

换成了自定义的 s-input.vue 组件,提供了 update-value-on-input

既然该都改了,那就两个都一起改掉了

换成了自定义的 `s-input.vue` 组件,提供了 `update-value-on-input`

既然该都改了,那就两个都一起改掉了
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @MoYingJi, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求旨在通过优化字体设置输入框的更新机制来提升用户界面的性能。通过引入一个自定义的输入组件,并配置其在用户输入时延迟更新绑定的值,解决了在启用自定义CSS字体时,频繁修改全局字体导致的卡顿问题,从而提供了更流畅的用户体验。

Highlights

  • 性能优化: 修复了在「自定义 CSS 字体」开启时,修改「全局字体」导致的用户界面卡顿问题。
  • 引入自定义输入组件: 将 n-input 组件替换为自定义的 s-input.vue 组件,以更好地控制输入行为。
  • 延迟更新输入值: s-input 组件新增 update-value-on-input 属性,当设置为 false 时,输入框的值只会在失焦或按下回车键时更新,从而避免了频繁的UI重绘。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

你好,感谢你的贡献。这个 PR 通过创建一个自定义的 s-input 组件来解决更新字体时的性能问题,这是一个很好的优化。新的组件通过 update-value-on-input 属性来控制值的更新时机,从而避免了在输入时频繁触发更新导致的卡顿。我对新组件的实现提出了一些建议,主要在于修复一个潜在的 UI 响应问题并提高代码的可读性。请查看具体的审查意见。

Comment on lines +40 to +47
const handleInput = (newValue: string) => {
if (props.updateValueOnInput) {
value.value = newValue;
emit("update:value", newValue);
} else {
input.value = newValue;
}
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

updateValueOnInputtrue 的模式下,handleInput 函数没有更新 input 这个 ref。这可能导致 UI 输入响应延迟或闪烁,因为 <n-input> 的值绑定在 input 上,它需要等待父组件更新 prop 后通过 watch 回调才能更新,而不是在输入时立即更新。建议总是先更新 input 的值来保证 UI 实时响应。

const handleInput = (newValue: string) => {
  input.value = newValue;
  if (props.updateValueOnInput) {
    value.value = newValue;
    emit("update:value", newValue);
  }
};

}>();

const input = ref(props.value); // 内部值
const value = ref(props.value); // 外部值
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

为了提高代码的可读性,建议将 value 这个 ref 重命名为 committedValue 或其他更能表明其用途的名称。当前的命名 valueprops.value 相同,容易引起混淆。这个 ref 实际上是作为已提交值的缓存。如果采纳此建议,请记得更新所有使用到该 ref 的地方 (watch, handleInput, handleConfirm)。

@imsyy imsyy merged commit cae4289 into imsyy:dev Dec 26, 2025
@MoYingJi MoYingJi deleted the pr/fix-fk branch December 26, 2025 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants