From e7d455932510f0c39830e408c87b9fcd324a429c Mon Sep 17 00:00:00 2001 From: click33 <36243476+click33@users.noreply.github.com> Date: Tue, 1 Apr 2025 06:47:28 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E5=A4=9A=E8=B4=A6=E5=8F=B7=E6=A8=A1?= =?UTF-8?q?=E5=BC=8FQA=EF=BC=9A=E5=9C=A8=E4=B8=80=E4=B8=AA=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E9=87=8C=E8=8E=B7=E5=8F=96=E6=98=AF=E5=93=AA=E4=B8=AA?= =?UTF-8?q?=E4=BD=93=E7=B3=BB=E7=9A=84=E8=B4=A6=E5=8F=B7=E6=AD=A3=E5=9C=A8?= =?UTF-8?q?=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sa-token-doc/plugin/thymeleaf-extend.md | 1 - sa-token-doc/up/many-account.md | 26 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/sa-token-doc/plugin/thymeleaf-extend.md b/sa-token-doc/plugin/thymeleaf-extend.md index 93a75bc2..e3f8b557 100644 --- a/sa-token-doc/plugin/thymeleaf-extend.md +++ b/sa-token-doc/plugin/thymeleaf-extend.md @@ -24,7 +24,6 @@ implementation 'cn.dev33:sa-token-thymeleaf:${sa.top.version}' ``` -123 ### 2、注册标签方言对象 在 SaTokenConfigure 配置类中注册 Bean diff --git a/sa-token-doc/up/many-account.md b/sa-token-doc/up/many-account.md index 800d50a5..a4a504af 100644 --- a/sa-token-doc/up/many-account.md +++ b/sa-token-doc/up/many-account.md @@ -288,6 +288,32 @@ public void addInterceptors(InterceptorRegistry registry) { ``` +### 11、在一个接口里获取是哪个体系的账号正在登录 + +可以分别用两个体系的 isLogin() 方法去判断,哪个返回 true 就代表正在登录哪个体系 + +``` java +@RequestMapping("test") +public SaResult test2() { + + String loginType = ""; + + if(StpUtil.isLogin()) { + loginType = StpUtil.getLoginType(); + } + if(StpUserUtil.isLogin()) { + loginType = StpUserUtil.getLoginType(); + } + + System.out.println("当前登录的 loginType:" + loginType); + + return SaResult.ok(); +} +``` + +请注意此处可能出现的两种边际情况: +- 两个 if 均返回 false:代表客户端在两个账号体系都没有登录。 +- 两个 if 均返回 true:代表客户端在两个账号体系都登录了。