mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-07 01:18:27 +08:00
前端展示二维码
This commit is contained in:
parent
474f18f61c
commit
603c3f7a81
@ -56,7 +56,7 @@ public class ScanCodeService {
|
||||
public Long createTicket() {
|
||||
Long ticket = 0L;
|
||||
ticket = Long.parseLong(idGenerator.generate());
|
||||
momentaryService.put(getKey(ticket), "ORCode", Duration.ofSeconds(validitySeconds));
|
||||
momentaryService.put(getKey(ticket), "", Duration.ofSeconds(validitySeconds));
|
||||
_logger.info("Ticket {} , Duration {}", ticket , Duration.ofSeconds(validitySeconds));
|
||||
return ticket;
|
||||
}
|
||||
|
||||
@ -83,9 +83,9 @@
|
||||
</nz-form-item>
|
||||
</div>
|
||||
<div nz-row *ngIf="loginType=='qrscan'">
|
||||
<div class="qrcode" id="div_qrcodelogin" style="background: #fff;padding: 20px;"> </div>
|
||||
<div class="qrcode" id="div_qrcodelogin" style="background: #fff;padding: 20px;"></div>
|
||||
<div id="qrexpire" *ngIf="qrexpire" style="width: 100%;text-align: center;background: #fff;padding-bottom: 20px;">
|
||||
二维码过期 <a href="javascript:" (click)="getLoginQrCode()">刷新</a>
|
||||
二维码过期 <a href="javascript:void(0);" (click)="getLoginQrCode()">刷新</a>
|
||||
</div>
|
||||
</div>
|
||||
<nz-form-item *ngIf="loginType == 'normal' || loginType == 'mobile'">
|
||||
|
||||
@ -299,13 +299,26 @@ export class UserLoginComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
getLoginQrCode() {
|
||||
this.qrCodeService.getLoginQrCode().subscribe(res => {
|
||||
if (res.code === 0) {
|
||||
this.qrexpire = false;
|
||||
|
||||
this.qrCodeService.getLoginQrCode().subscribe(res => {
|
||||
if (res.code === 0 && res.data.rqCode) { // 使用返回的 rqCode
|
||||
const qrImageElement = document.getElementById('div_qrcodelogin');
|
||||
if (qrImageElement) {
|
||||
qrImageElement.innerHTML = `<img src="${res.data.rqCode}" alt="QR Code" style="width: 200px; height: 200px;">`;
|
||||
}
|
||||
|
||||
// 设置三分钟后 qrexpire 为 false
|
||||
setTimeout(() => {
|
||||
this.qrexpire = true;
|
||||
this.cdr.detectChanges(); // 更新视图
|
||||
}, 3 * 60 * 1000); // 180000 毫秒 = 3 分钟
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
getQrCode(): void {
|
||||
this.qrexpire = false;
|
||||
if (this.interval$) {
|
||||
|
||||
@ -25,6 +25,8 @@ import org.dromara.maxkey.authn.LoginCredential;
|
||||
import org.dromara.maxkey.authn.jwt.AuthJwt;
|
||||
import org.dromara.maxkey.authn.jwt.AuthTokenService;
|
||||
import org.dromara.maxkey.authn.provider.AbstractAuthenticationProvider;
|
||||
import org.dromara.maxkey.authn.session.Session;
|
||||
import org.dromara.maxkey.authn.session.SessionManager;
|
||||
import org.dromara.maxkey.authn.support.kerberos.KerberosService;
|
||||
import org.dromara.maxkey.authn.support.rememberme.AbstractRemeberMeManager;
|
||||
import org.dromara.maxkey.authn.support.rememberme.RemeberMe;
|
||||
@ -107,6 +109,9 @@ public class LoginEntryPoint {
|
||||
@Autowired
|
||||
AbstractRemeberMeManager remeberMeManager;
|
||||
|
||||
@Autowired
|
||||
SessionManager sessionManager;
|
||||
|
||||
/**
|
||||
* init login
|
||||
* @return
|
||||
@ -214,7 +219,7 @@ public class LoginEntryPoint {
|
||||
|
||||
/**
|
||||
* normal
|
||||
* @param loginCredential
|
||||
* @param credential
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "登录接口", description = "登录接口",method="POST")
|
||||
@ -254,7 +259,7 @@ public class LoginEntryPoint {
|
||||
|
||||
/**
|
||||
* for congress
|
||||
* @param loginCredential
|
||||
* @param credential
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value={"/congress"})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user