<template>
  <div class="custom-local-node">
    <img class="app-icon" v-if="appProperty.iconUrl" :src="appProperty.iconUrl" alt="" />
    <div class="app-icon app-text" v-else>{{ appProperty?.name.split('')[0] }}</div>
    <!-- <div class="app-info">
      <div class="app-name">{{ appProperty.name }}</div>
      <div class="app-tag">{{ appProperty.type }}</div>
    </div> -->
    <!-- <div>
      <span @click="attributeFun">属性</span>
      <span @click="paramFun">参数</span>
    </div> -->
  </div>
</template>

<script lang="ts" setup>
import { inject, onMounted, reactive } from 'vue';
// import { setNodeAttribute } from './nodeEvents';

// const emits = defineEmits(['attribute', 'param']);

const appProperty = reactive({
  name: '',
  iconUrl: '',
  type: '',
});

const getNode: any = inject('getNode');

// const attributeFun = () => {
//   setNodeAttribute(appProperty);
// };

// const paramFun = () => {
//   emits('param', appProperty);
// };

onMounted(() => {
  if (getNode) {
    const node = getNode();
    const data = node.getData();
    if (data?.label) {
      appProperty.name = data.label;
      appProperty.iconUrl = data.iconUrl;
      appProperty.type = data.type;
    }
  }
});
</script>
<style lang="scss">
.custom-local-node {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  .app-icon {
    width: 56px;
    height: 56px;
    border-radius: 4px;
  }
  .app-info {
    display: flex;
    flex-direction: column;
    width: 100px;
  }
  .app-name {
    font-size: 14px;
    font-weight: 500;
    color: #191919;
  }
  .app-tag {
    font-size: 12px;
    color: #595959;
  }
}
</style>
