2024-09-25 14:25:44 +08:00
|
|
|
import { defineComponent } from 'vue'
|
|
|
|
import type { Block } from '../layout.types'
|
2024-09-25 18:23:54 +08:00
|
|
|
import { useMenuStore } from '../GlobalMenu'
|
2024-09-25 14:25:44 +08:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
props: {
|
|
|
|
block: {
|
|
|
|
type: Object as () => Block,
|
|
|
|
required: true
|
2024-09-25 18:23:54 +08:00
|
|
|
},
|
|
|
|
brief: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false
|
2024-10-10 16:04:00 +08:00
|
|
|
},
|
|
|
|
dock: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false
|
2024-09-25 14:25:44 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
setup(props) {
|
2024-09-25 18:23:54 +08:00
|
|
|
const menu = useMenuStore()
|
2024-09-25 14:25:44 +08:00
|
|
|
return () => (
|
|
|
|
<div
|
|
|
|
class="w-full h-full flex justify-center items-center font-bold bg-cover bg-center bg-no-repeat"
|
2024-09-25 18:23:54 +08:00
|
|
|
onContextmenu={(e) => {
|
|
|
|
e.preventDefault()
|
|
|
|
menu.open(props.block)
|
|
|
|
}}
|
2024-09-25 14:25:44 +08:00
|
|
|
style={{
|
|
|
|
backgroundColor: props.block.background || 'white',
|
|
|
|
color: props.block.color || 'black',
|
|
|
|
backgroundImage: props.block.icon ? `url('${props.block.icon}')` : '',
|
2024-10-10 16:04:00 +08:00
|
|
|
fontSize: props.dock ? '16px' : props.brief ? '12px' : 'calc(var(--block-size) / 5)'
|
2024-09-25 14:25:44 +08:00
|
|
|
}}
|
|
|
|
>
|
2024-09-25 18:23:54 +08:00
|
|
|
<div>{props.brief ? props.block.text[0] : props.block.text}</div>
|
2024-09-25 14:25:44 +08:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
})
|