diff --git a/TeXmacs/plugins/account/progs/liii/account.scm b/TeXmacs/plugins/account/progs/liii/account.scm index e76cbb38e24b849ff00a204b8ab6ff8ddf05b398..aa363966ba41550e5c6ce99241094e79adabcb6f 100644 --- a/TeXmacs/plugins/account/progs/liii/account.scm +++ b/TeXmacs/plugins/account/progs/liii/account.scm @@ -17,7 +17,7 @@ ; ((== key "scope") "user+llm") ; ((== key "port") "1895") ; ((== key "user-info-url") "http://www.liiistem.cn/api/oauthUser/info") -; ((== key "pricing-url") "https://liiistem.cn/pricing-fruit.html") +; ((== key "pricing-url") "http://www.liiistem.cn/pricing-fruit.html") ; (else ""))) ;; 测试 @@ -29,7 +29,7 @@ ((== key "scope") "user+llm") ((== key "port") "1895") ((== key "user-info-url") "http://test-www.liiistem.cn/api/oauthUser/info") - ((== key "pricing-url") "https://test-liiistem.cn/pricing-fruit.html") + ((== key "pricing-url") "http://test-www.liiistem.cn/pricing-fruit.html") (else ""))) ;; 本地 @@ -42,7 +42,7 @@ ; ((== key "scope") "user+llm") ; ((== key "port") "1895") ; ((== key "user-info-url") "http://127.0.0.1:8080/api/oauthUser/info") -; ((== key "pricing-url") "https://test-liiistem.cn/pricing-fruit.html") +; ((== key "pricing-url") "http://test-www.liiistem.cn/pricing-fruit.html") ; (else ""))) diff --git a/devel/200_33.md b/devel/200_33.md index 02e127c7c871b96dd625ab17a24c3ce1d1644480..2c85a043a7806f9d734dbfe8cb35dfbd3966802b 100644 --- a/devel/200_33.md +++ b/devel/200_33.md @@ -7,8 +7,12 @@ ### 测试数据(当前使用) ##### 测试数据 +1. 会员账号: - **邮箱**: zhangjiadong2019@163.com - **密码**: 123456 +2. 非会员账号 +- **邮箱**: 13326159240@163.com +- **密码**: 123456 ##### 模拟数据 - **位置**: `src/Plugins/Qt/qt_tm_widget.cpp` @@ -41,10 +45,13 @@ - `triggerOAuth2()` - 触发OAuth2认证流程 - `updateDialogContent()` - 更新对话框内容 -## next tips -- [ ] 退出按钮 -- [ ] 跳转自动登陆官网页面 -- [ ] 登陆按钮美化 +## 2025/11/21 跳转实现自动登陆 +### 如何测试 +- 用户非会员:用户点击登录按钮 → 显示登录对话框 → 用户点击登录按钮 → 浏览器打开认证页面 → 用户完成认证 → 再次点击登录按钮 → 对话框出现注册会员按钮 → 点击该按钮 → 跳转到订阅网页可直接购买会员 + +### Why +- 优化前:目前的实现会影响用户购买会员的体验,比如用户点击注册会员按钮后,跳转到官网的购买会员链接,但是由于用户在官网没有登陆,那么是无法购买会员(购买会员需要在官网登陆),所以需要用户在官网再次登陆,影响用户的体验。 +- 优化后:优化用户的体验,用户点击注册会员按钮后,跳转到官网自定实现登陆,通过技术的处理,不需要再次做登陆操作。 ## 2025/11/20 登录板块ui优化 diff --git a/src/Plugins/Qt/qt_tm_widget.cpp b/src/Plugins/Qt/qt_tm_widget.cpp index 37619a8cb2848d6f2e57534a8db00d223a4c9a09..e0f72d34479c8a8aa363838b249e10c8d2f20ba5 100644 --- a/src/Plugins/Qt/qt_tm_widget.cpp +++ b/src/Plugins/Qt/qt_tm_widget.cpp @@ -1722,17 +1722,76 @@ qt_tm_widget_rep::setupLoginDialog (QWK::LoginDialog* loginDialog) { triggerOAuth2 (); } else if (loginActionButton->text () == qt_translate ("注册会员")) { - // 打开第三方注册链接 + /* + 1. 用户点击"注册会员"按钮 + 2. 系统获取本地token + 3. 发送带Authorization Header的HTTP请求到定价页面 + 4. 网页端根据Header识别用户身份 + */ eval ("(use-modules (liii account))"); - string pricingUrl= - as_string (call ("account-oauth2-config", "pricing-url")); - QDesktopServices::openUrl (QUrl (to_qstring (pricingUrl))); + string pricingUrl=as_string (call ("account-oauth2-config", "pricing-url")); + string token = as_string (call ("account-load-token")); + QString q_token= to_qstring (token); + + if (!q_token.isEmpty ()) { + // 使用QNetworkAccessManager发送带Authorization Header的请求 + QNetworkAccessManager* manager= new QNetworkAccessManager (); + QNetworkRequest request (QUrl (to_qstring (pricingUrl))); + + // 去掉token末尾的'˙'字符 + QString clean_token= q_token; + if (clean_token.endsWith ("˙")) { + clean_token= clean_token.left (clean_token.length () - 1); + } + + // 设置Authorization Header + QString auth_header= "Bearer " + clean_token; + request.setRawHeader ("Authorization", auth_header.toUtf8 ()); + + QNetworkReply* reply= manager->get (request); + + // 连接信号处理响应 + QObject::connect (reply, &QNetworkReply::finished, [reply, manager, pricingUrl] () { + if (reply->error () == QNetworkReply::NoError) { + // 获取重定向URL或原始URL + QVariant redirectUrl= reply->attribute (QNetworkRequest::RedirectionTargetAttribute); + QUrl finalUrl; + if (redirectUrl.isValid ()) { + finalUrl= redirectUrl.toUrl (); + } else { + finalUrl= reply->url (); + } + + // 在浏览器中打开最终URL + if (finalUrl.isValid ()) { + QDesktopServices::openUrl (finalUrl); + } + } else { + // 网络错误,直接打开原始URL + QDesktopServices::openUrl (QUrl (to_qstring (pricingUrl))); + } + + // 清理资源 + reply->deleteLater (); + manager->deleteLater (); + }); + } else { + // 没有token,直接打开URL + QDesktopServices::openUrl (QUrl (to_qstring (pricingUrl))); + } } }); } void qt_tm_widget_rep::checkLocalTokenAndLogin () { + // 检查是否为社区版本,如果是则打开官方网址 + if (is_community_stem ()) { + string pricingUrl=as_string (call ("account-oauth2-config", "pricing-url")); + QDesktopServices::openUrl (QUrl (to_qstring (pricingUrl))); + return; + } + // 使用scheme代码获取本地token缓存 eval ("(use-modules (liii account))"); string token = as_string (call ("account-load-token")); diff --git a/src/System/Misc/tm_sys_utils.cpp b/src/System/Misc/tm_sys_utils.cpp index 76ba0d2e11ff581feae394124213e80aeceb83f1..d1c0c513e22fce41fdb070fd9a3b43563660ca04 100644 --- a/src/System/Misc/tm_sys_utils.cpp +++ b/src/System/Misc/tm_sys_utils.cpp @@ -237,3 +237,16 @@ system_wait (string message, string argument, int level) { } else the_wait_handler (message, argument, level); } + +/****************************************************************************** + * Community version check + ******************************************************************************/ + +bool +is_community_stem () { +#ifdef IS_COMMUNITY + return true; +#else + return false; +#endif +} diff --git a/src/System/Misc/tm_sys_utils.hpp b/src/System/Misc/tm_sys_utils.hpp index 94a8999de123d93af508cfc8be96e5062eaf0c64..38d32c7c899248c25eef52653759191b5eb957ce 100644 --- a/src/System/Misc/tm_sys_utils.hpp +++ b/src/System/Misc/tm_sys_utils.hpp @@ -42,4 +42,6 @@ void open_url (url u); void set_wait_handler (void (*) (string, string, int)); void system_wait (string message, string argument= "", int level= 0); +bool is_community_stem (); + #endif diff --git a/src/System/config.h.xmake b/src/System/config.h.xmake index 2433997e9803c8d776a99e1b6f104761e351ff7b..7b31e606750359375d9373918ab9e6ca44dec93a 100644 --- a/src/System/config.h.xmake +++ b/src/System/config.h.xmake @@ -85,3 +85,5 @@ ${define USE_PLUGIN_SPARKLE} /* Use MuPDF library */ ${define USE_MUPDF_RENDERER} + +${define IS_COMMUNITY} diff --git a/xmake.lua b/xmake.lua index 8b6e1f33025149757be68b812d5ef9d4e003dd92..b6ffa425467721029080c48b7cea7c1add909a69 100644 --- a/xmake.lua +++ b/xmake.lua @@ -24,6 +24,14 @@ option_end() -- Temporary statement to move into MuPDF set_config("mupdf", true) +-- Adjust community or commercial version +option("is_community") + set_default(true) + set_description("Adjust community or commercial version") +option_end() + +set_config("is_community", true) + -- Generate build/config.h from template add_configfiles("src/System/config.h.xmake", { filename = "config.h", @@ -55,6 +63,7 @@ add_configfiles("src/System/config.h.xmake", { USE_FONTCONFIG = true, PDFHUMMUS_NO_TIFF = true, USE_MUPDF_RENDERER = has_config("mupdf"), + IS_COMMUNITY = has_config("is_community"), } }) @@ -627,6 +636,7 @@ target("libmogan") do USE_PLUGIN_SPARKLE = false, USE_PLUGIN_HTML = true, USE_MUPDF_RENDERER = has_config("mupdf"), + IS_COMMUNITY = has_config("is_community"), }}) if is_plat("linux") then