-
Notifications
You must be signed in to change notification settings - Fork 275
feat(social): 实现社交解锁状态管理与多语言支持 #2672
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
Changes from all commits
f5d8621
60187dc
3d40fa1
457b1cb
2cc2cd7
fb0f3f2
5a27377
7062b35
939aecd
2228de5
56cbafc
90cd5e0
08ebc51
3c1cca1
7600458
daeb590
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| import asyncio | ||
| import os | ||
| import secrets | ||
| from urllib.parse import parse_qsl | ||
|
|
||
| import httpx | ||
| from fastapi import Request | ||
|
|
@@ -34,11 +35,29 @@ | |
| logger = runtime.logger | ||
|
|
||
|
|
||
| def _has_generated_asset_version(query_string: bytes) -> bool: | ||
| """Return whether ``v`` is a content-derived version safe to cache immutably.""" | ||
| try: | ||
| query_params = parse_qsl(query_string.decode("ascii"), keep_blank_values=True) | ||
| except UnicodeDecodeError: | ||
| return False | ||
|
|
||
| for key, value in query_params: | ||
| if key != "v": | ||
| continue | ||
| version_tail = value.rsplit("-", 1)[-1] | ||
| if version_tail.isascii() and version_tail.isdigit() and len(version_tail) >= 9: | ||
| return True | ||
| return False | ||
|
|
||
|
|
||
| class CustomStaticFiles(StaticFiles): | ||
| async def get_response(self, path, scope): | ||
| response = await super().get_response(path, scope) | ||
| if path.endswith(".js"): | ||
| response.headers["Content-Type"] = "application/javascript" | ||
| if _has_generated_asset_version(scope.get("query_string", b"")): | ||
| response.headers["Cache-Control"] = "public, max-age=31536000, immutable" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Because this header is now applied solely from the shape of the Useful? React with 👍 / 👎.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 已处理,提交 56cbafc:将 static/social-embed.js 加入 _YUI_GUIDE_ASSET_VERSION_PATHS。现在该文件内容变化会更新 static_asset_version,避免继续复用旧的 immutable 缓存。
Comment on lines
+59
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Fresh evidence after the current fixes: Useful? React with 👍 / 👎.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 已处理,感谢指出。之前版本仅维护了部分静态资源清单,导致模板中的 app-chat.js 等资源单独变更时版本号不会更新。现在 pages_router 会自动扫描 templates 中所有带 static_asset_version 的静态资源引用,并将实际存在的文件加入版本计算,同时保留运行时/非模板资源的手工清单。新增回归测试覆盖全部模板引用;修复已在提交 90cd5e0 中推送。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Fresh evidence after the template-scan fix: Useful? React with 👍 / 👎.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 已处理,提交 7600458。 |
||
| return response | ||
|
|
||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.