feat(frontend): initialize Vue 3 + Vite project structure
This commit is contained in:
32
src/App.vue
Normal file
32
src/App.vue
Normal file
@@ -0,0 +1,32 @@
|
||||
<template>
|
||||
<header>
|
||||
<nav>
|
||||
<router-link to="/">Главная</router-link> | <router-link to="/login">Вход</router-link> |
|
||||
<router-link to="/register">Регистрация</router-link>
|
||||
</nav>
|
||||
</header>
|
||||
<main>
|
||||
<!-- Здесь будут отображаться компоненты-страницы -->
|
||||
<router-view />
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
header {
|
||||
background-color: #f0f0f0;
|
||||
padding: 1rem;
|
||||
text-align: center;
|
||||
}
|
||||
nav a {
|
||||
margin: 0 1rem;
|
||||
text-decoration: none;
|
||||
color: #2c3e50;
|
||||
}
|
||||
nav a.router-link-exact-active {
|
||||
font-weight: bold;
|
||||
color: #42b983;
|
||||
}
|
||||
main {
|
||||
padding: 1rem;
|
||||
}
|
||||
</style>
|
||||
26
src/api/axios.ts
Normal file
26
src/api/axios.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import axios from "axios";
|
||||
|
||||
const apiClient = axios.create({
|
||||
// Vite предоставляет переменную import.meta.env.VITE_API_URL
|
||||
// В режиме разработки это будет прокси, в продакшене - реальный URL
|
||||
baseURL: import.meta.env.VITE_API_URL || "/api",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
|
||||
// Мы можем добавить interceptor для автоматического добавления JWT
|
||||
apiClient.interceptors.request.use(
|
||||
(config) => {
|
||||
const token = localStorage.getItem("authToken");
|
||||
if (token) {
|
||||
config.headers.Authorization = `Bearer ${token}`;
|
||||
}
|
||||
return config;
|
||||
},
|
||||
(error) => {
|
||||
return Promise.reject(error);
|
||||
},
|
||||
);
|
||||
|
||||
export default apiClient;
|
||||
12
src/main.ts
Normal file
12
src/main.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { createApp } from "vue";
|
||||
import { createPinia } from "pinia"; // Импортируем Pinia
|
||||
import App from "./App.vue";
|
||||
import router from "./router"; // Импортируем наш роутер
|
||||
import "./style.css"; // Глобальные стили
|
||||
|
||||
const app = createApp(App);
|
||||
|
||||
app.use(createPinia()); // Подключаем Pinia
|
||||
app.use(router); // Подключаем роутер
|
||||
|
||||
app.mount("#app");
|
||||
29
src/router/index.ts
Normal file
29
src/router/index.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { createRouter, createWebHistory } from "vue-router";
|
||||
import HomeView from "../views/HomeView.vue"; // Мы создадим его позже
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: "/",
|
||||
name: "home",
|
||||
component: HomeView,
|
||||
},
|
||||
{
|
||||
path: "/login",
|
||||
name: "login",
|
||||
// Ленивая загрузка (lazy-loading) для страниц, которые не нужны сразу
|
||||
component: () => import("../views/LoginView.vue"),
|
||||
},
|
||||
{
|
||||
path: "/register",
|
||||
name: "register",
|
||||
component: () => import("../views/RegisterView.vue"),
|
||||
},
|
||||
// Здесь будут другие роуты: личный кабинет, мониторинг и т.д.
|
||||
];
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes,
|
||||
});
|
||||
|
||||
export default router;
|
||||
79
src/style.css
Normal file
79
src/style.css
Normal file
@@ -0,0 +1,79 @@
|
||||
:root {
|
||||
font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
|
||||
line-height: 1.5;
|
||||
font-weight: 400;
|
||||
|
||||
color-scheme: light dark;
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
background-color: #242424;
|
||||
|
||||
font-synthesis: none;
|
||||
text-rendering: optimizeLegibility;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
a {
|
||||
font-weight: 500;
|
||||
color: #646cff;
|
||||
text-decoration: inherit;
|
||||
}
|
||||
a:hover {
|
||||
color: #535bf2;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
display: flex;
|
||||
place-items: center;
|
||||
min-width: 320px;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 3.2em;
|
||||
line-height: 1.1;
|
||||
}
|
||||
|
||||
button {
|
||||
border-radius: 8px;
|
||||
border: 1px solid transparent;
|
||||
padding: 0.6em 1.2em;
|
||||
font-size: 1em;
|
||||
font-weight: 500;
|
||||
font-family: inherit;
|
||||
background-color: #1a1a1a;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.25s;
|
||||
}
|
||||
button:hover {
|
||||
border-color: #646cff;
|
||||
}
|
||||
button:focus,
|
||||
button:focus-visible {
|
||||
outline: 4px auto -webkit-focus-ring-color;
|
||||
}
|
||||
|
||||
.card {
|
||||
padding: 2em;
|
||||
}
|
||||
|
||||
#app {
|
||||
max-width: 1280px;
|
||||
margin: 0 auto;
|
||||
padding: 2rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: light) {
|
||||
:root {
|
||||
color: #213547;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
a:hover {
|
||||
color: #747bff;
|
||||
}
|
||||
button {
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
}
|
||||
3
src/views/HomeView.vue
Normal file
3
src/views/HomeView.vue
Normal file
@@ -0,0 +1,3 @@
|
||||
<template>
|
||||
<h1>Главная страница</h1>
|
||||
</template>
|
||||
3
src/views/LoginView.vue
Normal file
3
src/views/LoginView.vue
Normal file
@@ -0,0 +1,3 @@
|
||||
<template>
|
||||
<h1>Вход</h1>
|
||||
</template>
|
||||
3
src/views/RegisterView.vue
Normal file
3
src/views/RegisterView.vue
Normal file
@@ -0,0 +1,3 @@
|
||||
<template>
|
||||
<h1>Регистрация</h1>
|
||||
</template>
|
||||
1
src/vite-env.d.ts
vendored
Normal file
1
src/vite-env.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/// <reference types="vite/client" />
|
||||
Reference in New Issue
Block a user