You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

184 lines
3.7 KiB
Vue

1 month ago
<!--
工具栏组件
add by RYG
-->
<template>
<div class="flex-container">
<div v-if="!isInside" class="flex-container">
1 month ago
<img src="~/assets/img/KEP001.svg" class="align-item" />
1 month ago
<span class="text-item">KE Platform</span>
</div>
1 month ago
<ImageButton
v-for="btn in buttons"
:key="btn.key"
:imageUrl="btn.imageUrl"
:text="btn.text"
@click="handleButtonClick(btn)"
class="imgBtn"
:class="{ active: activeIndex === btn.index }"
/>
1 month ago
</div>
</template>
<script setup>
import { ref } from "vue";
1 month ago
import ImageButton from "./ImageButton.vue";
import { emitter } from "~/utils/eventBus";
1 month ago
1 month ago
const activeIndex = ref(-1);
// import { useBtnClickStore } from "~/stores/btnClickStore";
1 month ago
1 month ago
// const store = useBtnClickStore();
1 month ago
1 month ago
// const emit = defineEmits(["btnClick"]);
// const imageUrl = ref('/assets/img/mornejiantou.svg'); // 确保路径正确
1 month ago
const isInside = ref(true);
const buttons = [
{
1 month ago
imageUrl: "_nuxt/assets/img/default.svg",
1 month ago
text: "默认",
key: "default",
index: 0,
},
{
1 month ago
imageUrl: "_nuxt/assets/img/zoom_in.svg",
1 month ago
text: "放大",
key: "zoom_in",
index: 1,
},
{
1 month ago
imageUrl: "_nuxt/assets/img/zoom_out.svg",
1 month ago
text: "缩小",
key: "zoom_out",
index: 2,
},
{
1 month ago
imageUrl: "_nuxt/assets/img/refresh.svg",
1 month ago
text: "刷新",
key: "refresh",
index: 3,
},
{
1 month ago
imageUrl: "_nuxt/assets/img/center.svg",
1 month ago
text: "居中",
key: "center",
index: 4,
},
{
1 month ago
imageUrl: "_nuxt/assets/img/part.svg",
1 month ago
text: "局部",
key: "part",
index: 5,
},
{
1 month ago
imageUrl: "_nuxt/assets/img/all.svg",
1 month ago
text: "全部",
key: "all",
index: 6,
},
{
1 month ago
imageUrl: "_nuxt/assets/img/move.svg",
1 month ago
text: "移动",
key: "move",
index: 7,
},
{
1 month ago
imageUrl: "_nuxt/assets/img/choose_arrow.svg",
1 month ago
text: "选择",
key: "choose",
index: 8,
},
{
1 month ago
imageUrl: "_nuxt/assets/img/save.svg",
1 month ago
text: "保存",
key: "save",
index: 9,
},
1 month ago
{
imageUrl: "_nuxt/assets/img/image_layer_tree.svg",
text: "图层",
key: "layer",
index: 10,
},
1 month ago
];
const handleButtonClick = (btn) => {
1 month ago
activeIndex.value = btn.index;
emitter.emit("btnClick", { key: btn.key, index: btn.index });
// emit("btnClick", btn.key); // 触发事件将按钮的key传递出去
// store.newBtnClicked(btn.key);
// switch (btn.key) {
// case "default":
// // 处理默认按钮点击
// break;
// case "zoom_in":
// // 处理放大按钮点击
// break;
// case "zoom_out":
// // 处理缩小按钮点击
// break;
// case "refresh":
// // 处理刷新按钮点击
// break;
// case "center":
// // 处理居中按钮点击
// break;
// case "part":
// // 处理局部按钮点击
// break;
// case "all":
// // 处理全部按钮点击
// break;
// case "move":
// // 处理移动按钮点击
// break;
// case "choose":
// // 处理选择按钮点击
// break;
// case "save":
// // 处理保存按钮点击
// break;
// case "layer":
// // 处理图层按钮点击
// break;
// default:
// console.warn(`未定义的按钮:${btn.key}`);
// }
1 month ago
};
</script>
<style scoped>
.flex-container {
display: flex;
flex-direction: row;
align-items: center;
/* 元素间距 */
gap: 12px;
1 month ago
padding-left:15px;
1 month ago
}
.align-item {
width: 30px;
height: 35px;
}
.text-item {
font-size: 20px;
}
.active {
background-color: #fff;
color: rgb(24, 144, 255);
}
.imgBtn {
height: 35px;
width: 30px;
}
.imgBtn :hover {
color: rgb(24, 144, 255);
}
</style>