modified: begushiybashkir/bbvue/src/main.js

modified:   begushiybashkir/bbvue/src/stores/auth.js
	new file:   begushiybashkir/bbvue/src/stores/helpers/api.js
	new file:   begushiybashkir/bbvue/src/stores/index.js
	new file:   begushiybashkir/bbvue/src/stores/plugins/persistence.js
	modified:   begushiybashkir/bbvue/src/stores/user.js
	modified:   serv_nginx/api_bb/internal/models/user.go
	new file:   serv_nginx/api_bb/internal/models/workout.go
fix save store, add helpers, add new models
This commit is contained in:
2025-10-12 06:11:54 +05:00
parent fd9be2199c
commit 237ee6742e
8 changed files with 229 additions and 201 deletions
+2 -32
View File
@@ -1,44 +1,14 @@
import './assets/main.css'
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import pinia from './stores'
import App from './App.vue'
import router from './router'
import axios from 'axios'
// Глобальная конфигурация axios
axios.defaults.baseURL = 'https://begushiybashkir.ru/api/v1'
axios.defaults.withCredentials = true // Для работы с куками
// Интерцептор для автоматического добавления токена
axios.interceptors.request.use((config) => {
const token = localStorage.getItem('auth_token')
if (token) {
config.headers.Authorization = `Bearer ${token}`
}
return config
})
// Интерцептор для обработки ошибок авторизации
axios.interceptors.response.use(
(response) => response,
(error) => {
if (error.response?.status === 401) {
// Токен истек или невалиден
const authStore = useAuthStore()
authStore.clearToken()
authStore.clearUser()
window.location.href = '/login'
}
return Promise.reject(error)
}
)
const app = createApp(App)
app.use(createPinia())
app.use(pinia)
app.use(router)
// Инициализация auth store после создания app