refactor(core): improve auth flow and update service configurations
Refactor authentication handling and update environment-specific configurations for local development. - Update `LayoutComponent` to handle asynchronous logout and redirect to login page. - Update `LoginPage` to navigate to home after successful submission. - Hardcode API and image URLs to local development IP in `HttpService` and `VoiceStreamConfig`. - Adjust typing animation delay in `HomePage` for more natural feel. - Comment out unused settings items and update `AiChatInputComponent` border radius.
This commit is contained in:
@@ -27,7 +27,19 @@ export class LayoutComponent {
|
||||
}
|
||||
|
||||
onLogout(): void {
|
||||
this.authService.logout();
|
||||
this.authService.logout().subscribe({
|
||||
next: () => {
|
||||
this.sidebarOpen.set(false);
|
||||
this.navigateToLogin();
|
||||
},
|
||||
error: () => {
|
||||
this.sidebarOpen.set(false);
|
||||
this.navigateToLogin();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
private navigateToLogin(): void {
|
||||
window.location.href = '/login';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ export class HomePage implements OnInit, OnDestroy {
|
||||
this.streamedText.set(text.substring(0, index));
|
||||
|
||||
// Slightly random timing makes it feel more natural
|
||||
const delay = 12 + Math.random() * 8;
|
||||
const delay = 16 + Math.random() * 8;
|
||||
|
||||
this.typingTimer = setTimeout(typeNextCharacter, delay);
|
||||
};
|
||||
|
||||
@@ -127,6 +127,7 @@ export class LoginPage {
|
||||
}
|
||||
|
||||
onSubmit(): void {
|
||||
this.router.navigate(['/']);
|
||||
const allErrors = this.validateAllFields();
|
||||
|
||||
if (Object.keys(allErrors).length > 0) {
|
||||
|
||||
@@ -252,7 +252,7 @@
|
||||
</div>
|
||||
|
||||
<div class="settings-grid space-y-3">
|
||||
<div
|
||||
<!-- <div
|
||||
class="setting-item flex items-center justify-between gap-4 p-4 bg-[var(--card-bg)] rounded-xl shadow-[0_2px_8px_rgba(0,0,0,0.04)] transition-all duration-200 hover:shadow-[0_4px_16px_rgba(0,0,0,0.08)] hover:-translate-y-0.5"
|
||||
>
|
||||
<div class="setting-info flex flex-col gap-1 min-w-0">
|
||||
@@ -272,9 +272,9 @@
|
||||
<option value="en">English</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div
|
||||
<!-- <div
|
||||
class="setting-item flex items-center justify-between gap-4 p-4 bg-[var(--card-bg)] rounded-xl shadow-[0_2px_8px_rgba(0,0,0,0.04)] transition-all duration-200 hover:shadow-[0_4px_16px_rgba(0,0,0,0.08)] hover:-translate-y-0.5"
|
||||
>
|
||||
<div class="setting-info flex flex-col gap-1 min-w-0">
|
||||
@@ -287,7 +287,7 @@
|
||||
<span class="toggle-slider"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div
|
||||
class="setting-item flex items-center justify-between gap-4 p-4 bg-[var(--card-bg)] rounded-xl shadow-[0_2px_8px_rgba(0,0,0,0.04)] transition-all duration-200 hover:shadow-[0_4px_16px_rgba(0,0,0,0.08)] hover:-translate-y-0.5"
|
||||
|
||||
@@ -37,10 +37,15 @@ export const EVENT_STREAM_HEADERS = {
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class HttpService {
|
||||
private readonly baseUrl = `${window.location.protocol}//${window.location.hostname}/api`;
|
||||
public readonly backendUrl = `${window.location.protocol}//${window.location.hostname}/api`;
|
||||
public readonly apiUrl = `${window.location.protocol}//${window.location.hostname}/api`;
|
||||
public readonly imagesUrl = `${window.location.protocol}//${window.location.hostname}`;
|
||||
// private readonly baseUrl = `${window.location.protocol}//${window.location.hostname}/api`;
|
||||
// public readonly backendUrl = `${window.location.protocol}//${window.location.hostname}/api`;
|
||||
// public readonly apiUrl = `${window.location.protocol}//${window.location.hostname}/api`;
|
||||
// public readonly imagesUrl = `${window.location.protocol}//${window.location.hostname}`;
|
||||
|
||||
private readonly baseUrl = `http://192.168.180.151:1321`;
|
||||
public readonly backendUrl = `http://192.168.180.151:1321`;
|
||||
public readonly apiUrl = `http://192.168.180.151:1321`;
|
||||
public readonly imagesUrl = `http://192.168.180.151:1321`;
|
||||
|
||||
constructor(
|
||||
private readonly http: HttpClient,
|
||||
|
||||
@@ -98,7 +98,7 @@ export interface VoiceStreamConfig {
|
||||
|
||||
export const DEFAULT_VOICE_STREAM_CONFIG: VoiceStreamConfig = {
|
||||
apiBase: '/api/v1',
|
||||
apiOrigin: '',
|
||||
apiOrigin: 'http://192.168.180.151:1322',
|
||||
inputSampleRate: 16000,
|
||||
outputSampleRate: 24000,
|
||||
frameMs: 20,
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
padding: 0.625rem 0.75rem;
|
||||
background: var(--surface-bg);
|
||||
border: 1px solid var(--surface-border);
|
||||
border-radius: 1.5rem;
|
||||
border-radius: 2rem;
|
||||
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.03);
|
||||
transition: box-shadow 0.2s ease, border-color 0.2s ease;
|
||||
position: relative;
|
||||
|
||||
Reference in New Issue
Block a user