Include complete API and frontend sources for unified deployment
This commit is contained in:
1 parent
627b0ae60e
commit
d8fcae32b0
93 files changed
+53270
-3
No files matched your search
@@ -0,0 +1,52 @@
|
||||
<template>
|
||||
<svg
|
||||
:width="size"
|
||||
:height="size"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.65"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<path v-for="(path, index) in paths" :key="index" :d="path" />
|
||||
</svg>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
const icons = {
|
||||
leaf: ['M12 21V11', 'M12 16C4 16 3 11 3 7c6 0 9 2 9 7', 'M12 11c0-6 3-8 9-8 0 6-3 9-9 9'],
|
||||
grid: ['M3 3h7v7H3z', 'M14 3h7v7h-7z', 'M3 14h7v7H3z', 'M14 14h7v7h-7z'],
|
||||
users: [
|
||||
'M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2',
|
||||
'M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8',
|
||||
'M17 4a4 4 0 0 1 0 8',
|
||||
'M22 21v-2a4 4 0 0 0-3-3.87',
|
||||
],
|
||||
chart: ['M4 20h16', 'M7 16v-5', 'M12 16V4', 'M17 16V8'],
|
||||
arrow: ['M5 12h14', 'm13 6 6 6-6 6'],
|
||||
back: ['M19 12H5', 'm11 6-6 6 6 6'],
|
||||
check: ['m5 12 4 4L19 6'],
|
||||
search: ['M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16', 'm17 17 4 4'],
|
||||
logout: ['M9 21H4V3h5', 'M10 12h11', 'm17 8 4 4-4 4'],
|
||||
close: ['m6 6 12 12', 'M6 18 18 6'],
|
||||
plus: ['M12 5v14', 'M5 12h14'],
|
||||
lock: ['M5 11h14v10H5z', 'M8 11V7a4 4 0 0 1 8 0v4'],
|
||||
info: ['M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20', 'M12 11v6', 'M12 7h.01'],
|
||||
clock: ['M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20', 'M12 6v6l4 2'],
|
||||
file: ['M14 2H4v20h16V8z', 'M14 2v6h6', 'M8 13h8', 'M8 17h5'],
|
||||
eye: ['M2 12s3-7 10-7 10 7 10 7-3 7-10 7S2 12 2 12', 'M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6'],
|
||||
copy: ['M8 8h13v13H8z', 'M16 4V2H2v14h2'],
|
||||
award: ['M12 15a6 6 0 1 0 0-12 6 6 0 0 0 0 12', 'm8 14-1 8 5-3 5 3-1-8'],
|
||||
menu: ['M4 6h16', 'M4 12h16', 'M4 18h16'],
|
||||
}
|
||||
export default {
|
||||
props: { name: { type: String, default: 'grid' }, size: { type: [Number, String], default: 20 } },
|
||||
computed: {
|
||||
paths() {
|
||||
return icons[this.name] || icons.grid
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,105 @@
|
||||
<template>
|
||||
<div class="app-shell simple-shell" :class="{ 'menu-open': isAdmin && menuOpen }">
|
||||
<a class="skip-link" href="#main-content" @click.prevent="focusMain">Перейти к содержимому</a>
|
||||
<button
|
||||
v-if="isAdmin && menuOpen"
|
||||
class="menu-backdrop"
|
||||
type="button"
|
||||
aria-label="Закрыть меню"
|
||||
@click="toggleMenu"
|
||||
/>
|
||||
<aside v-if="isAdmin && menuOpen" id="admin-sidebar" class="sidebar">
|
||||
<div class="sidebar-heading">
|
||||
<NuxtLink to="/admin" class="brand" aria-label="CyberGarden — главная"
|
||||
><img src="/logo2026.png" alt="" width="32" height="30" /><strong>CyberGarden</strong></NuxtLink
|
||||
>
|
||||
</div>
|
||||
<nav class="main-nav" aria-label="Основная навигация">
|
||||
<NuxtLink
|
||||
v-for="item in navigation"
|
||||
:key="item.to"
|
||||
:to="item.to"
|
||||
:exact="item.to !== '/admin'"
|
||||
class="nav-item"
|
||||
:class="{ 'current-nav': item.to === '/admin' && $route.path.startsWith('/admin/cases') }"
|
||||
@click.native="closeOnMobile"
|
||||
><AppIcon :name="item.icon" :size="18" /><span>{{ item.label }}</span></NuxtLink
|
||||
>
|
||||
</nav>
|
||||
</aside>
|
||||
<div class="workspace">
|
||||
<header class="workspace-header">
|
||||
<button
|
||||
v-if="isAdmin"
|
||||
class="button menu-toggle"
|
||||
type="button"
|
||||
:aria-expanded="String(menuOpen)"
|
||||
aria-controls="admin-sidebar"
|
||||
:aria-label="menuOpen ? 'Скрыть меню' : 'Показать меню'"
|
||||
@click="toggleMenu"
|
||||
>
|
||||
<AppIcon name="menu" :size="18" /></button
|
||||
><NuxtLink v-else to="/" class="compact-brand" aria-label="CyberGarden — кейсы"
|
||||
><img src="/logo2026.png" width="36" height="34" alt="" /><strong>CyberGarden</strong></NuxtLink
|
||||
>
|
||||
<div class="header-profile">
|
||||
<span>{{ fullName }}</span
|
||||
><button class="icon-button" type="button" aria-label="Выйти" @click="exit">
|
||||
<AppIcon name="logout" :size="18" />
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
<main id="main-content" class="main-content" tabindex="-1"><Nuxt /></main>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return { menuOpen: false }
|
||||
},
|
||||
computed: {
|
||||
isAdmin() {
|
||||
return this.$route.path.startsWith('/admin') || this.$auth.user?.login === 'admin'
|
||||
},
|
||||
fullName() {
|
||||
const user = this.$auth.user || {}
|
||||
return (
|
||||
[
|
||||
user.firstName || localStorage.getItem('user.firstName'),
|
||||
user.lastName || localStorage.getItem('user.lastName'),
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' ') || (this.isAdmin ? 'Администратор' : 'Эксперт')
|
||||
)
|
||||
},
|
||||
navigation() {
|
||||
return [
|
||||
{ to: '/admin', icon: 'file', label: 'Кейсы' },
|
||||
{ to: '/admin/users', icon: 'users', label: 'Эксперты' },
|
||||
{ to: '/admin/marks', icon: 'chart', label: 'Результаты' },
|
||||
]
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.menuOpen = window.innerWidth > 800 && localStorage.getItem('admin.menuOpen') !== 'false'
|
||||
},
|
||||
methods: {
|
||||
toggleMenu() {
|
||||
this.menuOpen = !this.menuOpen
|
||||
if (window.innerWidth > 800) localStorage.setItem('admin.menuOpen', String(this.menuOpen))
|
||||
},
|
||||
closeOnMobile() {
|
||||
if (window.innerWidth <= 800) this.menuOpen = false
|
||||
},
|
||||
focusMain() {
|
||||
const main = this.$el.querySelector('#main-content')
|
||||
main.focus()
|
||||
main.scrollIntoView({ block: 'start' })
|
||||
},
|
||||
async exit() {
|
||||
await this.$auth.logout()
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,6 @@
|
||||
<template>
|
||||
<span class="case-picture"><img v-if="src" :src="src" alt="" /><AppIcon v-else name="file" :size="22" /></span>
|
||||
</template>
|
||||
<script>
|
||||
export default { props: { src: { type: String, default: null } } }
|
||||
</script>
|
||||
@@ -0,0 +1,65 @@
|
||||
<template>
|
||||
<div class="icon-upload field">
|
||||
<label :for="inputId"><span>Иконка кейса (PNG)</span></label>
|
||||
<div class="icon-upload-controls">
|
||||
<CaseIcon :src="value" /><input
|
||||
:id="inputId"
|
||||
ref="file"
|
||||
type="file"
|
||||
accept="image/png,.png"
|
||||
:disabled="disabled"
|
||||
@change="select"
|
||||
/><button v-if="value || error" class="button button-sm" type="button" :disabled="disabled" @click="remove">
|
||||
Убрать
|
||||
</button>
|
||||
</div>
|
||||
<p class="muted">До 1 МБ, не более 1024 × 1024 пикселей.</p>
|
||||
<div v-if="error" class="form-error" role="alert">{{ error }}</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
props: { value: { type: String, default: null }, disabled: Boolean },
|
||||
data() {
|
||||
return { error: '', inputId: 'case-icon-file' }
|
||||
},
|
||||
methods: {
|
||||
select(event) {
|
||||
this.error = ''
|
||||
event.target.setCustomValidity('')
|
||||
const file = event.target.files[0]
|
||||
if (!file) return
|
||||
if (file.type !== 'image/png' || file.size > 1024 * 1024) {
|
||||
this.fail('Выберите PNG-файл размером до 1 МБ.')
|
||||
return
|
||||
}
|
||||
event.target.setCustomValidity('Дождитесь загрузки иконки.')
|
||||
const reader = new FileReader()
|
||||
reader.onerror = () => this.fail('Не удалось прочитать файл.')
|
||||
reader.onload = () => {
|
||||
const image = new Image()
|
||||
image.onload = () => {
|
||||
if (image.width > 1024 || image.height > 1024) this.fail('Размер иконки — не более 1024 × 1024 пикселей.')
|
||||
else {
|
||||
event.target.setCustomValidity('')
|
||||
this.$emit('input', reader.result)
|
||||
}
|
||||
}
|
||||
image.onerror = () => this.fail('Не удалось прочитать PNG-файл.')
|
||||
image.src = reader.result
|
||||
}
|
||||
reader.readAsDataURL(file)
|
||||
},
|
||||
fail(message) {
|
||||
this.error = message
|
||||
this.$refs.file.setCustomValidity(message)
|
||||
},
|
||||
remove() {
|
||||
this.$emit('input', null)
|
||||
this.error = ''
|
||||
this.$refs.file.value = ''
|
||||
this.$refs.file.setCustomValidity('')
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,40 @@
|
||||
<template>
|
||||
<dialog ref="dialog" class="score-dialog form-dialog" aria-labelledby="form-dialog-title" @cancel.prevent="close">
|
||||
<form @submit.prevent="$emit('save')">
|
||||
<div class="dialog-header">
|
||||
<h2 id="form-dialog-title">{{ title }}</h2>
|
||||
<button class="icon-button" type="button" aria-label="Закрыть" :disabled="busy" @click="close">
|
||||
<AppIcon name="close" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="dialog-body"><slot /></div>
|
||||
<div class="dialog-footer dialog-footer-actions">
|
||||
<button class="button" type="button" :disabled="busy" @click="close">Отмена</button
|
||||
><button class="button button-primary" :class="{ 'button-danger': danger }" type="submit" :disabled="busy">
|
||||
{{ busy ? 'Сохраняем…' : submitLabel }}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</dialog>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
title: { type: String, required: true },
|
||||
busy: Boolean,
|
||||
danger: Boolean,
|
||||
submitLabel: { type: String, default: 'Сохранить' },
|
||||
},
|
||||
mounted() {
|
||||
this.$refs.dialog.showModal()
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.$refs.dialog.close()
|
||||
},
|
||||
methods: {
|
||||
close() {
|
||||
if (!this.busy) this.$emit('close')
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,47 @@
|
||||
<template>
|
||||
<th scope="col" :aria-sort="active ? (direction === 'asc' ? 'ascending' : 'descending') : 'none'">
|
||||
<button class="sort-header" type="button" @click="$emit('sort')">
|
||||
<span><slot /></span>
|
||||
<span class="sort-indicator" :class="{ active }" aria-hidden="true">{{
|
||||
active ? (direction === 'asc' ? '↑' : '↓') : '↕'
|
||||
}}</span>
|
||||
</button>
|
||||
</th>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
active: { type: Boolean, default: false },
|
||||
direction: { type: String, default: 'asc' },
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.sort-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: inherit;
|
||||
font: inherit;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
.sort-header:hover,
|
||||
.sort-header:focus-visible {
|
||||
color: var(--primary, #28634c);
|
||||
}
|
||||
.sort-indicator {
|
||||
flex-shrink: 0;
|
||||
opacity: 0.45;
|
||||
}
|
||||
.sort-indicator.active {
|
||||
opacity: 1;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user