<script setup lang="ts">
import type { Session } from '@/api/chat'
import { calendar } from '@/utils'

defineProps<
  Session & {
    active: boolean
    disabled?: boolean
  }
>()
</script>

<template>
  <div
    :key="id"
    class="session-item"
    :class="{
      active,
      local,
    }"
    :title="title"
  >
    <div class="content" :disabled="disabled">
      <div class="title g-one-line">
        {{ title }}
      </div>
      <div class="bottom">
        <span class="size">{{ num || 0 }}条</span>
        <span class="time">{{ calendar(updateTime) }}</span>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
@use '@/page/chat/index.scss' as *;

.session-item {
  cursor: pointer;
  height: 8vh;
  padding: 1.25vh;
  margin: 0.83vh 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #f5feff;

  &.active {
    background-color: #fffef5;
  }

  &.active.local {
    background-color: #fedd7e;
  }

  .content {
    flex: 1;
    margin-right: 8px;
  }

  .title {
    font-size: $font_size2;
    margin-bottom: 1vh;
    color: $font-color;
    width: $side_title_w; /* 必须设置宽度 */
  }

  .bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;

    .size,
    .time {
      font-size: $font_size3;
      color: #999;
    }
  }
}
</style>
