|
25 | 25 | </template> |
26 | 26 |
|
27 | 27 | <script setup> |
28 | | -const menuStore = useMenuStore(); |
29 | | -const dataBaseStore = useDataBaseStore(); |
| 28 | + const menuStore = useMenuStore() |
| 29 | + const dataBaseStore = useDataBaseStore() |
30 | 30 |
|
31 | | -const props = defineProps({ |
32 | | - id: { type: String, required: true }, |
33 | | - x: { type: Number, required: true }, |
34 | | - y: { type: Number, required: true }, |
35 | | - containerWidth: { type: Number, required: true }, |
36 | | - containerHeight: { type: Number, required: true }, |
37 | | -}); |
| 31 | + const props = defineProps({ |
| 32 | + id: { type: String, required: true }, |
| 33 | + x: { type: Number, required: true }, |
| 34 | + y: { type: Number, required: true }, |
| 35 | + containerWidth: { type: Number, required: true }, |
| 36 | + containerHeight: { type: Number, required: true }, |
| 37 | + }) |
38 | 38 |
|
39 | | -const meta_data = computed(() => { |
40 | | - const itemId = props.id || menuStore.current_id; |
41 | | - return itemId ? dataBaseStore.itemMetaDatas(itemId) : {}; |
42 | | -}); |
43 | | -const radius = 80; |
44 | | -const show_menu = ref(true); |
| 39 | + const meta_data = computed(() => { |
| 40 | + const itemId = props.id || menuStore.current_id |
| 41 | + return itemId ? dataBaseStore.itemMetaDatas(itemId) : {} |
| 42 | + }) |
| 43 | + const radius = 80 |
| 44 | + const show_menu = ref(true) |
45 | 45 |
|
46 | | -watch(show_menu, (value) => { |
47 | | - if (!value) { |
48 | | - menuStore.closeMenu(); |
49 | | - } |
50 | | -}); |
| 46 | + watch(show_menu, (value) => { |
| 47 | + if (!value) { |
| 48 | + menuStore.closeMenu() |
| 49 | + } |
| 50 | + }) |
51 | 51 |
|
52 | | -const menu_items = computed(() => |
53 | | - menuStore.getMenuItems( |
54 | | - meta_data.value.object_type, |
55 | | - meta_data.value.geode_object |
| 52 | + const menu_items = computed(() => |
| 53 | + menuStore.getMenuItems( |
| 54 | + meta_data.value.object_type, |
| 55 | + meta_data.value.geode_object, |
| 56 | + ), |
56 | 57 | ) |
57 | | -); |
58 | 58 |
|
59 | | -const menuItemCount = computed(() => menu_items.value.length); |
| 59 | + const menuItemCount = computed(() => menu_items.value.length) |
60 | 60 |
|
61 | | -function getMenuStyle() { |
62 | | - const x = props.x || menuStore.menuX; |
63 | | - const y = props.y || menuStore.menuY; |
64 | | - const width = props.containerWidth || menuStore.containerWidth; |
65 | | - const height = props.containerHeight || menuStore.containerHeight; |
| 61 | + function getMenuStyle() { |
| 62 | + const x = props.x || menuStore.menuX |
| 63 | + const y = props.y || menuStore.menuY |
| 64 | + const width = props.containerWidth || menuStore.containerWidth |
| 65 | + const height = props.containerHeight || menuStore.containerHeight |
66 | 66 |
|
67 | | - const adjustedX = Math.min(Math.max(x, radius), width - radius); |
68 | | - const adjustedY = Math.min(Math.max(y, radius), height - radius); |
| 67 | + const adjustedX = Math.min(Math.max(x, radius), width - radius) |
| 68 | + const adjustedY = Math.min(Math.max(y, radius), height - radius) |
69 | 69 |
|
70 | | - return { |
71 | | - left: `${adjustedX - radius}px`, |
72 | | - top: `${adjustedY - radius}px`, |
73 | | - }; |
74 | | -} |
| 70 | + return { |
| 71 | + left: `${adjustedX - radius}px`, |
| 72 | + top: `${adjustedY - radius}px`, |
| 73 | + } |
| 74 | + } |
75 | 75 |
|
76 | | -function getTooltipLocation(index) { |
77 | | - const angle = (index / menuItemCount.value) * 360; |
78 | | - if (angle < 45 || angle >= 315) return "right"; |
79 | | - if (angle >= 45 && angle < 135) return "top"; |
80 | | - if (angle >= 135 && angle < 225) return "left"; |
81 | | - return "bottom"; |
82 | | -} |
| 76 | + function getTooltipLocation(index) { |
| 77 | + const angle = (index / menuItemCount.value) * 360 |
| 78 | + if (angle < 45 || angle >= 315) return "right" |
| 79 | + if (angle >= 45 && angle < 135) return "top" |
| 80 | + if (angle >= 135 && angle < 225) return "left" |
| 81 | + return "bottom" |
| 82 | + } |
83 | 83 |
|
84 | | -function getTooltipOrigin(index) { |
85 | | - const angle = (index / menuItemCount.value) * 360; |
86 | | - if (angle < 45 || angle >= 315) return "left"; |
87 | | - if (angle >= 45 && angle < 135) return "bottom"; |
88 | | - if (angle >= 135 && angle < 225) return "right"; |
89 | | - return "top"; |
90 | | -} |
| 84 | + function getTooltipOrigin(index) { |
| 85 | + const angle = (index / menuItemCount.value) * 360 |
| 86 | + if (angle < 45 || angle >= 315) return "left" |
| 87 | + if (angle >= 45 && angle < 135) return "bottom" |
| 88 | + if (angle >= 135 && angle < 225) return "right" |
| 89 | + return "top" |
| 90 | + } |
91 | 91 |
|
92 | | -function getItemStyle(index) { |
93 | | - const angle = (index / menuItemCount.value) * 2 * Math.PI; |
94 | | - return { |
95 | | - transform: `translate(${Math.cos(angle) * radius}px, ${ |
96 | | - Math.sin(angle) * radius |
97 | | - }px)`, |
98 | | - transition: "opacity 0.1s ease, transform 0.1s ease", |
99 | | - position: "absolute", |
100 | | - }; |
101 | | -} |
| 92 | + function getItemStyle(index) { |
| 93 | + const angle = (index / menuItemCount.value) * 2 * Math.PI |
| 94 | + return { |
| 95 | + transform: `translate(${Math.cos(angle) * radius}px, ${ |
| 96 | + Math.sin(angle) * radius |
| 97 | + }px)`, |
| 98 | + transition: "opacity 0.1s ease, transform 0.1s ease", |
| 99 | + position: "absolute", |
| 100 | + } |
| 101 | + } |
102 | 102 | </script> |
103 | 103 |
|
104 | 104 | <style scoped> |
105 | | -.circular-menu { |
106 | | - position: absolute; |
107 | | - border-radius: 50%; |
108 | | - background-color: rgba(0, 0, 0, 0.8); |
109 | | -} |
| 105 | + .circular-menu { |
| 106 | + position: absolute; |
| 107 | + border-radius: 50%; |
| 108 | + background-color: rgba(0, 0, 0, 0.8); |
| 109 | + } |
110 | 110 |
|
111 | | -.circular-menu-items { |
112 | | - position: relative; |
113 | | - display: flex; |
114 | | - align-items: center; |
115 | | - justify-content: center; |
116 | | -} |
| 111 | + .circular-menu-items { |
| 112 | + position: relative; |
| 113 | + display: flex; |
| 114 | + align-items: center; |
| 115 | + justify-content: center; |
| 116 | + } |
117 | 117 |
|
118 | | -.menu-item-wrapper { |
119 | | - position: absolute; |
120 | | - transform-origin: center; |
121 | | - will-change: transform, opacity; |
122 | | -} |
| 118 | + .menu-item-wrapper { |
| 119 | + position: absolute; |
| 120 | + transform-origin: center; |
| 121 | + will-change: transform, opacity; |
| 122 | + } |
123 | 123 | </style> |
0 commit comments