<template>
  <div class="time-sort-select-box">
    <el-select v-model="isSort" placeholder="发布时间" style="width: 130px" @change="handlePxChange">
      <template #prefix>
        <div style="display: flex; align-items: center; height: 100%">
          <img v-if="isSort" src="./down.svg" style="width: 16px; height: 16px" />
          <img v-else src="./up.svg" style="width: 16px; height: 16px" />
        </div>
      </template>
      <el-option v-for="item in timeList" :key="item.value" :label="item.label" :value="item.value" />
    </el-select>
  </div>
</template>

<script setup>
import { ref } from 'vue'

const isSort = ref(true)

const timeList = ref([
  { label: "时间倒序", value: true },
  { label: "时间正序", value: false }
])

const emits = defineEmits(['handlePxChange'])

const handlePxChange = () => {
  emits('handlePxChange', isSort.value)
}

</script>

<style scoped>
.time-sort-select-box {
  height: 42px;
  box-sizing: border-box;
  padding: 5px 0;
}
</style>