mirror of
https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git
synced 2025-08-14 00:25:46 +02:00
вв222323232231в231
This commit is contained in:
@@ -5,18 +5,19 @@ WORKDIR /app
|
|||||||
# Копируем package.json и package-lock.json
|
# Копируем package.json и package-lock.json
|
||||||
COPY frontend/package*.json ./
|
COPY frontend/package*.json ./
|
||||||
|
|
||||||
|
# Очищаем cache и node_modules
|
||||||
|
RUN npm cache clean --force
|
||||||
|
RUN rm -rf node_modules
|
||||||
|
|
||||||
# Устанавливаем зависимости
|
# Устанавливаем зависимости
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
|
||||||
# Устанавливаем Tailwind и его зависимости
|
|
||||||
RUN npm install -D tailwindcss@latest postcss@latest autoprefixer@latest
|
|
||||||
|
|
||||||
# Инициализируем Tailwind
|
|
||||||
RUN npx tailwindcss init -p
|
|
||||||
|
|
||||||
# Копируем исходный код
|
# Копируем исходный код
|
||||||
COPY frontend/ .
|
COPY frontend/ .
|
||||||
|
|
||||||
|
# Создаем .env файл
|
||||||
|
RUN echo "VITE_API_URL=/api" > .env
|
||||||
|
|
||||||
# Открываем порт для Vite
|
# Открываем порт для Vite
|
||||||
EXPOSE 5173
|
EXPOSE 5173
|
||||||
|
|
||||||
|
|||||||
@@ -10,12 +10,12 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@vueuse/core": "^10.9.0",
|
"@vueuse/core": "^10.9.0",
|
||||||
|
"axios": "^1.6.2",
|
||||||
"chart.js": "^4.4.1",
|
"chart.js": "^4.4.1",
|
||||||
"lucide-vue-next": "^0.344.0",
|
"lucide-vue-next": "^0.344.0",
|
||||||
"pinia": "^2.1.7",
|
"pinia": "^2.1.7",
|
||||||
"vue": "^3.4.21",
|
"vue": "^3.4.21",
|
||||||
"vue-router": "^4.3.0",
|
"vue-router": "^4.3.0"
|
||||||
"axios": "^1.7.9"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^20.17.11",
|
"@types/node": "^20.17.11",
|
||||||
|
|||||||
@@ -1,13 +1,18 @@
|
|||||||
import { createApp } from 'vue';
|
import './assets/main.css'
|
||||||
import { createPinia } from 'pinia';
|
|
||||||
import axios from 'axios';
|
|
||||||
import App from './App.vue';
|
|
||||||
import router from './router';
|
|
||||||
import './assets/main.css';
|
|
||||||
|
|
||||||
const app = createApp(App);
|
import { createApp } from 'vue'
|
||||||
|
import { createPinia } from 'pinia'
|
||||||
|
import axios from './plugins/axios'
|
||||||
|
|
||||||
app.use(createPinia());
|
import App from './App.vue'
|
||||||
app.use(router);
|
import router from './router'
|
||||||
|
|
||||||
app.mount('#app');
|
const app = createApp(App)
|
||||||
|
|
||||||
|
app.use(createPinia())
|
||||||
|
app.use(router)
|
||||||
|
|
||||||
|
// Добавляем axios как глобальное свойство
|
||||||
|
app.config.globalProperties.$axios = axios
|
||||||
|
|
||||||
|
app.mount('#app')
|
||||||
37
frontend/src/plugins/axios.ts
Normal file
37
frontend/src/plugins/axios.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import axios from 'axios'
|
||||||
|
|
||||||
|
const axiosInstance = axios.create({
|
||||||
|
baseURL: import.meta.env.VITE_API_URL || '/api',
|
||||||
|
timeout: 5000,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// Добавляем перехватчик для добавления токена
|
||||||
|
axiosInstance.interceptors.request.use(
|
||||||
|
(config) => {
|
||||||
|
const token = localStorage.getItem('token')
|
||||||
|
if (token) {
|
||||||
|
config.headers.Authorization = `Bearer ${token}`
|
||||||
|
}
|
||||||
|
return config
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Добавляем перехватчик для обработки ошибок
|
||||||
|
axiosInstance.interceptors.response.use(
|
||||||
|
(response) => response,
|
||||||
|
(error) => {
|
||||||
|
if (error.response?.status === 401) {
|
||||||
|
localStorage.removeItem('token')
|
||||||
|
window.location.href = '/admin/login'
|
||||||
|
}
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
export default axiosInstance
|
||||||
Reference in New Issue
Block a user