Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: reduce global redundant code #1872

Merged
merged 2 commits into from
Dec 20, 2024
Merged

refactor: reduce global redundant code #1872

merged 2 commits into from
Dec 20, 2024

Conversation

wang1212
Copy link
Member

@wang1212 wang1212 commented Dec 19, 2024

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / Document optimization
  • TypeScript definition update
  • Refactoring
  • Performance improvement
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

🔗 Related issue link

💡 Background and solution

There are a lot of direct references to window in the global code, which is strongly coupled with the web platform, and the calculation of dpr is repeated in each renderer. It is easy to maintain by converging it into the core package.

📝 Changelog

Language Changelog
🇺🇸 English refactor: reduce global redundant code
🇨🇳 Chinese refactor: 减少全局冗余代码

☑️ Self Check before Merge

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed


// use user-defined dpr first
let dpr = devicePixelRatio || (isBrowser && window.devicePixelRatio) || 1;
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
Copy link
Member

Choose a reason for hiding this comment

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

这个是默认逻辑,还删除不了吧。

Copy link
Member Author

Choose a reason for hiding this comment

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

收敛到 g-lite 包里面了,以前是 g-lite、以及各个渲染器包里面都写了同样的代码

@wang1212 wang1212 merged commit 244d6dd into release Dec 20, 2024
2 checks passed
@wang1212 wang1212 deleted the chore branch December 20, 2024 06:34
wang1212 added a commit that referenced this pull request Dec 20, 2024
* fix: lineDash支持多位数组 (#1867)

* chore: add changeset

* fix: rendering error when line break appears at the beginning of text (#1871)

* docs: 修复异常示例

* refactor: reduce global redundant code (#1872)

* refactor: reduce global redundant code

* chore: add changeset

* fix: svg path element A command drawing abnormality (#1874)

* Version Packages (#1869)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: HuangLiangchen <[email protected]>
Co-authored-by: wang1212 <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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