✨ feat(src/stores/auth.store.ts): обновляет логику получения пользователя после входа и регистрации
✨ feat(src/components/layout/TauriTitlebar.vue): изменяет название приложения с "Daiting" на "Dating" ✨ feat(src/components/layout/SideNav.vue): изменяет название приложения с "Daiting" на "Dating" ✨ fix(README.md): исправляет название приложения с "Daiting" на "Dating" ✨ fix(src/api/client.ts): обновляет базовый URL API с 'localhost:3000' на 'localhost:1337' ✨ fix(src/views/auth/LoginView.vue): изменяет название приложения с "Daiting" на "Dating" ✨ fix(src/views/auth/RegisterView.vue): изменяет название приложения с "Daiting" на "Dating" ✨ fix(src-tauri/Cargo.toml): исправляет описание приложения с "Daiting" на "Dating" ✨ fix(src-tauri/tauri.conf.json): изменяет имя продукта с "Daiting" на "Dating" ✨ fix(vite.config.ts): обновляет порт разработки с 1420 на 3000 ✨ fix(index.html): изменяет заголовок страницы с "Daiting" на "Dating" ✨ fix(dating-app-frontend-prompt.md): исправляет название приложения с "Daiting" на "Dating" ✨ fix(PRODUCT.md): изменяет название приложения с "Daiting" на "Dating"
This commit is contained in:
@@ -2,7 +2,7 @@ import axios from 'axios';
|
||||
import type { AxiosInstance, InternalAxiosRequestConfig } from 'axios';
|
||||
import { Api, HttpClient } from './api';
|
||||
|
||||
const BASE_URL = import.meta.env.VITE_API_BASE_URL ?? 'http://localhost:3000';
|
||||
const BASE_URL = import.meta.env.VITE_API_BASE_URL ?? 'http://localhost:1337';
|
||||
|
||||
// ─── Raw axios instance with interceptors ────────────────────────────────────
|
||||
|
||||
@@ -36,7 +36,12 @@ function _processQueue(error: unknown, token: string | null) {
|
||||
}
|
||||
|
||||
axiosInstance.interceptors.response.use(
|
||||
(response) => response,
|
||||
(response) => {
|
||||
if (response.data !== null && typeof response.data === 'object' && 'data' in response.data) {
|
||||
response.data = response.data.data;
|
||||
}
|
||||
return response;
|
||||
},
|
||||
async (error) => {
|
||||
const originalRequest = error.config as InternalAxiosRequestConfig & { _retry?: boolean };
|
||||
|
||||
@@ -62,11 +67,11 @@ axiosInstance.interceptors.response.use(
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await axios.post<{ accessToken: string; refreshToken: string }>(
|
||||
const res = await axios.post<{ data: { accessToken: string; refreshToken: string } }>(
|
||||
`${BASE_URL}/api/v1/auth/refresh`,
|
||||
{ refreshToken },
|
||||
);
|
||||
const { accessToken, refreshToken: newRefresh } = res.data;
|
||||
const { accessToken, refreshToken: newRefresh } = res.data.data;
|
||||
_setAccessToken(accessToken);
|
||||
localStorage.setItem('refreshToken', newRefresh);
|
||||
_processQueue(null, accessToken);
|
||||
|
||||
@@ -50,7 +50,7 @@ function toggle() {
|
||||
<div class="sidenav__header">
|
||||
<span class="sidenav__logo">D</span>
|
||||
<Transition name="fade">
|
||||
<span v-if="uiStore.sidebarExpanded" class="sidenav__brand">Daiting</span>
|
||||
<span v-if="uiStore.sidebarExpanded" class="sidenav__brand">Dating</span>
|
||||
</Transition>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ async function closeWindow() {
|
||||
class="titlebar"
|
||||
data-tauri-drag-region
|
||||
>
|
||||
<span class="titlebar__brand">Daiting</span>
|
||||
<span class="titlebar__brand">Dating</span>
|
||||
<div class="titlebar__controls">
|
||||
<button class="titlebar__btn titlebar__btn--minimize" @click="minimize" aria-label="Свернуть" />
|
||||
<button class="titlebar__btn titlebar__btn--maximize" @click="maximize" aria-label="Развернуть" />
|
||||
|
||||
@@ -43,25 +43,20 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
const res = await apiClient.api.authControllerLogin(dto) as unknown as {
|
||||
accessToken: string;
|
||||
refreshToken: string;
|
||||
user: AuthUser;
|
||||
};
|
||||
_setAccessToken(res.accessToken);
|
||||
localStorage.setItem('refreshToken', res.refreshToken);
|
||||
user.value = res.user;
|
||||
if (res.user.profiles.length > 0) {
|
||||
activeProfileId.value = res.user.profiles[0].id;
|
||||
}
|
||||
await fetchMe();
|
||||
}
|
||||
|
||||
async function register(dto: RegisterDto) {
|
||||
const res = await apiClient.api.authControllerRegister(dto) as unknown as {
|
||||
accessToken: string;
|
||||
refreshToken: string;
|
||||
user: AuthUser;
|
||||
};
|
||||
_setAccessToken(res.accessToken);
|
||||
localStorage.setItem('refreshToken', res.refreshToken);
|
||||
user.value = res.user;
|
||||
await fetchMe();
|
||||
}
|
||||
|
||||
async function logout() {
|
||||
@@ -78,7 +73,7 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
async function fetchMe() {
|
||||
const res = await apiClient.api.usersControllerGetMe() as unknown as AuthUser;
|
||||
user.value = res;
|
||||
if (res.profiles.length > 0 && !activeProfileId.value) {
|
||||
if (res.profiles?.length > 0 && !activeProfileId.value) {
|
||||
activeProfileId.value = res.profiles[0].id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ async function submit() {
|
||||
<div class="auth-page__grain" aria-hidden="true" />
|
||||
|
||||
<div class="auth-card">
|
||||
<div class="auth-card__wordmark">Daiting</div>
|
||||
<div class="auth-card__wordmark">Dating</div>
|
||||
<h1 class="auth-card__heading">С возвращением</h1>
|
||||
<p class="auth-card__sub">Войдите, чтобы продолжить</p>
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ async function submit() {
|
||||
<div class="auth-page__grain" aria-hidden="true" />
|
||||
|
||||
<div class="auth-card">
|
||||
<div class="auth-card__wordmark">Daiting</div>
|
||||
<div class="auth-card__wordmark">Dating</div>
|
||||
<h1 class="auth-card__heading">Создать аккаунт</h1>
|
||||
<p class="auth-card__sub">Начните своё путешествие</p>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user