1
0
mirror of https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git synced 2025-08-14 00:25:46 +02:00

вв222323232231в231

This commit is contained in:
MoonTestUse1
2025-01-05 00:14:55 +06:00
parent bfd41d5590
commit 2cff9a4e44
4 changed files with 61 additions and 18 deletions

View File

@@ -5,18 +5,19 @@ WORKDIR /app
# Копируем package.json и package-lock.json
COPY frontend/package*.json ./
# Очищаем cache и node_modules
RUN npm cache clean --force
RUN rm -rf node_modules
# Устанавливаем зависимости
RUN npm install
# Устанавливаем Tailwind и его зависимости
RUN npm install -D tailwindcss@latest postcss@latest autoprefixer@latest
# Инициализируем Tailwind
RUN npx tailwindcss init -p
# Копируем исходный код
COPY frontend/ .
# Создаем .env файл
RUN echo "VITE_API_URL=/api" > .env
# Открываем порт для Vite
EXPOSE 5173

View File

@@ -10,12 +10,12 @@
},
"dependencies": {
"@vueuse/core": "^10.9.0",
"axios": "^1.6.2",
"chart.js": "^4.4.1",
"lucide-vue-next": "^0.344.0",
"pinia": "^2.1.7",
"vue": "^3.4.21",
"vue-router": "^4.3.0",
"axios": "^1.7.9"
"vue-router": "^4.3.0"
},
"devDependencies": {
"@types/node": "^20.17.11",

View File

@@ -1,13 +1,18 @@
import { createApp } from 'vue';
import { createPinia } from 'pinia';
import axios from 'axios';
import App from './App.vue';
import router from './router';
import './assets/main.css';
import './assets/main.css'
const app = createApp(App);
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import axios from './plugins/axios'
app.use(createPinia());
app.use(router);
import App from './App.vue'
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')

View 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