<script lang="ts" setup>
import { useTimeFormat } from '@/utils/hooks/useTimeFormat';
import { deepMerge } from '@/utils/index';
import { eventsDic, numRend, mapJson } from '@/utils/hooks/useRepoInit';
interface ActivityEvent{
    target_type:string;
    action_name:string;
    created_at:string;
    project_name:string;
    note?:any;
    merge_request_info?:any;
    push_data?:any;
    target_title?:any;
    _links?:any;
}
defineProps<{eventData:ActivityEvent}>();
const { formatTime } = useTimeFormat();
const followDic = { // follow字典
  $: 'target_type',
  Project: {
    $: 'action_name',
    star: (num = 0) => `star了${numRend(num)}项目`
  },
  Group: {
    $: 'action_name',
    follow: (num = 0) => `关注了${numRend(num)}组织`
  },
  Release: {
    $: 'action_name',
    created: (num = 0) => `新建了${numRend(num)}发行版`
  }
};
const compseDic = deepMerge(eventsDic, followDic);// 字典合并
const rdEventName = mapJson(compseDic);
</script>

<template>
    <div>
        <div class="flex items-center">
            <Icon name="gt-issue" class="mr-2"></Icon>
            <span class="mr-1">{{ rdEventName(eventData,1) }}</span>
            <span class="text-G600 text-xs">{{ formatTime(eventData.created_at, 'HH:mm') }}</span>
        </div>
        <div class="text-xs text-CG600 pl-6 break-all">
            <a :href="eventData._links.action_type||eventData._links.project||eventData._links.group" target="_blank" class="hover:text-inherit">{{eventData.project_name||eventData.group?.name}}</a>
        </div>
    </div>
</template>
