Conversation
…direct - Add GOOGLE_ANALYTICS_ID to backend Settings and .env.example - Pass google_analytics_id through /config/frontend API endpoint - Frontend dynamically configures vue-gtag from backend config instead of hardcoded ID - Improve login page redirect: also check auth_provider on /login route so that auth_provider=none users are redirected away from login page immediately Co-authored-by: Simpleyyt <simpleyyt@gmail.com>
- Cache config load failure (set isClientConfigLoaded=true on error) so subsequent navigations don't retry the request every time - Add configFailed early-return branch in route guard: when config is unavailable, fall back to pure token-based checks without authProvider-dependent redirects, avoiding redirect loops - Export isConfigLoadFailed() and resetCachedClientConfig() for consumers that need to check or retry Co-authored-by: Simpleyyt <simpleyyt@gmail.com>
The normal guard branches already degrade correctly when authProvider is null (config unavailable): 'none' checks won't match, so it falls through to pure token-based logic. No special configFailed branch needed. Co-authored-by: Simpleyyt <simpleyyt@gmail.com>
When config fetch fails authProvider is null. Treat it the same as 'none' — let the user through instead of bouncing to /login where the server is equally unreachable. Co-authored-by: Simpleyyt <simpleyyt@gmail.com>
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.
Summary
Google Analytics 配置外置
G-XCRZ3HH31S) 从frontend/src/main.ts中移除Settings中新增google_analytics_id配置项,通过.env环境变量设置/api/v1/config/frontend接口将google_analytics_id传递给前端vue-gtag,未配置时不加载 GA登录页跳转优化
/login路由也检查auth_providerauth_provider=none时,访问/login会立即重定向到首页authProvider为null(服务端不可用)时,与none同等处理——放行用户,不跳/login服务端不可用时防止路由跳转循环
getCachedClientConfig()请求失败时标记isClientConfigLoaded=true,缓存失败结果,避免每次导航都重试authProvider为null时守卫直接放行,不会把用户踢到同样不可用的/loginChanged Files
backend/app/core/config.pygoogle_analytics_id设置backend/app/interfaces/schemas/config.pyClientConfigResponse新增google_analytics_id字段backend/app/interfaces/api/config_routes.pygoogle_analytics_idfrontend/src/api/config.tsgoogle_analytics_id;失败时缓存结果避免重复请求frontend/src/main.tsauthProvider为null时放行.env.exampleGOOGLE_ANALYTICS_ID模板