-
Notifications
You must be signed in to change notification settings - Fork 35
优化了一些内容 #658
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
优化了一些内容 #658
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,21 @@ | ||
| { | ||
| "name": "Alas Web UI", | ||
| "short_name": "Alas", | ||
| "start_url": "/?app=index", | ||
| "start_url": "../../../?app=index", | ||
| "scope": "../../../", | ||
| "display": "standalone", | ||
| "background_color": "#ffffff", | ||
| "theme_color": "#000000", | ||
| "icons": [ | ||
| { | ||
| "src": "/static/assets/spa/spa-icon-192x192.png", | ||
| "src": "spa-icon-192x192.png", | ||
| "sizes": "192x192", | ||
| "type": "image/png" | ||
| }, | ||
| { | ||
| "src": "/static/assets/spa/spa-icon-512x512.png", | ||
| "src": "spa-icon-512x512.png", | ||
| "sizes": "512x512", | ||
| "type": "image/png" | ||
| } | ||
| ] | ||
| } | ||
| } |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| from typing import Optional | ||
|
|
||
| import requests | ||
|
|
||
|
|
||
| IP9_LOCATION_URL = 'https://ip9.com.cn/get' | ||
|
|
||
|
|
||
| def get_country_code(timeout=5) -> Optional[str]: | ||
| """查询当前公网 IP 所在国家的 ISO 代码。 | ||
|
|
||
| 查询失败或响应格式不符合预期时返回 ``None``,调用方应保留当前更新源。 | ||
| """ | ||
| try: | ||
| response = requests.get( | ||
| IP9_LOCATION_URL, | ||
| timeout=timeout, | ||
| headers={'User-Agent': 'AzurPilot'}, | ||
| ) | ||
| response.raise_for_status() | ||
| payload = response.json() | ||
| except (requests.RequestException, ValueError): | ||
| return None | ||
|
|
||
| try: | ||
| country_code = payload['data']['country_code'] | ||
| except (KeyError, TypeError): | ||
| return None | ||
|
|
||
| if isinstance(country_code, str): | ||
| return country_code.lower() | ||
| return None |
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (bug_risk): Handle missing/invalid asset files in _versioned_static_asset to avoid startup-time crashes.
If this file doesn’t exist or the path is wrong, this will raise (e.g.
FileNotFoundError) whenINITIAL_WEBUI_CSSis resolved and can prevent the app from starting. Please catch file/IO errors here and either fall back to an unversioned path or return/log a safe default so a missing asset doesn’t break the web UI.Original comment in English
issue (bug_risk): Handle missing/invalid asset files in _versioned_static_asset to avoid startup-time crashes.
If this file doesn’t exist or the path is wrong, this will raise (e.g.
FileNotFoundError) whenINITIAL_WEBUI_CSSis resolved and can prevent the app from starting. Please catch file/IO errors here and either fall back to an unversioned path or return/log a safe default so a missing asset doesn’t break the web UI.