This commit is contained in:
2026-04-10 15:26:51 +03:00
parent a8a2239d37
commit 5821006bf2
68 changed files with 3292 additions and 19 deletions

39
frontend/.gitignore vendored Normal file
View File

@@ -0,0 +1,39 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
.DS_Store
dist
dist-ssr
coverage
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
*.tsbuildinfo
.eslintcache
# Cypress
/cypress/videos/
/cypress/screenshots/
# Vitest
__screenshots__/
# Vite
*.timestamp-*-*.mjs

3
frontend/.vscode/extensions.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"recommendations": ["Vue.volar"]
}

38
frontend/README.md Normal file
View File

@@ -0,0 +1,38 @@
# frontend
This template should help get you started developing with Vue 3 in Vite.
## Recommended IDE Setup
[VS Code](https://code.visualstudio.com/) + [Vue (Official)](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur).
## Recommended Browser Setup
- Chromium-based browsers (Chrome, Edge, Brave, etc.):
- [Vue.js devtools](https://chromewebstore.google.com/detail/vuejs-devtools/nhdogjmejiglipccpnnnanhbledajbpd)
- [Turn on Custom Object Formatter in Chrome DevTools](http://bit.ly/object-formatters)
- Firefox:
- [Vue.js devtools](https://addons.mozilla.org/en-US/firefox/addon/vue-js-devtools/)
- [Turn on Custom Object Formatter in Firefox DevTools](https://fxdx.dev/firefox-devtools-custom-object-formatters/)
## Customize configuration
See [Vite Configuration Reference](https://vite.dev/config/).
## Project Setup
```sh
npm install
```
### Compile and Hot-Reload for Development
```sh
npm run dev
```
### Compile and Minify for Production
```sh
npm run build
```

13
frontend/index.html Normal file
View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vite App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>

8
frontend/jsconfig.json Normal file
View File

@@ -0,0 +1,8 @@
{
"compilerOptions": {
"paths": {
"@/*": ["./src/*"]
}
},
"exclude": ["node_modules", "dist"]
}

2561
frontend/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

24
frontend/package.json Normal file
View File

@@ -0,0 +1,24 @@
{
"name": "frontend",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"axios": "^1.15.0",
"vue": "^3.5.31",
"vue-router": "^4.6.4"
},
"devDependencies": {
"@vitejs/plugin-vue": "^6.0.5",
"vite": "^8.0.3",
"vite-plugin-vue-devtools": "^8.1.1"
},
"engines": {
"node": "^20.19.0 || >=22.12.0"
}
}

BIN
frontend/public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

3
frontend/src/App.vue Normal file
View File

@@ -0,0 +1,3 @@
<template>
<router-view />
</template>

5
frontend/src/main.ts Normal file
View File

@@ -0,0 +1,5 @@
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
createApp(App).use(router).mount('#app')

View File

@@ -0,0 +1,37 @@
import { createRouter, createWebHistory } from 'vue-router'
import Login from '../views/Login.vue'
import Setup from '../views/Setup.vue'
import Dashboard from '../views/Dashboard.vue'
const routes = [
{ path: '/login', component: Login },
{ path: '/setup', component: Setup },
{ path: '/', component: Dashboard, meta: { requiresAuth: true } }
]
const router = createRouter({
history: createWebHistory(),
routes
})
router.beforeEach(async (to, from, next) => {
const requiresAuth = to.matched.some(record => record.meta.requiresAuth)
const loggedIn = await checkAuth() // запрос к /api/admin/users или специальному endpoint
if (requiresAuth && !loggedIn) {
next('/login')
} else {
next()
}
})
async function checkAuth(): Promise<boolean> {
try {
const res = await fetch('/api/admin/users')
return res.ok
} catch {
return false
}
}
export default router

View File

@@ -0,0 +1,43 @@
<template>
<div>
<h2>Dashboard</h2>
<button @click="logout">Logout</button>
<h3>Users</h3>
<table>
<thead>
<tr><th>ID</th><th>Login</th><th>Created</th><th>IP</th></tr>
</thead>
<tbody>
<tr v-for="user in users" :key="user.id">
<td>{{ user.id }}</td>
<td>{{ user.login }}</td>
<td>{{ user.created }}</td>
<td>{{ user.ip }}</td>
</tr>
</tbody>
</table>
</div>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import axios from 'axios'
const router = useRouter()
const users = ref([])
onMounted(async () => {
try {
const res = await axios.get('/api/admin/users')
users.value = res.data
} catch {
router.push('/login')
}
})
async function logout() {
await axios.post('/api/logout')
router.push('/login')
}
</script>

View File

@@ -0,0 +1,30 @@
<template>
<div>
<h2>Login</h2>
<form @submit.prevent="login">
<input v-model="loginForm.login" placeholder="Login" />
<input v-model="loginForm.password" type="password" placeholder="Password" />
<button type="submit">Login</button>
</form>
<p v-if="error">{{ error }}</p>
</div>
</template>
<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import axios from 'axios'
const router = useRouter()
const loginForm = ref({ login: '', password: '' })
const error = ref('')
async function login() {
try {
await axios.post('/api/login', loginForm.value)
router.push('/')
} catch (e) {
error.value = 'Invalid credentials'
}
}
</script>

View File

@@ -0,0 +1,30 @@
<template>
<div>
<h2>Setup Admin Account</h2>
<form @submit.prevent="setup">
<input v-model="form.login" placeholder="Admin login" />
<input v-model="form.password" type="password" placeholder="Password (min 6 chars)" />
<button type="submit">Create Admin</button>
</form>
<p v-if="error">{{ error }}</p>
</div>
</template>
<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import axios from 'axios'
const router = useRouter()
const form = ref({ login: '', password: '' })
const error = ref('')
async function setup() {
try {
await axios.post('/api/setup', form.value)
router.push('/login')
} catch (e) {
error.value = e.response?.data || 'Setup failed'
}
}
</script>

15
frontend/vite.config.ts Normal file
View File

@@ -0,0 +1,15 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
export default defineConfig({
plugins: [vue()],
server: {
proxy: {
'/api': 'http://localhost:8080' // для разработки
}
},
build: {
outDir: '../src/main/resources/webroot', // после сборки копируем в ресурсы Vert.x
emptyOutDir: true
}
})