From 61fcd77fcd7cad11200022f30b77aba72f481880 Mon Sep 17 00:00:00 2001 From: jiadong Date: Fri, 21 Nov 2025 11:43:33 +0800 Subject: [PATCH 1/4] =?UTF-8?q?[200=5F33]=20=E7=99=BB=E9=99=86=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E5=AE=9E=E7=8E=B0-=E8=B7=B3=E8=BD=AC=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E8=87=AA=E5=8A=A8=E7=99=BB=E9=99=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- devel/200_33.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/devel/200_33.md b/devel/200_33.md index 02e127c7c..b45dca4c0 100644 --- a/devel/200_33.md +++ b/devel/200_33.md @@ -41,10 +41,13 @@ - `triggerOAuth2()` - 触发OAuth2认证流程 - `updateDialogContent()` - 更新对话框内容 -## next tips -- [ ] 退出按钮 -- [ ] 跳转自动登陆官网页面 -- [ ] 登陆按钮美化 +## 2025/11/21 跳转实现自动登陆 +### 如何测试 +- 用户非会员:用户点击登录按钮 → 显示登录对话框 → 用户点击登录按钮 → 浏览器打开认证页面 → 用户完成认证 → 再次点击登录按钮 → 对话框出现注册会员按钮 → 点击该按钮 → 跳转到订阅网页可直接购买会员 + +### Why +- 优化前:目前的实现会影响用户购买会员的体验,比如用户点击注册会员按钮后,跳转到官网的购买会员链接,但是由于用户在官网没有登陆,那么是无法购买会员(购买会员需要在官网登陆),所以需要用户在官网再次登陆,影响用户的体验。 +- 优化后:优化用户的体验,用户点击注册会员按钮后,跳转到官网自定实现登陆,通过技术的处理,不需要再次做登陆操作。 ## 2025/11/20 登录板块ui优化 -- Gitee From 94a52e89a3e5d42ee7f5c0caa9c878db4e2198f1 Mon Sep 17 00:00:00 2001 From: jiadong Date: Fri, 21 Nov 2025 11:56:33 +0800 Subject: [PATCH 2/4] =?UTF-8?q?wip=20=E8=AF=B7=E6=B1=82=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Plugins/Qt/qt_tm_widget.cpp | 60 ++++++++++++++++++++++++++++++--- 1 file changed, 56 insertions(+), 4 deletions(-) diff --git a/src/Plugins/Qt/qt_tm_widget.cpp b/src/Plugins/Qt/qt_tm_widget.cpp index 37619a8cb..6fa7142d8 100644 --- a/src/Plugins/Qt/qt_tm_widget.cpp +++ b/src/Plugins/Qt/qt_tm_widget.cpp @@ -1722,11 +1722,63 @@ 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))); + } } }); } -- Gitee From c477ad57309526edcd726bfa2587a01791061344 Mon Sep 17 00:00:00 2001 From: jiadong Date: Fri, 21 Nov 2025 14:29:45 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=AE=98=E7=BD=91=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TeXmacs/plugins/account/progs/liii/account.scm | 6 +++--- devel/200_33.md | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/TeXmacs/plugins/account/progs/liii/account.scm b/TeXmacs/plugins/account/progs/liii/account.scm index e76cbb38e..aa363966b 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 b45dca4c0..2c85a043a 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` -- Gitee From a4a15c59a7c64daae28630fa75c1bd7253336a8a Mon Sep 17 00:00:00 2001 From: jiadong Date: Fri, 21 Nov 2025 20:27:34 +0800 Subject: [PATCH 4/4] wip --- src/Plugins/Qt/qt_tm_widget.cpp | 7 +++++++ src/System/Misc/tm_sys_utils.cpp | 13 +++++++++++++ src/System/Misc/tm_sys_utils.hpp | 2 ++ src/System/config.h.xmake | 2 ++ xmake.lua | 10 ++++++++++ 5 files changed, 34 insertions(+) diff --git a/src/Plugins/Qt/qt_tm_widget.cpp b/src/Plugins/Qt/qt_tm_widget.cpp index 6fa7142d8..e0f72d344 100644 --- a/src/Plugins/Qt/qt_tm_widget.cpp +++ b/src/Plugins/Qt/qt_tm_widget.cpp @@ -1785,6 +1785,13 @@ qt_tm_widget_rep::setupLoginDialog (QWK::LoginDialog* loginDialog) { 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 76ba0d2e1..d1c0c513e 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 94a8999de..38d32c7c8 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 2433997e9..7b31e6067 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 8b6e1f330..b6ffa4254 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 -- Gitee