2026-04-14 16:33:23 +08:00
|
|
|
<template>
|
2026-04-21 19:50:57 +08:00
|
|
|
<div
|
|
|
|
|
class="right-button-box"
|
|
|
|
|
v-show="useStatusStore().uiComponents.rightButton.show"
|
|
|
|
|
>
|
2026-04-14 16:33:23 +08:00
|
|
|
<ul class="right-button-ul">
|
|
|
|
|
<li v-for="(buttonItem, index) in buttonList" :key="index">
|
|
|
|
|
<button
|
|
|
|
|
@click="handelButton(index, buttonItem.callback)"
|
|
|
|
|
:style="{
|
2026-04-21 19:50:57 +08:00
|
|
|
'background-image': `url(${useButtonSelectedIdStore().rightButtonSelectedId == index ? rightOrangeButton : rightBlueButton})`,
|
2026-04-14 16:33:23 +08:00
|
|
|
}"
|
|
|
|
|
>
|
|
|
|
|
{{ buttonItem.name }}
|
|
|
|
|
</button>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { rightBlueButton, rightOrangeButton } from '@/assets';
|
2026-04-21 19:50:57 +08:00
|
|
|
import { useButtonSelectedIdStore } from '@/stores/useButtonSelectedIdStore.ts';
|
|
|
|
|
import { useStatusStore } from '@/stores/useStatusStore.ts';
|
2026-04-14 16:33:23 +08:00
|
|
|
|
|
|
|
|
// 接收父组件传递的参数
|
|
|
|
|
const props = defineProps<{
|
|
|
|
|
buttonList: {
|
|
|
|
|
name: string;
|
|
|
|
|
callback: (...args: unknown[]) => unknown;
|
|
|
|
|
executeOnce?: boolean;
|
|
|
|
|
}[];
|
|
|
|
|
}>();
|
|
|
|
|
|
|
|
|
|
// 点击按钮触发
|
|
|
|
|
const handelButton = (
|
|
|
|
|
index: number,
|
|
|
|
|
callback: (...args: unknown[]) => unknown
|
|
|
|
|
) => {
|
2026-04-21 19:50:57 +08:00
|
|
|
if (index == useButtonSelectedIdStore().rightButtonSelectedId) {
|
|
|
|
|
useButtonSelectedIdStore().rightButtonSelectedId = -1;
|
2026-04-14 16:33:23 +08:00
|
|
|
return;
|
|
|
|
|
} else if (
|
2026-04-21 19:50:57 +08:00
|
|
|
useButtonSelectedIdStore().rightButtonSelectedId != -1 &&
|
|
|
|
|
useButtonSelectedIdStore().rightButtonSelectedId != index
|
2026-04-14 16:33:23 +08:00
|
|
|
) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2026-04-21 19:50:57 +08:00
|
|
|
useButtonSelectedIdStore().rightButtonSelectedId = index;
|
2026-04-14 16:33:23 +08:00
|
|
|
callback();
|
|
|
|
|
if (props.buttonList[index].executeOnce) {
|
2026-04-21 19:50:57 +08:00
|
|
|
useButtonSelectedIdStore().rightButtonSelectedId = -1;
|
2026-04-14 16:33:23 +08:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
.right-button-box {
|
|
|
|
|
width: 180px;
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: 45px;
|
|
|
|
|
right: 200px;
|
|
|
|
|
z-index: 1000;
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0);
|
|
|
|
|
padding: 15px 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.right-button-ul {
|
|
|
|
|
list-style: none;
|
|
|
|
|
padding: 0;
|
|
|
|
|
margin: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.right-button-ul li {
|
|
|
|
|
margin: 15px 0 0 0;
|
|
|
|
|
padding: 0;
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
|
|
|
|
.right-button-ul li button {
|
|
|
|
|
width: 190px;
|
|
|
|
|
height: 30px;
|
|
|
|
|
padding: 5px;
|
|
|
|
|
color: white;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
min-width: 100px;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
opacity: 1;
|
|
|
|
|
background-color: transparent;
|
|
|
|
|
background-size: 100%;
|
|
|
|
|
background-repeat: no-repeat;
|
|
|
|
|
background-position: 20px center;
|
|
|
|
|
border: none;
|
|
|
|
|
box-shadow: none;
|
|
|
|
|
border-radius: 0;
|
|
|
|
|
}
|
|
|
|
|
</style>
|