<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 = () => {
//   console.log('click attributeFun');
//   setNodeAttribute(appProperty);
// };

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

onMounted(() => {
  if (getNode) {
    const node = getNode();
    // console.log('getNode()', node, node.getData());
    const data = node.getData();
    if (data?.label) {
      appProperty.name = data.label;
      appProperty.iconUrl = data.iconUrl;
      appProperty.type = data.type;
      // console.log('data', data, appProperty);
    }
  }
});

</script>
<style lang="scss">
 .custom-local-node {
  width: 100%;
  height: 100%;
  // background-color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  // padding: 8px;
    // border-radius: 4px;
    .app-icon {
    width: 56px;
    height: 56px;
    // margin-right: 8px;
    // background-color: #0ea5e9;
    border-radius: 4px;
    //  transform: scale(1.7);
    // display: flex;
    // align-items: center;
    // justify-content: center;
    // color: white;
    // font-weight: bold;
    // flex-shrink: 0;
}
    .app-text {

    }
    .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>
