Оставил onContextMenu в App

This commit is contained in:
Ilia Miheev
2026-03-07 22:38:06 +03:00
parent 6c7d14ed37
commit 0b0adf48ff
3 changed files with 136 additions and 131 deletions
+50 -1
View File
@@ -5,7 +5,7 @@ import {useEventListener} from "@vueuse/core";
import MyDialog from "./components/MyDialog.vue"; import MyDialog from "./components/MyDialog.vue";
import MyDropMenu from "./components/MyDropMenu.vue"; import MyDropMenu from "./components/MyDropMenu.vue";
import copyToclipboard from "./shared/copyToclipboard"; import copyToclipboard from "./shared/copyToclipboard";
import onContextMenu from './shared/ContextMenu' import ContextMenu from "@imengyu/vue3-context-menu";
const numbers = ref([]); // Инициализируем массив с пустыми строками const numbers = ref([]); // Инициализируем массив с пустыми строками
const clickCount = ref(1); // Счетчик нажатий const clickCount = ref(1); // Счетчик нажатий
@@ -159,6 +159,55 @@ function deletePlatform(item) {
clickCount.value-- clickCount.value--
} }
function onContextMenu(e, item) {
ContextMenu.showContextMenu({
theme: 'mac dark',
x: e.x,
y: e.y,
items: [
{
label: "Платформы",
children: [
{
label: "Белая",
onClick: () => createPlatform(item, 'white'),
},
{
label: "Синяя",
onClick: () => createPlatform(item, 'blue'),
},
{
label: "Красная",
onClick: () => createPlatform(item, 'red'),
},
{
label: "Удалить",
onClick: () => deletePlatform(item),
},
]
},
{
label: "QR код",
children: [
{
label: "Добавить",
onClick: () => alert('Здесь ещё предстоит написать код')
},
{
label: "Удалить",
onClick: () => alert('Здесь ещё предстоит написать код')
},
],
},
{
label: "Отмена",
onClick: () => {
alert('Здесь ещё предстоит написать код')
}
},
]
});
}
</script> </script>
<template> <template>
+86 -79
View File
@@ -1,36 +1,37 @@
<template> <template>
<transition name="modal-fade"> <transition name="modal-fade">
<div class="modal-backdrop" @click="closeModal"> <div class="modal-backdrop" @click="closeModal">
<div class="modal" @click.stop> <div class="modal" @click.stop>
<header :class="['modal-header', isSuccess ? 'modal-header-success': 'modal-header-error']"> <header :class="['modal-header', isSuccess ? 'modal-header-success': 'modal-header-error']">
<slot name="header"> <slot name="header">
<strong>Заголовок по умолчанию</strong> <strong>Заголовок по умолчанию</strong>
</slot> </slot>
<button class="modal-btn-close" @click="closeModal" aria-label="Закрыть модальное окно"> <button class="modal-btn-close" @click="closeModal" aria-label="Закрыть модальное окно">
× ×
</button> </button>
</header> </header>
<section class="modal-body"> <section class="modal-body">
<slot name="body">Тело по умолчанию</slot> <slot name="body">Тело по умолчанию</slot>
</section> </section>
<footer :class="['modal-footer', isSuccess ? 'modal-footer-success': 'modal-footer-error']"> <footer :class="['modal-footer', isSuccess ? 'modal-footer-success': 'modal-footer-error']">
<slot name="footer"> <slot name="footer">
<button @click="closeModal">Закрыть</button> <button @click="closeModal">Закрыть</button>
</slot> </slot>
</footer> </footer>
</div> </div>
</div> </div>
</transition> </transition>
</template> </template>
<script setup> <script setup>
const emit = defineEmits(['close']) const emit = defineEmits(['close'])
const props = defineProps({ const props = defineProps({
isSuccess: { isSuccess: {
type: Boolean, type: Boolean,
required: true required: true
} }
}) })
function closeModal() { function closeModal() {
emit('close'); emit('close');
} }
@@ -38,82 +39,88 @@ function closeModal() {
<style> <style>
.modal-backdrop { .modal-backdrop {
position: fixed; position: fixed;
top: 0; top: 0;
bottom: 0; bottom: 0;
left: 0; left: 0;
right: 0; right: 0;
background-color: rgba(0, 0, 0, 0.3); background-color: rgba(0, 0, 0, 0.3);
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
.modal { .modal {
background: #2f2f2f; background: #2f2f2f;
box-shadow: 2px 2px 20px 1px; box-shadow: 2px 2px 20px 1px;
overflow-x: auto; overflow-x: auto;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
max-width: 500px; max-width: 500px;
width: 90%; width: 90%;
border-radius: 5px; border-radius: 5px;
} }
.modal-header, .modal-header,
.modal-footer { .modal-footer {
padding: 10px; padding: 10px;
display: flex; display: flex;
} }
.modal-header { .modal-header {
border-bottom: 1px solid #eeeeee; border-bottom: 1px solid #eeeeee;
justify-content: space-between; justify-content: space-between;
}
.modal-header-success {
color: #4AAE9B;
}
.modal-header-error {
color: red;
} }
.modal-header [type = 'button'] { .modal-header-success {
color: red; color: #4AAE9B;
font-size: 25px; }
.modal-header-error {
color: red;
}
.modal-header button {
color: red;
font-size: 25px;
} }
.modal-footer { .modal-footer {
justify-content: flex-end; justify-content: flex-end;
border-top: 1px solid white; border-top: 1px solid white;
} }
.modal-footer [type = 'button'] {
justify-content: flex-end; .modal-footer button {
border-top: 1px solid white; justify-content: flex-end;
padding: 5px; border-top: 1px solid white;
padding: 5px;
color: white;
} }
.modal-footer-success [type = 'button'] {
background-color: #4AAE9B; .modal-footer-success button {
border: none; background-color: #4AAE9B;
margin: 3px; border: none;
margin: 3px;
} }
.modal-footer-error [type = 'button'] {
background: red; .modal-footer-error button {
border: none; background: red;
border: none;
} }
.modal-body { .modal-body {
position: relative; position: relative;
padding: 20px 10px; padding: 20px 10px;
color: white color: white
} }
.modal-btn-close { .modal-btn-close {
border: none; border: none;
font-size: 20px; font-size: 20px;
padding: 0; padding: 0;
cursor: pointer; cursor: pointer;
font-weight: bold; font-weight: bold;
color: red; color: red;
background: transparent; background: transparent;
} }
</style> </style>
-51
View File
@@ -1,51 +0,0 @@
import ContextMenu from "@imengyu/vue3-context-menu";
export default function onContextMenu(e, item) {
ContextMenu.showContextMenu({
theme: 'mac dark',
x: e.x,
y: e.y,
items: [
{
label: "Платформы",
children: [
{
label: "Белая",
onClick: () => createPlatform(item, 'white'),
},
{
label: "Синяя",
onClick: () => createPlatform(item, 'blue'),
},
{
label: "Красная",
onClick: () => createPlatform(item, 'red'),
},
{
label: "Удалить",
onClick: () => deletePlatform(item),
},
]
},
{
label: "QR код",
children: [
{
label: "Добавить",
onClick: () => alert('Здесь ещё предстоит написать код')
},
{
label: "Удалить",
onClick: () => alert('Здесь ещё предстоит написать код')
},
],
},
{
label: "Отмена",
onClick: () => {
alert('Здесь ещё предстоит написать код')
}
},
]
});
}