Skip to content
This repository was archived by the owner on Jul 17, 2026. It is now read-only.

🐛 fix: update dialog hyperlinks opening in Electron window - #616

Merged
imsyy merged 2 commits into
SPlayer-Dev:devfrom
uarix:dev
Dec 7, 2025
Merged

imsyy merged 2 commits into
SPlayer-Dev:devfrom
uarix:dev

Conversation

@uarix

@uarix uarix commented Dec 6, 2025

Copy link
Copy Markdown
Contributor

修复了点击更新弹窗中的 Github 超链接会在 Electron 窗口内直接跳转,导致用户被困在更新页面的问题。

这个 PR 在 UpdateApp.vue 的 Markdown 容器中增加了点击处理逻辑来拦截链接,使用 window.open(href, '_blank') 从而触发主窗口现有的 setWindowOpenHandler 配置,调用系统浏览器来打开这些 URL。

Added a click handler for markdown links to open them in system browser.
Copilot AI review requested due to automatic review settings December 6, 2025 11:56
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @uarix, 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!

此拉取请求旨在修复一个关键的用户体验问题,即当用户点击更新弹窗中发布的 GitHub 超链接时,链接会在 Electron 应用程序内部打开,导致用户无法正常浏览外部内容并可能被困在更新页面。通过引入一个事件处理机制,现在所有此类链接都将被正确地重定向到用户的系统默认浏览器中打开,从而提供更流畅和预期的交互体验。

Highlights

  • 修复更新弹窗链接行为: 解决了更新弹窗中的 GitHub 超链接在 Electron 窗口内打开的问题,避免用户被困在更新页面。
  • 外部浏览器打开链接: 确保所有更新日志中的外部链接通过系统默认浏览器打开,提供更流畅的用户体验。
  • 添加点击事件处理: 在 UpdateApp.vue 的 Markdown 容器中新增了 handleMarkdownClick 方法来拦截并处理链接点击事件。
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. ↩

Copilot AI left a comment

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.

Pull request overview

This PR fixes an issue where clicking hyperlinks in the update dialog's release notes would open within the Electron window instead of the system browser, causing users to get stuck on the update page.

Key Changes

  • Added click event handler to the markdown container to intercept link clicks
  • Implemented handleMarkdownClick function that prevents default behavior and uses window.open(href, '_blank') to trigger the main window's setWindowOpenHandler configuration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/components/Modal/UpdateApp.vue Outdated
if (target.tagName?.toUpperCase() === "A") {
event.preventDefault();
const href = target.getAttribute("href");
if (href) {

Copilot AI Dec 6, 2025

Copy link

Choose a reason for hiding this comment

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

The href attribute obtained from the link should be validated before opening to prevent potential XSS attacks through javascript: or data: URLs. Consider adding validation to only allow http:// and https:// protocols, similar to the check in main-window.ts:

if (href && (href.startsWith("https://") || href.startsWith("http://"))) {
  window.open(href, "_blank");
}
Suggested change
if (href) {
if (href && (href.startsWith("https://") || href.startsWith("http://"))) {

Copilot uses AI. Check for mistakes.

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

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.

Code Review

本次 PR 旨在修复更新弹窗中链接点击的问题,通过拦截 Markdown 内容中的链接点击,并使用 window.open 在系统浏览器中打开,避免了在 Electron 窗口内跳转。整体实现方向正确,但存在一些可以改进的地方。

我提出了两点建议:

  1. 增强链接点击处理的健壮性,以正确处理链接中包含其他 HTML 元素的情况。
  2. 出于安全考虑,建议对通过 v-html 渲染的外部内容进行净化,以防范潜在的 XSS 攻击。

这些修改将使新功能更加可靠和安全。

Comment on lines +44 to +54
const handleMarkdownClick = (event: MouseEvent) => {
const target = event.target as HTMLElement;
// 检查是否点击的是链接
if (target.tagName?.toUpperCase() === "A") {
event.preventDefault();
const href = target.getAttribute("href");
if (href) {
window.open(href, "_blank");
}
}
};

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

当前实现只检查 event.target 是否为 <a> 标签。如果链接内嵌了其他 HTML 元素(例如 <a><strong>text</strong></a>),点击 <strong> 元素时 event.target 将是 <strong> 而不是 <a>,导致链接点击失效。

建议使用 element.closest('a') 从事件目标向上查找最近的 <a> 标签,这样可以更可靠地处理所有内嵌元素的链接点击,使代码更健壮。

const handleMarkdownClick = (event: MouseEvent) => {
  const target = event.target as HTMLElement;
  // 从事件目标向上遍历,查找最近的 <a> 标签
  const anchor = target.closest('a');

  // 如果找到了 <a> 标签并且它有 href 属性
  if (anchor?.href) {
    // 阻止默认的导航行为
    event.preventDefault();
    // 使用 window.open 在用户的默认浏览器中打开链接
    window.open(anchor.href, '_blank');
  }
};

Comment thread src/components/Modal/UpdateApp.vue
@uarix uarix changed the title 🐛 Fix update dialog hyperlinks opening in Electron window 🐛 fix: update dialog hyperlinks opening in Electron window Dec 7, 2025
@imsyy
imsyy merged commit 47ec9c7 into SPlayer-Dev:dev Dec 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants