fix: 在目录选择器不可用时降级为浏览器下载 - #198
Open
iamkuangzhang wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
修改说明
这个 PR 修复自托管 HTTP/IP 访问场景下,部分导出按钮可能无响应的问题。
在普通 HTTP 或服务器 IP 访问页面时,浏览器通常不是 secure context,
window.showDirectoryPicker()不可用。原导出流程会优先申请目录写入权限,因此 HTML / TXT / Markdown / Word / PDF 等导出方式在这类环境下可能无法继续执行。简单来说就是我把本项目部署到云上如果没有配置HTTPS就没法通过HTML / TXT / Markdown / Word / PDF 等方式导出。
本次修改增加了导出降级逻辑:
showDirectoryPicker()的 HTTPS / localhost 环境:保留原有目录导出行为showDirectoryPicker()或当前页面不是 secure context:自动降级为普通浏览器下载jszip打包为wechat-articles-html.zipfile-saver直接下载文件验证情况
已在自托管 HTTP 环境中验证:
本地检查: