Skip to content

fix: screen should not flash in the dark mode #14

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

Merged
merged 1 commit into from
Jun 22, 2025

Conversation

YDX-2147483647
Copy link
Member

@YDX-2147483647 YDX-2147483647 commented Jun 22, 2025

pnpm build && pnpm preview没问题了。

pnpm dev还是闪屏,因为 vite 热重载的脚本需要type=module,加载得晚。

Copy link

netlify bot commented Jun 22, 2025

Deploy Preview for clreq-gap-typst ready!

Name Link
🔨 Latest commit
🔍 Latest deploy log https://app.netlify.com/projects/clreq-gap-typst/deploys/6857d896bf93d950f0d907c7
😎 Deploy Preview https://deploy-preview-14--clreq-gap-typst.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

Diff between #14 and main

Feedback

Copy link
Contributor

@Copilot Copilot AI left a comment

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 addresses the screen flashing issue in dark mode by ensuring that the theme script is loaded early and properly configured during development and production builds.

  • Added a theme entry in vite.config.ts to support early theme loading.
  • Updated typ/packages/vite.typ to handle scripts with the #nomodule suffix and refined the script loader logic.
  • Introduced src/theme.ts to apply the theme before DOM load and removed its import from src/main.ts, updating index.typ accordingly.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
vite.config.ts Added the theme entry to include the early loading of the theme script.
typ/packages/vite.typ Modified the script loader to parse raw paths and handle the #nomodule suffix.
src/theme.ts Introduced a pre-DOM theme application script and updated the toggle logic.
src/main.ts Removed the theme import to avoid late loading.
index.typ Updated file loading to include the theme script with #nomodule in dev mode.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@YDX-2147483647
Copy link
Member Author

目录还会闪一下,不过先记在 #16,下次解决吧。

@YDX-2147483647 YDX-2147483647 merged commit 4fb6f67 into typst-doc-cn:main Jun 22, 2025
8 checks passed
@YDX-2147483647 YDX-2147483647 deleted the dark branch June 22, 2025 13:42
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.

1 participant