|
@@ -59,8 +59,10 @@ export class App implements OnInit {
|
|
|
// Login state
|
|
// Login state
|
|
|
needLogin = false;
|
|
needLogin = false;
|
|
|
loggedInUser: string = '';
|
|
loggedInUser: string = '';
|
|
|
|
|
+ sessionToken: string = '';
|
|
|
apigList: ApigData[] = [];
|
|
apigList: ApigData[] = [];
|
|
|
apigListLoading = false;
|
|
apigListLoading = false;
|
|
|
|
|
+ tokenCopied = false;
|
|
|
|
|
|
|
|
// State
|
|
// State
|
|
|
apig: ApigData | null = null;
|
|
apig: ApigData | null = null;
|
|
@@ -116,6 +118,7 @@ export class App implements OnInit {
|
|
|
console.log('[AUTH] 从 localStorage 恢复用户:', cachedUserId);
|
|
console.log('[AUTH] 从 localStorage 恢复用户:', cachedUserId);
|
|
|
this.userId = cachedUserId;
|
|
this.userId = cachedUserId;
|
|
|
this.loggedInUser = cachedUserId;
|
|
this.loggedInUser = cachedUserId;
|
|
|
|
|
+ this.sessionToken = cachedToken;
|
|
|
// 后台验证 token 是否还有效
|
|
// 后台验证 token 是否还有效
|
|
|
this.validateCachedToken(cachedToken, cachedUserId);
|
|
this.validateCachedToken(cachedToken, cachedUserId);
|
|
|
if (this.apigId) {
|
|
if (this.apigId) {
|
|
@@ -155,6 +158,7 @@ export class App implements OnInit {
|
|
|
console.log('[AUTH] 登录成功, userId:', event.userId);
|
|
console.log('[AUTH] 登录成功, userId:', event.userId);
|
|
|
this.userId = event.userId;
|
|
this.userId = event.userId;
|
|
|
this.loggedInUser = event.userId;
|
|
this.loggedInUser = event.userId;
|
|
|
|
|
+ this.sessionToken = event.sessionToken;
|
|
|
this.needLogin = false;
|
|
this.needLogin = false;
|
|
|
this.errorMsg = '';
|
|
this.errorMsg = '';
|
|
|
|
|
|
|
@@ -200,6 +204,15 @@ export class App implements OnInit {
|
|
|
window.location.href = url.toString();
|
|
window.location.href = url.toString();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ copyToken(): void {
|
|
|
|
|
+ if (!this.sessionToken) return;
|
|
|
|
|
+ navigator.clipboard.writeText(this.sessionToken).then(() => {
|
|
|
|
|
+ this.tokenCopied = true;
|
|
|
|
|
+ this.cdr.detectChanges();
|
|
|
|
|
+ setTimeout(() => { this.tokenCopied = false; this.cdr.detectChanges(); }, 2000);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// ─── Load APIG Info ───
|
|
// ─── Load APIG Info ───
|
|
|
async loadApig(): Promise<void> {
|
|
async loadApig(): Promise<void> {
|
|
|
try {
|
|
try {
|